Commit | Line | Data |
---|---|---|
4a71579b PC |
1 | .data 8 |
2 | ok: | |
3 | .c "ok\n" | |
4 | ||
5 | /* ia64 code generation is not optimized for size, and also some | |
6 | * codes generate quite long sequences due to need for stops causing | |
7 | * no code template match and needing to add nops, and other cases | |
8 | * are division/remainder that needs function calls, or float division | |
9 | * that requires a quite long sequence. | |
10 | * (the brute force tests of all register combinations can easily | |
11 | * generate several GB of jit). | |
12 | */ | |
13 | ||
14 | /* 3 operand */ | |
15 | ||
16 | /* reg0 = reg1 op reg2 */ | |
17 | #define ALUR(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
18 | movi %R1 I0 \ | |
19 | movi %R2 I1 \ | |
20 | OP##r##T %R0 %R1 %R2 \ | |
21 | beqi OP##T##N##r_##R0##R1##R2 %R0 V \ | |
22 | calli @abort \ | |
23 | OP##T##N##r_##R0##R1##R2: | |
24 | ||
25 | /* reg0 = reg1 op im */ | |
26 | #define ALUI(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
27 | movi %R1 I0 \ | |
28 | movi %R2 V \ | |
29 | OP##i##T %R0 %R1 I1 \ | |
30 | beqr OP##T##N##i_##R0##R1##R2 %R0 %R2 \ | |
31 | calli @abort \ | |
32 | OP##T##N##i_##R0##R1##R2: | |
33 | ||
34 | /* reg0 = reg0 op reg1 */ | |
35 | #define ALUR0(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
36 | movi %R0 I0 \ | |
37 | movi %R1 I1 \ | |
38 | movi %R2 V \ | |
39 | OP##r##T %R0 %R0 %R1 \ | |
40 | beqr OP##T##N##r_0##R0##R1##R2 %R0 %R2 \ | |
41 | calli @abort \ | |
42 | OP##T##N##r_0##R0##R1##R2: | |
43 | ||
44 | /* reg0 = reg1 op reg0 */ | |
45 | #define ALUR1(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
46 | movi %R0 I1 \ | |
47 | movi %R1 I0 \ | |
48 | movi %R2 V \ | |
49 | OP##r##T %R0 %R1 %R0 \ | |
50 | beqr OP##T##N##r_1##R0##R1##R2 %R0 %R2 \ | |
51 | calli @abort \ | |
52 | OP##T##N##r_1##R0##R1##R2: | |
53 | ||
54 | /* reg0 = reg0 op im */ | |
55 | #define ALUI0(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
56 | movi %R0 I0 \ | |
57 | movi %R1 V \ | |
58 | OP##i##T %R0 %R0 I1 \ | |
59 | beqr OP##T##N##i_0##R0##R1##R2 %R0 %R1 \ | |
60 | calli @abort \ | |
61 | OP##T##N##i_0##R0##R1##R2: | |
62 | ||
63 | #define ALU3(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
64 | ALUR(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
65 | ALUI(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
66 | ALUR0(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
67 | ALUR1(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
68 | ALUI0(N, T, OP, I0, I1, V, R0, R1, R2) | |
69 | ||
70 | #define ALU2(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
71 | ALU3(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
72 | ALU3(N, T, OP, I0, I1, V, R0, R2, R1) | |
73 | ||
74 | #define ALU1(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
75 | ALU2(N, T, OP, I0, I1, V, R0, R1, R2) \ | |
76 | ALU2(N, T, OP, I0, I1, V, R1, R0, R2) \ | |
77 | ALU2(N, T, OP, I0, I1, V, R2, R1, R0) | |
78 | ||
79 | #if __ia64__ | |
80 | # define ALU(N, T, OP, I0, I1, V) \ | |
81 | ALU3(N, T, OP, I0, I1, V, r0, r1, r2) \ | |
82 | ALU3(N, T, OP, I0, I1, V, v0, v1, v2) | |
83 | #else | |
84 | # define ALU(N, T, OP, I0, I1, V) \ | |
85 | ALU1(N, T, OP, I0, I1, V, v0, v1, v2) \ | |
86 | ALU1(N, T, OP, I0, I1, V, v0, v1, r0) \ | |
87 | ALU1(N, T, OP, I0, I1, V, v0, v1, r1) \ | |
88 | ALU1(N, T, OP, I0, I1, V, v0, v1, r2) \ | |
89 | ALU1(N, T, OP, I0, I1, V, v1, v2, r1) \ | |
90 | ALU1(N, T, OP, I0, I1, V, v1, v2, r2) \ | |
91 | ALU1(N, T, OP, I0, I1, V, v2, r0, r1) \ | |
92 | ALU1(N, T, OP, I0, I1, V, v2, r0, r2) \ | |
93 | ALU1(N, T, OP, I0, I1, V, r0, r1, r2) | |
94 | #endif | |
95 | ||
96 | /* 3 carry set/propagate */ | |
97 | ||
98 | /* | |
99 | * r0 = i0 | |
100 | * r1 = i1 | |
101 | * r2 = 0 | |
102 | * r0 = r0 opc r1 <only want carry> | |
103 | * r2 = r2 opx r2 <r2 must match v> | |
104 | */ | |
105 | #define ALUXII(N, OP, I0, I1, V, R0, R1, R2) \ | |
106 | movi %R0 I0 \ | |
107 | movi %R2 0 \ | |
108 | OP##ci %R0 %R0 I1 \ | |
109 | OP##xi %R2 %R2 0 \ | |
110 | beqi OP##N##ii##R0##R1##R2 %R2 V \ | |
111 | calli @abort \ | |
112 | OP##N##ii##R0##R1##R2: | |
113 | ||
114 | #define ALUXIR(N, OP, I0, I1, V, R0, R1, R2) \ | |
115 | movi %R0 I0 \ | |
116 | movi %R2 0 \ | |
117 | OP##ci %R0 %R0 I1 \ | |
118 | OP##xr %R2 %R2 %R2 \ | |
119 | beqi OP##N##ir##R0##R1##R2 %R2 V \ | |
120 | calli @abort \ | |
121 | OP##N##ir##R0##R1##R2: | |
122 | ||
123 | #define ALUXRI(N, OP, I0, I1, V, R0, R1, R2) \ | |
124 | movi %R0 I0 \ | |
125 | movi %R1 I1 \ | |
126 | movi %R2 0 \ | |
127 | OP##cr %R0 %R0 %R1 \ | |
128 | OP##xi %R2 %R2 0 \ | |
129 | beqi OP##N##ri##R0##R1##R2 %R2 V \ | |
130 | calli @abort \ | |
131 | OP##N##ri##R0##R1##R2: | |
132 | ||
133 | #define ALUXRR(N, OP, I0, I1, V, R0, R1, R2) \ | |
134 | movi %R0 I0 \ | |
135 | movi %R1 I1 \ | |
136 | movi %R2 0 \ | |
137 | OP##cr %R0 %R0 %R1 \ | |
138 | OP##xr %R2 %R2 %R2 \ | |
139 | beqi OP##N##rr##R0##R1##R2 %R2 V \ | |
140 | calli @abort \ | |
141 | OP##N##rr##R0##R1##R2: | |
142 | ||
143 | #define ALUX2(N, OP, I0, I1, V, R0, R1, R2) \ | |
144 | ALUXII(N, OP, I0, I1, V, R0, R1, R2) \ | |
145 | ALUXIR(N, OP, I0, I1, V, R0, R1, R2) \ | |
146 | ALUXRI(N, OP, I0, I1, V, R0, R1, R2) \ | |
147 | ALUXRR(N, OP, I0, I1, V, R0, R1, R2) | |
148 | ||
149 | #define ALUX1(N, OP, I0, I1, V, R0, R1, R2) \ | |
150 | ALUX2(N, OP, I0, I1, V, R0, R1, R2) \ | |
151 | ALUX2(N, OP, I0, I1, V, R0, R2, R1) | |
152 | ||
153 | #define ALUX0(N, OP, I0, I1, V, R0, R1, R2) \ | |
154 | ALUX1(N, OP, I0, I1, V, R0, R1, R2) \ | |
155 | ALUX1(N, OP, I0, I1, V, R1, R0, R2) \ | |
156 | ALUX1(N, OP, I0, I1, V, R2, R1, R0) | |
157 | ||
158 | #if __ia64__ | |
159 | # define ALUX(N, OP, I0, I1, V) \ | |
160 | ALUX2(N, OP, I0, I1, V, r0, r1, r2) \ | |
161 | ALUX2(N, OP, I0, I1, V, v0, v1, v2) | |
162 | #else | |
163 | # define ALUX(N, OP, I0, I1, V) \ | |
164 | ALUX0(N, OP, I0, I1, V, v0, v1, v2) \ | |
165 | ALUX0(N, OP, I0, I1, V, v0, v1, r0) \ | |
166 | ALUX0(N, OP, I0, I1, V, v0, v1, r1) \ | |
167 | ALUX0(N, OP, I0, I1, V, v0, v1, r2) \ | |
168 | ALUX0(N, OP, I0, I1, V, v1, v2, r0) \ | |
169 | ALUX0(N, OP, I0, I1, V, v1, v2, r1) \ | |
170 | ALUX0(N, OP, I0, I1, V, v1, v2, r2) \ | |
171 | ALUX0(N, OP, I0, I1, V, v2, r0, r1) \ | |
172 | ALUX0(N, OP, I0, I1, V, v2, r0, r2) \ | |
173 | ALUX0(N, OP, I0, I1, V, r0, r1, r2) | |
174 | #endif | |
175 | ||
176 | /* unary int */ | |
177 | ||
178 | #define UNR(N, OP, I, V, R0, R1) \ | |
179 | movi %R1 I \ | |
180 | OP##r %R0 %R1 \ | |
181 | beqi OP##N##R0##R1 %R0 V \ | |
182 | calli @abort \ | |
183 | OP##N##R0##R1: | |
184 | ||
185 | #define UNRC(N, OP, I, V, R0, R1) \ | |
186 | movi %R0 I \ | |
187 | OP##r %R0 %R0 \ | |
188 | beqi OP##N##c##R0##R1 %R0 V \ | |
189 | calli @abort \ | |
190 | OP##N##c##R0##R1: | |
191 | ||
192 | #define UN2(N, OP, I, V, R0, R1) \ | |
193 | UNR(N, OP, I, V, R0, R1) \ | |
194 | UNRC(N, OP, I, V, R0, R1) | |
195 | ||
196 | #define UN1(N, OP, I, V, R0, R1) \ | |
197 | UN2(N, OP, I, V, R0, R1) \ | |
198 | UN2(N, OP, I, V, R1, R0) | |
199 | ||
200 | #if __ia64__ | |
201 | # define UN(N, OP, I, V) \ | |
202 | UN2(N, OP, I, V, r0, r1) \ | |
203 | UN2(N, OP, I, V, v0, v1) | |
204 | #else | |
205 | # define UN(N, OP, I, V) \ | |
206 | UN1(N, OP, I, V, v0, v1) \ | |
207 | UN1(N, OP, I, V, v0, v2) \ | |
208 | UN1(N, OP, I, V, v0, r0) \ | |
209 | UN1(N, OP, I, V, v0, r1) \ | |
210 | UN1(N, OP, I, V, v0, r2) \ | |
211 | UN1(N, OP, I, V, v1, v2) \ | |
212 | UN1(N, OP, I, V, v1, r0) \ | |
213 | UN1(N, OP, I, V, v1, r1) \ | |
214 | UN1(N, OP, I, V, v1, r2) \ | |
215 | UN1(N, OP, I, V, v2, r0) \ | |
216 | UN1(N, OP, I, V, v2, r1) \ | |
217 | UN1(N, OP, I, V, v2, r2) \ | |
218 | UN1(N, OP, I, V, r0, r1) \ | |
219 | UN1(N, OP, I, V, r0, r2) \ | |
220 | UN1(N, OP, I, V, r1, r2) | |
221 | #endif | |
222 | ||
223 | /* reg0 = reg1 op reg2 */ | |
224 | #define FOPR(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
225 | movi##T %F1 I0 \ | |
226 | movi##T %F2 I1 \ | |
227 | OP##r##T %F0 %F1 %F2 \ | |
228 | beqi##T OP##T##N##F0##F1##F2 %F0 V \ | |
229 | calli @abort \ | |
230 | OP##T##N##F0##F1##F2: | |
231 | ||
232 | /* reg0 = reg0 op reg1 */ | |
233 | #define FOPR0(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
234 | movi##T %F0 I0 \ | |
235 | movi##T %F1 I1 \ | |
236 | OP##r##T %F0 %F0 %F1 \ | |
237 | beqi##T OP##T##N##0##F0##F1##F2 %F0 V \ | |
238 | calli @abort \ | |
239 | OP##T##N##0##F0##F1##F2: | |
240 | ||
241 | /* reg1 = reg0 op reg1 */ | |
242 | #define FOPR1(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
243 | movi##T %F0 I0 \ | |
244 | movi##T %F1 I1 \ | |
245 | OP##r##T %F1 %F0 %F1 \ | |
246 | beqi##T OP##T##N##1##F0##F1##F2 %F1 V \ | |
247 | calli @abort \ | |
248 | OP##T##N##1##F0##F1##F2: | |
249 | ||
250 | /* reg0 = reg1 op im */ | |
251 | #define FOPI(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
252 | movi##T %F1 I0 \ | |
253 | movi##T %F2 V \ | |
254 | OP##i##T %F0 %F1 I1 \ | |
255 | beqr##T OP##T##N##i##F0##F1##F2 %F0 %F2 \ | |
256 | calli @abort \ | |
257 | OP##T##N##i##F0##F1##F2: | |
258 | ||
259 | /* reg0 = reg0 op im */ | |
260 | #define FOPI0(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
261 | movi##T %F0 I0 \ | |
262 | movi##T %F2 V \ | |
263 | OP##i##T %F0 %F0 I1 \ | |
264 | beqr##T OP##T##N##i0##F0##F1##F2 %F0 %F2 \ | |
265 | calli @abort \ | |
266 | OP##T##N##i0##F0##F1##F2: | |
267 | ||
268 | #define FOP1(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
269 | FOPR(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
270 | FOPR0(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
271 | FOPR1(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
272 | FOPI(N, T, OP, I0, I1, V, F0, F1, F2) \ | |
273 | FOPI0(N, T, OP, I0, I1, V, F0, F1, F2) | |
274 | ||
275 | #if __ia64__ | |
276 | # define FOP(N, T, OP, I0, I1, V) \ | |
277 | FOP1(N, T, OP, I0, I1, V, f0, f1, f2) | |
278 | #else | |
279 | # define FOP(N, T, OP, I0, I1, V) \ | |
280 | FOP1(N, T, OP, I0, I1, V, f0, f1, f2) \ | |
281 | FOP1(N, T, OP, I0, I1, V, f0, f2, f3) \ | |
282 | FOP1(N, T, OP, I0, I1, V, f0, f3, f4) \ | |
283 | FOP1(N, T, OP, I0, I1, V, f0, f5, f1) | |
284 | #endif | |
285 | ||
286 | /* unary float */ | |
287 | ||
288 | #define FUNR(N, T, OP, I, V, R0, R1) \ | |
289 | movi##T %R1 I \ | |
290 | OP##r##T %R0 %R1 \ | |
291 | beqi##T OP##N##T##R0##R1 %R0 V \ | |
292 | calli @abort \ | |
293 | OP##N##T##R0##R1: | |
294 | ||
295 | #define FUNRC(N, T, OP, I, V, R0, R1) \ | |
296 | movi##T %R0 I \ | |
297 | OP##r##T %R0 %R0 \ | |
298 | beqi##T OP##N##T##c##R0##R1 %R0 V \ | |
299 | calli @abort \ | |
300 | OP##N##T##c##R0##R1: | |
301 | ||
302 | #define FUN2(N, T, OP, I, V, R0, R1) \ | |
303 | FUNR(N, T, OP, I, V, R0, R1) \ | |
304 | FUNRC(N, T, OP, I, V, R0, R1) | |
305 | ||
306 | #define FUN1(N, T, OP, I, V, R0, R1) \ | |
307 | FUN2(N, T, OP, I, V, R0, R1) \ | |
308 | FUN2(N, T, OP, I, V, R1, R0) | |
309 | ||
310 | #if __ia64__ | |
311 | # define FUN(N, T, OP, I, V) \ | |
312 | FUN2(N, T, OP, I, V, f0, f1) | |
313 | #else | |
314 | # define FUN(N, T, OP, I, V) \ | |
315 | FUN1(N, T, OP, I, V, f0, f1) \ | |
316 | FUN1(N, T, OP, I, V, f0, f2) \ | |
317 | FUN1(N, T, OP, I, V, f0, f3) \ | |
318 | FUN1(N, T, OP, I, V, f0, f4) \ | |
319 | FUN1(N, T, OP, I, V, f0, f5) | |
320 | #endif | |
321 | ||
322 | /* unordered comparison unary float */ | |
323 | ||
324 | #define UFUNR(N, T, OP, I, V, R0, R1) \ | |
325 | movi##T %R1 I \ | |
326 | OP##r##T %R0 %R1 \ | |
327 | buneqi##T OP##N##T##u##R0##R1 %R0 V \ | |
328 | calli @abort \ | |
329 | OP##N##T##u##R0##R1: | |
330 | ||
331 | #define UFUNRC(N, T, OP, I, V, R0, R1) \ | |
332 | movi##T %R0 I \ | |
333 | OP##r##T %R0 %R0 \ | |
334 | buneqi##T OP##N##T##uc##R0##R1 %R0 V \ | |
335 | calli @abort \ | |
336 | OP##N##T##uc##R0##R1: | |
337 | ||
338 | #define UFUN2(N, T, OP, I, V, R0, R1) \ | |
339 | UFUNR(N, T, OP, I, V, R0, R1) \ | |
340 | UFUNRC(N, T, OP, I, V, R0, R1) | |
341 | ||
342 | #define UFUN1(N, T, OP, I, V, R0, R1) \ | |
343 | UFUN2(N, T, OP, I, V, R0, R1) \ | |
344 | UFUN2(N, T, OP, I, V, R1, R0) | |
345 | ||
346 | #if __ia64__ | |
347 | # define UFUN(N, T, OP, I, V) \ | |
348 | UFUN2(N, T, OP, I, V, f0, f1) | |
349 | #else | |
350 | # define UFUN(N, T, OP, I, V) \ | |
351 | UFUN1(N, T, OP, I, V, f0, f1) \ | |
352 | UFUN1(N, T, OP, I, V, f0, f2) \ | |
353 | UFUN1(N, T, OP, I, V, f0, f3) \ | |
354 | UFUN1(N, T, OP, I, V, f0, f4) \ | |
355 | UFUN1(N, T, OP, I, V, f0, f5) | |
356 | #endif | |
357 | ||
358 | . $( $NaN = 0.0/0.0) | |
359 | . $( $Inf = 1.0/0.0) | |
360 | . $($nInf = -1.0/0.0) |