3 # This is the specification for the ia32 assembler Firm-operations
8 $normal = 0; # no special type
9 $caller_save = 1; # caller save (register must be saved by the caller of a function)
10 $callee_save = 2; # callee save (register must be saved by the called function)
11 $ignore = 4; # ignore (do not assign this register)
12 $arbitrary = 8; # emitter can choose an arbitrary register of this class
13 $virtual = 16; # the register is a virtual one
14 $state = 32; # register represents a state
15 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
18 { name => "edx", type => $caller_save },
19 { name => "ecx", type => $caller_save },
20 { name => "eax", type => $caller_save },
21 { name => "ebx", type => $callee_save },
22 { name => "esi", type => $callee_save },
23 { name => "edi", type => $callee_save },
24 { name => "ebp", type => $callee_save },
25 { name => "esp", type => $ignore },
26 { name => "gp_NOREG", type => $ignore | $arbitrary | $virtual }, # we need a dummy register for NoReg nodes
30 { name => "mm0", type => $ignore },
31 { name => "mm1", type => $ignore },
32 { name => "mm2", type => $ignore },
33 { name => "mm3", type => $ignore },
34 { name => "mm4", type => $ignore },
35 { name => "mm5", type => $ignore },
36 { name => "mm6", type => $ignore },
37 { name => "mm7", type => $ignore },
38 { mode => "mode_E", flags => "manual_ra" }
41 { name => "xmm0", type => $caller_save },
42 { name => "xmm1", type => $caller_save },
43 { name => "xmm2", type => $caller_save },
44 { name => "xmm3", type => $caller_save },
45 { name => "xmm4", type => $caller_save },
46 { name => "xmm5", type => $caller_save },
47 { name => "xmm6", type => $caller_save },
48 { name => "xmm7", type => $caller_save },
49 { name => "xmm_NOREG", type => $ignore | $virtual }, # we need a dummy register for NoReg nodes
53 { name => "vf0", type => $caller_save },
54 { name => "vf1", type => $caller_save },
55 { name => "vf2", type => $caller_save },
56 { name => "vf3", type => $caller_save },
57 { name => "vf4", type => $caller_save },
58 { name => "vf5", type => $caller_save },
59 { name => "vf6", type => $caller_save },
60 { name => "vf7", type => $caller_save },
61 { name => "vfp_NOREG", type => $ignore | $arbitrary | $virtual }, # we need a dummy register for NoReg nodes
65 { name => "st0", realname => "st", type => $ignore },
66 { name => "st1", realname => "st(1)", type => $ignore },
67 { name => "st2", realname => "st(2)", type => $ignore },
68 { name => "st3", realname => "st(3)", type => $ignore },
69 { name => "st4", realname => "st(4)", type => $ignore },
70 { name => "st5", realname => "st(5)", type => $ignore },
71 { name => "st6", realname => "st(6)", type => $ignore },
72 { name => "st7", realname => "st(7)", type => $ignore },
73 { mode => "mode_E", flags => "manual_ra" }
75 fp_cw => [ # the floating point control word
76 { name => "fpcw", type => $ignore | $state },
77 { mode => "ia32_mode_fpcw", flags => "manual_ra|state" }
80 { name => "eflags", type => 0 },
81 { mode => "mode_Iu", flags => "manual_ra" }
86 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
87 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
88 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
89 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
94 bundels_per_cycle => 1
98 S0 => "${arch}_emit_source_register(node, 0);",
99 S1 => "${arch}_emit_source_register(node, 1);",
100 S2 => "${arch}_emit_source_register(node, 2);",
101 S3 => "${arch}_emit_source_register(node, 3);",
102 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
103 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
104 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
105 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
106 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
107 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
108 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
109 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
110 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
111 D0 => "${arch}_emit_dest_register(node, 0);",
112 D1 => "${arch}_emit_dest_register(node, 1);",
113 DS0 => "${arch}_emit_dest_register_size(node, 0);",
114 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
115 X0 => "${arch}_emit_x87_register(node, 0);",
116 X1 => "${arch}_emit_x87_register(node, 1);",
117 EX => "${arch}_emit_extend_suffix(node);",
118 M => "${arch}_emit_mode_suffix(node);",
119 XM => "${arch}_emit_x87_mode_suffix(node);",
120 XXM => "${arch}_emit_xmm_mode_suffix(node);",
121 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
122 AM => "${arch}_emit_am(node);",
123 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
124 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
125 binop => "${arch}_emit_binop(node);",
126 x87_binop => "${arch}_emit_x87_binop(node);",
127 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
133 $default_op_attr_type = "ia32_op_attr_t";
134 $default_attr_type = "ia32_attr_t";
135 $default_copy_attr = "ia32_copy_attr";
137 sub ia32_custom_init_attr {
143 if(defined($node->{modified_flags})) {
144 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
146 if(defined($node->{am})) {
147 my $am = $node->{am};
148 if($am eq "source,unary") {
149 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
150 } elsif($am eq "source,binary") {
151 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
152 } elsif($am eq "none") {
155 die("Invalid address mode '$am' specified on op $name");
158 if($node->{state} ne "exc_pinned"
159 and $node->{state} ne "pinned") {
160 die("AM nodes must have pinned or AM pinned state ($name)");
166 $custom_init_attr_func = \&ia32_custom_init_attr;
170 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
171 "\tinit_ia32_x87_attributes(res);".
172 "\tinit_ia32_asm_attributes(res);",
174 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);",
176 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
177 "\tinit_ia32_call_attributes(res, pop, call_tp);",
178 ia32_condcode_attr_t =>
179 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
180 "\tinit_ia32_condcode_attributes(res, condition_code);",
181 ia32_switch_attr_t =>
182 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
183 "\tinit_ia32_switch_attributes(res, default_pn);",
185 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
186 "\tinit_ia32_copyb_attributes(res, size);",
187 ia32_immediate_attr_t =>
188 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
189 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
191 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
192 "\tinit_ia32_x87_attributes(res);",
193 ia32_climbframe_attr_t =>
194 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
195 "\tinit_ia32_climbframe_attributes(res, count);",
199 ia32_asm_attr_t => "ia32_compare_asm_attr",
200 ia32_attr_t => "ia32_compare_nodes_attr",
201 ia32_call_attr_t => "ia32_compare_call_attr",
202 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
203 ia32_switch_attr_t => "ia32_compare_switch_attr",
204 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
205 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
206 ia32_x87_attr_t => "ia32_compare_x87_attr",
207 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
213 $mode_xmm = "mode_E";
214 $mode_gp = "mode_Iu";
215 $mode_flags = "mode_Iu";
216 $mode_fpcw = "ia32_mode_fpcw";
217 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
218 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
219 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
220 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
226 op_flags => [ "constlike" ],
227 irn_flags => [ "not_scheduled" ],
228 reg_req => { out => [ "gp_NOREG:I" ] },
229 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
230 attr_type => "ia32_immediate_attr_t",
231 hash_func => "ia32_hash_Immediate",
239 out_arity => "variable",
240 attr_type => "ia32_asm_attr_t",
241 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
242 init_attr => "attr->asm_text = asm_text;\n".
243 "\tattr->register_map = register_map;\n",
245 modified_flags => $status_flags,
248 # "allocates" a free register
250 op_flags => [ "constlike", "cse_neutral" ],
251 irn_flags => [ "rematerializable" ],
252 reg_req => { out => [ "gp" ] },
257 cmp_attr => "return 1;",
261 irn_flags => [ "rematerializable" ],
262 state => "exc_pinned",
263 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
264 out => [ "in_r4 in_r5", "flags", "none" ] },
265 ins => [ "base", "index", "mem", "left", "right" ],
266 outs => [ "res", "flags", "M" ],
267 emit => '. add%M %binop',
268 am => "source,binary",
272 modified_flags => $status_flags
276 irn_flags => [ "rematerializable" ],
277 state => "exc_pinned",
278 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
279 ins => [ "base", "index", "mem", "val" ],
280 emit => ". add%M %SI3, %AM",
284 modified_flags => $status_flags
288 irn_flags => [ "rematerializable" ],
289 state => "exc_pinned",
290 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
291 ins => [ "base", "index", "mem", "val" ],
292 emit => ". add%M %SB3, %AM",
296 modified_flags => $status_flags
300 state => "exc_pinned",
301 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
302 out => [ "in_r4 in_r5", "flags", "none" ] },
303 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
304 outs => [ "res", "flags", "M" ],
305 emit => '. adc%M %binop',
306 am => "source,binary",
310 modified_flags => $status_flags
314 op_flags => [ "constlike" ],
315 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
316 ins => [ "left", "right" ],
320 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
321 ins => [ "left", "right", "eflags" ],
325 # we should not rematrialize this node. It produces 2 results and has
326 # very strict constraints
327 state => "exc_pinned",
328 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
329 out => [ "eax", "flags", "none", "edx" ] },
330 ins => [ "base", "index", "mem", "left", "right" ],
331 emit => '. mul%M %unop4',
332 outs => [ "res_low", "flags", "M", "res_high" ],
333 am => "source,binary",
336 modified_flags => $status_flags
340 # we should not rematrialize this node. It produces 2 results and has
341 # very strict constraints
342 op_flags => [ "constlike" ],
343 cmp_attr => "return 1;",
344 reg_req => { in => [ "none", "none" ],
345 out => [ "none", "none", "none", "none" ] },
346 ins => [ "left", "right" ],
347 outs => [ "res_low", "flags", "M", "res_high" ],
351 irn_flags => [ "rematerializable" ],
352 state => "exc_pinned",
353 # TODO: adjust out requirements for the 3 operand form
354 # (no need for should_be_same then)
355 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
356 out => [ "in_r4 in_r5", "flags", "none" ] },
357 ins => [ "base", "index", "mem", "left", "right" ],
358 outs => [ "res", "flags", "M" ],
359 am => "source,binary",
363 modified_flags => $status_flags
367 irn_flags => [ "rematerializable" ],
368 state => "exc_pinned",
369 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
370 out => [ "eax", "flags", "none", "edx" ] },
371 ins => [ "base", "index", "mem", "left", "right" ],
372 emit => '. imul%M %unop4',
373 outs => [ "res_low", "flags", "M", "res_high" ],
374 am => "source,binary",
377 modified_flags => $status_flags
381 op_flags => [ "constlike" ],
382 cmp_attr => "return 1;",
383 reg_req => { in => [ "none", "none" ],
384 out => [ "none", "none", "none", "none" ] },
385 ins => [ "left", "right" ],
386 outs => [ "res_low", "flags", "M", "res_high" ],
390 irn_flags => [ "rematerializable" ],
391 state => "exc_pinned",
392 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
393 out => [ "in_r4 in_r5", "flags", "none" ] },
394 ins => [ "base", "index", "mem", "left", "right" ],
395 outs => [ "res", "flags", "M" ],
396 am => "source,binary",
397 emit => '. and%M %binop',
401 modified_flags => $status_flags
405 irn_flags => [ "rematerializable" ],
406 state => "exc_pinned",
407 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
408 ins => [ "base", "index", "mem", "val" ],
409 emit => '. and%M %SI3, %AM',
413 modified_flags => $status_flags
417 irn_flags => [ "rematerializable" ],
418 state => "exc_pinned",
419 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
420 ins => [ "base", "index", "mem", "val" ],
421 emit => '. and%M %SB3, %AM',
425 modified_flags => $status_flags
429 irn_flags => [ "rematerializable" ],
430 state => "exc_pinned",
431 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
432 out => [ "in_r4 in_r5", "flags", "none" ] },
433 ins => [ "base", "index", "mem", "left", "right" ],
434 outs => [ "res", "flags", "M" ],
435 am => "source,binary",
436 emit => '. or%M %binop',
440 modified_flags => $status_flags
444 irn_flags => [ "rematerializable" ],
445 state => "exc_pinned",
446 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
447 ins => [ "base", "index", "mem", "val" ],
448 emit => '. or%M %SI3, %AM',
452 modified_flags => $status_flags
456 irn_flags => [ "rematerializable" ],
457 state => "exc_pinned",
458 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
459 ins => [ "base", "index", "mem", "val" ],
460 emit => '. or%M %SB3, %AM',
464 modified_flags => $status_flags
468 irn_flags => [ "rematerializable" ],
469 state => "exc_pinned",
470 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
471 out => [ "in_r4 in_r5", "flags", "none" ] },
472 ins => [ "base", "index", "mem", "left", "right" ],
473 outs => [ "res", "flags", "M" ],
474 am => "source,binary",
475 emit => '. xor%M %binop',
479 modified_flags => $status_flags
483 op_flags => [ "constlike" ],
484 irn_flags => [ "rematerializable" ],
485 reg_req => { out => [ "gp", "flags" ] },
486 outs => [ "res", "flags" ],
487 emit => ". xor%M %D0, %D0",
491 modified_flags => $status_flags
495 irn_flags => [ "rematerializable" ],
496 state => "exc_pinned",
497 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
498 ins => [ "base", "index", "mem", "val" ],
499 emit => '. xor%M %SI3, %AM',
503 modified_flags => $status_flags
507 irn_flags => [ "rematerializable" ],
508 state => "exc_pinned",
509 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
510 ins => [ "base", "index", "mem", "val" ],
511 emit => '. xor%M %SB3, %AM',
515 modified_flags => $status_flags
519 irn_flags => [ "rematerializable" ],
520 state => "exc_pinned",
521 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
522 out => [ "in_r4", "flags", "none" ] },
523 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
524 outs => [ "res", "flags", "M" ],
525 am => "source,binary",
526 emit => '. sub%M %binop',
530 modified_flags => $status_flags
534 irn_flags => [ "rematerializable" ],
535 state => "exc_pinned",
536 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
537 ins => [ "base", "index", "mem", "subtrahend" ],
538 emit => '. sub%M %SI3, %AM',
542 modified_flags => $status_flags
546 irn_flags => [ "rematerializable" ],
547 state => "exc_pinned",
548 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
549 ins => [ "base", "index", "mem", "subtrahend" ],
550 emit => '. sub%M %SB3, %AM',
554 modified_flags => $status_flags
558 state => "exc_pinned",
559 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
560 out => [ "in_r4 !in_r5", "flags", "none" ] },
561 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
562 outs => [ "res", "flags", "M" ],
563 am => "source,binary",
564 emit => '. sbb%M %binop',
568 modified_flags => $status_flags
572 # Spiller currently fails when rematerializing flag consumers
573 # irn_flags => [ "rematerializable" ],
574 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
575 outs => [ "res", "flags" ],
576 emit => ". sbb%M %D0, %D0",
580 modified_flags => $status_flags
584 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
585 ins => [ "minuend", "subtrahend" ],
589 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
590 ins => [ "minuend", "subtrahend", "eflags" ],
594 op_flags => [ "fragile", "labeled" ],
595 state => "exc_pinned",
596 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
597 out => [ "eax", "flags", "none", "edx", "none" ] },
598 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
599 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
600 am => "source,unary",
601 emit => ". idiv%M %unop3",
604 modified_flags => $status_flags
608 op_flags => [ "fragile", "labeled" ],
609 state => "exc_pinned",
610 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
611 out => [ "eax", "flags", "none", "edx", "none" ] },
612 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
613 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
614 am => "source,unary",
615 emit => ". div%M %unop3",
618 modified_flags => $status_flags
622 irn_flags => [ "rematerializable" ],
623 reg_req => { in => [ "gp", "ecx" ],
624 out => [ "in_r1 !in_r2", "flags" ] },
625 ins => [ "val", "count" ],
626 outs => [ "res", "flags" ],
627 emit => '. shl%M %SB1, %S0',
631 modified_flags => $status_flags
635 irn_flags => [ "rematerializable" ],
636 state => "exc_pinned",
637 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
638 ins => [ "base", "index", "mem", "count" ],
639 emit => '. shl%M %SB3, %AM',
643 modified_flags => $status_flags
647 irn_flags => [ "rematerializable" ],
648 reg_req => { in => [ "gp", "gp", "ecx" ],
649 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
650 ins => [ "val_high", "val_low", "count" ],
651 outs => [ "res", "flags" ],
652 emit => ". shld%M %SB2, %S1, %D0",
656 modified_flags => $status_flags
660 irn_flags => [ "rematerializable" ],
661 reg_req => { in => [ "gp", "ecx" ],
662 out => [ "in_r1 !in_r2", "flags" ] },
663 ins => [ "val", "count" ],
664 outs => [ "res", "flags" ],
665 emit => '. shr%M %SB1, %S0',
669 modified_flags => $status_flags
673 irn_flags => [ "rematerializable" ],
674 state => "exc_pinned",
675 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
676 ins => [ "base", "index", "mem", "count" ],
677 emit => '. shr%M %SB3, %AM',
681 modified_flags => $status_flags
685 irn_flags => [ "rematerializable" ],
686 reg_req => { in => [ "gp", "gp", "ecx" ],
687 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
688 ins => [ "val_high", "val_low", "count" ],
689 outs => [ "res", "flags" ],
690 emit => ". shrd%M %SB2, %S1, %D0",
694 modified_flags => $status_flags
698 irn_flags => [ "rematerializable" ],
699 reg_req => { in => [ "gp", "ecx" ],
700 out => [ "in_r1 !in_r2", "flags" ] },
701 ins => [ "val", "count" ],
702 outs => [ "res", "flags" ],
703 emit => '. sar%M %SB1, %S0',
707 modified_flags => $status_flags
711 irn_flags => [ "rematerializable" ],
712 state => "exc_pinned",
713 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
714 ins => [ "base", "index", "mem", "count" ],
715 emit => '. sar%M %SB3, %AM',
719 modified_flags => $status_flags
723 irn_flags => [ "rematerializable" ],
724 reg_req => { in => [ "gp", "ecx" ],
725 out => [ "in_r1 !in_r2", "flags" ] },
726 ins => [ "val", "count" ],
727 outs => [ "res", "flags" ],
728 emit => '. ror%M %SB1, %S0',
732 modified_flags => $status_flags
736 irn_flags => [ "rematerializable" ],
737 state => "exc_pinned",
738 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
739 ins => [ "base", "index", "mem", "count" ],
740 emit => '. ror%M %SB3, %AM',
744 modified_flags => $status_flags
748 irn_flags => [ "rematerializable" ],
749 reg_req => { in => [ "gp", "ecx" ],
750 out => [ "in_r1 !in_r2", "flags" ] },
751 ins => [ "val", "count" ],
752 outs => [ "res", "flags" ],
753 emit => '. rol%M %SB1, %S0',
757 modified_flags => $status_flags
761 irn_flags => [ "rematerializable" ],
762 state => "exc_pinned",
763 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
764 ins => [ "base", "index", "mem", "count" ],
765 emit => '. rol%M %SB3, %AM',
769 modified_flags => $status_flags
773 irn_flags => [ "rematerializable" ],
774 reg_req => { in => [ "gp" ],
775 out => [ "in_r1", "flags" ] },
776 emit => '. neg%M %S0',
778 outs => [ "res", "flags" ],
782 modified_flags => $status_flags
786 irn_flags => [ "rematerializable" ],
787 state => "exc_pinned",
788 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
789 ins => [ "base", "index", "mem" ],
790 emit => '. neg%M %AM',
794 modified_flags => $status_flags
798 irn_flags => [ "rematerializable" ],
799 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
800 outs => [ "low_res", "high_res" ],
803 modified_flags => $status_flags
808 irn_flags => [ "rematerializable" ],
809 reg_req => { in => [ "gp" ],
810 out => [ "in_r1", "flags" ] },
812 outs => [ "res", "flags" ],
813 emit => '. inc%M %S0',
817 modified_flags => $status_flags_wo_cf
821 irn_flags => [ "rematerializable" ],
822 state => "exc_pinned",
823 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
824 ins => [ "base", "index", "mem" ],
825 emit => '. inc%M %AM',
829 modified_flags => $status_flags_wo_cf
833 irn_flags => [ "rematerializable" ],
834 reg_req => { in => [ "gp" ],
835 out => [ "in_r1", "flags" ] },
837 outs => [ "res", "flags" ],
838 emit => '. dec%M %S0',
842 modified_flags => $status_flags_wo_cf
846 irn_flags => [ "rematerializable" ],
847 state => "exc_pinned",
848 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
849 ins => [ "base", "index", "mem" ],
850 emit => '. dec%M %AM',
854 modified_flags => $status_flags_wo_cf
858 irn_flags => [ "rematerializable" ],
859 reg_req => { in => [ "gp" ],
860 out => [ "in_r1" ] },
863 emit => '. not%M %S0',
871 irn_flags => [ "rematerializable" ],
872 state => "exc_pinned",
873 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
874 ins => [ "base", "index", "mem" ],
875 emit => '. not%M %AM',
883 reg_req => { in => [ "flags" ], out => [ "flags" ] },
888 modified_flags => $status_flags
892 reg_req => { out => [ "flags" ] },
897 modified_flags => $status_flags
901 irn_flags => [ "rematerializable" ],
902 state => "exc_pinned",
903 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
904 out => [ "flags", "none", "none" ] },
905 ins => [ "base", "index", "mem", "left", "right" ],
906 outs => [ "eflags", "unused", "M" ],
907 am => "source,binary",
908 emit => '. cmp%M %binop',
909 attr => "bool ins_permuted",
910 init_attr => "attr->data.ins_permuted = ins_permuted;",
914 modified_flags => $status_flags
918 irn_flags => [ "rematerializable" ],
919 state => "exc_pinned",
920 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
921 out => [ "flags", "none", "none" ] },
922 ins => [ "base", "index", "mem", "left", "right" ],
923 outs => [ "eflags", "unused", "M" ],
924 am => "source,binary",
925 emit => '. cmpb %binop',
926 attr => "bool ins_permuted",
927 init_attr => "attr->data.ins_permuted = ins_permuted;",
931 modified_flags => $status_flags
935 irn_flags => [ "rematerializable" ],
936 state => "exc_pinned",
937 reg_req => { in => [ "eax ebx ecx edx" ],
938 out => [ "in_r1", "flags" ] },
939 emit => '. xorb %SH0, %SB0',
941 outs => [ "res", "flags" ],
945 modified_flags => $status_flags,
949 irn_flags => [ "rematerializable" ],
950 state => "exc_pinned",
951 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
952 out => [ "flags", "none", "none" ] },
953 ins => [ "base", "index", "mem", "left", "right" ],
954 outs => [ "eflags", "unused", "M" ],
955 am => "source,binary",
956 emit => '. test%M %binop',
957 attr => "bool ins_permuted",
958 init_attr => "attr->data.ins_permuted = ins_permuted;",
962 modified_flags => $status_flags
966 irn_flags => [ "rematerializable" ],
967 state => "exc_pinned",
968 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
969 out => [ "flags", "none", "none" ] },
970 ins => [ "base", "index", "mem", "left", "right" ],
971 outs => [ "eflags", "unused", "M" ],
972 am => "source,binary",
973 emit => '. testb %binop',
974 attr => "bool ins_permuted",
975 init_attr => "attr->data.ins_permuted = ins_permuted;",
979 modified_flags => $status_flags
983 #irn_flags => [ "rematerializable" ],
984 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
987 attr_type => "ia32_condcode_attr_t",
988 attr => "ia32_condition_code_t condition_code",
989 # The way we handle Setcc with float nodes (potentially) destroys the flags
990 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
991 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
992 . "\tif (condition_code & ia32_cc_additional_float_cases) {\n"
993 . "\t\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n"
994 . "\t\t/* attr->latency = 3; */\n"
1002 #irn_flags => [ "rematerializable" ],
1003 state => "exc_pinned",
1004 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1005 ins => [ "base", "index", "mem","eflags" ],
1006 attr_type => "ia32_condcode_attr_t",
1007 attr => "ia32_condition_code_t condition_code",
1008 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1009 emit => '. set%CMP3 %AM',
1016 #irn_flags => [ "rematerializable" ],
1017 state => "exc_pinned",
1018 # (note: leave the false,true order intact to make it compatible with other
1020 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1021 out => [ "in_r4 in_r5", "flags", "none" ] },
1022 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1023 outs => [ "res", "flags", "M" ],
1024 am => "source,binary",
1025 attr_type => "ia32_condcode_attr_t",
1026 attr => "ia32_condition_code_t condition_code",
1034 op_flags => [ "labeled", "cfopcode", "forking" ],
1035 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1036 ins => [ "eflags" ],
1037 outs => [ "false", "true" ],
1038 attr_type => "ia32_condcode_attr_t",
1039 attr => "ia32_condition_code_t condition_code",
1041 units => [ "BRANCH" ],
1046 op_flags => [ "labeled", "cfopcode", "forking" ],
1047 reg_req => { in => [ "gp" ] },
1049 attr_type => "ia32_switch_attr_t",
1050 attr => "long default_pn",
1052 units => [ "BRANCH" ],
1053 modified_flags => $status_flags,
1054 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1059 irn_flags => [ "simple_jump" ],
1060 op_flags => [ "cfopcode" ],
1061 reg_req => { out => [ "none" ] },
1063 units => [ "BRANCH" ],
1069 op_flags => [ "cfopcode", "unknown_jump" ],
1070 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1071 ins => [ "base", "index", "mem", "target" ],
1072 am => "source,unary",
1073 emit => '. jmp *%unop3',
1075 units => [ "BRANCH" ],
1077 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1081 op_flags => [ "constlike" ],
1082 irn_flags => [ "rematerializable" ],
1083 reg_req => { out => [ "gp" ] },
1085 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1086 attr_type => "ia32_immediate_attr_t",
1092 op_flags => [ "constlike" ],
1093 irn_flags => [ "rematerializable" ],
1094 reg_req => { out => [ "gp" ] },
1101 op_flags => [ "constlike" ],
1102 reg_req => { out => [ "gp" ] },
1106 modified_flags => $status_flags,
1111 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1112 irn_flags => [ "not_scheduled" ],
1113 reg_req => { out => [ "gp_NOREG:I" ] },
1122 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1123 irn_flags => [ "not_scheduled" ],
1124 reg_req => { out => [ "vfp_NOREG:I" ] },
1129 attr_type => "ia32_x87_attr_t",
1134 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1135 irn_flags => [ "not_scheduled" ],
1136 reg_req => { out => [ "xmm_NOREG:I" ] },
1145 op_flags => [ "constlike" ],
1146 irn_flags => [ "not_scheduled" ],
1147 reg_req => { out => [ "fpcw:I" ] },
1151 modified_flags => $fpcw_flags
1155 op_flags => [ "fragile", "labeled" ],
1157 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1158 ins => [ "base", "index", "mem" ],
1160 emit => ". fldcw %AM",
1163 modified_flags => $fpcw_flags
1167 op_flags => [ "fragile", "labeled" ],
1169 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1170 ins => [ "base", "index", "mem", "fpcw" ],
1172 emit => ". fnstcw %AM",
1178 op_flags => [ "fragile", "labeled" ],
1180 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1188 # we should not rematrialize this node. It has very strict constraints.
1189 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1190 ins => [ "val", "clobbered" ],
1199 # Note that we add additional latency values depending on address mode, so a
1200 # lateny of 0 for load is correct
1203 op_flags => [ "fragile", "labeled" ],
1204 state => "exc_pinned",
1205 reg_req => { in => [ "gp", "gp", "none" ],
1206 out => [ "gp", "none", "none", "none" ] },
1207 ins => [ "base", "index", "mem" ],
1208 outs => [ "res", "unused", "M", "X_exc" ],
1210 emit => ". mov%EX%.l %AM, %D0",
1215 op_flags => [ "fragile", "labeled" ],
1216 state => "exc_pinned",
1217 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1218 ins => [ "base", "index", "mem", "val" ],
1219 outs => [ "M", "X_exc" ],
1220 emit => '. mov%M %SI3, %AM',
1227 op_flags => [ "fragile", "labeled" ],
1228 state => "exc_pinned",
1229 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1230 ins => [ "base", "index", "mem", "val" ],
1231 outs => [ "M", "X_exc" ],
1232 emit => '. mov%M %SB3, %AM',
1239 irn_flags => [ "rematerializable" ],
1240 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1241 ins => [ "base", "index" ],
1242 emit => '. leal %AM, %D0',
1246 # lea doesn't modify the flags, but setting this seems advantageous since it
1247 # increases chances that the Lea is transformed back to an Add
1248 modified_flags => 1,
1252 state => "exc_pinned",
1253 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1254 ins => [ "base", "index", "mem", "val", "stack" ],
1255 emit => '. push%M %unop3',
1256 outs => [ "stack", "M" ],
1257 am => "source,unary",
1263 state => "exc_pinned",
1264 reg_req => { in => [ "esp" ], out => [ "esp:I|S" ] },
1266 outs => [ "stack" ],
1267 emit => '. pushl %%eax',
1274 state => "exc_pinned",
1275 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1276 ins => [ "mem", "stack" ],
1277 outs => [ "res", "M", "unused", "stack" ],
1278 emit => '. pop%M %D0',
1279 latency => 3, # Pop is more expensive than Push on Athlon
1284 state => "exc_pinned",
1285 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1286 ins => [ "mem", "stack" ],
1287 outs => [ "res", "M", "unused", "stack" ],
1288 emit => '. pop%M %D0',
1289 latency => 3, # Pop is more expensive than Push on Athlon
1294 state => "exc_pinned",
1295 reg_req => { in => [ "ebp" ], out => [ "esp:I|S" ] },
1298 emit => '. movl %S0, %D0',
1305 state => "exc_pinned",
1306 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1307 ins => [ "base", "index", "mem", "stack" ],
1308 outs => [ "unused0", "M", "unused1", "stack" ],
1309 emit => '. pop%M %AM',
1310 latency => 3, # Pop is more expensive than Push on Athlon
1315 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1317 outs => [ "frame", "stack", "M" ],
1323 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1325 outs => [ "frame", "stack" ],
1328 state => "exc_pinned",
1333 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1334 ins => [ "base", "index", "mem", "stack", "size" ],
1335 am => "source,binary",
1336 emit => '. addl %binop',
1338 outs => [ "stack", "M" ],
1340 modified_flags => $status_flags
1345 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1346 ins => [ "base", "index", "mem", "stack", "size" ],
1347 am => "source,binary",
1348 emit => ". subl %binop\n".
1349 ". movl %%esp, %D1",
1351 outs => [ "stack", "addr", "M" ],
1353 modified_flags => $status_flags
1357 op_flags => [ "keep" ],
1365 irn_flags => [ "rematerializable" ],
1366 reg_req => { out => [ "gp" ] },
1368 emit => ". movl %%gs:0, %D0",
1374 # BT supports source address mode, but this is unused yet
1377 irn_flags => [ "rematerializable" ],
1378 state => "exc_pinned",
1379 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1380 ins => [ "left", "right" ],
1381 emit => '. bt%M %S1, %S0',
1384 mode => $mode_flags,
1385 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1389 irn_flags => [ "rematerializable" ],
1390 state => "exc_pinned",
1391 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1392 out => [ "gp", "flags", "none" ] },
1393 ins => [ "base", "index", "mem", "operand" ],
1394 outs => [ "res", "flags", "M" ],
1395 am => "source,binary",
1396 emit => '. bsf%M %unop3, %D0',
1400 modified_flags => $status_flags
1404 irn_flags => [ "rematerializable" ],
1405 state => "exc_pinned",
1406 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1407 out => [ "gp", "flags", "none" ] },
1408 ins => [ "base", "index", "mem", "operand" ],
1409 outs => [ "res", "flags", "M" ],
1410 am => "source,binary",
1411 emit => '. bsr%M %unop3, %D0',
1415 modified_flags => $status_flags
1419 # SSE4.2 or SSE4a popcnt instruction
1422 irn_flags => [ "rematerializable" ],
1423 state => "exc_pinned",
1424 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1425 out => [ "gp", "flags", "none" ] },
1426 ins => [ "base", "index", "mem", "operand" ],
1427 outs => [ "res", "flags", "M" ],
1428 am => "source,binary",
1429 emit => '. popcnt%M %unop3, %D0',
1433 modified_flags => $status_flags
1437 state => "exc_pinned",
1439 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1440 out => [ "esp:I|S", "fpcw:I", "none", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ]
1442 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1443 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1444 attr_type => "ia32_call_attr_t",
1445 attr => "unsigned pop, ir_type *call_tp",
1446 am => "source,unary",
1447 units => [ "BRANCH" ],
1448 latency => 4, # random number
1449 modified_flags => $status_flags
1453 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1455 # PS: try gcc __builtin_frame_address(100000) :-)
1458 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1459 ins => [ "frame", "cnt", "tmp" ],
1461 latency => 4, # random number
1462 attr_type => "ia32_climbframe_attr_t",
1463 attr => "unsigned count",
1472 irn_flags => [ "rematerializable" ],
1473 reg_req => { in => [ "gp" ],
1474 out => [ "in_r1" ] },
1475 emit => '. bswap%M %S0',
1483 # bswap16, use xchg here
1486 irn_flags => [ "rematerializable" ],
1487 reg_req => { in => [ "eax ebx ecx edx" ],
1488 out => [ "in_r1" ] },
1489 emit => '. xchg %SB0, %SH0',
1501 reg_req => { in => [ "none" ], out => [ "none" ] },
1510 # Undefined Instruction on ALL x86 CPU's
1514 reg_req => { in => [ "none" ], out => [ "none" ] },
1517 emit => ". .value 0x0b0f",
1526 irn_flags => [ "rematerializable" ],
1528 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1529 ins => [ "port", "value", "mem" ],
1530 emit => '. out%M %SS0, %SI1',
1534 modified_flags => $status_flags
1541 irn_flags => [ "rematerializable" ],
1543 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1544 ins => [ "port", "mem" ],
1545 outs => [ "res", "M" ],
1546 emit => '. in%M %DS0, %SS0',
1550 modified_flags => $status_flags
1554 # Intel style prefetching
1557 op_flags => [ "fragile", "labeled" ],
1558 state => "exc_pinned",
1559 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1560 ins => [ "base", "index", "mem" ],
1563 emit => ". prefetcht0 %AM",
1568 op_flags => [ "fragile", "labeled" ],
1569 state => "exc_pinned",
1570 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1571 ins => [ "base", "index", "mem" ],
1574 emit => ". prefetcht1 %AM",
1579 op_flags => [ "fragile", "labeled" ],
1580 state => "exc_pinned",
1581 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1582 ins => [ "base", "index", "mem" ],
1585 emit => ". prefetcht2 %AM",
1590 op_flags => [ "fragile", "labeled" ],
1591 state => "exc_pinned",
1592 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1593 ins => [ "base", "index", "mem" ],
1596 emit => ". prefetchnta %AM",
1601 # 3DNow! prefetch instructions
1604 op_flags => [ "fragile", "labeled" ],
1605 state => "exc_pinned",
1606 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1607 ins => [ "base", "index", "mem" ],
1610 emit => ". prefetch %AM",
1615 op_flags => [ "fragile", "labeled" ],
1616 state => "exc_pinned",
1617 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1618 ins => [ "base", "index", "mem" ],
1621 emit => ". prefetchw %AM",
1627 irn_flags => [ "rematerializable" ],
1628 reg_req => { out => [ "xmm" ] },
1629 emit => '. xorp%XSD %D0, %D0',
1636 op_flags => [ "constlike" ],
1637 irn_flags => [ "rematerializable" ],
1638 reg_req => { out => [ "xmm" ] },
1645 irn_flags => [ "rematerializable" ],
1646 reg_req => { out => [ "xmm" ] },
1647 emit => '. pxor %D0, %D0',
1653 # produces all 1 bits
1655 irn_flags => [ "rematerializable" ],
1656 reg_req => { out => [ "xmm" ] },
1657 emit => '. pcmpeqb %D0, %D0',
1663 # integer shift left, dword
1665 irn_flags => [ "rematerializable" ],
1666 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1667 emit => '. pslld %SI1, %D0',
1673 # integer shift left, qword
1675 irn_flags => [ "rematerializable" ],
1676 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1677 emit => '. psllq %SI1, %D0',
1683 # integer shift right, dword
1685 irn_flags => [ "rematerializable" ],
1686 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1687 emit => '. psrld %SI1, %D0',
1693 # mov from integer to SSE register
1695 irn_flags => [ "rematerializable" ],
1696 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1697 emit => '. movd %S0, %D0',
1704 irn_flags => [ "rematerializable" ],
1705 state => "exc_pinned",
1706 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1707 out => [ "in_r4 in_r5", "flags", "none" ] },
1708 ins => [ "base", "index", "mem", "left", "right" ],
1709 outs => [ "res", "flags", "M" ],
1710 am => "source,binary",
1711 emit => '. add%XXM %binop',
1718 irn_flags => [ "rematerializable" ],
1719 state => "exc_pinned",
1720 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1721 out => [ "in_r4 in_r5", "flags", "none" ] },
1722 ins => [ "base", "index", "mem", "left", "right" ],
1723 outs => [ "res", "flags", "M" ],
1724 am => "source,binary",
1725 emit => '. mul%XXM %binop',
1732 irn_flags => [ "rematerializable" ],
1733 state => "exc_pinned",
1734 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1735 out => [ "in_r4 in_r5", "flags", "none" ] },
1736 ins => [ "base", "index", "mem", "left", "right" ],
1737 outs => [ "res", "flags", "M" ],
1738 am => "source,binary",
1739 emit => '. max%XXM %binop',
1746 irn_flags => [ "rematerializable" ],
1747 state => "exc_pinned",
1748 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1749 out => [ "in_r4 in_r5", "flags", "none" ] },
1750 ins => [ "base", "index", "mem", "left", "right" ],
1751 outs => [ "res", "flags", "M" ],
1752 am => "source,binary",
1753 emit => '. min%XXM %binop',
1760 irn_flags => [ "rematerializable" ],
1761 state => "exc_pinned",
1762 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1763 out => [ "in_r4 in_r5", "flags", "none" ] },
1764 ins => [ "base", "index", "mem", "left", "right" ],
1765 outs => [ "res", "flags", "M" ],
1766 am => "source,binary",
1767 emit => '. andp%XSD %binop',
1774 irn_flags => [ "rematerializable" ],
1775 state => "exc_pinned",
1776 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1777 out => [ "in_r4 in_r5", "flags", "none" ] },
1778 ins => [ "base", "index", "mem", "left", "right" ],
1779 outs => [ "res", "flags", "M" ],
1780 am => "source,binary",
1781 emit => '. orp%XSD %binop',
1788 irn_flags => [ "rematerializable" ],
1789 state => "exc_pinned",
1790 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1791 out => [ "in_r4 in_r5", "flags", "none" ] },
1792 ins => [ "base", "index", "mem", "left", "right" ],
1793 outs => [ "res", "flags", "M" ],
1794 am => "source,binary",
1795 emit => '. xorp%XSD %binop',
1802 irn_flags => [ "rematerializable" ],
1803 state => "exc_pinned",
1804 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1805 out => [ "in_r4 !in_r5", "flags", "none" ] },
1806 ins => [ "base", "index", "mem", "left", "right" ],
1807 outs => [ "res", "flags", "M" ],
1808 am => "source,binary",
1809 emit => '. andnp%XSD %binop',
1816 irn_flags => [ "rematerializable" ],
1817 state => "exc_pinned",
1818 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1819 out => [ "in_r4", "flags", "none" ] },
1820 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1821 outs => [ "res", "flags", "M" ],
1822 am => "source,binary",
1823 emit => '. sub%XXM %binop',
1830 irn_flags => [ "rematerializable" ],
1831 state => "exc_pinned",
1832 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1833 out => [ "in_r4 !in_r5", "flags", "none" ] },
1834 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1835 outs => [ "res", "flags", "M" ],
1836 am => "source,binary",
1837 emit => '. div%XXM %binop',
1843 irn_flags => [ "rematerializable" ],
1844 state => "exc_pinned",
1845 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1846 out => [ "eflags" ] },
1847 ins => [ "base", "index", "mem", "left", "right" ],
1848 outs => [ "flags" ],
1849 am => "source,binary",
1850 attr => "bool ins_permuted",
1851 init_attr => "attr->data.ins_permuted = ins_permuted;",
1852 emit => ' .ucomi%XXM %binop',
1855 mode => $mode_flags,
1856 modified_flags => 1,
1860 op_flags => [ "fragile", "labeled" ],
1861 state => "exc_pinned",
1862 reg_req => { in => [ "gp", "gp", "none" ],
1863 out => [ "xmm", "none", "none", "none" ] },
1864 ins => [ "base", "index", "mem" ],
1865 outs => [ "res", "unused", "M", "X_exc" ],
1866 emit => '. mov%XXM %AM, %D0',
1867 attr => "ir_mode *load_mode",
1868 init_attr => "attr->ls_mode = load_mode;",
1874 op_flags => [ "fragile", "labeled" ],
1875 state => "exc_pinned",
1876 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1877 ins => [ "base", "index", "mem", "val" ],
1878 outs => [ "M", "X_exc" ],
1879 emit => '. mov%XXM %S3, %AM',
1886 op_flags => [ "fragile", "labeled" ],
1887 state => "exc_pinned",
1888 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
1889 ins => [ "base", "index", "mem", "val" ],
1891 emit => '. mov%XXM %S3, %AM',
1898 op_flags => [ "fragile", "labeled" ],
1899 state => "exc_pinned",
1900 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1901 ins => [ "base", "index", "mem", "val" ],
1902 am => "source,unary",
1903 emit => '. cvtsi2ss %unop3, %D0',
1910 op_flags => [ "fragile", "labeled" ],
1911 state => "exc_pinned",
1912 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1913 ins => [ "base", "index", "mem", "val" ],
1914 am => "source,unary",
1915 emit => '. cvtsi2sd %unop3, %D0',
1923 op_flags => [ "fragile", "labeled" ],
1924 cmp_attr => "return 1;",
1925 ins => [ "val_high", "val_low" ],
1926 reg_req => { in => [ "none", "none" ], out => [ "none" ] }
1930 op_flags => [ "fragile", "labeled" ],
1931 cmp_attr => "return 1;",
1933 outs => [ "res_high", "res_low" ],
1934 reg_req => { in => [ "none" ], out => [ "none", "none" ] }
1938 op_flags => [ "fragile" ],
1940 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1941 outs => [ "DST", "SRC", "CNT", "M" ],
1942 attr_type => "ia32_copyb_attr_t",
1943 attr => "unsigned size",
1946 # we don't care about this flag, so no need to mark this node
1947 # modified_flags => [ "DF" ]
1951 op_flags => [ "fragile" ],
1953 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1954 outs => [ "DST", "SRC", "M" ],
1955 attr_type => "ia32_copyb_attr_t",
1956 attr => "unsigned size",
1959 # we don't care about this flag, so no need to mark this node
1960 # modified_flags => [ "DF" ]
1964 state => "exc_pinned",
1965 reg_req => { in => [ "eax" ], out => [ "eax" ] },
1975 state => "exc_pinned",
1976 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1977 out => [ "gp", "none", "none" ] },
1978 ins => [ "base", "index", "mem", "val" ],
1979 outs => [ "res", "flags", "M" ],
1980 am => "source,unary",
1983 attr => "ir_mode *smaller_mode",
1984 init_attr => "attr->ls_mode = smaller_mode;",
1989 state => "exc_pinned",
1990 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
1991 out => [ "gp", "none", "none" ] },
1992 ins => [ "base", "index", "mem", "val" ],
1993 outs => [ "res", "flags", "M" ],
1994 am => "source,unary",
1997 attr => "ir_mode *smaller_mode",
1998 init_attr => "attr->ls_mode = smaller_mode;",
2003 state => "exc_pinned",
2004 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2005 ins => [ "base", "index", "mem", "val" ],
2006 am => "source,unary",
2013 state => "exc_pinned",
2014 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2015 ins => [ "base", "index", "mem", "val" ],
2016 am => "source,unary",
2023 state => "exc_pinned",
2024 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2025 ins => [ "base", "index", "mem", "val" ],
2026 am => "source,unary",
2032 # rematerialisation disabled for all float nodes for now, because the fpcw
2033 # handler runs before spilling and we might end up with wrong fpcw then
2036 # irn_flags => [ "rematerializable" ],
2037 state => "exc_pinned",
2038 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2039 out => [ "vfp", "none", "none" ] },
2040 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2041 outs => [ "res", "dummy", "M" ],
2042 am => "source,binary",
2046 attr_type => "ia32_x87_attr_t",
2050 # irn_flags => [ "rematerializable" ],
2051 state => "exc_pinned",
2052 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2053 out => [ "vfp", "none", "none" ] },
2054 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2055 outs => [ "res", "dummy", "M" ],
2056 am => "source,binary",
2060 attr_type => "ia32_x87_attr_t",
2064 # irn_flags => [ "rematerializable" ],
2065 state => "exc_pinned",
2066 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2067 out => [ "vfp", "none", "none" ] },
2068 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2069 outs => [ "res", "dummy", "M" ],
2070 am => "source,binary",
2074 attr_type => "ia32_x87_attr_t",
2078 state => "exc_pinned",
2079 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2080 out => [ "vfp", "none", "none" ] },
2081 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2082 outs => [ "res", "dummy", "M" ],
2083 am => "source,binary",
2086 attr_type => "ia32_x87_attr_t",
2090 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2091 ins => [ "left", "right", "fpcw" ],
2095 attr_type => "ia32_x87_attr_t",
2099 irn_flags => [ "rematerializable" ],
2100 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2105 attr_type => "ia32_x87_attr_t",
2109 irn_flags => [ "rematerializable" ],
2110 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2115 attr_type => "ia32_x87_attr_t",
2119 irn_flags => [ "rematerializable" ],
2120 op_flags => [ "fragile", "labeled" ],
2121 state => "exc_pinned",
2122 reg_req => { in => [ "gp", "gp", "none" ],
2123 out => [ "vfp", "none", "none", "none" ] },
2124 ins => [ "base", "index", "mem" ],
2125 outs => [ "res", "unused", "M", "X_exc" ],
2126 attr => "ir_mode *load_mode",
2127 init_attr => "attr->attr.ls_mode = load_mode;",
2130 attr_type => "ia32_x87_attr_t",
2134 irn_flags => [ "rematerializable" ],
2135 op_flags => [ "fragile", "labeled" ],
2136 state => "exc_pinned",
2137 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2138 out => [ "none", "none" ] },
2139 ins => [ "base", "index", "mem", "val" ],
2140 outs => [ "M", "X_exc" ],
2141 attr => "ir_mode *store_mode",
2142 init_attr => "attr->attr.ls_mode = store_mode;",
2146 attr_type => "ia32_x87_attr_t",
2150 state => "exc_pinned",
2151 reg_req => { in => [ "gp", "gp", "none" ],
2152 out => [ "vfp", "none", "none" ] },
2153 outs => [ "res", "unused", "M" ],
2154 ins => [ "base", "index", "mem" ],
2157 attr_type => "ia32_x87_attr_t",
2161 state => "exc_pinned",
2162 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2163 ins => [ "base", "index", "mem", "val", "fpcw" ],
2168 attr_type => "ia32_x87_attr_t",
2171 # SSE3 fisttp instruction
2173 state => "exc_pinned",
2174 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2175 ins => [ "base", "index", "mem", "val" ],
2176 outs => [ "res", "M" ],
2179 attr_type => "ia32_x87_attr_t",
2183 irn_flags => [ "rematerializable" ],
2184 reg_req => { out => [ "vfp" ] },
2189 attr_type => "ia32_x87_attr_t",
2193 irn_flags => [ "rematerializable" ],
2194 reg_req => { out => [ "vfp" ] },
2199 attr_type => "ia32_x87_attr_t",
2203 irn_flags => [ "rematerializable" ],
2204 reg_req => { out => [ "vfp" ] },
2209 attr_type => "ia32_x87_attr_t",
2213 irn_flags => [ "rematerializable" ],
2214 reg_req => { out => [ "vfp" ] },
2219 attr_type => "ia32_x87_attr_t",
2223 irn_flags => [ "rematerializable" ],
2224 reg_req => { out => [ "vfp" ] },
2229 attr_type => "ia32_x87_attr_t",
2233 irn_flags => [ "rematerializable" ],
2234 reg_req => { out => [ "vfp" ] },
2239 attr_type => "ia32_x87_attr_t",
2243 irn_flags => [ "rematerializable" ],
2244 reg_req => { out => [ "vfp" ] },
2249 attr_type => "ia32_x87_attr_t",
2253 # we can't allow to rematerialize this node so we don't
2254 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2255 # irn_flags => [ "rematerializable" ],
2256 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2257 ins => [ "left", "right" ],
2258 outs => [ "flags" ],
2259 attr => "bool ins_permuted",
2260 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2263 attr_type => "ia32_x87_attr_t",
2268 irn_flags => [ "rematerializable" ],
2269 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2270 ins => [ "left", "right" ],
2271 outs => [ "flags" ],
2272 attr => "bool ins_permuted",
2273 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2276 attr_type => "ia32_x87_attr_t",
2281 # irn_flags => [ "rematerializable" ],
2282 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2284 outs => [ "flags" ],
2285 attr => "bool ins_permuted",
2286 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2289 attr_type => "ia32_x87_attr_t",
2294 irn_flags => [ "rematerializable" ],
2295 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2297 outs => [ "flags" ],
2301 mode => $mode_flags,
2305 state => "exc_pinned",
2306 emit => '. fadd%XM %x87_binop',
2308 attr_type => "ia32_x87_attr_t",
2313 state => "exc_pinned",
2314 emit => '. faddp%XM %x87_binop',
2316 attr_type => "ia32_x87_attr_t",
2321 state => "exc_pinned",
2322 emit => '. fmul%XM %x87_binop',
2324 attr_type => "ia32_x87_attr_t",
2329 state => "exc_pinned",
2330 emit => '. fmulp%XM %x87_binop',,
2332 attr_type => "ia32_x87_attr_t",
2337 state => "exc_pinned",
2338 emit => '. fsub%XM %x87_binop',
2340 attr_type => "ia32_x87_attr_t",
2344 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2345 # are swapped, we work this around in the emitter...
2348 state => "exc_pinned",
2349 # see note about gas bugs
2350 emit => '. fsubrp%XM %x87_binop',
2352 attr_type => "ia32_x87_attr_t",
2357 state => "exc_pinned",
2358 irn_flags => [ "rematerializable" ],
2359 emit => '. fsubr%XM %x87_binop',
2361 attr_type => "ia32_x87_attr_t",
2366 state => "exc_pinned",
2367 irn_flags => [ "rematerializable" ],
2368 # see note about gas bugs before fsubp
2369 emit => '. fsubp%XM %x87_binop',
2371 attr_type => "ia32_x87_attr_t",
2378 attr_type => "ia32_x87_attr_t",
2382 # this node is just here, to keep the simulator running
2383 # we can omit this when a fprem simulation function exists
2385 emit => '. fprem1\n'.
2388 attr_type => "ia32_x87_attr_t",
2393 state => "exc_pinned",
2394 emit => '. fdiv%XM %x87_binop',
2396 attr_type => "ia32_x87_attr_t",
2401 state => "exc_pinned",
2402 # see note about gas bugs before fsubp
2403 emit => '. fdivrp%XM %x87_binop',
2405 attr_type => "ia32_x87_attr_t",
2410 state => "exc_pinned",
2411 emit => '. fdivr%XM %x87_binop',
2413 attr_type => "ia32_x87_attr_t",
2418 state => "exc_pinned",
2419 # see note about gas bugs before fsubp
2420 emit => '. fdivp%XM %x87_binop',
2422 attr_type => "ia32_x87_attr_t",
2429 attr_type => "ia32_x87_attr_t",
2434 op_flags => [ "keep" ],
2435 irn_flags => [ "rematerializable" ],
2438 attr_type => "ia32_x87_attr_t",
2443 irn_flags => [ "rematerializable" ],
2444 op_flags => [ "fragile", "labeled" ],
2445 state => "exc_pinned",
2446 emit => '. fld%XM %AM',
2447 attr_type => "ia32_x87_attr_t",
2453 irn_flags => [ "rematerializable" ],
2454 op_flags => [ "fragile", "labeled" ],
2455 state => "exc_pinned",
2456 emit => '. fst%XM %AM',
2458 attr_type => "ia32_x87_attr_t",
2464 irn_flags => [ "rematerializable" ],
2465 op_flags => [ "fragile", "labeled" ],
2466 state => "exc_pinned",
2467 emit => '. fstp%XM %AM',
2469 attr_type => "ia32_x87_attr_t",
2475 state => "exc_pinned",
2476 emit => '. fild%XM %AM',
2477 attr_type => "ia32_x87_attr_t",
2483 state => "exc_pinned",
2484 emit => '. fist%XM %AM',
2486 attr_type => "ia32_x87_attr_t",
2492 state => "exc_pinned",
2493 emit => '. fistp%XM %AM',
2495 attr_type => "ia32_x87_attr_t",
2500 # SSE3 fisttp instruction
2502 state => "exc_pinned",
2503 emit => '. fisttp%XM %AM',
2505 attr_type => "ia32_x87_attr_t",
2511 op_flags => [ "constlike", "keep" ],
2512 irn_flags => [ "rematerializable" ],
2513 reg_req => { out => [ "vfp" ] },
2515 attr_type => "ia32_x87_attr_t",
2520 op_flags => [ "constlike", "keep" ],
2521 irn_flags => [ "rematerializable" ],
2522 reg_req => { out => [ "vfp" ] },
2524 attr_type => "ia32_x87_attr_t",
2529 op_flags => [ "constlike", "keep" ],
2530 irn_flags => [ "rematerializable" ],
2531 reg_req => { out => [ "vfp" ] },
2533 attr_type => "ia32_x87_attr_t",
2538 op_flags => [ "constlike", "keep" ],
2539 irn_flags => [ "rematerializable" ],
2540 reg_req => { out => [ "vfp" ] },
2542 attr_type => "ia32_x87_attr_t",
2547 op_flags => [ "constlike", "keep" ],
2548 irn_flags => [ "rematerializable" ],
2549 reg_req => { out => [ "vfp" ] },
2551 attr_type => "ia32_x87_attr_t",
2556 op_flags => [ "constlike", "keep" ],
2557 irn_flags => [ "rematerializable" ],
2558 reg_req => { out => [ "vfp" ] },
2559 emit => '. fldll2t',
2560 attr_type => "ia32_x87_attr_t",
2565 op_flags => [ "constlike", "keep" ],
2566 irn_flags => [ "rematerializable" ],
2567 reg_req => { out => [ "vfp" ] },
2569 attr_type => "ia32_x87_attr_t",
2574 # Note that it is NEVER allowed to do CSE on these nodes
2575 # Moreover, note the virtual register requierements!
2578 op_flags => [ "keep" ],
2579 reg_req => { out => [ "none" ] },
2580 cmp_attr => "return 1;",
2581 emit => '. fxch %X0',
2582 attr_type => "ia32_x87_attr_t",
2588 op_flags => [ "keep" ],
2589 reg_req => { out => [ "none" ] },
2590 cmp_attr => "return 1;",
2591 emit => '. fld %X0',
2592 attr_type => "ia32_x87_attr_t",
2598 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2599 cmp_attr => "return 1;",
2600 emit => '. fld %X0',
2601 attr_type => "ia32_x87_attr_t",
2606 op_flags => [ "keep" ],
2607 reg_req => { out => [ "none" ] },
2608 cmp_attr => "return 1;",
2609 emit => '. fstp %X0',
2610 attr_type => "ia32_x87_attr_t",
2616 op_flags => [ "keep" ],
2617 reg_req => { out => [ "none" ] },
2618 cmp_attr => "return 1;",
2619 emit => '. ffreep %X0',
2620 attr_type => "ia32_x87_attr_t",
2626 op_flags => [ "keep" ],
2627 reg_req => { out => [ "none" ] },
2628 cmp_attr => "return 1;",
2630 attr_type => "ia32_x87_attr_t",
2636 op_flags => [ "keep" ],
2637 reg_req => { out => [ "none" ] },
2638 cmp_attr => "return 1;",
2640 attr_type => "ia32_x87_attr_t",
2647 emit => ". fucom %X1\n".
2649 attr_type => "ia32_x87_attr_t",
2655 emit => ". fucomp %X1\n".
2657 attr_type => "ia32_x87_attr_t",
2663 emit => ". fucompp\n".
2665 attr_type => "ia32_x87_attr_t",
2671 emit => '. fucomi %X1',
2672 attr_type => "ia32_x87_attr_t",
2678 emit => '. fucompi %X1',
2679 attr_type => "ia32_x87_attr_t",
2687 attr_type => "ia32_x87_attr_t",
2691 # Spilling and reloading of SSE registers, hardcoded, not generated #
2694 op_flags => [ "fragile", "labeled" ],
2695 state => "exc_pinned",
2696 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2697 emit => '. movdqu %D0, %AM',
2698 outs => [ "res", "M" ],
2704 op_flags => [ "fragile", "labeled" ],
2705 state => "exc_pinned",
2706 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2707 ins => [ "base", "index", "mem", "val" ],
2708 emit => '. movdqu %binop',
2716 # Transform some attributes
2717 foreach my $op (keys(%nodes)) {
2718 my $node = $nodes{$op};
2719 my $op_attr_init = $node->{op_attr_init};
2721 if(defined($op_attr_init)) {
2722 $op_attr_init .= "\n\t";
2727 if(!defined($node->{latency})) {
2729 $node->{latency} = 0;
2731 die("Latency missing for op $op");
2734 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2736 $node->{op_attr_init} = $op_attr_init;