1 /* Test signed integer comparison ops
2 cr, cgr, cgfr, c, cg, cgf, cfi, cgfi
4 missing: cy, crl, cgrl, cgfrl
14 #define RIL_RI(op1,r1,op2,i2) \
15 ".short 0x" #op1 #r1 #op2 "\n\t" \
19 /* Perform a single signed comparison
20 Both operands in register */
21 #define SCOMP_REG_REG(insn, v1, v2) \
26 asm volatile( #insn " %1, %2\n\t" \
30 : "d" (op1), "d" (op2) \
32 printf("%.6s (%"PRId64", %"PRId64") --> cc = %d\n", \
33 #insn, op1, op2, cc); \
36 /* Perform a single signed comparison
37 Left operand in register, right operand in memory */
38 #define SCOMP_REG_MEM(insn, v1, v2, op2_t) \
43 asm volatile( #insn " %1, %2\n\t" \
47 : "d" (op1), "Q" (op2) \
49 printf("%.6s (%"PRId64", %"PRId64") --> cc = %d\n", \
50 #insn, op1, (int64_t)op2, cc); \
53 /* Perform a single signed comparison
54 Left operand in register, right operand is an immediate constant */
55 #define SCOMP_REG_IMM(insn, v1, v2) \
58 register int64_t op1 asm("8") = v1; \
59 asm volatile( insn(8, v2) \
65 printf("%.6s (%"PRId64", %"PRId64") --> cc = %d\n", \
66 #insn, op1, (int64_t)v2, cc); \
69 /* Run a sequence of signed comparisons for a given insn */
70 #define run_scomp_reg_reg(insn) \
72 SCOMP_REG_REG(insn, 0, 0); \
73 SCOMP_REG_REG(insn, 0, 1); \
74 SCOMP_REG_REG(insn, 0, -1); \
75 SCOMP_REG_REG(insn, 1, 0); \
76 SCOMP_REG_REG(insn, -1, 0); \
77 SCOMP_REG_REG(insn, -2, -1); \
78 SCOMP_REG_REG(insn, -2, -2); \
79 SCOMP_REG_REG(insn, -2, -3); \
80 SCOMP_REG_REG(insn, 2, 1); \
81 SCOMP_REG_REG(insn, 2, 2); \
82 SCOMP_REG_REG(insn, 2, 3); \
83 SCOMP_REG_REG(insn, -2, 1); \
84 SCOMP_REG_REG(insn, 2, -1); \
85 SCOMP_REG_REG(insn, INT8_MIN, INT8_MIN); \
86 SCOMP_REG_REG(insn, INT8_MIN, INT8_MAX); \
87 SCOMP_REG_REG(insn, INT8_MAX, INT8_MIN); \
88 SCOMP_REG_REG(insn, INT8_MAX, INT8_MAX); \
89 SCOMP_REG_REG(insn, INT16_MIN, INT16_MIN); \
90 SCOMP_REG_REG(insn, INT16_MIN, INT16_MAX); \
91 SCOMP_REG_REG(insn, INT16_MAX, INT16_MIN); \
92 SCOMP_REG_REG(insn, INT16_MAX, INT16_MAX); \
93 SCOMP_REG_REG(insn, INT32_MIN, INT32_MIN); \
94 SCOMP_REG_REG(insn, INT32_MIN, INT32_MAX); \
95 SCOMP_REG_REG(insn, INT32_MAX, INT32_MIN); \
96 SCOMP_REG_REG(insn, INT32_MAX, INT32_MAX); \
99 /* Run a sequence of signed comparisons for a given insn */
100 #define run_scomp_reg_mem(insn, op2_t) \
102 SCOMP_REG_MEM(insn, 0, 0, op2_t); \
103 SCOMP_REG_MEM(insn, 0, 1, op2_t); \
104 SCOMP_REG_MEM(insn, 0, -1, op2_t); \
105 SCOMP_REG_MEM(insn, 1, 0, op2_t); \
106 SCOMP_REG_MEM(insn, -1, 0, op2_t); \
107 SCOMP_REG_MEM(insn, -2, -1, op2_t); \
108 SCOMP_REG_MEM(insn, -2, -2, op2_t); \
109 SCOMP_REG_MEM(insn, -2, -3, op2_t); \
110 SCOMP_REG_MEM(insn, 2, 1, op2_t); \
111 SCOMP_REG_MEM(insn, 2, 2, op2_t); \
112 SCOMP_REG_MEM(insn, 2, 3, op2_t); \
113 SCOMP_REG_MEM(insn, -2, 1, op2_t); \
114 SCOMP_REG_MEM(insn, 2, -1, op2_t); \
115 SCOMP_REG_MEM(insn, INT8_MIN, INT8_MIN, op2_t); \
116 SCOMP_REG_MEM(insn, INT8_MIN, INT8_MAX, op2_t); \
117 SCOMP_REG_MEM(insn, INT8_MAX, INT8_MIN, op2_t); \
118 SCOMP_REG_MEM(insn, INT8_MAX, INT8_MAX, op2_t); \
119 SCOMP_REG_MEM(insn, INT16_MIN, INT16_MIN, op2_t); \
120 SCOMP_REG_MEM(insn, INT16_MIN, INT16_MAX, op2_t); \
121 SCOMP_REG_MEM(insn, INT16_MAX, INT16_MIN, op2_t); \
122 SCOMP_REG_MEM(insn, INT16_MAX, INT16_MAX, op2_t); \
123 SCOMP_REG_MEM(insn, INT32_MIN, INT32_MIN, op2_t); \
124 SCOMP_REG_MEM(insn, INT32_MIN, INT32_MAX, op2_t); \
125 SCOMP_REG_MEM(insn, INT32_MAX, INT32_MIN, op2_t); \
126 SCOMP_REG_MEM(insn, INT32_MAX, INT32_MAX, op2_t); \
129 /* Run a sequence of signed comparisons for a given insn */
130 #define run_scomp_reg_imm(insn) \
132 SCOMP_REG_IMM(insn, 0, 0); \
133 SCOMP_REG_IMM(insn, 0, 1); \
134 SCOMP_REG_IMM(insn, 0, -1); \
135 SCOMP_REG_IMM(insn, 1, 0); \
136 SCOMP_REG_IMM(insn, -1, 0); \
137 SCOMP_REG_IMM(insn, -2, -1); \
138 SCOMP_REG_IMM(insn, -2, -2); \
139 SCOMP_REG_IMM(insn, -2, -3); \
140 SCOMP_REG_IMM(insn, 2, 1); \
141 SCOMP_REG_IMM(insn, 2, 2); \
142 SCOMP_REG_IMM(insn, 2, 3); \
143 SCOMP_REG_IMM(insn, -2, 1); \
144 SCOMP_REG_IMM(insn, 2, -1); \
145 SCOMP_REG_IMM(insn, INT8_MIN, INT8_MIN); \
146 SCOMP_REG_IMM(insn, INT8_MIN, INT8_MAX); \
147 SCOMP_REG_IMM(insn, INT8_MAX, INT8_MIN); \
148 SCOMP_REG_IMM(insn, INT8_MAX, INT8_MAX); \
149 SCOMP_REG_IMM(insn, INT16_MIN, INT16_MIN); \
150 SCOMP_REG_IMM(insn, INT16_MIN, INT16_MAX); \
151 SCOMP_REG_IMM(insn, INT16_MAX, INT16_MIN); \
152 SCOMP_REG_IMM(insn, INT16_MAX, INT16_MAX); \
153 SCOMP_REG_IMM(insn, INT32_MIN, INT32_MIN); \
154 SCOMP_REG_IMM(insn, INT32_MIN, INT32_MAX); \
155 SCOMP_REG_IMM(insn, INT32_MAX, INT32_MIN); \
156 SCOMP_REG_IMM(insn, INT32_MAX, INT32_MAX); \
160 signed_comparison_reg_reg(void)
162 run_scomp_reg_reg(cr
);
164 run_scomp_reg_reg(cgr
);
165 /* Special cases for cgr */
166 SCOMP_REG_REG(cgr
, INT64_MIN
, INT64_MIN
);
167 SCOMP_REG_REG(cgr
, INT64_MIN
, INT64_MAX
);
168 SCOMP_REG_REG(cgr
, INT64_MAX
, INT64_MIN
);
169 SCOMP_REG_REG(cgr
, INT64_MAX
, INT64_MAX
);
171 run_scomp_reg_reg(cgfr
);
172 /* Special cases for cgfr */
173 SCOMP_REG_REG(cgfr
, INT64_MIN
, INT32_MIN
);
174 SCOMP_REG_REG(cgfr
, INT64_MIN
, INT32_MAX
);
175 SCOMP_REG_REG(cgfr
, INT64_MAX
, INT32_MIN
);
176 SCOMP_REG_REG(cgfr
, INT64_MAX
, INT32_MAX
);
180 signed_comparison_reg_mem(void)
182 run_scomp_reg_mem(c
, int32_t);
184 run_scomp_reg_mem(cg
, int64_t);
185 /* Special cases for cg */
186 SCOMP_REG_MEM(cg
, INT64_MIN
, INT64_MIN
, int64_t);
187 SCOMP_REG_MEM(cg
, INT64_MIN
, INT64_MAX
, int64_t);
188 SCOMP_REG_MEM(cg
, INT64_MAX
, INT64_MIN
, int64_t);
189 SCOMP_REG_MEM(cg
, INT64_MAX
, INT64_MAX
, int64_t);
191 run_scomp_reg_mem(cgf
, int32_t);
192 /* Special cases for cgf */
193 SCOMP_REG_MEM(cgf
, INT64_MIN
, INT32_MIN
, int32_t);
194 SCOMP_REG_MEM(cgf
, INT64_MIN
, INT32_MAX
, int32_t);
195 SCOMP_REG_MEM(cgf
, INT64_MAX
, INT32_MIN
, int32_t);
196 SCOMP_REG_MEM(cgf
, INT64_MAX
, INT32_MAX
, int32_t);
200 signed_comparison_reg_imm(void)
202 run_scomp_reg_imm(CFI
);
204 run_scomp_reg_imm(CGFI
);
205 /* Special cases for cgfi */
206 SCOMP_REG_IMM(CGFI
, INT64_MIN
, INT32_MIN
);
207 SCOMP_REG_IMM(CGFI
, INT64_MIN
, INT32_MAX
);
208 SCOMP_REG_IMM(CGFI
, INT64_MAX
, INT32_MIN
);
209 SCOMP_REG_IMM(CGFI
, INT64_MAX
, INT32_MAX
);
215 signed_comparison_reg_reg();
216 signed_comparison_reg_mem();
217 signed_comparison_reg_imm();