aboutsummaryrefslogtreecommitdiff
path: root/tests/test-i386-shift.h
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-03-02 22:19:12 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-03-02 22:19:12 +0000
commit776f2227f6244003a5bcb20ea77c49427e6af023 (patch)
tree8949fa9ed46cd0fe2b7006f2249c50191532d400 /tests/test-i386-shift.h
parentd785e6be4d85d08ae34f7942da139493be28ec6b (diff)
downloadqemu-776f2227f6244003a5bcb20ea77c49427e6af023.zip
qemu-776f2227f6244003a5bcb20ea77c49427e6af023.tar.gz
qemu-776f2227f6244003a5bcb20ea77c49427e6af023.tar.bz2
x86_64 test program
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1321 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tests/test-i386-shift.h')
-rw-r--r--tests/test-i386-shift.h110
1 files changed, 77 insertions, 33 deletions
diff --git a/tests/test-i386-shift.h b/tests/test-i386-shift.h
index c3d8793..7a98e27 100644
--- a/tests/test-i386-shift.h
+++ b/tests/test-i386-shift.h
@@ -1,5 +1,6 @@
#define exec_op glue(exec_, OP)
+#define exec_opq glue(glue(exec_, OP), q)
#define exec_opl glue(glue(exec_, OP), l)
#define exec_opw glue(glue(exec_, OP), w)
#define exec_opb glue(glue(exec_, OP), b)
@@ -7,106 +8,141 @@
#ifndef OP_SHIFTD
#ifdef OP_NOBYTE
-#define EXECSHIFT(size, res, s1, s2, flags) \
+#define EXECSHIFT(size, rsize, res, s1, s2, flags) \
asm ("push %4\n\t"\
"popf\n\t"\
- stringify(OP) size " %" size "2, %" size "0\n\t" \
+ stringify(OP) size " %" rsize "2, %" rsize "0\n\t" \
"pushf\n\t"\
- "popl %1\n\t"\
+ "pop %1\n\t"\
: "=g" (res), "=g" (flags)\
: "r" (s1), "0" (res), "1" (flags));
#else
-#define EXECSHIFT(size, res, s1, s2, flags) \
+#define EXECSHIFT(size, rsize, res, s1, s2, flags) \
asm ("push %4\n\t"\
"popf\n\t"\
- stringify(OP) size " %%cl, %" size "0\n\t" \
+ stringify(OP) size " %%cl, %" rsize "0\n\t" \
"pushf\n\t"\
- "popl %1\n\t"\
+ "pop %1\n\t"\
: "=q" (res), "=g" (flags)\
: "c" (s1), "0" (res), "1" (flags));
#endif
-void exec_opl(int s2, int s0, int s1, int iflags)
+#if defined(__x86_64__)
+void exec_opq(long s2, long s0, long s1, long iflags)
{
- int res, flags;
+ long res, flags;
res = s0;
flags = iflags;
- EXECSHIFT("", res, s1, s2, flags);
+ EXECSHIFT("q", "", res, s1, s2, flags);
/* overflow is undefined if count != 1 */
if (s1 != 1)
flags &= ~CC_O;
- printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
+ 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",
stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK);
}
-void exec_opw(int s2, int s0, int s1, int iflags)
+void exec_opw(long s2, long s0, long s1, long iflags)
{
- int res, flags;
+ long res, flags;
res = s0;
flags = iflags;
- EXECSHIFT("w", res, s1, s2, flags);
+ EXECSHIFT("w", "w", res, s1, s2, flags);
/* overflow is undefined if count != 1 */
if (s1 != 1)
flags &= ~CC_O;
- printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
+ printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK);
}
#else
-#define EXECSHIFT(size, res, s1, s2, flags) \
+#define EXECSHIFT(size, rsize, res, s1, s2, flags) \
asm ("push %4\n\t"\
"popf\n\t"\
- stringify(OP) size " %%cl, %" size "5, %" size "0\n\t" \
+ stringify(OP) size " %%cl, %" rsize "5, %" rsize "0\n\t" \
"pushf\n\t"\
- "popl %1\n\t"\
+ "pop %1\n\t"\
: "=g" (res), "=g" (flags)\
: "c" (s1), "0" (res), "1" (flags), "r" (s2));
-void exec_opl(int s2, int s0, int s1, int iflags)
+#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)
{
- int res, flags;
+ long res, flags;
res = s0;
flags = iflags;
- EXECSHIFT("", res, s1, s2, flags);
+ EXECSHIFT("l", "k", res, s1, s2, flags);
/* overflow is undefined if count != 1 */
if (s1 != 1)
flags &= ~CC_O;
- printf("%-10s A=%08x B=%08x C=%08x R=%08x CCIN=%04x CC=%04x\n",
+ printf("%-10s A=" FMTLX " B=" FMTLX " C=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
stringify(OP) "l", s0, s2, s1, res, iflags, flags & CC_MASK);
}
-void exec_opw(int s2, int s0, int s1, int iflags)
+void exec_opw(long s2, long s0, long s1, long iflags)
{
- int res, flags;
+ long res, flags;
res = s0;
flags = iflags;
- EXECSHIFT("w", res, s1, s2, flags);
+ EXECSHIFT("w", "w", res, s1, s2, flags);
/* overflow is undefined if count != 1 */
if (s1 != 1)
flags &= ~CC_O;
- printf("%-10s A=%08x B=%08x C=%08x R=%08x CCIN=%04x CC=%04x\n",
+ printf("%-10s A=" FMTLX " B=" FMTLX " C=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
stringify(OP) "w", s0, s2, s1, res, iflags, flags & CC_MASK);
}
#endif
#ifndef OP_NOBYTE
-void exec_opb(int s0, int s1, int iflags)
+void exec_opb(long s0, long s1, long iflags)
{
- int res, flags;
+ long res, flags;
res = s0;
flags = iflags;
- EXECSHIFT("b", res, s1, 0, flags);
+ EXECSHIFT("b", "b", res, s1, 0, flags);
/* overflow is undefined if count != 1 */
if (s1 != 1)
flags &= ~CC_O;
- printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
+ printf("%-10s A=" FMTLX " B=" FMTLX " R=" FMTLX " CCIN=%04lx CC=%04lx\n",
stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK);
}
#endif
-void exec_op(int s2, int s0, int s1)
+void exec_op(long s2, long s0, long s1)
{
+ s2 = i2l(s2);
+ s0 = i2l(s0);
+#if defined(__x86_64__)
+ exec_opq(s2, s0, s1, 0);
+#endif
exec_opl(s2, s0, s1, 0);
#ifdef OP_SHIFTD
if (s1 <= 15)
@@ -118,6 +154,9 @@ void exec_op(int s2, int s0, int s1)
exec_opb(s0, s1, 0);
#endif
#ifdef OP_CC
+#if defined(__x86_64__)
+ exec_opq(s2, s0, s1, CC_C);
+#endif
exec_opl(s2, s0, s1, CC_C);
exec_opw(s2, s0, s1, CC_C);
exec_opb(s0, s1, CC_C);
@@ -126,10 +165,15 @@ void exec_op(int s2, int s0, int s1)
void glue(test_, OP)(void)
{
- int i;
- for(i = 0; i < 32; i++)
+ int i, n;
+#if defined(__x86_64__)
+ n = 64;
+#else
+ n = 32;
+#endif
+ for(i = 0; i < n; i++)
exec_op(0x21ad3d34, 0x12345678, i);
- for(i = 0; i < 32; i++)
+ for(i = 0; i < n; i++)
exec_op(0x813f3421, 0x82345678, i);
}