1 # This is the specification for the ia32 assembler Firm-operations
7 $mode_fp87 = "ia32_mode_E";
9 $mode_flags = "mode_Iu";
10 $mode_fpcw = "ia32_mode_fpcw";
13 $normal = 0; # no special type
14 $ignore = 1; # ignore (do not assign this register)
15 $arbitrary = 2; # emitter can choose an arbitrary register of this class
16 $virtual = 4; # the register is a virtual one
17 $state = 8; # register represents a state
18 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
28 { name => "esp", type => $ignore },
29 { name => "gp_NOREG", type => $ignore | $arbitrary | $virtual }, # we need a dummy register for NoReg nodes
33 { name => "mm0", type => $ignore },
34 { name => "mm1", type => $ignore },
35 { name => "mm2", type => $ignore },
36 { name => "mm3", type => $ignore },
37 { name => "mm4", type => $ignore },
38 { name => "mm5", type => $ignore },
39 { name => "mm6", type => $ignore },
40 { name => "mm7", type => $ignore },
41 { mode => $mode_mmx, flags => "manual_ra" }
52 { name => "xmm_NOREG", type => $ignore | $virtual }, # we need a dummy register for NoReg nodes
64 { name => "vfp_NOREG", type => $ignore | $arbitrary | $virtual }, # we need a dummy register for NoReg nodes
65 { mode => $mode_fp87 }
68 { name => "st0", realname => "st", type => $ignore },
69 { name => "st1", realname => "st(1)", type => $ignore },
70 { name => "st2", realname => "st(2)", type => $ignore },
71 { name => "st3", realname => "st(3)", type => $ignore },
72 { name => "st4", realname => "st(4)", type => $ignore },
73 { name => "st5", realname => "st(5)", type => $ignore },
74 { name => "st6", realname => "st(6)", type => $ignore },
75 { name => "st7", realname => "st(7)", type => $ignore },
76 { mode => $mode_fp87, flags => "manual_ra" }
78 fp_cw => [ # the floating point control word
79 { name => "fpcw", type => $ignore | $state },
80 { mode => $mode_fpcw, flags => "manual_ra|state" }
83 { name => "eflags", type => 0 },
84 { mode => "mode_Iu", flags => "manual_ra" }
89 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
90 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
91 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
92 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
97 bundels_per_cycle => 1
101 S0 => "${arch}_emit_source_register(node, 0);",
102 S1 => "${arch}_emit_source_register(node, 1);",
103 S2 => "${arch}_emit_source_register(node, 2);",
104 S3 => "${arch}_emit_source_register(node, 3);",
105 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
106 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
107 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
108 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
109 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
110 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
111 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
112 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
113 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
114 D0 => "${arch}_emit_dest_register(node, 0);",
115 D1 => "${arch}_emit_dest_register(node, 1);",
116 DS0 => "${arch}_emit_dest_register_size(node, 0);",
117 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
118 X0 => "${arch}_emit_x87_register(node, 0);",
119 X1 => "${arch}_emit_x87_register(node, 1);",
120 EX => "${arch}_emit_extend_suffix(node);",
121 M => "${arch}_emit_mode_suffix(node);",
122 XM => "${arch}_emit_x87_mode_suffix(node);",
123 XXM => "${arch}_emit_xmm_mode_suffix(node);",
124 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
125 AM => "${arch}_emit_am(node);",
126 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
127 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
128 binop => "${arch}_emit_binop(node);",
129 x87_binop => "${arch}_emit_x87_binop(node);",
130 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
136 $default_op_attr_type = "ia32_op_attr_t";
137 $default_attr_type = "ia32_attr_t";
138 $default_copy_attr = "ia32_copy_attr";
140 sub ia32_custom_init_attr {
146 if(defined($node->{modified_flags})) {
147 $res .= "\tarch_add_irn_flags(res, arch_irn_flags_modify_flags);\n";
149 if(defined($node->{am})) {
150 my $am = $node->{am};
151 if($am eq "source,unary") {
152 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
153 } elsif($am eq "source,binary") {
154 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
155 } elsif($am eq "none") {
158 die("Invalid address mode '$am' specified on op $name");
161 if($node->{state} ne "exc_pinned"
162 and $node->{state} ne "pinned") {
163 die("AM nodes must have pinned or AM pinned state ($name)");
169 $custom_init_attr_func = \&ia32_custom_init_attr;
173 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
174 "\tinit_ia32_x87_attributes(res);".
175 "\tinit_ia32_asm_attributes(res);",
177 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);",
179 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
180 "\tinit_ia32_call_attributes(res, pop, call_tp);",
181 ia32_condcode_attr_t =>
182 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
183 "\tinit_ia32_condcode_attributes(res, condition_code);",
184 ia32_switch_attr_t =>
185 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
186 "\tinit_ia32_switch_attributes(res, switch_table);",
188 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
189 "\tinit_ia32_copyb_attributes(res, size);",
190 ia32_immediate_attr_t =>
191 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
192 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
194 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
195 "\tinit_ia32_x87_attributes(res);",
196 ia32_climbframe_attr_t =>
197 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, n_res);\n".
198 "\tinit_ia32_climbframe_attributes(res, count);",
202 ia32_asm_attr_t => "ia32_compare_asm_attr",
203 ia32_attr_t => "ia32_compare_nodes_attr",
204 ia32_call_attr_t => "ia32_compare_call_attr",
205 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
206 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
207 ia32_switch_attr_t => "ia32_compare_nodes_attr",
208 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
209 ia32_x87_attr_t => "ia32_compare_x87_attr",
210 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
216 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
217 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
218 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
219 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
225 op_flags => [ "constlike" ],
226 irn_flags => [ "not_scheduled" ],
227 reg_req => { out => [ "gp_NOREG:I" ] },
228 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
229 attr_type => "ia32_immediate_attr_t",
230 hash_func => "ia32_hash_Immediate",
238 out_arity => "variable",
239 attr_type => "ia32_asm_attr_t",
240 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
241 init_attr => "attr->asm_text = asm_text;\n".
242 "\tattr->register_map = register_map;\n",
244 modified_flags => $status_flags,
247 # "allocates" a free register
249 op_flags => [ "constlike", "cse_neutral" ],
250 irn_flags => [ "rematerializable" ],
251 reg_req => { out => [ "gp" ] },
256 cmp_attr => "return 1;",
260 irn_flags => [ "rematerializable" ],
261 state => "exc_pinned",
262 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
263 out => [ "in_r4 in_r5", "flags", "none" ] },
264 ins => [ "base", "index", "mem", "left", "right" ],
265 outs => [ "res", "flags", "M" ],
266 emit => '. add%M %binop',
267 am => "source,binary",
271 modified_flags => $status_flags
275 irn_flags => [ "rematerializable" ],
276 state => "exc_pinned",
277 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
278 ins => [ "base", "index", "mem", "val" ],
279 emit => ". add%M %SI3, %AM",
283 modified_flags => $status_flags
287 irn_flags => [ "rematerializable" ],
288 state => "exc_pinned",
289 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
290 ins => [ "base", "index", "mem", "val" ],
291 emit => ". add%M %SB3, %AM",
295 modified_flags => $status_flags
299 state => "exc_pinned",
300 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
301 out => [ "in_r4 in_r5", "flags", "none" ] },
302 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
303 outs => [ "res", "flags", "M" ],
304 emit => '. adc%M %binop',
305 am => "source,binary",
309 modified_flags => $status_flags
313 ins => [ "left", "right" ],
319 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 ins => [ "left", "right" ],
341 outs => [ "res_low", "flags", "M", "res_high" ],
347 irn_flags => [ "rematerializable" ],
348 state => "exc_pinned",
349 # TODO: adjust out requirements for the 3 operand form
350 # (no need for should_be_same then)
351 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
352 out => [ "in_r4 in_r5", "flags", "none" ] },
353 ins => [ "base", "index", "mem", "left", "right" ],
354 outs => [ "res", "flags", "M" ],
355 am => "source,binary",
359 modified_flags => $status_flags
363 irn_flags => [ "rematerializable" ],
364 state => "exc_pinned",
365 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
366 out => [ "eax", "flags", "none", "edx" ] },
367 ins => [ "base", "index", "mem", "left", "right" ],
368 emit => '. imul%M %unop4',
369 outs => [ "res_low", "flags", "M", "res_high" ],
370 am => "source,binary",
373 modified_flags => $status_flags
377 ins => [ "left", "right" ],
378 outs => [ "res_low", "flags", "M", "res_high" ],
384 irn_flags => [ "rematerializable" ],
385 state => "exc_pinned",
386 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
387 out => [ "in_r4 in_r5", "flags", "none" ] },
388 ins => [ "base", "index", "mem", "left", "right" ],
389 outs => [ "res", "flags", "M" ],
390 am => "source,binary",
391 emit => '. and%M %binop',
395 modified_flags => $status_flags
399 irn_flags => [ "rematerializable" ],
400 state => "exc_pinned",
401 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
402 ins => [ "base", "index", "mem", "val" ],
403 emit => '. and%M %SI3, %AM',
407 modified_flags => $status_flags
411 irn_flags => [ "rematerializable" ],
412 state => "exc_pinned",
413 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
414 ins => [ "base", "index", "mem", "val" ],
415 emit => '. and%M %SB3, %AM',
419 modified_flags => $status_flags
423 irn_flags => [ "rematerializable" ],
424 state => "exc_pinned",
425 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
426 out => [ "in_r4 in_r5", "flags", "none" ] },
427 ins => [ "base", "index", "mem", "left", "right" ],
428 outs => [ "res", "flags", "M" ],
429 am => "source,binary",
430 emit => '. or%M %binop',
434 modified_flags => $status_flags
438 irn_flags => [ "rematerializable" ],
439 state => "exc_pinned",
440 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
441 ins => [ "base", "index", "mem", "val" ],
442 emit => '. or%M %SI3, %AM',
446 modified_flags => $status_flags
450 irn_flags => [ "rematerializable" ],
451 state => "exc_pinned",
452 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
453 ins => [ "base", "index", "mem", "val" ],
454 emit => '. or%M %SB3, %AM',
458 modified_flags => $status_flags
462 irn_flags => [ "rematerializable" ],
463 state => "exc_pinned",
464 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
465 out => [ "in_r4 in_r5", "flags", "none" ] },
466 ins => [ "base", "index", "mem", "left", "right" ],
467 outs => [ "res", "flags", "M" ],
468 am => "source,binary",
469 emit => '. xor%M %binop',
473 modified_flags => $status_flags
477 op_flags => [ "constlike" ],
478 irn_flags => [ "rematerializable" ],
479 reg_req => { out => [ "gp", "flags" ] },
480 outs => [ "res", "flags" ],
481 emit => ". xor%M %D0, %D0",
485 modified_flags => $status_flags
489 irn_flags => [ "rematerializable" ],
490 state => "exc_pinned",
491 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
492 ins => [ "base", "index", "mem", "val" ],
493 emit => '. xor%M %SI3, %AM',
497 modified_flags => $status_flags
501 irn_flags => [ "rematerializable" ],
502 state => "exc_pinned",
503 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
504 ins => [ "base", "index", "mem", "val" ],
505 emit => '. xor%M %SB3, %AM',
509 modified_flags => $status_flags
513 irn_flags => [ "rematerializable" ],
514 state => "exc_pinned",
515 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
516 out => [ "in_r4", "flags", "none" ] },
517 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
518 outs => [ "res", "flags", "M" ],
519 am => "source,binary",
520 emit => '. sub%M %binop',
524 modified_flags => $status_flags
528 irn_flags => [ "rematerializable" ],
529 state => "exc_pinned",
530 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
531 ins => [ "base", "index", "mem", "subtrahend" ],
532 emit => '. sub%M %SI3, %AM',
536 modified_flags => $status_flags
540 irn_flags => [ "rematerializable" ],
541 state => "exc_pinned",
542 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
543 ins => [ "base", "index", "mem", "subtrahend" ],
544 emit => '. sub%M %SB3, %AM',
548 modified_flags => $status_flags
552 state => "exc_pinned",
553 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
554 out => [ "in_r4", "flags", "none" ] },
555 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
556 outs => [ "res", "flags", "M" ],
557 am => "source,binary",
558 emit => '. sbb%M %binop',
562 modified_flags => $status_flags
566 # Spiller currently fails when rematerializing flag consumers
567 # irn_flags => [ "rematerializable" ],
568 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
569 outs => [ "res", "flags" ],
570 emit => ". sbb%M %D0, %D0",
574 modified_flags => $status_flags
578 ins => [ "minuend", "subtrahend" ],
584 ins => [ "minuend", "subtrahend", "eflags" ],
590 op_flags => [ "fragile", "uses_memory", "labeled" ],
591 state => "exc_pinned",
592 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
593 out => [ "eax", "flags", "none", "edx", "none", "none" ] },
594 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
595 outs => [ "div_res", "flags", "M", "mod_res", "X_regular", "X_except" ],
596 am => "source,unary",
597 emit => ". idiv%M %unop3",
600 modified_flags => $status_flags
604 op_flags => [ "fragile", "uses_memory", "labeled" ],
605 state => "exc_pinned",
606 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
607 out => [ "eax", "flags", "none", "edx", "none", "none" ] },
608 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
609 outs => [ "div_res", "flags", "M", "mod_res", "X_regular", "X_except" ],
610 am => "source,unary",
611 emit => ". div%M %unop3",
614 modified_flags => $status_flags
618 irn_flags => [ "rematerializable" ],
619 reg_req => { in => [ "gp", "ecx" ],
620 out => [ "in_r1 !in_r2", "flags" ] },
621 ins => [ "val", "count" ],
622 outs => [ "res", "flags" ],
623 emit => '. shl%M %SB1, %S0',
627 modified_flags => $status_flags
631 irn_flags => [ "rematerializable" ],
632 state => "exc_pinned",
633 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
634 ins => [ "base", "index", "mem", "count" ],
635 emit => '. shl%M %SB3, %AM',
639 modified_flags => $status_flags
643 irn_flags => [ "rematerializable" ],
644 reg_req => { in => [ "gp", "gp", "ecx" ],
645 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
646 ins => [ "val_high", "val_low", "count" ],
647 outs => [ "res", "flags" ],
648 emit => ". shld%M %SB2, %S1, %D0",
652 modified_flags => $status_flags
656 irn_flags => [ "rematerializable" ],
657 reg_req => { in => [ "gp", "ecx" ],
658 out => [ "in_r1 !in_r2", "flags" ] },
659 ins => [ "val", "count" ],
660 outs => [ "res", "flags" ],
661 emit => '. shr%M %SB1, %S0',
665 modified_flags => $status_flags
669 irn_flags => [ "rematerializable" ],
670 state => "exc_pinned",
671 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
672 ins => [ "base", "index", "mem", "count" ],
673 emit => '. shr%M %SB3, %AM',
677 modified_flags => $status_flags
681 irn_flags => [ "rematerializable" ],
682 reg_req => { in => [ "gp", "gp", "ecx" ],
683 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
684 ins => [ "val_high", "val_low", "count" ],
685 outs => [ "res", "flags" ],
686 emit => ". shrd%M %SB2, %S1, %D0",
690 modified_flags => $status_flags
694 irn_flags => [ "rematerializable" ],
695 reg_req => { in => [ "gp", "ecx" ],
696 out => [ "in_r1 !in_r2", "flags" ] },
697 ins => [ "val", "count" ],
698 outs => [ "res", "flags" ],
699 emit => '. sar%M %SB1, %S0',
703 modified_flags => $status_flags
707 irn_flags => [ "rematerializable" ],
708 state => "exc_pinned",
709 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
710 ins => [ "base", "index", "mem", "count" ],
711 emit => '. sar%M %SB3, %AM',
715 modified_flags => $status_flags
719 irn_flags => [ "rematerializable" ],
720 reg_req => { in => [ "gp", "ecx" ],
721 out => [ "in_r1 !in_r2", "flags" ] },
722 ins => [ "val", "count" ],
723 outs => [ "res", "flags" ],
724 emit => '. ror%M %SB1, %S0',
728 modified_flags => $status_flags
732 irn_flags => [ "rematerializable" ],
733 state => "exc_pinned",
734 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
735 ins => [ "base", "index", "mem", "count" ],
736 emit => '. ror%M %SB3, %AM',
740 modified_flags => $status_flags
744 irn_flags => [ "rematerializable" ],
745 reg_req => { in => [ "gp", "ecx" ],
746 out => [ "in_r1 !in_r2", "flags" ] },
747 ins => [ "val", "count" ],
748 outs => [ "res", "flags" ],
749 emit => '. rol%M %SB1, %S0',
753 modified_flags => $status_flags
757 irn_flags => [ "rematerializable" ],
758 state => "exc_pinned",
759 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
760 ins => [ "base", "index", "mem", "count" ],
761 emit => '. rol%M %SB3, %AM',
765 modified_flags => $status_flags
769 irn_flags => [ "rematerializable" ],
770 reg_req => { in => [ "gp" ],
771 out => [ "in_r1", "flags" ] },
772 emit => '. neg%M %S0',
774 outs => [ "res", "flags" ],
778 modified_flags => $status_flags
782 irn_flags => [ "rematerializable" ],
783 state => "exc_pinned",
784 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
785 ins => [ "base", "index", "mem" ],
786 emit => '. neg%M %AM',
790 modified_flags => $status_flags
794 irn_flags => [ "rematerializable" ],
795 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
796 outs => [ "low_res", "high_res" ],
799 modified_flags => $status_flags
804 irn_flags => [ "rematerializable" ],
805 reg_req => { in => [ "gp" ],
806 out => [ "in_r1", "flags" ] },
808 outs => [ "res", "flags" ],
809 emit => '. inc%M %S0',
813 modified_flags => $status_flags_wo_cf
817 irn_flags => [ "rematerializable" ],
818 state => "exc_pinned",
819 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
820 ins => [ "base", "index", "mem" ],
821 emit => '. inc%M %AM',
825 modified_flags => $status_flags_wo_cf
829 irn_flags => [ "rematerializable" ],
830 reg_req => { in => [ "gp" ],
831 out => [ "in_r1", "flags" ] },
833 outs => [ "res", "flags" ],
834 emit => '. dec%M %S0',
838 modified_flags => $status_flags_wo_cf
842 irn_flags => [ "rematerializable" ],
843 state => "exc_pinned",
844 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
845 ins => [ "base", "index", "mem" ],
846 emit => '. dec%M %AM',
850 modified_flags => $status_flags_wo_cf
854 irn_flags => [ "rematerializable" ],
855 reg_req => { in => [ "gp" ],
856 out => [ "in_r1" ] },
859 emit => '. not%M %S0',
867 irn_flags => [ "rematerializable" ],
868 state => "exc_pinned",
869 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
870 ins => [ "base", "index", "mem" ],
871 emit => '. not%M %AM',
879 reg_req => { in => [ "flags" ], out => [ "flags" ] },
884 modified_flags => $status_flags
888 reg_req => { out => [ "flags" ] },
893 modified_flags => $status_flags
897 irn_flags => [ "rematerializable" ],
898 state => "exc_pinned",
899 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
900 out => [ "flags", "none", "none" ] },
901 ins => [ "base", "index", "mem", "left", "right" ],
902 outs => [ "eflags", "unused", "M" ],
903 am => "source,binary",
904 emit => '. cmp%M %binop',
905 attr => "bool ins_permuted",
906 init_attr => "attr->data.ins_permuted = ins_permuted;",
910 modified_flags => $status_flags
914 irn_flags => [ "rematerializable" ],
915 state => "exc_pinned",
916 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
917 out => [ "flags", "none", "none" ] },
918 ins => [ "base", "index", "mem", "left", "right" ],
919 outs => [ "eflags", "unused", "M" ],
920 am => "source,binary",
921 emit => '. cmpb %binop',
922 attr => "bool ins_permuted",
923 init_attr => "attr->data.ins_permuted = ins_permuted;",
927 modified_flags => $status_flags
931 irn_flags => [ "rematerializable" ],
932 state => "exc_pinned",
933 reg_req => { in => [ "eax ebx ecx edx" ],
934 out => [ "in_r1", "flags" ] },
935 emit => '. xorb %SH0, %SB0',
937 outs => [ "res", "flags" ],
941 modified_flags => $status_flags,
945 irn_flags => [ "rematerializable" ],
946 state => "exc_pinned",
947 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
948 out => [ "flags", "none", "none" ] },
949 ins => [ "base", "index", "mem", "left", "right" ],
950 outs => [ "eflags", "unused", "M" ],
951 am => "source,binary",
952 emit => '. test%M %binop',
953 attr => "bool ins_permuted",
954 init_attr => "attr->data.ins_permuted = ins_permuted;",
958 modified_flags => $status_flags
962 irn_flags => [ "rematerializable" ],
963 state => "exc_pinned",
964 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
965 out => [ "flags", "none", "none" ] },
966 ins => [ "base", "index", "mem", "left", "right" ],
967 outs => [ "eflags", "unused", "M" ],
968 am => "source,binary",
969 emit => '. testb %binop',
970 attr => "bool ins_permuted",
971 init_attr => "attr->data.ins_permuted = ins_permuted;",
975 modified_flags => $status_flags
979 #irn_flags => [ "rematerializable" ],
980 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
983 attr_type => "ia32_condcode_attr_t",
984 attr => "ia32_condition_code_t condition_code",
985 # The way we handle Setcc with float nodes (potentially) destroys the flags
986 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
987 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
988 . "\tif (condition_code & ia32_cc_additional_float_cases) {\n"
989 . "\t\tarch_add_irn_flags(res, arch_irn_flags_modify_flags);\n"
990 . "\t\t/* attr->latency = 3; */\n"
998 #irn_flags => [ "rematerializable" ],
999 state => "exc_pinned",
1000 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1001 ins => [ "base", "index", "mem","eflags" ],
1002 attr_type => "ia32_condcode_attr_t",
1003 attr => "ia32_condition_code_t condition_code",
1004 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1005 emit => '. set%CMP3 %AM',
1012 #irn_flags => [ "rematerializable" ],
1013 state => "exc_pinned",
1014 # (note: leave the false,true order intact to make it compatible with other
1016 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1017 out => [ "in_r4 in_r5", "flags", "none" ] },
1018 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1019 outs => [ "res", "flags", "M" ],
1020 am => "source,binary",
1021 attr_type => "ia32_condcode_attr_t",
1022 attr => "ia32_condition_code_t condition_code",
1030 op_flags => [ "labeled", "cfopcode", "forking" ],
1031 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1032 ins => [ "eflags" ],
1033 outs => [ "false", "true" ],
1034 attr_type => "ia32_condcode_attr_t",
1035 attr => "ia32_condition_code_t condition_code",
1037 units => [ "BRANCH" ],
1042 op_flags => [ "labeled", "cfopcode", "forking" ],
1043 reg_req => { in => [ "gp", "gp" ] },
1044 ins => [ "base", "index" ],
1045 out_arity => "variable",
1046 attr_type => "ia32_switch_attr_t",
1047 attr => "const ir_switch_table *switch_table",
1049 units => [ "BRANCH" ],
1054 irn_flags => [ "simple_jump" ],
1055 op_flags => [ "cfopcode" ],
1056 reg_req => { out => [ "none" ] },
1058 units => [ "BRANCH" ],
1064 op_flags => [ "cfopcode", "unknown_jump" ],
1065 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1066 ins => [ "base", "index", "mem", "target" ],
1067 am => "source,unary",
1068 emit => '. jmp *%unop3',
1070 units => [ "BRANCH" ],
1072 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1076 op_flags => [ "constlike" ],
1077 irn_flags => [ "rematerializable" ],
1078 reg_req => { out => [ "gp" ] },
1080 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1081 attr_type => "ia32_immediate_attr_t",
1087 op_flags => [ "constlike" ],
1088 irn_flags => [ "rematerializable" ],
1089 reg_req => { out => [ "gp" ] },
1096 op_flags => [ "constlike" ],
1097 reg_req => { out => [ "gp" ] },
1101 modified_flags => $status_flags,
1106 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1107 irn_flags => [ "not_scheduled" ],
1108 reg_req => { out => [ "gp_NOREG:I" ] },
1117 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1118 irn_flags => [ "not_scheduled" ],
1119 reg_req => { out => [ "vfp_NOREG:I" ] },
1124 attr_type => "ia32_x87_attr_t",
1129 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1130 irn_flags => [ "not_scheduled" ],
1131 reg_req => { out => [ "xmm_NOREG:I" ] },
1140 op_flags => [ "constlike" ],
1141 irn_flags => [ "not_scheduled" ],
1142 reg_req => { out => [ "fpcw:I" ] },
1146 modified_flags => $fpcw_flags
1150 op_flags => [ "labeled" ],
1152 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1153 ins => [ "base", "index", "mem" ],
1155 emit => ". fldcw %AM",
1158 modified_flags => $fpcw_flags
1162 op_flags => [ "labeled" ],
1164 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1165 ins => [ "base", "index", "mem", "fpcw" ],
1167 emit => ". fnstcw %AM",
1173 op_flags => [ "labeled" ],
1175 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1183 # we should not rematrialize this node. It has very strict constraints.
1184 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1185 ins => [ "val", "clobbered" ],
1194 # Note that we add additional latency values depending on address mode, so a
1195 # lateny of 0 for load is correct
1198 op_flags => [ "uses_memory", "fragile", "labeled" ],
1199 state => "exc_pinned",
1200 reg_req => { in => [ "gp", "gp", "none" ],
1201 out => [ "gp", "none", "none", "none", "none" ] },
1202 ins => [ "base", "index", "mem" ],
1203 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
1205 emit => ". mov%EX%.l %AM, %D0",
1210 op_flags => [ "uses_memory", "fragile", "labeled" ],
1211 state => "exc_pinned",
1212 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1213 out => [ "none", "none", "none" ] },
1214 ins => [ "base", "index", "mem", "val" ],
1215 outs => [ "M", "X_regular", "X_except" ],
1216 emit => '. mov%M %SI3, %AM',
1222 op_flags => [ "uses_memory", "fragile", "labeled" ],
1223 state => "exc_pinned",
1224 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
1225 out => ["none", "none", "none" ] },
1226 ins => [ "base", "index", "mem", "val" ],
1227 outs => [ "M", "X_regular", "X_except" ],
1228 emit => '. mov%M %SB3, %AM',
1234 irn_flags => [ "rematerializable" ],
1235 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1236 ins => [ "base", "index" ],
1237 emit => '. leal %AM, %D0',
1241 # lea doesn't modify the flags, but setting this seems advantageous since it
1242 # increases chances that the Lea is transformed back to an Add
1243 modified_flags => 1,
1247 state => "exc_pinned",
1248 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1249 ins => [ "base", "index", "mem", "val", "stack" ],
1250 emit => '. push%M %unop3',
1251 outs => [ "stack", "M" ],
1252 am => "source,unary",
1258 state => "exc_pinned",
1259 reg_req => { in => [ "esp" ], out => [ "esp:I|S" ] },
1261 outs => [ "stack" ],
1262 emit => '. pushl %%eax',
1269 state => "exc_pinned",
1270 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1271 ins => [ "mem", "stack" ],
1272 outs => [ "res", "M", "unused", "stack" ],
1273 emit => '. pop%M %D0',
1274 latency => 3, # Pop is more expensive than Push on Athlon
1279 state => "exc_pinned",
1280 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1281 ins => [ "mem", "stack" ],
1282 outs => [ "res", "M", "unused", "stack" ],
1283 emit => '. pop%M %D0',
1284 latency => 3, # Pop is more expensive than Push on Athlon
1289 state => "exc_pinned",
1290 reg_req => { in => [ "ebp" ], out => [ "esp:I|S" ] },
1293 emit => '. movl %S0, %D0',
1300 state => "exc_pinned",
1301 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1302 ins => [ "base", "index", "mem", "stack" ],
1303 outs => [ "unused0", "M", "unused1", "stack" ],
1304 emit => '. pop%M %AM',
1305 latency => 3, # Pop is more expensive than Push on Athlon
1310 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1312 outs => [ "frame", "stack", "M" ],
1318 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1320 outs => [ "frame", "stack" ],
1323 state => "exc_pinned",
1328 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1329 ins => [ "base", "index", "mem", "stack", "size" ],
1330 am => "source,binary",
1331 emit => '. addl %binop',
1333 outs => [ "stack", "M" ],
1335 modified_flags => $status_flags
1340 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1341 ins => [ "base", "index", "mem", "stack", "size" ],
1342 am => "source,binary",
1343 emit => ". subl %binop\n".
1344 ". movl %%esp, %D1",
1346 outs => [ "stack", "addr", "M" ],
1348 modified_flags => $status_flags
1352 op_flags => [ "keep" ],
1360 irn_flags => [ "rematerializable" ],
1361 reg_req => { out => [ "gp" ] },
1363 emit => ". movl %%gs:0, %D0",
1369 # BT supports source address mode, but this is unused yet
1372 irn_flags => [ "rematerializable" ],
1373 state => "exc_pinned",
1374 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1375 ins => [ "left", "right" ],
1376 emit => '. bt%M %S1, %S0',
1379 mode => $mode_flags,
1380 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1384 irn_flags => [ "rematerializable" ],
1385 state => "exc_pinned",
1386 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1387 out => [ "gp", "flags", "none" ] },
1388 ins => [ "base", "index", "mem", "operand" ],
1389 outs => [ "res", "flags", "M" ],
1390 am => "source,binary",
1391 emit => '. bsf%M %unop3, %D0',
1395 modified_flags => $status_flags
1399 irn_flags => [ "rematerializable" ],
1400 state => "exc_pinned",
1401 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1402 out => [ "gp", "flags", "none" ] },
1403 ins => [ "base", "index", "mem", "operand" ],
1404 outs => [ "res", "flags", "M" ],
1405 am => "source,binary",
1406 emit => '. bsr%M %unop3, %D0',
1410 modified_flags => $status_flags
1414 # SSE4.2 or SSE4a popcnt instruction
1417 irn_flags => [ "rematerializable" ],
1418 state => "exc_pinned",
1419 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1420 out => [ "gp", "flags", "none" ] },
1421 ins => [ "base", "index", "mem", "operand" ],
1422 outs => [ "res", "flags", "M" ],
1423 am => "source,binary",
1424 emit => '. popcnt%M %unop3, %D0',
1428 modified_flags => $status_flags
1432 op_flags => [ "uses_memory", "fragile" ],
1433 state => "exc_pinned",
1435 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1436 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", "none", "none" ]
1438 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1439 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "X_regular", "X_except" ],
1440 attr_type => "ia32_call_attr_t",
1441 attr => "unsigned pop, ir_type *call_tp",
1442 am => "source,unary",
1443 units => [ "BRANCH" ],
1444 latency => 4, # random number
1445 modified_flags => $status_flags
1449 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1451 # PS: try gcc __builtin_frame_address(100000) :-)
1454 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1455 ins => [ "frame", "cnt", "tmp" ],
1457 latency => 4, # random number
1458 attr_type => "ia32_climbframe_attr_t",
1459 attr => "unsigned count",
1468 irn_flags => [ "rematerializable" ],
1469 reg_req => { in => [ "gp" ],
1470 out => [ "in_r1" ] },
1471 emit => '. bswap%M %S0',
1479 # bswap16, use xchg here
1482 irn_flags => [ "rematerializable" ],
1483 reg_req => { in => [ "eax ebx ecx edx" ],
1484 out => [ "in_r1" ] },
1485 emit => '. xchg %SB0, %SH0',
1497 reg_req => { in => [ "none" ], out => [ "none" ] },
1506 # Undefined Instruction on ALL x86 CPU's
1510 reg_req => { in => [ "none" ], out => [ "none" ] },
1513 emit => ". .value 0x0b0f",
1522 irn_flags => [ "rematerializable" ],
1524 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1525 ins => [ "port", "value", "mem" ],
1526 emit => '. out%M %SS0, %SI1',
1530 modified_flags => $status_flags
1537 irn_flags => [ "rematerializable" ],
1539 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1540 ins => [ "port", "mem" ],
1541 outs => [ "res", "M" ],
1542 emit => '. in%M %DS0, %SS0',
1546 modified_flags => $status_flags
1550 # Intel style prefetching
1553 op_flags => [ "labeled" ],
1554 state => "exc_pinned",
1555 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1556 ins => [ "base", "index", "mem" ],
1559 emit => ". prefetcht0 %AM",
1564 op_flags => [ "labeled" ],
1565 state => "exc_pinned",
1566 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1567 ins => [ "base", "index", "mem" ],
1570 emit => ". prefetcht1 %AM",
1575 op_flags => [ "labeled" ],
1576 state => "exc_pinned",
1577 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1578 ins => [ "base", "index", "mem" ],
1581 emit => ". prefetcht2 %AM",
1586 op_flags => [ "labeled" ],
1587 state => "exc_pinned",
1588 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1589 ins => [ "base", "index", "mem" ],
1592 emit => ". prefetchnta %AM",
1597 # 3DNow! prefetch instructions
1600 op_flags => [ "labeled" ],
1601 state => "exc_pinned",
1602 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1603 ins => [ "base", "index", "mem" ],
1606 emit => ". prefetch %AM",
1611 op_flags => [ "labeled" ],
1612 state => "exc_pinned",
1613 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1614 ins => [ "base", "index", "mem" ],
1617 emit => ". prefetchw %AM",
1623 irn_flags => [ "rematerializable" ],
1624 reg_req => { out => [ "xmm" ] },
1625 emit => '. xorp%XSD %D0, %D0',
1632 op_flags => [ "constlike" ],
1633 irn_flags => [ "rematerializable" ],
1634 reg_req => { out => [ "xmm" ] },
1641 irn_flags => [ "rematerializable" ],
1642 reg_req => { out => [ "xmm" ] },
1643 emit => '. pxor %D0, %D0',
1649 # produces all 1 bits
1651 irn_flags => [ "rematerializable" ],
1652 reg_req => { out => [ "xmm" ] },
1653 emit => '. pcmpeqb %D0, %D0',
1659 # integer shift left, dword
1661 irn_flags => [ "rematerializable" ],
1662 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1663 emit => '. pslld %SI1, %D0',
1669 # integer shift left, qword
1671 irn_flags => [ "rematerializable" ],
1672 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1673 emit => '. psllq %SI1, %D0',
1679 # integer shift right, dword
1681 irn_flags => [ "rematerializable" ],
1682 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1683 emit => '. psrld %SI1, %D0',
1689 # mov from integer to SSE register
1691 irn_flags => [ "rematerializable" ],
1692 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1693 emit => '. movd %S0, %D0',
1700 irn_flags => [ "rematerializable" ],
1701 state => "exc_pinned",
1702 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1703 out => [ "in_r4 in_r5", "flags", "none" ] },
1704 ins => [ "base", "index", "mem", "left", "right" ],
1705 outs => [ "res", "flags", "M" ],
1706 am => "source,binary",
1707 emit => '. add%XXM %binop',
1714 irn_flags => [ "rematerializable" ],
1715 state => "exc_pinned",
1716 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1717 out => [ "in_r4 in_r5", "flags", "none" ] },
1718 ins => [ "base", "index", "mem", "left", "right" ],
1719 outs => [ "res", "flags", "M" ],
1720 am => "source,binary",
1721 emit => '. mul%XXM %binop',
1728 irn_flags => [ "rematerializable" ],
1729 state => "exc_pinned",
1730 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1731 out => [ "in_r4 in_r5", "flags", "none" ] },
1732 ins => [ "base", "index", "mem", "left", "right" ],
1733 outs => [ "res", "flags", "M" ],
1734 am => "source,binary",
1735 emit => '. max%XXM %binop',
1742 irn_flags => [ "rematerializable" ],
1743 state => "exc_pinned",
1744 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1745 out => [ "in_r4 in_r5", "flags", "none" ] },
1746 ins => [ "base", "index", "mem", "left", "right" ],
1747 outs => [ "res", "flags", "M" ],
1748 am => "source,binary",
1749 emit => '. min%XXM %binop',
1756 irn_flags => [ "rematerializable" ],
1757 state => "exc_pinned",
1758 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1759 out => [ "in_r4 in_r5", "flags", "none" ] },
1760 ins => [ "base", "index", "mem", "left", "right" ],
1761 outs => [ "res", "flags", "M" ],
1762 am => "source,binary",
1763 emit => '. andp%XSD %binop',
1770 irn_flags => [ "rematerializable" ],
1771 state => "exc_pinned",
1772 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1773 out => [ "in_r4 in_r5", "flags", "none" ] },
1774 ins => [ "base", "index", "mem", "left", "right" ],
1775 outs => [ "res", "flags", "M" ],
1776 am => "source,binary",
1777 emit => '. orp%XSD %binop',
1784 irn_flags => [ "rematerializable" ],
1785 state => "exc_pinned",
1786 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1787 out => [ "in_r4 in_r5", "flags", "none" ] },
1788 ins => [ "base", "index", "mem", "left", "right" ],
1789 outs => [ "res", "flags", "M" ],
1790 am => "source,binary",
1791 emit => '. xorp%XSD %binop',
1798 irn_flags => [ "rematerializable" ],
1799 state => "exc_pinned",
1800 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1801 out => [ "in_r4 !in_r5", "flags", "none" ] },
1802 ins => [ "base", "index", "mem", "left", "right" ],
1803 outs => [ "res", "flags", "M" ],
1804 am => "source,binary",
1805 emit => '. andnp%XSD %binop',
1812 irn_flags => [ "rematerializable" ],
1813 state => "exc_pinned",
1814 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1815 out => [ "in_r4", "flags", "none" ] },
1816 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1817 outs => [ "res", "flags", "M" ],
1818 am => "source,binary",
1819 emit => '. sub%XXM %binop',
1826 irn_flags => [ "rematerializable" ],
1827 state => "exc_pinned",
1828 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1829 out => [ "in_r4 !in_r5", "flags", "none" ] },
1830 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1831 outs => [ "res", "flags", "M" ],
1832 am => "source,binary",
1833 emit => '. div%XXM %binop',
1839 irn_flags => [ "rematerializable" ],
1840 state => "exc_pinned",
1841 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1842 out => [ "eflags" ] },
1843 ins => [ "base", "index", "mem", "left", "right" ],
1844 outs => [ "flags" ],
1845 am => "source,binary",
1846 attr => "bool ins_permuted",
1847 init_attr => "attr->data.ins_permuted = ins_permuted;",
1848 emit => ' .ucomi%XXM %binop',
1851 mode => $mode_flags,
1852 modified_flags => 1,
1856 op_flags => [ "uses_memory", "fragile", "labeled" ],
1857 state => "exc_pinned",
1858 reg_req => { in => [ "gp", "gp", "none" ],
1859 out => [ "xmm", "none", "none", "none", "none" ] },
1860 ins => [ "base", "index", "mem" ],
1861 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
1862 emit => '. mov%XXM %AM, %D0',
1863 attr => "ir_mode *load_mode",
1864 init_attr => "attr->ls_mode = load_mode;",
1870 op_flags => [ "uses_memory", "fragile", "labeled" ],
1871 state => "exc_pinned",
1872 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
1873 out => [ "none", "none", "none" ] },
1874 ins => [ "base", "index", "mem", "val" ],
1875 outs => [ "M", "X_regular", "X_except" ],
1876 emit => '. mov%XXM %S3, %AM',
1882 op_flags => [ "uses_memory", "fragile", "labeled" ],
1883 state => "exc_pinned",
1884 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
1885 out => [ "none", "none", "none" ] },
1886 ins => [ "base", "index", "mem", "val" ],
1887 outs => [ "M", "X_regular", "X_except" ],
1888 emit => '. mov%XXM %S3, %AM',
1894 op_flags => [ "labeled" ],
1895 state => "exc_pinned",
1896 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1897 ins => [ "base", "index", "mem", "val" ],
1898 am => "source,unary",
1899 emit => '. cvtsi2ss %unop3, %D0',
1906 op_flags => [ "labeled" ],
1907 state => "exc_pinned",
1908 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1909 ins => [ "base", "index", "mem", "val" ],
1910 am => "source,unary",
1911 emit => '. cvtsi2sd %unop3, %D0',
1919 ins => [ "val_high", "val_low" ],
1921 dump_func => "NULL",
1926 outs => [ "res_high", "res_low" ],
1928 dump_func => "NULL",
1932 op_flags => [ "uses_memory", "fragile" ],
1934 reg_req => { in => [ "edi", "esi", "ecx", "none" ],
1935 out => [ "edi", "esi", "ecx", "none", "none", "none" ] },
1936 ins => [ "dest", "source", "count", "mem" ],
1937 outs => [ "dest", "source", "count", "M", "X_regular", "X_except" ],
1938 attr_type => "ia32_copyb_attr_t",
1939 attr => "unsigned size",
1942 # we don't care about this flag, so no need to mark this node
1943 # modified_flags => [ "DF" ]
1947 op_flags => [ "uses_memory", "fragile" ],
1949 reg_req => { in => [ "edi", "esi", "none" ],
1950 out => [ "edi", "esi", "none", "none", "none" ] },
1951 ins => [ "dest", "source", "mem" ],
1952 outs => [ "dest", "source", "M", "X_regular", "X_except" ],
1953 attr_type => "ia32_copyb_attr_t",
1954 attr => "unsigned size",
1957 # we don't care about this flag, so no need to mark this node
1958 # modified_flags => [ "DF" ]
1962 state => "exc_pinned",
1963 reg_req => { in => [ "eax" ], out => [ "eax" ] },
1973 op_flags => [ "uses_memory", "fragile" ],
1974 state => "exc_pinned",
1975 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1976 out => [ "gp", "none", "none", "none", "none" ] },
1977 ins => [ "base", "index", "mem", "val" ],
1978 outs => [ "res", "flags", "M", "X_regular", "X_except" ],
1979 am => "source,unary",
1982 attr => "ir_mode *smaller_mode",
1983 init_attr => "attr->ls_mode = smaller_mode;",
1988 op_flags => [ "uses_memory", "fragile" ],
1989 state => "exc_pinned",
1990 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
1991 out => [ "gp", "none", "none", "none", "none" ] },
1992 ins => [ "base", "index", "mem", "val" ],
1993 outs => [ "res", "flags", "M", "X_regular", "X_except" ],
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 => [ "uses_memory", "fragile", "labeled" ],
2121 state => "exc_pinned",
2122 reg_req => { in => [ "gp", "gp", "none" ],
2123 out => [ "vfp", "none", "none", "none", "none" ] },
2124 ins => [ "base", "index", "mem" ],
2125 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
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 => [ "uses_memory", "fragile", "labeled" ],
2136 state => "exc_pinned",
2137 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2138 out => [ "none", "none", "none" ] },
2139 ins => [ "base", "index", "mem", "val" ],
2140 outs => [ "M", "X_regular", "X_except" ],
2141 attr => "ir_mode *store_mode",
2142 init_attr => "attr->attr.ls_mode = store_mode;",
2145 attr_type => "ia32_x87_attr_t",
2149 state => "exc_pinned",
2150 reg_req => { in => [ "gp", "gp", "none" ],
2151 out => [ "vfp", "none", "none" ] },
2152 outs => [ "res", "unused", "M" ],
2153 ins => [ "base", "index", "mem" ],
2156 attr_type => "ia32_x87_attr_t",
2160 op_flags => [ "uses_memory", "fragile" ],
2161 state => "exc_pinned",
2162 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ],
2163 out => [ "none", "none", "none", "none" ] },
2164 ins => [ "base", "index", "mem", "val", "fpcw" ],
2165 outs => [ "dummy", "M", "X_regular", "X_except" ],
2168 attr_type => "ia32_x87_attr_t",
2171 # SSE3 fisttp instruction
2173 op_flags => [ "uses_memory", "fragile" ],
2174 state => "exc_pinned",
2175 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2176 out => [ "in_r4", "none", "none", "none" ]},
2177 ins => [ "base", "index", "mem", "val" ],
2178 outs => [ "res", "M", "X_regular", "X_except" ],
2181 attr_type => "ia32_x87_attr_t",
2185 irn_flags => [ "rematerializable" ],
2186 reg_req => { out => [ "vfp" ] },
2191 attr_type => "ia32_x87_attr_t",
2195 irn_flags => [ "rematerializable" ],
2196 reg_req => { out => [ "vfp" ] },
2201 attr_type => "ia32_x87_attr_t",
2205 irn_flags => [ "rematerializable" ],
2206 reg_req => { out => [ "vfp" ] },
2211 attr_type => "ia32_x87_attr_t",
2215 irn_flags => [ "rematerializable" ],
2216 reg_req => { out => [ "vfp" ] },
2221 attr_type => "ia32_x87_attr_t",
2225 irn_flags => [ "rematerializable" ],
2226 reg_req => { out => [ "vfp" ] },
2231 attr_type => "ia32_x87_attr_t",
2235 irn_flags => [ "rematerializable" ],
2236 reg_req => { out => [ "vfp" ] },
2241 attr_type => "ia32_x87_attr_t",
2245 irn_flags => [ "rematerializable" ],
2246 reg_req => { out => [ "vfp" ] },
2251 attr_type => "ia32_x87_attr_t",
2255 # we can't allow to rematerialize this node so we don't
2256 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2257 # irn_flags => [ "rematerializable" ],
2258 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2259 ins => [ "left", "right" ],
2260 outs => [ "flags" ],
2261 attr => "bool ins_permuted",
2262 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2265 attr_type => "ia32_x87_attr_t",
2270 irn_flags => [ "rematerializable" ],
2271 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2272 ins => [ "left", "right" ],
2273 outs => [ "flags" ],
2274 attr => "bool ins_permuted",
2275 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2278 attr_type => "ia32_x87_attr_t",
2283 # irn_flags => [ "rematerializable" ],
2284 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2286 outs => [ "flags" ],
2287 attr => "bool ins_permuted",
2288 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2291 attr_type => "ia32_x87_attr_t",
2296 irn_flags => [ "rematerializable" ],
2297 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2299 outs => [ "flags" ],
2303 mode => $mode_flags,
2307 state => "exc_pinned",
2308 emit => '. fadd%XM %x87_binop',
2310 attr_type => "ia32_x87_attr_t",
2315 state => "exc_pinned",
2316 emit => '. faddp%XM %x87_binop',
2318 attr_type => "ia32_x87_attr_t",
2323 state => "exc_pinned",
2324 emit => '. fmul%XM %x87_binop',
2326 attr_type => "ia32_x87_attr_t",
2331 state => "exc_pinned",
2332 emit => '. fmulp%XM %x87_binop',,
2334 attr_type => "ia32_x87_attr_t",
2339 state => "exc_pinned",
2340 emit => '. fsub%XM %x87_binop',
2342 attr_type => "ia32_x87_attr_t",
2346 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2347 # are swapped, we work this around in the emitter...
2350 state => "exc_pinned",
2351 # see note about gas bugs
2352 emit => '. fsubrp%XM %x87_binop',
2354 attr_type => "ia32_x87_attr_t",
2359 state => "exc_pinned",
2360 irn_flags => [ "rematerializable" ],
2361 emit => '. fsubr%XM %x87_binop',
2363 attr_type => "ia32_x87_attr_t",
2368 state => "exc_pinned",
2369 irn_flags => [ "rematerializable" ],
2370 # see note about gas bugs before fsubp
2371 emit => '. fsubp%XM %x87_binop',
2373 attr_type => "ia32_x87_attr_t",
2380 attr_type => "ia32_x87_attr_t",
2384 # this node is just here, to keep the simulator running
2385 # we can omit this when a fprem simulation function exists
2387 emit => '. fprem1\n'.
2390 attr_type => "ia32_x87_attr_t",
2395 state => "exc_pinned",
2396 emit => '. fdiv%XM %x87_binop',
2398 attr_type => "ia32_x87_attr_t",
2403 state => "exc_pinned",
2404 # see note about gas bugs before fsubp
2405 emit => '. fdivrp%XM %x87_binop',
2407 attr_type => "ia32_x87_attr_t",
2412 state => "exc_pinned",
2413 emit => '. fdivr%XM %x87_binop',
2415 attr_type => "ia32_x87_attr_t",
2420 state => "exc_pinned",
2421 # see note about gas bugs before fsubp
2422 emit => '. fdivp%XM %x87_binop',
2424 attr_type => "ia32_x87_attr_t",
2431 attr_type => "ia32_x87_attr_t",
2436 op_flags => [ "keep" ],
2437 irn_flags => [ "rematerializable" ],
2440 attr_type => "ia32_x87_attr_t",
2445 irn_flags => [ "rematerializable" ],
2446 op_flags => [ "labeled" ],
2447 state => "exc_pinned",
2448 emit => '. fld%XM %AM',
2449 attr_type => "ia32_x87_attr_t",
2455 irn_flags => [ "rematerializable" ],
2456 op_flags => [ "labeled" ],
2457 state => "exc_pinned",
2458 emit => '. fst%XM %AM',
2460 attr_type => "ia32_x87_attr_t",
2466 irn_flags => [ "rematerializable" ],
2467 op_flags => [ "labeled" ],
2468 state => "exc_pinned",
2469 emit => '. fstp%XM %AM',
2471 attr_type => "ia32_x87_attr_t",
2477 state => "exc_pinned",
2478 emit => '. fild%XM %AM',
2479 attr_type => "ia32_x87_attr_t",
2485 state => "exc_pinned",
2486 emit => '. fist%XM %AM',
2488 attr_type => "ia32_x87_attr_t",
2494 state => "exc_pinned",
2495 emit => '. fistp%XM %AM',
2497 attr_type => "ia32_x87_attr_t",
2502 # SSE3 fisttp instruction
2504 state => "exc_pinned",
2505 emit => '. fisttp%XM %AM',
2507 attr_type => "ia32_x87_attr_t",
2513 op_flags => [ "constlike", "keep" ],
2514 irn_flags => [ "rematerializable" ],
2515 reg_req => { out => [ "vfp" ] },
2517 attr_type => "ia32_x87_attr_t",
2522 op_flags => [ "constlike", "keep" ],
2523 irn_flags => [ "rematerializable" ],
2524 reg_req => { out => [ "vfp" ] },
2526 attr_type => "ia32_x87_attr_t",
2531 op_flags => [ "constlike", "keep" ],
2532 irn_flags => [ "rematerializable" ],
2533 reg_req => { out => [ "vfp" ] },
2535 attr_type => "ia32_x87_attr_t",
2540 op_flags => [ "constlike", "keep" ],
2541 irn_flags => [ "rematerializable" ],
2542 reg_req => { out => [ "vfp" ] },
2544 attr_type => "ia32_x87_attr_t",
2549 op_flags => [ "constlike", "keep" ],
2550 irn_flags => [ "rematerializable" ],
2551 reg_req => { out => [ "vfp" ] },
2553 attr_type => "ia32_x87_attr_t",
2558 op_flags => [ "constlike", "keep" ],
2559 irn_flags => [ "rematerializable" ],
2560 reg_req => { out => [ "vfp" ] },
2561 emit => '. fldll2t',
2562 attr_type => "ia32_x87_attr_t",
2567 op_flags => [ "constlike", "keep" ],
2568 irn_flags => [ "rematerializable" ],
2569 reg_req => { out => [ "vfp" ] },
2571 attr_type => "ia32_x87_attr_t",
2576 # Note that it is NEVER allowed to do CSE on these nodes
2577 # Moreover, note the virtual register requierements!
2580 op_flags => [ "keep" ],
2581 reg_req => { out => [ "none" ] },
2582 cmp_attr => "return 1;",
2583 emit => '. fxch %X0',
2584 attr_type => "ia32_x87_attr_t",
2590 op_flags => [ "keep" ],
2591 reg_req => { out => [ "none" ] },
2592 cmp_attr => "return 1;",
2593 emit => '. fld %X0',
2594 attr_type => "ia32_x87_attr_t",
2600 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2601 cmp_attr => "return 1;",
2602 emit => '. fld %X0',
2603 attr_type => "ia32_x87_attr_t",
2608 op_flags => [ "keep" ],
2609 reg_req => { out => [ "none" ] },
2610 cmp_attr => "return 1;",
2611 emit => '. fstp %X0',
2612 attr_type => "ia32_x87_attr_t",
2618 op_flags => [ "keep" ],
2619 reg_req => { out => [ "none" ] },
2620 cmp_attr => "return 1;",
2621 emit => '. ffreep %X0',
2622 attr_type => "ia32_x87_attr_t",
2628 op_flags => [ "keep" ],
2629 reg_req => { out => [ "none" ] },
2630 cmp_attr => "return 1;",
2632 attr_type => "ia32_x87_attr_t",
2638 op_flags => [ "keep" ],
2639 reg_req => { out => [ "none" ] },
2640 cmp_attr => "return 1;",
2642 attr_type => "ia32_x87_attr_t",
2649 emit => ". fucom %X1\n".
2651 attr_type => "ia32_x87_attr_t",
2657 emit => ". fucomp %X1\n".
2659 attr_type => "ia32_x87_attr_t",
2665 emit => ". fucompp\n".
2667 attr_type => "ia32_x87_attr_t",
2673 emit => '. fucomi %X1',
2674 attr_type => "ia32_x87_attr_t",
2680 emit => '. fucompi %X1',
2681 attr_type => "ia32_x87_attr_t",
2689 attr_type => "ia32_x87_attr_t",
2693 # Spilling and reloading of SSE registers, hardcoded, not generated #
2696 op_flags => [ "uses_memory", "fragile", "labeled" ],
2697 state => "exc_pinned",
2698 reg_req => { in => [ "gp", "gp", "none" ],
2699 out => [ "xmm", "none", "none", "none" ] },
2700 emit => '. movdqu %D0, %AM',
2701 ins => [ "base", "index", "mem" ],
2702 outs => [ "res", "M", "X_regular", "X_except" ],
2708 op_flags => [ "uses_memory", "fragile", "labeled" ],
2709 state => "exc_pinned",
2710 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
2711 out => [ "none", "none", "none" ] },
2712 ins => [ "base", "index", "mem", "val" ],
2713 outs => [ "M", "X_regular", "X_except" ],
2714 emit => '. movdqu %binop',
2721 # Transform some attributes
2722 foreach my $op (keys(%nodes)) {
2723 my $node = $nodes{$op};
2724 my $op_attr_init = $node->{op_attr_init};
2726 if(defined($op_attr_init)) {
2727 $op_attr_init .= "\n\t";
2732 if(!defined($node->{latency})) {
2734 $node->{latency} = 0;
2736 die("Latency missing for op $op");
2739 $op_attr_init .= "ia32_init_op(op, ".$node->{latency} . ");";
2741 $node->{op_attr_init} = $op_attr_init;