3 # This is the specification for the ia32 assembler Firm-operations
8 $normal = 0; # no special type
9 $ignore = 1; # ignore (do not assign this register)
10 $arbitrary = 2; # emitter can choose an arbitrary register of this class
11 $virtual = 4; # the register is a virtual one
12 $state = 8; # register represents a state
13 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
23 { name => "esp", type => $ignore },
24 { name => "gp_NOREG", type => $ignore | $arbitrary | $virtual }, # we need a dummy register for NoReg nodes
28 { name => "mm0", type => $ignore },
29 { name => "mm1", type => $ignore },
30 { name => "mm2", type => $ignore },
31 { name => "mm3", type => $ignore },
32 { name => "mm4", type => $ignore },
33 { name => "mm5", type => $ignore },
34 { name => "mm6", type => $ignore },
35 { name => "mm7", type => $ignore },
36 { mode => "mode_E", flags => "manual_ra" }
47 { name => "xmm_NOREG", type => $ignore | $virtual }, # we need a dummy register for NoReg nodes
59 { name => "vfp_NOREG", type => $ignore | $arbitrary | $virtual }, # we need a dummy register for NoReg nodes
63 { name => "st0", realname => "st", type => $ignore },
64 { name => "st1", realname => "st(1)", type => $ignore },
65 { name => "st2", realname => "st(2)", type => $ignore },
66 { name => "st3", realname => "st(3)", type => $ignore },
67 { name => "st4", realname => "st(4)", type => $ignore },
68 { name => "st5", realname => "st(5)", type => $ignore },
69 { name => "st6", realname => "st(6)", type => $ignore },
70 { name => "st7", realname => "st(7)", type => $ignore },
71 { mode => "mode_E", flags => "manual_ra" }
73 fp_cw => [ # the floating point control word
74 { name => "fpcw", type => $ignore | $state },
75 { mode => "ia32_mode_fpcw", flags => "manual_ra|state" }
78 { name => "eflags", type => 0 },
79 { mode => "mode_Iu", flags => "manual_ra" }
84 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
85 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
86 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
87 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
92 bundels_per_cycle => 1
96 S0 => "${arch}_emit_source_register(node, 0);",
97 S1 => "${arch}_emit_source_register(node, 1);",
98 S2 => "${arch}_emit_source_register(node, 2);",
99 S3 => "${arch}_emit_source_register(node, 3);",
100 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
101 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
102 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
103 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
104 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
105 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
106 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
107 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
108 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
109 D0 => "${arch}_emit_dest_register(node, 0);",
110 D1 => "${arch}_emit_dest_register(node, 1);",
111 DS0 => "${arch}_emit_dest_register_size(node, 0);",
112 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
113 X0 => "${arch}_emit_x87_register(node, 0);",
114 X1 => "${arch}_emit_x87_register(node, 1);",
115 EX => "${arch}_emit_extend_suffix(node);",
116 M => "${arch}_emit_mode_suffix(node);",
117 XM => "${arch}_emit_x87_mode_suffix(node);",
118 XXM => "${arch}_emit_xmm_mode_suffix(node);",
119 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
120 AM => "${arch}_emit_am(node);",
121 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
122 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
123 binop => "${arch}_emit_binop(node);",
124 x87_binop => "${arch}_emit_x87_binop(node);",
125 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
131 $default_op_attr_type = "ia32_op_attr_t";
132 $default_attr_type = "ia32_attr_t";
133 $default_copy_attr = "ia32_copy_attr";
135 sub ia32_custom_init_attr {
141 if(defined($node->{modified_flags})) {
142 $res .= "\tarch_add_irn_flags(res, arch_irn_flags_modify_flags);\n";
144 if(defined($node->{am})) {
145 my $am = $node->{am};
146 if($am eq "source,unary") {
147 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
148 } elsif($am eq "source,binary") {
149 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
150 } elsif($am eq "none") {
153 die("Invalid address mode '$am' specified on op $name");
156 if($node->{state} ne "exc_pinned"
157 and $node->{state} ne "pinned") {
158 die("AM nodes must have pinned or AM pinned state ($name)");
164 $custom_init_attr_func = \&ia32_custom_init_attr;
168 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
169 "\tinit_ia32_x87_attributes(res);".
170 "\tinit_ia32_asm_attributes(res);",
172 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);",
174 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
175 "\tinit_ia32_call_attributes(res, pop, call_tp);",
176 ia32_condcode_attr_t =>
177 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
178 "\tinit_ia32_condcode_attributes(res, condition_code);",
179 ia32_switch_attr_t =>
180 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
181 "\tinit_ia32_switch_attributes(res, default_pn);",
183 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
184 "\tinit_ia32_copyb_attributes(res, size);",
185 ia32_immediate_attr_t =>
186 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
187 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
189 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
190 "\tinit_ia32_x87_attributes(res);",
191 ia32_climbframe_attr_t =>
192 "\tinit_ia32_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
193 "\tinit_ia32_climbframe_attributes(res, count);",
197 ia32_asm_attr_t => "ia32_compare_asm_attr",
198 ia32_attr_t => "ia32_compare_nodes_attr",
199 ia32_call_attr_t => "ia32_compare_call_attr",
200 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
201 ia32_switch_attr_t => "ia32_compare_switch_attr",
202 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
203 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
204 ia32_x87_attr_t => "ia32_compare_x87_attr",
205 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
211 $mode_xmm = "mode_E";
212 $mode_gp = "mode_Iu";
213 $mode_flags = "mode_Iu";
214 $mode_fpcw = "ia32_mode_fpcw";
215 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
216 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
217 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
218 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
224 op_flags => [ "constlike" ],
225 irn_flags => [ "not_scheduled" ],
226 reg_req => { out => [ "gp_NOREG:I" ] },
227 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
228 attr_type => "ia32_immediate_attr_t",
229 hash_func => "ia32_hash_Immediate",
237 out_arity => "variable",
238 attr_type => "ia32_asm_attr_t",
239 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
240 init_attr => "attr->asm_text = asm_text;\n".
241 "\tattr->register_map = register_map;\n",
243 modified_flags => $status_flags,
246 # "allocates" a free register
248 op_flags => [ "constlike", "cse_neutral" ],
249 irn_flags => [ "rematerializable" ],
250 reg_req => { out => [ "gp" ] },
255 cmp_attr => "return 1;",
259 irn_flags => [ "rematerializable" ],
260 state => "exc_pinned",
261 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
262 out => [ "in_r4 in_r5", "flags", "none" ] },
263 ins => [ "base", "index", "mem", "left", "right" ],
264 outs => [ "res", "flags", "M" ],
265 emit => '. add%M %binop',
266 am => "source,binary",
270 modified_flags => $status_flags
274 irn_flags => [ "rematerializable" ],
275 state => "exc_pinned",
276 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
277 ins => [ "base", "index", "mem", "val" ],
278 emit => ". add%M %SI3, %AM",
282 modified_flags => $status_flags
286 irn_flags => [ "rematerializable" ],
287 state => "exc_pinned",
288 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
289 ins => [ "base", "index", "mem", "val" ],
290 emit => ". add%M %SB3, %AM",
294 modified_flags => $status_flags
298 state => "exc_pinned",
299 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
300 out => [ "in_r4 in_r5", "flags", "none" ] },
301 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
302 outs => [ "res", "flags", "M" ],
303 emit => '. adc%M %binop',
304 am => "source,binary",
308 modified_flags => $status_flags
312 ins => [ "left", "right" ],
318 ins => [ "left", "right", "eflags" ],
324 # we should not rematrialize this node. It produces 2 results and has
325 # very strict constraints
326 state => "exc_pinned",
327 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
328 out => [ "eax", "flags", "none", "edx" ] },
329 ins => [ "base", "index", "mem", "left", "right" ],
330 emit => '. mul%M %unop4',
331 outs => [ "res_low", "flags", "M", "res_high" ],
332 am => "source,binary",
335 modified_flags => $status_flags
339 ins => [ "left", "right" ],
340 outs => [ "res_low", "flags", "M", "res_high" ],
346 irn_flags => [ "rematerializable" ],
347 state => "exc_pinned",
348 # TODO: adjust out requirements for the 3 operand form
349 # (no need for should_be_same then)
350 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
351 out => [ "in_r4 in_r5", "flags", "none" ] },
352 ins => [ "base", "index", "mem", "left", "right" ],
353 outs => [ "res", "flags", "M" ],
354 am => "source,binary",
358 modified_flags => $status_flags
362 irn_flags => [ "rematerializable" ],
363 state => "exc_pinned",
364 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
365 out => [ "eax", "flags", "none", "edx" ] },
366 ins => [ "base", "index", "mem", "left", "right" ],
367 emit => '. imul%M %unop4',
368 outs => [ "res_low", "flags", "M", "res_high" ],
369 am => "source,binary",
372 modified_flags => $status_flags
376 ins => [ "left", "right" ],
377 outs => [ "res_low", "flags", "M", "res_high" ],
383 irn_flags => [ "rematerializable" ],
384 state => "exc_pinned",
385 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
386 out => [ "in_r4 in_r5", "flags", "none" ] },
387 ins => [ "base", "index", "mem", "left", "right" ],
388 outs => [ "res", "flags", "M" ],
389 am => "source,binary",
390 emit => '. and%M %binop',
394 modified_flags => $status_flags
398 irn_flags => [ "rematerializable" ],
399 state => "exc_pinned",
400 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
401 ins => [ "base", "index", "mem", "val" ],
402 emit => '. and%M %SI3, %AM',
406 modified_flags => $status_flags
410 irn_flags => [ "rematerializable" ],
411 state => "exc_pinned",
412 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
413 ins => [ "base", "index", "mem", "val" ],
414 emit => '. and%M %SB3, %AM',
418 modified_flags => $status_flags
422 irn_flags => [ "rematerializable" ],
423 state => "exc_pinned",
424 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
425 out => [ "in_r4 in_r5", "flags", "none" ] },
426 ins => [ "base", "index", "mem", "left", "right" ],
427 outs => [ "res", "flags", "M" ],
428 am => "source,binary",
429 emit => '. or%M %binop',
433 modified_flags => $status_flags
437 irn_flags => [ "rematerializable" ],
438 state => "exc_pinned",
439 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
440 ins => [ "base", "index", "mem", "val" ],
441 emit => '. or%M %SI3, %AM',
445 modified_flags => $status_flags
449 irn_flags => [ "rematerializable" ],
450 state => "exc_pinned",
451 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
452 ins => [ "base", "index", "mem", "val" ],
453 emit => '. or%M %SB3, %AM',
457 modified_flags => $status_flags
461 irn_flags => [ "rematerializable" ],
462 state => "exc_pinned",
463 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
464 out => [ "in_r4 in_r5", "flags", "none" ] },
465 ins => [ "base", "index", "mem", "left", "right" ],
466 outs => [ "res", "flags", "M" ],
467 am => "source,binary",
468 emit => '. xor%M %binop',
472 modified_flags => $status_flags
476 op_flags => [ "constlike" ],
477 irn_flags => [ "rematerializable" ],
478 reg_req => { out => [ "gp", "flags" ] },
479 outs => [ "res", "flags" ],
480 emit => ". xor%M %D0, %D0",
484 modified_flags => $status_flags
488 irn_flags => [ "rematerializable" ],
489 state => "exc_pinned",
490 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
491 ins => [ "base", "index", "mem", "val" ],
492 emit => '. xor%M %SI3, %AM',
496 modified_flags => $status_flags
500 irn_flags => [ "rematerializable" ],
501 state => "exc_pinned",
502 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
503 ins => [ "base", "index", "mem", "val" ],
504 emit => '. xor%M %SB3, %AM',
508 modified_flags => $status_flags
512 irn_flags => [ "rematerializable" ],
513 state => "exc_pinned",
514 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
515 out => [ "in_r4", "flags", "none" ] },
516 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
517 outs => [ "res", "flags", "M" ],
518 am => "source,binary",
519 emit => '. sub%M %binop',
523 modified_flags => $status_flags
527 irn_flags => [ "rematerializable" ],
528 state => "exc_pinned",
529 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
530 ins => [ "base", "index", "mem", "subtrahend" ],
531 emit => '. sub%M %SI3, %AM',
535 modified_flags => $status_flags
539 irn_flags => [ "rematerializable" ],
540 state => "exc_pinned",
541 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
542 ins => [ "base", "index", "mem", "subtrahend" ],
543 emit => '. sub%M %SB3, %AM',
547 modified_flags => $status_flags
551 state => "exc_pinned",
552 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
553 out => [ "in_r4", "flags", "none" ] },
554 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
555 outs => [ "res", "flags", "M" ],
556 am => "source,binary",
557 emit => '. sbb%M %binop',
561 modified_flags => $status_flags
565 # Spiller currently fails when rematerializing flag consumers
566 # irn_flags => [ "rematerializable" ],
567 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
568 outs => [ "res", "flags" ],
569 emit => ". sbb%M %D0, %D0",
573 modified_flags => $status_flags
577 ins => [ "minuend", "subtrahend" ],
583 ins => [ "minuend", "subtrahend", "eflags" ],
589 op_flags => [ "fragile", "labeled" ],
590 state => "exc_pinned",
591 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
592 out => [ "eax", "flags", "none", "edx", "none", "none" ] },
593 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
594 outs => [ "div_res", "flags", "M", "mod_res", "X_regular", "X_except" ],
595 am => "source,unary",
596 emit => ". idiv%M %unop3",
599 modified_flags => $status_flags
603 op_flags => [ "fragile", "labeled" ],
604 state => "exc_pinned",
605 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
606 out => [ "eax", "flags", "none", "edx", "none", "none" ] },
607 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
608 outs => [ "div_res", "flags", "M", "mod_res", "X_regular", "X_except" ],
609 am => "source,unary",
610 emit => ". div%M %unop3",
613 modified_flags => $status_flags
617 irn_flags => [ "rematerializable" ],
618 reg_req => { in => [ "gp", "ecx" ],
619 out => [ "in_r1 !in_r2", "flags" ] },
620 ins => [ "val", "count" ],
621 outs => [ "res", "flags" ],
622 emit => '. shl%M %SB1, %S0',
626 modified_flags => $status_flags
630 irn_flags => [ "rematerializable" ],
631 state => "exc_pinned",
632 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
633 ins => [ "base", "index", "mem", "count" ],
634 emit => '. shl%M %SB3, %AM',
638 modified_flags => $status_flags
642 irn_flags => [ "rematerializable" ],
643 reg_req => { in => [ "gp", "gp", "ecx" ],
644 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
645 ins => [ "val_high", "val_low", "count" ],
646 outs => [ "res", "flags" ],
647 emit => ". shld%M %SB2, %S1, %D0",
651 modified_flags => $status_flags
655 irn_flags => [ "rematerializable" ],
656 reg_req => { in => [ "gp", "ecx" ],
657 out => [ "in_r1 !in_r2", "flags" ] },
658 ins => [ "val", "count" ],
659 outs => [ "res", "flags" ],
660 emit => '. shr%M %SB1, %S0',
664 modified_flags => $status_flags
668 irn_flags => [ "rematerializable" ],
669 state => "exc_pinned",
670 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
671 ins => [ "base", "index", "mem", "count" ],
672 emit => '. shr%M %SB3, %AM',
676 modified_flags => $status_flags
680 irn_flags => [ "rematerializable" ],
681 reg_req => { in => [ "gp", "gp", "ecx" ],
682 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
683 ins => [ "val_high", "val_low", "count" ],
684 outs => [ "res", "flags" ],
685 emit => ". shrd%M %SB2, %S1, %D0",
689 modified_flags => $status_flags
693 irn_flags => [ "rematerializable" ],
694 reg_req => { in => [ "gp", "ecx" ],
695 out => [ "in_r1 !in_r2", "flags" ] },
696 ins => [ "val", "count" ],
697 outs => [ "res", "flags" ],
698 emit => '. sar%M %SB1, %S0',
702 modified_flags => $status_flags
706 irn_flags => [ "rematerializable" ],
707 state => "exc_pinned",
708 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
709 ins => [ "base", "index", "mem", "count" ],
710 emit => '. sar%M %SB3, %AM',
714 modified_flags => $status_flags
718 irn_flags => [ "rematerializable" ],
719 reg_req => { in => [ "gp", "ecx" ],
720 out => [ "in_r1 !in_r2", "flags" ] },
721 ins => [ "val", "count" ],
722 outs => [ "res", "flags" ],
723 emit => '. ror%M %SB1, %S0',
727 modified_flags => $status_flags
731 irn_flags => [ "rematerializable" ],
732 state => "exc_pinned",
733 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
734 ins => [ "base", "index", "mem", "count" ],
735 emit => '. ror%M %SB3, %AM',
739 modified_flags => $status_flags
743 irn_flags => [ "rematerializable" ],
744 reg_req => { in => [ "gp", "ecx" ],
745 out => [ "in_r1 !in_r2", "flags" ] },
746 ins => [ "val", "count" ],
747 outs => [ "res", "flags" ],
748 emit => '. rol%M %SB1, %S0',
752 modified_flags => $status_flags
756 irn_flags => [ "rematerializable" ],
757 state => "exc_pinned",
758 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
759 ins => [ "base", "index", "mem", "count" ],
760 emit => '. rol%M %SB3, %AM',
764 modified_flags => $status_flags
768 irn_flags => [ "rematerializable" ],
769 reg_req => { in => [ "gp" ],
770 out => [ "in_r1", "flags" ] },
771 emit => '. neg%M %S0',
773 outs => [ "res", "flags" ],
777 modified_flags => $status_flags
781 irn_flags => [ "rematerializable" ],
782 state => "exc_pinned",
783 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
784 ins => [ "base", "index", "mem" ],
785 emit => '. neg%M %AM',
789 modified_flags => $status_flags
793 irn_flags => [ "rematerializable" ],
794 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
795 outs => [ "low_res", "high_res" ],
798 modified_flags => $status_flags
803 irn_flags => [ "rematerializable" ],
804 reg_req => { in => [ "gp" ],
805 out => [ "in_r1", "flags" ] },
807 outs => [ "res", "flags" ],
808 emit => '. inc%M %S0',
812 modified_flags => $status_flags_wo_cf
816 irn_flags => [ "rematerializable" ],
817 state => "exc_pinned",
818 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
819 ins => [ "base", "index", "mem" ],
820 emit => '. inc%M %AM',
824 modified_flags => $status_flags_wo_cf
828 irn_flags => [ "rematerializable" ],
829 reg_req => { in => [ "gp" ],
830 out => [ "in_r1", "flags" ] },
832 outs => [ "res", "flags" ],
833 emit => '. dec%M %S0',
837 modified_flags => $status_flags_wo_cf
841 irn_flags => [ "rematerializable" ],
842 state => "exc_pinned",
843 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
844 ins => [ "base", "index", "mem" ],
845 emit => '. dec%M %AM',
849 modified_flags => $status_flags_wo_cf
853 irn_flags => [ "rematerializable" ],
854 reg_req => { in => [ "gp" ],
855 out => [ "in_r1" ] },
858 emit => '. not%M %S0',
866 irn_flags => [ "rematerializable" ],
867 state => "exc_pinned",
868 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
869 ins => [ "base", "index", "mem" ],
870 emit => '. not%M %AM',
878 reg_req => { in => [ "flags" ], out => [ "flags" ] },
883 modified_flags => $status_flags
887 reg_req => { out => [ "flags" ] },
892 modified_flags => $status_flags
896 irn_flags => [ "rematerializable" ],
897 state => "exc_pinned",
898 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
899 out => [ "flags", "none", "none" ] },
900 ins => [ "base", "index", "mem", "left", "right" ],
901 outs => [ "eflags", "unused", "M" ],
902 am => "source,binary",
903 emit => '. cmp%M %binop',
904 attr => "bool ins_permuted",
905 init_attr => "attr->data.ins_permuted = ins_permuted;",
909 modified_flags => $status_flags
913 irn_flags => [ "rematerializable" ],
914 state => "exc_pinned",
915 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
916 out => [ "flags", "none", "none" ] },
917 ins => [ "base", "index", "mem", "left", "right" ],
918 outs => [ "eflags", "unused", "M" ],
919 am => "source,binary",
920 emit => '. cmpb %binop',
921 attr => "bool ins_permuted",
922 init_attr => "attr->data.ins_permuted = ins_permuted;",
926 modified_flags => $status_flags
930 irn_flags => [ "rematerializable" ],
931 state => "exc_pinned",
932 reg_req => { in => [ "eax ebx ecx edx" ],
933 out => [ "in_r1", "flags" ] },
934 emit => '. xorb %SH0, %SB0',
936 outs => [ "res", "flags" ],
940 modified_flags => $status_flags,
944 irn_flags => [ "rematerializable" ],
945 state => "exc_pinned",
946 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
947 out => [ "flags", "none", "none" ] },
948 ins => [ "base", "index", "mem", "left", "right" ],
949 outs => [ "eflags", "unused", "M" ],
950 am => "source,binary",
951 emit => '. test%M %binop',
952 attr => "bool ins_permuted",
953 init_attr => "attr->data.ins_permuted = ins_permuted;",
957 modified_flags => $status_flags
961 irn_flags => [ "rematerializable" ],
962 state => "exc_pinned",
963 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
964 out => [ "flags", "none", "none" ] },
965 ins => [ "base", "index", "mem", "left", "right" ],
966 outs => [ "eflags", "unused", "M" ],
967 am => "source,binary",
968 emit => '. testb %binop',
969 attr => "bool ins_permuted",
970 init_attr => "attr->data.ins_permuted = ins_permuted;",
974 modified_flags => $status_flags
978 #irn_flags => [ "rematerializable" ],
979 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
982 attr_type => "ia32_condcode_attr_t",
983 attr => "ia32_condition_code_t condition_code",
984 # The way we handle Setcc with float nodes (potentially) destroys the flags
985 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
986 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
987 . "\tif (condition_code & ia32_cc_additional_float_cases) {\n"
988 . "\t\tarch_add_irn_flags(res, arch_irn_flags_modify_flags);\n"
989 . "\t\t/* attr->latency = 3; */\n"
997 #irn_flags => [ "rematerializable" ],
998 state => "exc_pinned",
999 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1000 ins => [ "base", "index", "mem","eflags" ],
1001 attr_type => "ia32_condcode_attr_t",
1002 attr => "ia32_condition_code_t condition_code",
1003 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1004 emit => '. set%CMP3 %AM',
1011 #irn_flags => [ "rematerializable" ],
1012 state => "exc_pinned",
1013 # (note: leave the false,true order intact to make it compatible with other
1015 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1016 out => [ "in_r4 in_r5", "flags", "none" ] },
1017 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1018 outs => [ "res", "flags", "M" ],
1019 am => "source,binary",
1020 attr_type => "ia32_condcode_attr_t",
1021 attr => "ia32_condition_code_t condition_code",
1029 op_flags => [ "labeled", "cfopcode", "forking" ],
1030 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1031 ins => [ "eflags" ],
1032 outs => [ "false", "true" ],
1033 attr_type => "ia32_condcode_attr_t",
1034 attr => "ia32_condition_code_t condition_code",
1036 units => [ "BRANCH" ],
1041 op_flags => [ "labeled", "cfopcode", "forking" ],
1042 reg_req => { in => [ "gp", "gp" ] },
1043 ins => [ "base", "index" ],
1045 attr_type => "ia32_switch_attr_t",
1046 attr => "long default_pn",
1048 units => [ "BRANCH" ],
1049 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 => [ "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 .= "attr->latency = ".$node->{latency} . ";";
2741 $node->{op_attr_init} = $op_attr_init;