Merge pull request #4630 from BrzVlad/feature-valloc-limit
[mono.git] / mono / arch / ia64 / codegen.c
1 /*
2  * codegen.c: Tests for the IA64 code generation macros
3  */
4
5 #include <glib.h>
6 #include <stdio.h>
7 #include <ctype.h>
8
9 #define IA64_SIMPLE_EMIT_BUNDLE
10
11 #include <mono/arch/ia64/ia64-codegen.h>
12
13 void
14 mono_disassemble_code (guint8 *code, int size, char *id)
15 {
16         int i;
17         FILE *ofd;
18         const char *tmp = g_get_tmp_dir ();
19         const char *objdump_args = g_getenv ("MONO_OBJDUMP_ARGS");
20         char *as_file;
21         char *o_file;
22         char *cmd;
23         
24         as_file = g_strdup_printf ("%s/test.s", tmp);    
25
26         if (!(ofd = fopen (as_file, "w")))
27                 g_assert_not_reached ();
28
29         for (i = 0; id [i]; ++i) {
30                 if (!isalnum (id [i]))
31                         fprintf (ofd, "_");
32                 else
33                         fprintf (ofd, "%c", id [i]);
34         }
35         fprintf (ofd, ":\n");
36
37         for (i = 0; i < size; ++i) 
38                 fprintf (ofd, ".byte %d\n", (unsigned int) code [i]);
39
40         fclose (ofd);
41
42 #ifdef __ia64__
43 #define DIS_CMD "objdump -d"
44 #define AS_CMD "as"
45 #else
46 #define DIS_CMD "ia64-linux-gnu-objdump -d"
47 #define AS_CMD "ia64-linux-gnu-as"
48 #endif
49
50         o_file = g_strdup_printf ("%s/test.o", tmp);    
51         cmd = g_strdup_printf (AS_CMD " %s -o %s", as_file, o_file);
52         system (cmd); 
53         g_free (cmd);
54         if (!objdump_args)
55                 objdump_args = strdup("");
56         
57         cmd = g_strdup_printf (DIS_CMD " %s %s", objdump_args, o_file);
58         system (cmd);
59         g_free (cmd);
60         g_free (objdump_args);
61         
62         g_free (o_file);
63         g_free (as_file);
64 }
65
66 int
67 main ()
68 {
69         Ia64CodegenState code;
70
71         guint8 *buf = g_malloc0 (40960);
72
73         ia64_codegen_init (code, buf);
74
75         ia64_add (code, 1, 2, 3);
76         ia64_add1 (code, 1, 2, 3);
77         ia64_sub (code, 1, 2, 3);
78         ia64_sub1 (code, 1, 2, 3);
79         ia64_addp4 (code, 1, 2, 3);
80         ia64_and (code, 1, 2, 3);
81         ia64_andcm (code, 1, 2, 3);
82         ia64_or (code, 1, 2, 3);
83         ia64_xor (code, 1, 2, 3);
84         ia64_shladd (code, 1, 2, 3, 4);
85         ia64_shladdp4 (code, 1, 2, 3, 4);
86         ia64_sub_imm (code, 1, 0x7f, 2);
87         ia64_sub_imm (code, 1, -1, 2);
88         ia64_and_imm (code, 1, -128, 2);
89         ia64_andcm_imm (code, 1, -128, 2);
90         ia64_or_imm (code, 1, -128, 2);
91         ia64_xor_imm (code, 1, -128, 2);
92         ia64_adds_imm (code, 1, 8191, 2);
93         ia64_adds_imm (code, 1, -8192, 2);
94         ia64_adds_imm (code, 1, 1234, 2);
95         ia64_adds_imm (code, 1, -1234, 2);
96         ia64_addp4_imm (code, 1, -1234, 2);
97         ia64_addl_imm (code, 1, 1234, 2);
98         ia64_addl_imm (code, 1, -1234, 2);
99         ia64_addl_imm (code, 1, 2097151, 2);
100         ia64_addl_imm (code, 1, -2097152, 2);
101
102         ia64_cmp_lt (code, 1, 2, 1, 2);
103         ia64_cmp_ltu (code, 1, 2, 1, 2);
104         ia64_cmp_eq (code, 1, 2, 1, 2);
105         ia64_cmp_lt_unc (code, 1, 2, 1, 2);
106         ia64_cmp_ltu_unc (code, 1, 2, 1, 2);
107         ia64_cmp_eq_unc (code, 1, 2, 1, 2);
108         ia64_cmp_eq_and (code, 1, 2, 1, 2);
109         ia64_cmp_eq_or (code, 1, 2, 1, 2);
110         ia64_cmp_eq_or_andcm (code, 1, 2, 1, 2);
111         ia64_cmp_ne_and (code, 1, 2, 1, 2);
112         ia64_cmp_ne_or (code, 1, 2, 1, 2);
113         ia64_cmp_ne_or_andcm (code, 1, 2, 1, 2);
114
115         ia64_cmp4_lt (code, 1, 2, 1, 2);
116         ia64_cmp4_ltu (code, 1, 2, 1, 2);
117         ia64_cmp4_eq (code, 1, 2, 1, 2);
118         ia64_cmp4_lt_unc (code, 1, 2, 1, 2);
119         ia64_cmp4_ltu_unc (code, 1, 2, 1, 2);
120         ia64_cmp4_eq_unc (code, 1, 2, 1, 2);
121         ia64_cmp4_eq_and (code, 1, 2, 1, 2);
122         ia64_cmp4_eq_or (code, 1, 2, 1, 2);
123         ia64_cmp4_eq_or_andcm (code, 1, 2, 1, 2);
124         ia64_cmp4_ne_and (code, 1, 2, 1, 2);
125         ia64_cmp4_ne_or (code, 1, 2, 1, 2);
126         ia64_cmp4_ne_or_andcm (code, 1, 2, 1, 2);
127
128         ia64_cmp_gt_and (code, 1, 2, 0, 2);
129         ia64_cmp_gt_or (code, 1, 2, 0, 2);
130         ia64_cmp_gt_or_andcm (code, 1, 2, 0, 2);
131         ia64_cmp_le_and (code, 1, 2, 0, 2);
132         ia64_cmp_le_or (code, 1, 2, 0, 2);
133         ia64_cmp_le_or_andcm (code, 1, 2, 0, 2);
134         ia64_cmp_ge_and (code, 1, 2, 0, 2);
135         ia64_cmp_ge_or (code, 1, 2, 0, 2);
136         ia64_cmp_ge_or_andcm (code, 1, 2, 0, 2);
137         ia64_cmp_lt_and (code, 1, 2, 0, 2);
138         ia64_cmp_lt_or (code, 1, 2, 0, 2);
139         ia64_cmp_lt_or_andcm (code, 1, 2, 0, 2);
140
141         ia64_cmp4_gt_and (code, 1, 2, 0, 2);
142         ia64_cmp4_gt_or (code, 1, 2, 0, 2);
143         ia64_cmp4_gt_or_andcm (code, 1, 2, 0, 2);
144         ia64_cmp4_le_and (code, 1, 2, 0, 2);
145         ia64_cmp4_le_or (code, 1, 2, 0, 2);
146         ia64_cmp4_le_or_andcm (code, 1, 2, 0, 2);
147         ia64_cmp4_ge_and (code, 1, 2, 0, 2);
148         ia64_cmp4_ge_or (code, 1, 2, 0, 2);
149         ia64_cmp4_ge_or_andcm (code, 1, 2, 0, 2);
150         ia64_cmp4_lt_and (code, 1, 2, 0, 2);
151         ia64_cmp4_lt_or (code, 1, 2, 0, 2);
152         ia64_cmp4_lt_or_andcm (code, 1, 2, 0, 2);
153
154         ia64_cmp_lt_imm (code, 1, 2, 127, 2);
155         ia64_cmp_lt_imm (code, 1, 2, -128, 2);
156
157         ia64_cmp_lt_imm (code, 1, 2, -128, 2);
158         ia64_cmp_ltu_imm (code, 1, 2, -128, 2);
159         ia64_cmp_eq_imm (code, 1, 2, -128, 2);
160         ia64_cmp_lt_unc_imm (code, 1, 2, -128, 2);
161         ia64_cmp_ltu_unc_imm (code, 1, 2, -128, 2);
162         ia64_cmp_eq_unc_imm (code, 1, 2, -128, 2);
163         ia64_cmp_eq_and_imm (code, 1, 2, -128, 2);
164         ia64_cmp_eq_or_imm (code, 1, 2, -128, 2);
165         ia64_cmp_eq_unc_imm (code, 1, 2, -128, 2);
166         ia64_cmp_ne_and_imm (code, 1, 2, -128, 2);
167         ia64_cmp_ne_or_imm (code, 1, 2, -128, 2);
168         ia64_cmp_ne_or_andcm_imm (code, 1, 2, -128, 2);
169
170         ia64_cmp4_lt_imm (code, 1, 2, -128, 2);
171         ia64_cmp4_ltu_imm (code, 1, 2, -128, 2);
172         ia64_cmp4_eq_imm (code, 1, 2, -128, 2);
173         ia64_cmp4_lt_unc_imm (code, 1, 2, -128, 2);
174         ia64_cmp4_ltu_unc_imm (code, 1, 2, -128, 2);
175         ia64_cmp4_eq_unc_imm (code, 1, 2, -128, 2);
176         ia64_cmp4_eq_and_imm (code, 1, 2, -128, 2);
177         ia64_cmp4_eq_or_imm (code, 1, 2, -128, 2);
178         ia64_cmp4_eq_unc_imm (code, 1, 2, -128, 2);
179         ia64_cmp4_ne_and_imm (code, 1, 2, -128, 2);
180         ia64_cmp4_ne_or_imm (code, 1, 2, -128, 2);
181         ia64_cmp4_ne_or_andcm_imm (code, 1, 2, -128, 2);
182
183         ia64_padd1 (code, 1, 2, 3);
184         ia64_padd2 (code, 1, 2, 3);
185         ia64_padd4 (code, 1, 2, 3);
186         ia64_padd1_sss (code, 1, 2, 3);
187         ia64_padd2_sss (code, 1, 2, 3);
188         ia64_padd1_uuu (code, 1, 2, 3);
189         ia64_padd2_uuu (code, 1, 2, 3);
190         ia64_padd1_uus (code, 1, 2, 3);
191         ia64_padd2_uus (code, 1, 2, 3);
192
193         ia64_psub1 (code, 1, 2, 3);
194         ia64_psub2 (code, 1, 2, 3);
195         ia64_psub4 (code, 1, 2, 3);
196         ia64_psub1_sss (code, 1, 2, 3);
197         ia64_psub2_sss (code, 1, 2, 3);
198         ia64_psub1_uuu (code, 1, 2, 3);
199         ia64_psub2_uuu (code, 1, 2, 3);
200         ia64_psub1_uus (code, 1, 2, 3);
201         ia64_psub2_uus (code, 1, 2, 3);
202
203         ia64_pavg1 (code, 1, 2, 3);
204         ia64_pavg2 (code, 1, 2, 3);
205         ia64_pavg1_raz (code, 1, 2, 3);
206         ia64_pavg2_raz (code, 1, 2, 3);
207         ia64_pavgsub1 (code, 1, 2, 3);
208         ia64_pavgsub2 (code, 1, 2, 3);
209         ia64_pcmp1_eq (code, 1, 2, 3);
210         ia64_pcmp2_eq (code, 1, 2, 3);
211         ia64_pcmp4_eq (code, 1, 2, 3);
212         ia64_pcmp1_gt (code, 1, 2, 3);
213         ia64_pcmp2_gt (code, 1, 2, 3);
214         ia64_pcmp4_gt (code, 1, 2, 3);
215         
216         ia64_pshladd2 (code, 1, 2, 3, 4);
217         ia64_pshradd2 (code, 1, 2, 3, 4);
218
219         ia64_pmpyshr2 (code, 1, 2, 3, 0);
220         ia64_pmpyshr2_u (code, 1, 2, 3, 0);
221         ia64_pmpyshr2 (code, 1, 2, 3, 7);
222         ia64_pmpyshr2_u (code, 1, 2, 3, 7);
223         ia64_pmpyshr2 (code, 1, 2, 3, 15);
224         ia64_pmpyshr2_u (code, 1, 2, 3, 15);
225         ia64_pmpyshr2 (code, 1, 2, 3, 16);
226         ia64_pmpyshr2_u (code, 1, 2, 3, 16);
227
228         ia64_pmpy2_r (code, 1, 2, 3);
229         ia64_pmpy2_l (code, 1, 2, 3);
230         ia64_mix1_r (code, 1, 2, 3);
231         ia64_mix2_r (code, 1, 2, 3);
232         ia64_mix4_r (code, 1, 2, 3);
233         ia64_mix1_l (code, 1, 2, 3);
234         ia64_mix2_l (code, 1, 2, 3);
235         ia64_mix4_l (code, 1, 2, 3);
236         ia64_pack2_uss (code, 1, 2, 3);
237         ia64_pack2_sss (code, 1, 2, 3);
238         ia64_pack4_sss (code, 1, 2, 3);
239         ia64_unpack1_h (code, 1, 2, 3);
240         ia64_unpack2_h (code, 1, 2, 3);
241         ia64_unpack4_h (code, 1, 2, 3);
242         ia64_unpack1_l (code, 1, 2, 3);
243         ia64_unpack2_l (code, 1, 2, 3);
244         ia64_unpack4_l (code, 1, 2, 3);
245         ia64_pmin1_u (code, 1, 2, 3);
246         ia64_pmax1_u (code, 1, 2, 3);
247         ia64_pmin2 (code, 1, 2, 3);
248         ia64_pmax2 (code, 1, 2, 3);
249         ia64_psad1 (code, 1, 2, 3);
250
251         ia64_mux1 (code, 1, 2, IA64_MUX1_BRCST);
252         ia64_mux1 (code, 1, 2, IA64_MUX1_MIX);
253         ia64_mux1 (code, 1, 2, IA64_MUX1_SHUF);
254         ia64_mux1 (code, 1, 2, IA64_MUX1_ALT);
255         ia64_mux1 (code, 1, 2, IA64_MUX1_REV);
256
257         ia64_mux2 (code, 1, 2, 0x8d);
258
259         ia64_pshr2 (code, 1, 2, 3);
260         ia64_pshr4 (code, 1, 2, 3);
261         ia64_shr (code, 1, 2, 3);
262         ia64_pshr2_u (code, 1, 2, 3);
263         ia64_pshr4_u (code, 1, 2, 3);
264         ia64_shr_u (code, 1, 2, 3);
265
266         ia64_pshr2_imm (code, 1, 2, 20);
267         ia64_pshr4_imm (code, 1, 2, 20);
268         ia64_pshr2_u_imm (code, 1, 2, 20);
269         ia64_pshr4_u_imm (code, 1, 2, 20);
270
271         ia64_pshl2 (code, 1, 2, 3);
272         ia64_pshl4 (code, 1, 2, 3);
273         ia64_shl (code, 1, 2, 3);
274
275         ia64_pshl2_imm (code, 1, 2, 20);
276         ia64_pshl4_imm (code, 1, 2, 20);
277
278         ia64_popcnt (code, 1, 2);
279
280         ia64_shrp (code, 1, 2, 3, 62);
281
282         ia64_extr_u (code, 1, 2, 62, 61);
283         ia64_extr (code, 1, 2, 62, 61);
284
285         ia64_dep_z (code, 1, 2, 62, 61);
286
287         ia64_dep_z_imm (code, 1, 127, 62, 61);
288         ia64_dep_z_imm (code, 1, -128, 62, 61);
289         ia64_dep_imm (code, 1, 0, 2, 62, 61);
290         ia64_dep_imm (code, 1, -1, 2, 62, 61);
291         ia64_dep (code, 1, 2, 3, 10, 15);
292
293         ia64_tbit_z (code, 1, 2, 3, 0);
294
295         ia64_tbit_z (code, 1, 2, 3, 63);
296         ia64_tbit_z_unc (code, 1, 2, 3, 63);
297         ia64_tbit_z_and (code, 1, 2, 3, 63);
298         ia64_tbit_nz_and (code, 1, 2, 3, 63);
299         ia64_tbit_z_or (code, 1, 2, 3, 63);
300         ia64_tbit_nz_or (code, 1, 2, 3, 63);
301         ia64_tbit_z_or_andcm (code, 1, 2, 3, 63);
302         ia64_tbit_nz_or_andcm (code, 1, 2, 3, 63);
303
304         ia64_tnat_z (code, 1, 2, 3);
305         ia64_tnat_z_unc (code, 1, 2, 3);
306         ia64_tnat_z_and (code, 1, 2, 3);
307         ia64_tnat_nz_and (code, 1, 2, 3);
308         ia64_tnat_z_or (code, 1, 2, 3);
309         ia64_tnat_nz_or (code, 1, 2, 3);
310         ia64_tnat_z_or_andcm (code, 1, 2, 3);
311         ia64_tnat_nz_or_andcm (code, 1, 2, 3);
312
313         ia64_nop_i (code, 0x1234);
314         ia64_hint_i (code, 0x1234);
315
316         ia64_break_i (code, 0x1234);
317
318         ia64_chk_s_i (code, 1, 0);
319         ia64_chk_s_i (code, 1, -1);
320         ia64_chk_s_i (code, 1, 1);
321
322         ia64_mov_to_br_hint (code, 1, 1, -1, IA64_MOV_TO_BR_WH_NONE, 0);
323         ia64_mov_to_br_hint (code, 1, 1, -1, IA64_MOV_TO_BR_WH_SPTK, 0);
324         ia64_mov_to_br_hint (code, 1, 1, -1, IA64_MOV_TO_BR_WH_DPTK, 0);
325         ia64_mov_to_br_hint (code, 1, 1, -1, IA64_MOV_TO_BR_WH_DPTK, IA64_BR_IH_IMP);
326         ia64_mov_ret_to_br_hint (code, 1, 1, -1, IA64_MOV_TO_BR_WH_NONE, 0);
327
328         ia64_mov_from_br (code, 1, 1);
329
330         ia64_mov_to_pred (code, 1, 0xfe);
331
332         ia64_mov_to_pred_rot_imm (code, 0xff0000);
333
334         ia64_mov_from_ip (code, 1);
335         ia64_mov_from_pred (code, 1);
336
337         ia64_mov_to_ar_i (code, 1, 1);
338
339         ia64_mov_to_ar_imm_i (code, 1, 127);
340
341         ia64_mov_from_ar_i (code, 1, 1);
342
343         ia64_zxt1 (code, 1, 2);
344         ia64_zxt2 (code, 1, 2);
345         ia64_zxt4 (code, 1, 2);
346         ia64_sxt1 (code, 1, 2);
347         ia64_sxt2 (code, 1, 2);
348         ia64_sxt4 (code, 1, 2);
349
350         ia64_czx1_l (code, 1, 2);
351         ia64_czx2_l (code, 1, 2);
352         ia64_czx1_r (code, 1, 2);
353         ia64_czx2_r (code, 1, 2);
354
355         ia64_ld1_hint (code, 1, 2, IA64_LD_HINT_NONE);
356         ia64_ld1_hint (code, 1, 2, IA64_LD_HINT_NT1);
357         ia64_ld1_hint (code, 1, 2, IA64_LD_HINT_NTA);
358
359         ia64_ld1_hint (code, 1, 2, 0);
360         ia64_ld2_hint (code, 1, 2, 0);
361         ia64_ld4_hint (code, 1, 2, 0);
362         ia64_ld8_hint (code, 1, 2, 0);
363
364         ia64_ld1_s_hint (code, 1, 2, 0);
365         ia64_ld2_s_hint (code, 1, 2, 0);
366         ia64_ld4_s_hint (code, 1, 2, 0);
367         ia64_ld8_s_hint (code, 1, 2, 0);
368
369         ia64_ld1_a_hint (code, 1, 2, 0);
370         ia64_ld2_a_hint (code, 1, 2, 0);
371         ia64_ld4_a_hint (code, 1, 2, 0);
372         ia64_ld8_a_hint (code, 1, 2, 0);
373
374         ia64_ld1_sa_hint (code, 1, 2, 0);
375         ia64_ld2_sa_hint (code, 1, 2, 0);
376         ia64_ld4_sa_hint (code, 1, 2, 0);
377         ia64_ld8_sa_hint (code, 1, 2, 0);
378
379         ia64_ld1_bias_hint (code, 1, 2, 0);
380         ia64_ld2_bias_hint (code, 1, 2, 0);
381         ia64_ld4_bias_hint (code, 1, 2, 0);
382         ia64_ld8_bias_hint (code, 1, 2, 0);
383
384         ia64_ld1_inc_hint (code, 1, 2, 3, IA64_LD_HINT_NONE);
385
386         ia64_ld1_inc_imm_hint (code, 1, 2, 255, IA64_LD_HINT_NONE);
387         ia64_ld1_inc_imm_hint (code, 1, 2, -256, IA64_LD_HINT_NONE);
388
389         ia64_st1_hint (code, 1, 2, IA64_ST_HINT_NTA);
390
391         ia64_st1_hint (code, 1, 2, IA64_ST_HINT_NONE);
392         ia64_st2_hint (code, 1, 2, IA64_ST_HINT_NONE);
393         ia64_st4_hint (code, 1, 2, IA64_ST_HINT_NONE);
394         ia64_st8_hint (code, 1, 2, IA64_ST_HINT_NONE);
395
396         ia64_st1_rel_hint (code, 1, 2, IA64_ST_HINT_NONE);
397         ia64_st2_rel_hint (code, 1, 2, IA64_ST_HINT_NONE);
398         ia64_st4_rel_hint (code, 1, 2, IA64_ST_HINT_NONE);
399         ia64_st8_rel_hint (code, 1, 2, IA64_ST_HINT_NONE);
400
401         ia64_st8_spill_hint (code, 1, 2, IA64_ST_HINT_NONE);
402
403         ia64_st16_hint (code, 1, 2, IA64_ST_HINT_NONE);
404         ia64_st16_rel_hint (code, 1, 2, IA64_ST_HINT_NONE);
405
406         ia64_st1_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
407         ia64_st2_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
408         ia64_st4_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
409         ia64_st8_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
410
411         ia64_st1_rel_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
412         ia64_st2_rel_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
413         ia64_st4_rel_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
414         ia64_st8_rel_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
415
416         ia64_st8_spill_inc_imm_hint (code, 1, 2, 255, IA64_ST_HINT_NONE);
417
418         ia64_ldfs_hint (code, 1, 2, 0);
419         ia64_ldfd_hint (code, 1, 2, 0);
420         ia64_ldf8_hint (code, 1, 2, 0);
421         ia64_ldfe_hint (code, 1, 2, 0);
422
423         ia64_ldfs_s_hint (code, 1, 2, 0);
424         ia64_ldfd_s_hint (code, 1, 2, 0);
425         ia64_ldf8_s_hint (code, 1, 2, 0);
426         ia64_ldfe_s_hint (code, 1, 2, 0);
427
428         ia64_ldfs_a_hint (code, 1, 2, 0);
429         ia64_ldfd_a_hint (code, 1, 2, 0);
430         ia64_ldf8_a_hint (code, 1, 2, 0);
431         ia64_ldfe_a_hint (code, 1, 2, 0);
432
433         ia64_ldfs_sa_hint (code, 1, 2, 0);
434         ia64_ldfd_sa_hint (code, 1, 2, 0);
435         ia64_ldf8_sa_hint (code, 1, 2, 0);
436         ia64_ldfe_sa_hint (code, 1, 2, 0);
437
438         ia64_ldfs_c_clr_hint (code, 1, 2, 0);
439         ia64_ldfd_c_clr_hint (code, 1, 2, 0);
440         ia64_ldf8_c_clr_hint (code, 1, 2, 0);
441         ia64_ldfe_c_clr_hint (code, 1, 2, 0);
442
443         ia64_ldfs_c_nc_hint (code, 1, 2, 0);
444         ia64_ldfd_c_nc_hint (code, 1, 2, 0);
445         ia64_ldf8_c_nc_hint (code, 1, 2, 0);
446         ia64_ldfe_c_nc_hint (code, 1, 2, 0);
447
448         ia64_ldf_fill_hint (code, 1, 2, 0);
449
450         ia64_ldfs_inc_hint (code, 1, 2, 3, 0);
451         ia64_ldfd_inc_hint (code, 1, 2, 3, 0);
452         ia64_ldf8_inc_hint (code, 1, 2, 3, 0);
453         ia64_ldfe_inc_hint (code, 1, 2, 3, 0);
454
455         ia64_ldfs_s_inc_hint (code, 1, 2, 3, 0);
456         ia64_ldfd_s_inc_hint (code, 1, 2, 3, 0);
457         ia64_ldf8_s_inc_hint (code, 1, 2, 3, 0);
458         ia64_ldfe_s_inc_hint (code, 1, 2, 3, 0);
459
460         ia64_ldfs_a_inc_hint (code, 1, 2, 3, 0);
461         ia64_ldfd_a_inc_hint (code, 1, 2, 3, 0);
462         ia64_ldf8_a_inc_hint (code, 1, 2, 3, 0);
463         ia64_ldfe_a_inc_hint (code, 1, 2, 3, 0);
464
465         ia64_ldfs_sa_inc_hint (code, 1, 2, 3, 0);
466         ia64_ldfd_sa_inc_hint (code, 1, 2, 3, 0);
467         ia64_ldf8_sa_inc_hint (code, 1, 2, 3, 0);
468         ia64_ldfe_sa_inc_hint (code, 1, 2, 3, 0);
469
470         ia64_ldfs_c_clr_inc_hint (code, 1, 2, 3, 0);
471         ia64_ldfd_c_clr_inc_hint (code, 1, 2, 3, 0);
472         ia64_ldf8_c_clr_inc_hint (code, 1, 2, 3, 0);
473         ia64_ldfe_c_clr_inc_hint (code, 1, 2, 3, 0);
474
475         ia64_ldfs_c_nc_inc_hint (code, 1, 2, 3, 0);
476         ia64_ldfd_c_nc_inc_hint (code, 1, 2, 3, 0);
477         ia64_ldf8_c_nc_inc_hint (code, 1, 2, 3, 0);
478         ia64_ldfe_c_nc_inc_hint (code, 1, 2, 3, 0);
479
480         ia64_ldf_fill_inc_hint (code, 1, 2, 3, 0);
481
482         ia64_ldfs_inc_imm_hint (code, 1, 2, 255, 0);
483         ia64_ldfd_inc_imm_hint (code, 1, 2, 255, 0);
484         ia64_ldf8_inc_imm_hint (code, 1, 2, 255, 0);
485         ia64_ldfe_inc_imm_hint (code, 1, 2, 255, 0);
486
487         ia64_ldfs_s_inc_imm_hint (code, 1, 2, 255, 0);
488         ia64_ldfd_s_inc_imm_hint (code, 1, 2, 255, 0);
489         ia64_ldf8_s_inc_imm_hint (code, 1, 2, 255, 0);
490         ia64_ldfe_s_inc_imm_hint (code, 1, 2, 255, 0);
491
492         ia64_ldfs_a_inc_imm_hint (code, 1, 2, 255, 0);
493         ia64_ldfd_a_inc_imm_hint (code, 1, 2, 255, 0);
494         ia64_ldf8_a_inc_imm_hint (code, 1, 2, 255, 0);
495         ia64_ldfe_a_inc_imm_hint (code, 1, 2, 255, 0);
496
497         ia64_ldfs_sa_inc_imm_hint (code, 1, 2, 255, 0);
498         ia64_ldfd_sa_inc_imm_hint (code, 1, 2, 255, 0);
499         ia64_ldf8_sa_inc_imm_hint (code, 1, 2, 255, 0);
500         ia64_ldfe_sa_inc_imm_hint (code, 1, 2, 255, 0);
501
502         ia64_ldfs_c_clr_inc_imm_hint (code, 1, 2, 255, 0);
503         ia64_ldfd_c_clr_inc_imm_hint (code, 1, 2, 255, 0);
504         ia64_ldf8_c_clr_inc_imm_hint (code, 1, 2, 255, 0);
505         ia64_ldfe_c_clr_inc_imm_hint (code, 1, 2, 255, 0);
506
507         ia64_ldfs_c_nc_inc_imm_hint (code, 1, 2, 255, 0);
508         ia64_ldfd_c_nc_inc_imm_hint (code, 1, 2, 255, 0);
509         ia64_ldf8_c_nc_inc_imm_hint (code, 1, 2, 255, 0);
510         ia64_ldfe_c_nc_inc_imm_hint (code, 1, 2, 255, 0);
511
512         ia64_ldf_fill_inc_imm_hint (code, 1, 2, 255, 0);
513
514         ia64_stfs_hint (code, 1, 2, 0);
515         ia64_stfd_hint (code, 1, 2, 0);
516         ia64_stf8_hint (code, 1, 2, 0);
517         ia64_stfe_hint (code, 1, 2, 0);
518
519         ia64_stf_spill_hint (code, 1, 2, 0);
520
521         ia64_stfs_inc_imm_hint (code, 1, 2, 255, 0);
522         ia64_stfd_inc_imm_hint (code, 1, 2, 255, 0);
523         ia64_stf8_inc_imm_hint (code, 1, 2, 255, 0);
524         ia64_stfe_inc_imm_hint (code, 1, 2, 255, 0);
525
526         ia64_stf_spill_inc_imm_hint (code, 1, 2, 255, 0);
527
528         ia64_ldfps_hint (code, 1, 2, 3, 0);
529         ia64_ldfpd_hint (code, 1, 2, 3, 0);
530         ia64_ldfp8_hint (code, 1, 2, 3, 0);
531
532         ia64_ldfps_s_hint (code, 1, 2, 3, 0);
533         ia64_ldfpd_s_hint (code, 1, 2, 3, 0);
534         ia64_ldfp8_s_hint (code, 1, 2, 3, 0);
535
536         ia64_ldfps_a_hint (code, 1, 2, 3, 0);
537         ia64_ldfpd_a_hint (code, 1, 2, 3, 0);
538         ia64_ldfp8_a_hint (code, 1, 2, 3, 0);
539
540         ia64_ldfps_sa_hint (code, 1, 2, 3, 0);
541         ia64_ldfpd_sa_hint (code, 1, 2, 3, 0);
542         ia64_ldfp8_sa_hint (code, 1, 2, 3, 0);
543
544         ia64_ldfps_c_clr_hint (code, 1, 2, 3, 0);
545         ia64_ldfpd_c_clr_hint (code, 1, 2, 3, 0);
546         ia64_ldfp8_c_clr_hint (code, 1, 2, 3, 0);
547
548         ia64_ldfps_c_nc_hint (code, 1, 2, 3, 0);
549         ia64_ldfpd_c_nc_hint (code, 1, 2, 3, 0);
550         ia64_ldfp8_c_nc_hint (code, 1, 2, 3, 0);
551
552         ia64_ldfps_inc_hint (code, 1, 2, 3, 0);
553         ia64_ldfpd_inc_hint (code, 1, 2, 3, 0);
554         ia64_ldfp8_inc_hint (code, 1, 2, 3, 0);
555
556         ia64_ldfps_s_inc_hint (code, 1, 2, 3, 0);
557         ia64_ldfpd_s_inc_hint (code, 1, 2, 3, 0);
558         ia64_ldfp8_s_inc_hint (code, 1, 2, 3, 0);
559
560         ia64_ldfps_a_inc_hint (code, 1, 2, 3, 0);
561         ia64_ldfpd_a_inc_hint (code, 1, 2, 3, 0);
562         ia64_ldfp8_a_inc_hint (code, 1, 2, 3, 0);
563
564         ia64_ldfps_sa_inc_hint (code, 1, 2, 3, 0);
565         ia64_ldfpd_sa_inc_hint (code, 1, 2, 3, 0);
566         ia64_ldfp8_sa_inc_hint (code, 1, 2, 3, 0);
567
568         ia64_ldfps_c_clr_inc_hint (code, 1, 2, 3, 0);
569         ia64_ldfpd_c_clr_inc_hint (code, 1, 2, 3, 0);
570         ia64_ldfp8_c_clr_inc_hint (code, 1, 2, 3, 0);
571
572         ia64_ldfps_c_nc_inc_hint (code, 1, 2, 3, 0);
573         ia64_ldfpd_c_nc_inc_hint (code, 1, 2, 3, 0);
574         ia64_ldfp8_c_nc_inc_hint (code, 1, 2, 3, 0);
575
576         ia64_lfetch_hint (code, 1, 0);
577         ia64_lfetch_excl_hint (code, 1, 0);
578         ia64_lfetch_fault_hint (code, 1, 0);
579         ia64_lfetch_fault_excl_hint (code, 1, 0);
580
581         ia64_lfetch_hint (code, 1, IA64_LFHINT_NT1);
582         ia64_lfetch_hint (code, 1, IA64_LFHINT_NT2);
583         ia64_lfetch_hint (code, 1, IA64_LFHINT_NTA);
584
585         ia64_lfetch_inc_hint (code, 1, 2, 0);
586         ia64_lfetch_excl_inc_hint (code, 1, 2, 0);
587         ia64_lfetch_fault_inc_hint (code, 1, 2, 0);
588         ia64_lfetch_fault_excl_inc_hint (code, 1, 2, 0);
589
590         ia64_lfetch_inc_imm_hint (code, 1, 255, 0);
591         ia64_lfetch_excl_inc_imm_hint (code, 1, 255, 0);
592         ia64_lfetch_fault_inc_imm_hint (code, 1, 255, 0);
593         ia64_lfetch_fault_excl_inc_imm_hint (code, 1, 255, 0);
594
595         ia64_cmpxchg1_acq_hint (code, 1, 2, 3, 0);
596         ia64_cmpxchg2_acq_hint (code, 1, 2, 3, 0);
597         ia64_cmpxchg4_acq_hint (code, 1, 2, 3, 0);
598         ia64_cmpxchg8_acq_hint (code, 1, 2, 3, 0);
599         ia64_cmpxchg1_rel_hint (code, 1, 2, 3, 0);
600         ia64_cmpxchg2_rel_hint (code, 1, 2, 3, 0);
601         ia64_cmpxchg4_rel_hint (code, 1, 2, 3, 0);
602         ia64_cmpxchg8_rel_hint (code, 1, 2, 3, 0);
603         ia64_cmpxchg16_acq_hint (code, 1, 2, 3, 0);
604         ia64_cmpxchg16_rel_hint (code, 1, 2, 3, 0);
605         ia64_xchg1_hint (code, 1, 2, 3, 0);
606         ia64_xchg2_hint (code, 1, 2, 3, 0);
607         ia64_xchg4_hint (code, 1, 2, 3, 0);
608         ia64_xchg8_hint (code, 1, 2, 3, 0);
609
610         ia64_fetchadd4_acq_hint (code, 1, 2, -16, 0);
611         ia64_fetchadd4_acq_hint (code, 1, 2, -8, 0);
612         ia64_fetchadd4_acq_hint (code, 1, 2, -4, 0);
613         ia64_fetchadd4_acq_hint (code, 1, 2, -1, 0);
614         ia64_fetchadd4_acq_hint (code, 1, 2, 1, 0);
615         ia64_fetchadd4_acq_hint (code, 1, 2, 4, 0);
616         ia64_fetchadd4_acq_hint (code, 1, 2, 8, 0);
617         ia64_fetchadd4_acq_hint (code, 1, 2, 16, 0);
618
619         ia64_fetchadd4_acq_hint (code, 1, 2, 16, 0);
620         ia64_fetchadd8_acq_hint (code, 1, 2, 16, 0);
621         ia64_fetchadd4_rel_hint (code, 1, 2, 16, 0);
622         ia64_fetchadd8_rel_hint (code, 1, 2, 16, 0);
623
624         ia64_setf_sig (code, 1, 2);
625         ia64_setf_exp (code, 1, 2);
626         ia64_setf_s (code, 1, 2);
627         ia64_setf_d (code, 1, 2);
628
629         ia64_getf_sig (code, 1, 2);
630         ia64_getf_exp (code, 1, 2);
631         ia64_getf_s (code, 1, 2);
632         ia64_getf_d (code, 1, 2);
633
634         ia64_chk_s_m (code, 1, 0);
635         ia64_chk_s_m (code, 1, 1);
636         ia64_chk_s_m (code, 1, -1);
637
638         ia64_chk_s_float_m (code, 1, 0);
639
640         ia64_chk_a_nc (code, 1, 0);
641         ia64_chk_a_nc (code, 1, 1);
642         ia64_chk_a_nc (code, 1, -1);
643
644         ia64_chk_a_nc (code, 1, 0);
645         ia64_chk_a_clr (code, 1, 0);
646
647         ia64_chk_a_nc_float (code, 1, 0);
648         ia64_chk_a_clr_float (code, 1, 0);
649
650         ia64_invala (code);
651         ia64_fwb (code);
652         ia64_mf (code);
653         ia64_mf_a (code);
654         ia64_srlz_d (code);
655         ia64_stlz_i (code);
656         ia64_sync_i (code);
657
658         ia64_flushrs (code);
659         ia64_loadrs (code);
660
661         ia64_invala_e (code, 1);
662         ia64_invala_e_float (code, 1);
663
664         ia64_fc (code, 1);
665         ia64_fc_i (code, 1);
666
667         ia64_mov_to_ar_m (code, 1, 1);
668
669         ia64_mov_to_ar_imm_m (code, 1, 127);
670
671         ia64_mov_from_ar_m (code, 1, 1);
672
673         ia64_mov_to_cr (code, 1, 2);
674
675         ia64_mov_from_cr (code, 1, 2);
676
677         ia64_alloc (code, 1, 3, 4, 5, 0);
678         ia64_alloc (code, 1, 3, 4, 5, 8);
679
680         ia64_mov_to_psr_l (code, 1);
681         ia64_mov_to_psr_um (code, 1);
682
683         ia64_mov_from_psr (code, 1);
684         ia64_mov_from_psr_um (code, 1);
685
686         ia64_break_m (code, 0x1234);
687         ia64_nop_m (code, 0x1234);
688         ia64_hint_m (code, 0x1234);
689
690         ia64_br_cond_hint (code, 0, 0, 0, 0);
691         ia64_br_wexit_hint (code, 0, 0, 0, 0);
692         ia64_br_wtop_hint (code, 0, 0, 0, 0);
693
694         ia64_br_cloop_hint (code, 0, 0, 0, 0);
695         ia64_br_cexit_hint (code, 0, 0, 0, 0);
696         ia64_br_ctop_hint (code, 0, 0, 0, 0);
697
698         ia64_br_call_hint (code, 1, 0, 0, 0, 0);
699
700         ia64_br_cond_reg_hint (code, 1, 0, 0, 0);
701         ia64_br_ia_reg_hint (code, 1, 0, 0, 0);
702         ia64_br_ret_reg_hint (code, 1, 0, 0, 0);
703
704         ia64_br_call_reg_hint (code, 1, 2, 0, 0, 0);
705
706         ia64_cover (code);
707         ia64_clrrrb (code);
708         ia64_clrrrb_pr (code);
709         ia64_rfi (code);
710         ia64_bsw_0 (code);
711         ia64_bsw_1 (code);
712         ia64_epc (code);
713
714         ia64_break_b (code, 0x1234);
715         ia64_nop_b (code, 0x1234);
716         ia64_hint_b (code, 0x1234);
717
718         ia64_break_x (code, 0x2123456789ABCDEFULL);
719
720         ia64_movl (code, 1, 0x123456789ABCDEF0LL);
721
722         ia64_brl_cond_hint (code, 0, 0, 0, 0);
723         ia64_brl_cond_hint (code, -1, 0, 0, 0);
724
725         ia64_brl_call_hint (code, 1, 0, 0, 0, 0);
726         ia64_brl_call_hint (code, 1, -1, 0, 0, 0);
727
728         ia64_nop_x (code, 0x2123456789ABCDEFULL);
729         ia64_hint_x (code, 0x2123456789ABCDEFULL);
730
731         ia64_movl_pred (code, 1, 1, 0x123456789ABCDEF0LL);
732
733         /* FLOATING-POINT */
734         ia64_fma_sf_pred (code, 1, 1, 2, 3, 4, 2);
735         ia64_fma_s_sf_pred (code, 1, 1, 2, 3, 4, 2);
736         ia64_fma_d_sf_pred (code, 1, 1, 2, 3, 4, 2);
737         ia64_fpma_sf_pred (code, 1, 1, 2, 3, 4, 2);
738         ia64_fms_sf_pred (code, 1, 1, 2, 3, 4, 2);
739         ia64_fms_s_sf_pred (code, 1, 1, 2, 3, 4, 2);
740         ia64_fms_d_sf_pred (code, 1, 1, 2, 3, 4, 2);
741         ia64_fpms_sf_pred (code, 1, 1, 2, 3, 4, 2);
742         ia64_fnma_sf_pred (code, 1, 1, 2, 3, 4, 2);
743         ia64_fnma_s_sf_pred (code, 1, 1, 2, 3, 4, 2);
744         ia64_fnma_d_sf_pred (code, 1, 1, 2, 3, 4, 2);
745         ia64_fpnma_sf_pred (code, 1, 1, 2, 3, 4, 2);
746
747         ia64_xma_l_pred (code, 1, 1, 2, 3, 4);
748         ia64_xma_h_pred (code, 1, 1, 2, 3, 4);
749         ia64_xma_hu_pred (code, 1, 1, 2, 3, 4);
750
751         ia64_fselect_pred (code, 1, 1, 2, 3, 4);
752
753         ia64_fcmp_eq_sf_pred (code, 1, 1, 2, 3, 4, 0);
754         ia64_fcmp_lt_sf_pred (code, 1, 1, 2, 3, 4, 0);
755         ia64_fcmp_le_sf_pred (code, 1, 1, 2, 3, 4, 0);
756         ia64_fcmp_unord_sf_pred (code, 1, 1, 2, 3, 4, 0);
757         ia64_fcmp_eq_unc_sf_pred (code, 1, 1, 2, 3, 4, 0);
758         ia64_fcmp_lt_unc_sf_pred (code, 1, 1, 2, 3, 4, 0);
759         ia64_fcmp_le_unc_sf_pred (code, 1, 1, 2, 3, 4, 0);
760         ia64_fcmp_unord_unc_sf_pred (code, 1, 1, 2, 3, 4, 0);
761
762         ia64_fclass_m_pred (code, 1, 1, 2, 3, 0x1ff);
763         ia64_fclass_m_unc_pred (code, 1, 1, 2, 3, 0x1ff);
764
765         ia64_frcpa_sf_pred (code, 1, 1, 2, 3, 4, 0);
766         ia64_fprcpa_sf_pred (code, 1, 1, 2, 3, 4, 0);
767
768         ia64_frsqrta_sf_pred (code, 1, 1, 2, 4, 0);
769         ia64_fprsqrta_sf_pred (code, 1, 1, 2, 4, 0);
770
771         ia64_fmin_sf_pred (code, 1, 2, 3, 4, 0);
772         ia64_fman_sf_pred (code, 1, 2, 3, 4, 0);
773         ia64_famin_sf_pred (code, 1, 2, 3, 4, 0);
774         ia64_famax_sf_pred (code, 1, 2, 3, 4, 0);
775         ia64_fpmin_sf_pred (code, 1, 2, 3, 4, 0);
776         ia64_fpman_sf_pred (code, 1, 2, 3, 4, 0);
777         ia64_fpamin_sf_pred (code, 1, 2, 3, 4, 0);
778         ia64_fpamax_sf_pred (code, 1, 2, 3, 4, 0);
779         ia64_fpcmp_eq_sf_pred (code, 1, 2, 3, 4, 0);
780         ia64_fpcmp_lt_sf_pred (code, 1, 2, 3, 4, 0);
781         ia64_fpcmp_le_sf_pred (code, 1, 2, 3, 4, 0);
782         ia64_fpcmp_unord_sf_pred (code, 1, 2, 3, 4, 0);
783         ia64_fpcmp_neq_sf_pred (code, 1, 2, 3, 4, 0);
784         ia64_fpcmp_nlt_sf_pred (code, 1, 2, 3, 4, 0);
785         ia64_fpcmp_nle_sf_pred (code, 1, 2, 3, 4, 0);
786         ia64_fpcmp_ord_sf_pred (code, 1, 2, 3, 4, 0);
787
788         ia64_fmerge_s_pred (code, 1, 2, 3, 4);
789         ia64_fmerge_ns_pred (code, 1, 2, 3, 4);
790         ia64_fmerge_se_pred (code, 1, 2, 3, 4);
791         ia64_fmix_lr_pred (code, 1, 2, 3, 4);
792         ia64_fmix_r_pred (code, 1, 2, 3, 4);
793         ia64_fmix_l_pred (code, 1, 2, 3, 4);
794         ia64_fsxt_r_pred (code, 1, 2, 3, 4);
795         ia64_fsxt_l_pred (code, 1, 2, 3, 4);
796         ia64_fpack_pred (code, 1, 2, 3, 4);
797         ia64_fswap_pred (code, 1, 2, 3, 4);
798         ia64_fswap_nl_pred (code, 1, 2, 3, 4);
799         ia64_fswap_nr_pred (code, 1, 2, 3, 4);
800         ia64_fand_pred (code, 1, 2, 3, 4);
801         ia64_fandcm_pred (code, 1, 2, 3, 4);
802         ia64_for_pred (code, 1, 2, 3, 4);
803         ia64_fxor_pred (code, 1, 2, 3, 4);
804         ia64_fpmerge_s_pred (code, 1, 2, 3, 4);
805         ia64_fpmerge_ns_pred (code, 1, 2, 3, 4);
806         ia64_fpmerge_se_pred (code, 1, 2, 3, 4);
807         
808         ia64_fcvt_fx_sf_pred ((code), 1, 2, 3, 0);
809         ia64_fcvt_fxu_sf_pred ((code), 1, 2, 3, 0);
810         ia64_fcvt_fx_trunc_sf_pred ((code), 1, 2, 3, 0);
811         ia64_fcvt_fxu_trunc_sf_pred ((code), 1, 2, 3, 0);
812         ia64_fpcvt_fx_sf_pred ((code), 1, 2, 3, 0);
813         ia64_fpcvt_fxu_sf_pred ((code), 1, 2, 3, 0);
814         ia64_fpcvt_fx_trunc_sf_pred ((code), 1, 2, 3, 0);
815         ia64_fpcvt_fxu_trunc_sf_pred ((code), 1, 2, 3, 0);
816
817         ia64_fcvt_xf_pred ((code), 1, 2, 3);
818
819         ia64_fsetc_sf_pred ((code), 1, 0x33, 0x33, 3);
820
821         ia64_fclrf_sf_pred ((code), 1, 3);
822
823         ia64_fchkf_sf_pred ((code), 1, -1, 3);
824
825         ia64_break_f_pred ((code), 1, 0x1234);
826
827         ia64_movl (code, 31, -123456);
828
829         ia64_codegen_close (code);
830
831 #if 0
832         /* disassembly */
833         {
834                 guint8 *buf = code.buf;
835                 int template;
836                 guint64 dw1, dw2;
837                 guint64 ins1, ins2, ins3;
838
839                 ia64_break_i (code, 0x1234);
840
841                 ia64_codegen_close (code);
842
843                 dw1 = ((guint64*)buf) [0];
844                 dw2 = ((guint64*)buf) [1];
845
846                 template = ia64_bundle_template (buf);
847                 ins1 = ia64_bundle_ins1 (buf);
848                 ins2 = ia64_bundle_ins2 (buf);
849                 ins3 = ia64_bundle_ins3 (buf);
850
851                 code.buf = buf;
852                 ia64_emit_bundle_template (&code, template, ins1, ins2, ins3);
853
854                 g_assert (dw1 == ((guint64*)buf) [0]);
855                 g_assert (dw2 == ((guint64*)buf) [1]);
856         }
857 #endif
858
859         mono_disassemble_code (buf, 40960, "code");
860
861         return 0;
862 }