2003-02-25 00:43:02 +01:00
|
|
|
|
|
|
|
#define exec_op glue(exec_, OP)
|
2005-03-02 23:19:12 +01:00
|
|
|
#define exec_opq glue(glue(exec_, OP), q)
|
2003-02-25 00:43:02 +01:00
|
|
|
#define exec_opl glue(glue(exec_, OP), l)
|
|
|
|
#define exec_opw glue(glue(exec_, OP), w)
|
|
|
|
#define exec_opb glue(glue(exec_, OP), b)
|
|
|
|
|
2003-03-04 02:14:13 +01:00
|
|
|
#ifndef OP_SHIFTD
|
|
|
|
|
|
|
|
#ifdef OP_NOBYTE
|
2005-03-02 23:19:12 +01:00
|
|
|
#define EXECSHIFT(size, rsize, res, s1, s2, flags) \
|
2003-03-04 02:14:13 +01:00
|
|
|
asm ("push %4\n\t"\
|
|
|
|
"popf\n\t"\
|
2005-03-02 23:19:12 +01:00
|
|
|
stringify(OP) size " %" rsize "2, %" rsize "0\n\t" \
|
2003-03-04 02:14:13 +01:00
|
|
|
"pushf\n\t"\
|
2005-03-02 23:19:12 +01:00
|
|
|
"pop %1\n\t"\
|
2003-03-04 02:14:13 +01:00
|
|
|
: "=g" (res), "=g" (flags)\
|
|
|
|
: "r" (s1), "0" (res), "1" (flags));
|
|
|
|
#else
|
2005-03-02 23:19:12 +01:00
|
|
|
#define EXECSHIFT(size, rsize, res, s1, s2, flags) \
|
2003-02-25 00:43:02 +01:00
|
|
|
asm ("push %4\n\t"\
|
|
|
|
"popf\n\t"\
|
2005-03-02 23:19:12 +01:00
|
|
|
stringify(OP) size " %%cl, %" rsize "0\n\t" \
|
2003-02-25 00:43:02 +01:00
|
|
|
"pushf\n\t"\
|
2005-03-02 23:19:12 +01:00
|
|
|
"pop %1\n\t"\
|
2003-02-25 00:43:02 +01:00
|
|
|
: "=q" (res), "=g" (flags)\
|
|
|
|
: "c" (s1), "0" (res), "1" (flags));
|
2003-03-04 02:14:13 +01:00
|
|
|
#endif
|
2003-02-25 00:43:02 +01:00
|
|
|
|
2005-03-02 23:19:12 +01:00
|
|
|
#if defined(__x86_64__)
|
|
|
|
void exec_opq(long s2, long s0, long s1, long iflags)
|
2003-02-25 00:43:02 +01:00
|
|
|
{
|
2005-03-02 23:19:12 +01:00
|
|
|
long res, flags;
|
2003-02-25 00:43:02 +01:00
|
|
|
res = s0;
|
|
|
|
flags = iflags;
|
2005-03-02 23:19:12 +01:00
|
|
|
EXECSHIFT("q", "", res, s1, s2, flags);
|
2003-02-25 00:43:02 +01:00
|
|
|
/* overflow is undefined if count != 1 */
|
|
|
|
if (s1 != 1)
|
|
|
|
flags &= ~CC_O;
|
2005-03-02 23:19:12 +01:00
|
|
|
printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
|
|
|
|
stringify(OP) "q", s0, s1, res, iflags, flags & CC_MASK);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void exec_opl(long s2, long s0, long s1, long iflags)
|
|
|
|
{
|
|
|
|
long res, flags;
|
|
|
|
res = s0;
|
|
|
|
flags = iflags;
|
|
|
|
EXECSHIFT("l", "k", res, s1, s2, flags);
|
|
|
|
/* overflow is undefined if count != 1 */
|
|
|
|
if (s1 != 1)
|
|
|
|
flags &= ~CC_O;
|
|
|
|
printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
|
2003-02-25 00:43:02 +01:00
|
|
|
stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK);
|
|
|
|
}
|
|
|
|
|
2005-03-02 23:19:12 +01:00
|
|
|
void exec_opw(long s2, long s0, long s1, long iflags)
|
2003-02-25 00:43:02 +01:00
|
|
|
{
|
2005-03-02 23:19:12 +01:00
|
|
|
long res, flags;
|
2003-02-25 00:43:02 +01:00
|
|
|
res = s0;
|
|
|
|
flags = iflags;
|
2005-03-02 23:19:12 +01:00
|
|
|
EXECSHIFT("w", "w", res, s1, s2, flags);
|
2003-02-25 00:43:02 +01:00
|
|
|
/* overflow is undefined if count != 1 */
|
|
|
|
if (s1 != 1)
|
|
|
|
flags &= ~CC_O;
|
2005-03-02 23:19:12 +01:00
|
|
|
printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
|
2003-02-25 00:43:02 +01:00
|
|
|
stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK);
|
|
|
|
}
|
|
|
|
|
2003-03-04 02:14:13 +01:00
|
|
|
#else
|
2005-03-02 23:19:12 +01:00
|
|
|
#define EXECSHIFT(size, rsize, res, s1, s2, flags) \
|
2003-03-04 02:14:13 +01:00
|
|
|
asm ("push %4\n\t"\
|
|
|
|
"popf\n\t"\
|
2005-03-02 23:19:12 +01:00
|
|
|
stringify(OP) size " %%cl, %" rsize "5, %" rsize "0\n\t" \
|
2003-03-04 02:14:13 +01:00
|
|
|
"pushf\n\t"\
|
2005-03-02 23:19:12 +01:00
|
|
|
"pop %1\n\t"\
|
2003-03-04 02:14:13 +01:00
|
|
|
: "=g" (res), "=g" (flags)\
|
|
|
|
: "c" (s1), "0" (res), "1" (flags), "r" (s2));
|
|
|
|
|
2005-03-02 23:19:12 +01:00
|
|
|
#if defined(__x86_64__)
|
|
|
|
void exec_opq(long s2, long s0, long s1, long iflags)
|
|
|
|
{
|
|
|
|
long res, flags;
|
|
|
|
res = s0;
|
|
|
|
flags = iflags;
|
|
|
|
EXECSHIFT("q", "", res, s1, s2, flags);
|
|
|
|
/* overflow is undefined if count != 1 */
|
|
|
|
if (s1 != 1)
|
|
|
|
flags &= ~CC_O;
|
|
|
|
printf("%-10s A=" FMTLX " B=" FMTLX " C=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
|
|
|
|
stringify(OP) "q", s0, s2, s1, res, iflags, flags & CC_MASK);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void exec_opl(long s2, long s0, long s1, long iflags)
|
2003-03-04 02:14:13 +01:00
|
|
|
{
|
2005-03-02 23:19:12 +01:00
|
|
|
long res, flags;
|
2003-03-04 02:14:13 +01:00
|
|
|
res = s0;
|
|
|
|
flags = iflags;
|
2005-03-02 23:19:12 +01:00
|
|
|
EXECSHIFT("l", "k", res, s1, s2, flags);
|
2003-03-04 02:14:13 +01:00
|
|
|
/* overflow is undefined if count != 1 */
|
|
|
|
if (s1 != 1)
|
|
|
|
flags &= ~CC_O;
|
2005-03-02 23:19:12 +01:00
|
|
|
printf("%-10s A=" FMTLX " B=" FMTLX " C=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
|
2003-03-04 02:14:13 +01:00
|
|
|
stringify(OP) "l", s0, s2, s1, res, iflags, flags & CC_MASK);
|
|
|
|
}
|
|
|
|
|
2005-03-02 23:19:12 +01:00
|
|
|
void exec_opw(long s2, long s0, long s1, long iflags)
|
2003-03-04 02:14:13 +01:00
|
|
|
{
|
2005-03-02 23:19:12 +01:00
|
|
|
long res, flags;
|
2003-03-04 02:14:13 +01:00
|
|
|
res = s0;
|
|
|
|
flags = iflags;
|
2005-03-02 23:19:12 +01:00
|
|
|
EXECSHIFT("w", "w", res, s1, s2, flags);
|
2003-03-04 02:14:13 +01:00
|
|
|
/* overflow is undefined if count != 1 */
|
|
|
|
if (s1 != 1)
|
|
|
|
flags &= ~CC_O;
|
2005-03-02 23:19:12 +01:00
|
|
|
printf("%-10s A=" FMTLX " B=" FMTLX " C=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
|
2003-03-04 02:14:13 +01:00
|
|
|
stringify(OP) "w", s0, s2, s1, res, iflags, flags & CC_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef OP_NOBYTE
|
2005-03-02 23:19:12 +01:00
|
|
|
void exec_opb(long s0, long s1, long iflags)
|
2003-02-25 00:43:02 +01:00
|
|
|
{
|
2005-03-02 23:19:12 +01:00
|
|
|
long res, flags;
|
2003-02-25 00:43:02 +01:00
|
|
|
res = s0;
|
|
|
|
flags = iflags;
|
2005-03-02 23:19:12 +01:00
|
|
|
EXECSHIFT("b", "b", res, s1, 0, flags);
|
2003-02-25 00:43:02 +01:00
|
|
|
/* overflow is undefined if count != 1 */
|
|
|
|
if (s1 != 1)
|
|
|
|
flags &= ~CC_O;
|
2005-03-02 23:19:12 +01:00
|
|
|
printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
|
2003-02-25 00:43:02 +01:00
|
|
|
stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK);
|
|
|
|
}
|
2003-03-04 02:14:13 +01:00
|
|
|
#endif
|
2003-02-25 00:43:02 +01:00
|
|
|
|
2005-03-02 23:19:12 +01:00
|
|
|
void exec_op(long s2, long s0, long s1)
|
2003-02-25 00:43:02 +01:00
|
|
|
{
|
2005-03-02 23:19:12 +01:00
|
|
|
s2 = i2l(s2);
|
|
|
|
s0 = i2l(s0);
|
|
|
|
#if defined(__x86_64__)
|
|
|
|
exec_opq(s2, s0, s1, 0);
|
|
|
|
#endif
|
2003-03-04 02:14:13 +01:00
|
|
|
exec_opl(s2, s0, s1, 0);
|
2003-04-11 02:12:54 +02:00
|
|
|
#ifdef OP_SHIFTD
|
2008-05-28 14:34:49 +02:00
|
|
|
exec_opw(s2, s0, s1, 0);
|
2003-04-11 02:12:54 +02:00
|
|
|
#else
|
2003-03-04 02:14:13 +01:00
|
|
|
exec_opw(s2, s0, s1, 0);
|
2003-04-11 02:12:54 +02:00
|
|
|
#endif
|
2003-03-04 02:14:13 +01:00
|
|
|
#ifndef OP_NOBYTE
|
2003-02-25 00:43:02 +01:00
|
|
|
exec_opb(s0, s1, 0);
|
2003-03-04 02:14:13 +01:00
|
|
|
#endif
|
2003-02-25 00:43:02 +01:00
|
|
|
#ifdef OP_CC
|
2005-03-02 23:19:12 +01:00
|
|
|
#if defined(__x86_64__)
|
|
|
|
exec_opq(s2, s0, s1, CC_C);
|
|
|
|
#endif
|
2003-03-04 02:14:13 +01:00
|
|
|
exec_opl(s2, s0, s1, CC_C);
|
|
|
|
exec_opw(s2, s0, s1, CC_C);
|
2003-02-25 00:43:02 +01:00
|
|
|
exec_opb(s0, s1, CC_C);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void glue(test_, OP)(void)
|
|
|
|
{
|
2005-03-02 23:19:12 +01:00
|
|
|
int i, n;
|
|
|
|
#if defined(__x86_64__)
|
|
|
|
n = 64;
|
|
|
|
#else
|
|
|
|
n = 32;
|
|
|
|
#endif
|
|
|
|
for(i = 0; i < n; i++)
|
2003-03-04 02:14:13 +01:00
|
|
|
exec_op(0x21ad3d34, 0x12345678, i);
|
2005-03-02 23:19:12 +01:00
|
|
|
for(i = 0; i < n; i++)
|
2006-04-24 22:18:26 +02:00
|
|
|
exec_op(0x813f3421, 0x82345679, i);
|
2003-02-25 00:43:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void *glue(_test_, OP) __init_call = glue(test_, OP);
|
|
|
|
|
|
|
|
#undef OP
|
|
|
|
#undef OP_CC
|
2003-03-04 02:14:13 +01:00
|
|
|
#undef OP_SHIFTD
|
|
|
|
#undef OP_NOBYTE
|
|
|
|
#undef EXECSHIFT
|