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)
11 #define EXECSHIFT(size, rsize, res, s1, s2, flags) \
14 stringify(OP) size " %" rsize "2, %" rsize "0\n\t" \
17 : "=g" (res), "=g" (flags)\
18 : "r" (s1), "0" (res), "1" (flags));
20 #define EXECSHIFT(size, rsize, res, s1, s2, flags) \
23 stringify(OP) size " %%cl, %" rsize "0\n\t" \
26 : "=q" (res), "=g" (flags)\
27 : "c" (s1), "0" (res), "1" (flags));
30 #if defined(__x86_64__)
31 void exec_opq(long s2
, long s0
, long s1
, long iflags
)
36 EXECSHIFT("q", "", res
, s1
, s2
, flags
);
37 /* overflow is undefined if count != 1 */
40 printf("%-10s A=" FMTLX
" B=" FMTLX
" R=" FMTLX
" CCIN=%04lx CC=%04lx\n",
41 stringify(OP
) "q", s0
, s1
, res
, iflags
, flags
& CC_MASK
);
45 void exec_opl(long s2
, long s0
, long s1
, long iflags
)
50 EXECSHIFT("l", "k", res
, s1
, s2
, flags
);
51 /* overflow is undefined if count != 1 */
54 printf("%-10s A=" FMTLX
" B=" FMTLX
" R=" FMTLX
" CCIN=%04lx CC=%04lx\n",
55 stringify(OP
) "l", s0
, s1
, res
, iflags
, flags
& CC_MASK
);
58 void exec_opw(long s2
, long s0
, long s1
, long iflags
)
63 EXECSHIFT("w", "w", res
, s1
, s2
, flags
);
64 /* overflow is undefined if count != 1 */
67 printf("%-10s A=" FMTLX
" B=" FMTLX
" R=" FMTLX
" CCIN=%04lx CC=%04lx\n",
68 stringify(OP
) "w", s0
, s1
, res
, iflags
, flags
& CC_MASK
);
72 #define EXECSHIFT(size, rsize, res, s1, s2, flags) \
75 stringify(OP) size " %%cl, %" rsize "5, %" rsize "0\n\t" \
78 : "=g" (res), "=g" (flags)\
79 : "c" (s1), "0" (res), "1" (flags), "r" (s2));
81 #if defined(__x86_64__)
82 void exec_opq(long s2
, long s0
, long s1
, long iflags
)
87 EXECSHIFT("q", "", res
, s1
, s2
, flags
);
88 /* overflow is undefined if count != 1 */
91 printf("%-10s A=" FMTLX
" B=" FMTLX
" C=" FMTLX
" R=" FMTLX
" CCIN=%04lx CC=%04lx\n",
92 stringify(OP
) "q", s0
, s2
, s1
, res
, iflags
, flags
& CC_MASK
);
96 void exec_opl(long s2
, long s0
, long s1
, long iflags
)
101 EXECSHIFT("l", "k", res
, s1
, s2
, flags
);
102 /* overflow is undefined if count != 1 */
105 printf("%-10s A=" FMTLX
" B=" FMTLX
" C=" FMTLX
" R=" FMTLX
" CCIN=%04lx CC=%04lx\n",
106 stringify(OP
) "l", s0
, s2
, s1
, res
, iflags
, flags
& CC_MASK
);
109 void exec_opw(long s2
, long s0
, long s1
, long iflags
)
114 EXECSHIFT("w", "w", res
, s1
, s2
, flags
);
115 /* overflow is undefined if count != 1 */
118 printf("%-10s A=" FMTLX
" B=" FMTLX
" C=" FMTLX
" R=" FMTLX
" CCIN=%04lx CC=%04lx\n",
119 stringify(OP
) "w", s0
, s2
, s1
, res
, iflags
, flags
& CC_MASK
);
125 void exec_opb(long s0
, long s1
, long iflags
)
130 EXECSHIFT("b", "b", res
, s1
, 0, flags
);
131 /* overflow is undefined if count != 1 */
134 printf("%-10s A=" FMTLX
" B=" FMTLX
" R=" FMTLX
" CCIN=%04lx CC=%04lx\n",
135 stringify(OP
) "b", s0
, s1
, res
, iflags
, flags
& CC_MASK
);
139 void exec_op(long s2
, long s0
, long s1
)
143 #if defined(__x86_64__)
144 exec_opq(s2
, s0
, s1
, 0);
146 exec_opl(s2
, s0
, s1
, 0);
148 exec_opw(s2
, s0
, s1
, 0);
150 exec_opw(s2
, s0
, s1
, 0);
156 #if defined(__x86_64__)
157 exec_opq(s2
, s0
, s1
, CC_C
);
159 exec_opl(s2
, s0
, s1
, CC_C
);
160 exec_opw(s2
, s0
, s1
, CC_C
);
161 exec_opb(s0
, s1
, CC_C
);
165 void glue(test_
, OP
)(void)
168 #if defined(__x86_64__)
173 for(i
= 0; i
< n
; i
++)
174 exec_op(0x21ad3d34, 0x12345678, i
);
175 for(i
= 0; i
< n
; i
++)
176 exec_op(0x813f3421, 0x82345679, i
);
179 void *glue(_test_
, OP
) __init_call
= glue(test_
, OP
);