non-linux regtest: update cmdline expecteds
[valgrind.git] / VEX / test / test-amd64-shift.h
blobe5ded43e65e34ad2c19eda392c92174a509d493f
2 #define exec_op glue(exec_, OP)
3 #define exec_opq glue(glue(exec_, OP), q)
4 #define exec_opl glue(glue(exec_, OP), l)
5 #define exec_opw glue(glue(exec_, OP), w)
6 #define exec_opb glue(glue(exec_, OP), b)
8 #ifndef OP_SHIFTD
10 #ifdef OP_NOBYTE
11 #define EXECSHIFT(size, res, s1, s2, flags) \
12 asm ("pushq %4\n\t"\
13 "popfq\n\t"\
14 stringify(OP) size " %" size "2, %" size "0\n\t" \
15 "pushfq\n\t"\
16 "popq %1\n\t"\
17 : "=g" (res), "=g" (flags)\
18 : "r" (s1), "0" (res), "1" (flags));
19 #else
20 #define EXECSHIFT(size, res, s1, s2, flags) \
21 asm ("pushq %4\n\t"\
22 "popfq\n\t"\
23 stringify(OP) size " %%cl, %" size "0\n\t" \
24 "pushfq\n\t"\
25 "popq %1\n\t"\
26 : "=q" (res), "=g" (flags)\
27 : "c" (s1), "0" (res), "1" (flags));
28 #endif
30 void exec_opq(int64 s2, int64 s0, int64 s1, int64 iflags)
32 int64 res, flags;
33 res = s0;
34 flags = iflags;
35 EXECSHIFT("q", res, s1, s2, flags);
36 /* overflow is undefined if count != 1 */
37 if (s1 != 1)
38 flags &= ~CC_O;
39 printf("%-10s A=%016llx B=%016llx R=%016llx CCIN=%04llx CC=%04llx\n",
40 stringify(OP) "q", s0, s1, res, iflags, flags & CC_MASK);
43 void exec_opl(int64 s2, int64 s0, int64 s1, int64 iflags)
45 int64 res, flags;
46 res = s0;
47 flags = iflags;
48 EXECSHIFT("", res, s1, s2, flags);
49 /* overflow is undefined if count != 1 */
50 if (s1 != 1)
51 flags &= ~CC_O;
52 printf("%-10s A=%016llx B=%016llx R=%016llx CCIN=%04llx CC=%04llx\n",
53 stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK);
56 void exec_opw(int64 s2, int64 s0, int64 s1, int64 iflags)
58 int64 res, flags;
59 res = s0;
60 flags = iflags;
61 EXECSHIFT("w", res, s1, s2, flags);
62 /* overflow is undefined if count != 1 */
63 if (s1 != 1)
64 flags &= ~CC_O;
65 printf("%-10s A=%016llx B=%016llx R=%016llx CCIN=%04llx CC=%04llx\n",
66 stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK);
69 #else
70 #define EXECSHIFT(size, res, s1, s2, flags) \
71 asm ("pushq %4\n\t"\
72 "popfq\n\t"\
73 stringify(OP) size " %%cl, %" size "5, %" size "0\n\t" \
74 "pushfq\n\t"\
75 "popq %1\n\t"\
76 : "=g" (res), "=g" (flags)\
77 : "c" (s1), "0" (res), "1" (flags), "r" (s2));
79 void exec_opl(int64 s2, int64 s0, int64 s1, int64 iflags)
81 int64 res, flags;
82 res = s0;
83 flags = iflags;
84 EXECSHIFT("", res, s1, s2, flags);
85 /* overflow is undefined if count != 1 */
86 if (s1 != 1)
87 flags &= ~CC_O;
88 printf("%-10s A=%016llx B=%016llx C=%016llx R=%016llx CCIN=%04llx CC=%04llx\n",
89 stringify(OP) "l", s0, s2, s1, res, iflags, flags & CC_MASK);
92 void exec_opw(int64 s2, int64 s0, int64 s1, int64 iflags)
94 int64 res, flags;
95 res = s0;
96 flags = iflags;
97 EXECSHIFT("w", res, s1, s2, flags);
98 /* overflow is undefined if count != 1 */
99 if (s1 != 1)
100 flags &= ~CC_O;
101 printf("%-10s A=%016llx B=%016llx C=%016llx R=%016llx CCIN=%04llx CC=%04llx\n",
102 stringify(OP) "w", s0, s2, s1, res, iflags, flags & CC_MASK);
105 #endif
107 #ifndef OP_NOBYTE
108 void exec_opb(int64 s0, int64 s1, int64 iflags)
110 int64 res, flags;
111 res = s0;
112 flags = iflags;
113 EXECSHIFT("b", res, s1, 0, flags);
114 /* overflow is undefined if count != 1 */
115 if (s1 != 1)
116 flags &= ~CC_O;
117 printf("%-10s A=%016llx B=%016llx R=%016llx CCIN=%04llx CC=%04llx\n",
118 stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK);
120 #endif
122 void exec_op(int64 s2, int64 s0, int64 s1)
124 int64 o,s,z,a,c,p,flags_in;
125 for (o = 0; o < 2; o++) {
126 for (s = 0; s < 2; s++) {
127 for (z = 0; z < 2; z++) {
128 for (a = 0; a < 2; a++) {
129 for (c = 0; c < 2; c++) {
130 for (p = 0; p < 2; p++) {
132 flags_in = (o ? CC_O : 0)
133 | (s ? CC_S : 0)
134 | (z ? CC_Z : 0)
135 | (a ? CC_A : 0)
136 | (c ? CC_C : 0)
137 | (p ? CC_P : 0);
139 exec_opq(s2, s0, s1, flags_in);
140 if (s1 <= 31)
141 exec_opl(s2, s0, s1, flags_in);
142 #ifdef OP_SHIFTD
143 if (s1 <= 15)
144 exec_opw(s2, s0, s1, flags_in);
145 #else
146 exec_opw(s2, s0, s1, flags_in);
147 #endif
148 #ifndef OP_NOBYTE
149 exec_opb(s0, s1, flags_in);
150 #endif
151 #ifdef OP_CC
152 exec_opq(s2, s0, s1, flags_in);
153 exec_opl(s2, s0, s1, flags_in);
154 exec_opw(s2, s0, s1, flags_in);
155 exec_opb(s0, s1, flags_in);
156 #endif
158 }}}}}}
162 void glue(test_, OP)(void)
164 int64 i;
165 for(i = 0; i < 64; i++)
166 exec_op(0x3141592721ad3d34, 0x2718284612345678, i);
167 for(i = 0; i < 64; i++)
168 exec_op(0x31415927813f3421, 0x2718284682345678, i);
171 void *glue(_test_, OP) __init_call = glue(test_, OP);
173 #undef OP
174 #undef OP_CC
175 #undef OP_SHIFTD
176 #undef OP_NOBYTE
177 #undef EXECSHIFT