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
986 #irn_flags => [ "rematerializable" ],
987 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
990 attr_type => "ia32_condcode_attr_t",
991 attr => "ia32_condition_code_t condition_code",
992 # The way we handle Setcc with float nodes (potentially) destroys the flags
993 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
994 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
995 . "\tif (condition_code & ia32_cc_additional_float_cases) {\n"
996 . "\t\tarch_add_irn_flags(res, arch_irn_flags_modify_flags);\n"
997 . "\t\t/* attr->latency = 3; */\n"
1005 #irn_flags => [ "rematerializable" ],
1006 state => "exc_pinned",
1007 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1008 ins => [ "base", "index", "mem","eflags" ],
1009 attr_type => "ia32_condcode_attr_t",
1010 attr => "ia32_condition_code_t condition_code",
1011 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1012 emit => '. set%CMP3 %AM',
1019 #irn_flags => [ "rematerializable" ],
1020 state => "exc_pinned",
1021 # (note: leave the false,true order intact to make it compatible with other
1023 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1024 out => [ "in_r4 in_r5", "flags", "none" ] },
1025 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1026 outs => [ "res", "flags", "M" ],
1027 am => "source,binary",
1028 attr_type => "ia32_condcode_attr_t",
1029 attr => "ia32_condition_code_t condition_code",
1037 op_flags => [ "labeled", "cfopcode", "forking" ],
1038 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1039 ins => [ "eflags" ],
1040 outs => [ "false", "true" ],
1041 attr_type => "ia32_condcode_attr_t",
1042 attr => "ia32_condition_code_t condition_code",
1044 units => [ "BRANCH" ],
1049 op_flags => [ "labeled", "cfopcode", "forking" ],
1050 reg_req => { in => [ "gp", "gp" ] },
1051 ins => [ "base", "index" ],
1053 attr_type => "ia32_switch_attr_t",
1054 attr => "long default_pn",
1056 units => [ "BRANCH" ],
1057 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1062 irn_flags => [ "simple_jump" ],
1063 op_flags => [ "cfopcode" ],
1064 reg_req => { out => [ "none" ] },
1066 units => [ "BRANCH" ],
1072 op_flags => [ "cfopcode", "unknown_jump" ],
1073 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1074 ins => [ "base", "index", "mem", "target" ],
1075 am => "source,unary",
1076 emit => '. jmp *%unop3',
1078 units => [ "BRANCH" ],
1080 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1084 op_flags => [ "constlike" ],
1085 irn_flags => [ "rematerializable" ],
1086 reg_req => { out => [ "gp" ] },
1088 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1089 attr_type => "ia32_immediate_attr_t",
1095 op_flags => [ "constlike" ],
1096 irn_flags => [ "rematerializable" ],
1097 reg_req => { out => [ "gp" ] },
1104 op_flags => [ "constlike" ],
1105 reg_req => { out => [ "gp" ] },
1109 modified_flags => $status_flags,
1114 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1115 irn_flags => [ "not_scheduled" ],
1116 reg_req => { out => [ "gp_NOREG:I" ] },
1125 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1126 irn_flags => [ "not_scheduled" ],
1127 reg_req => { out => [ "vfp_NOREG:I" ] },
1132 attr_type => "ia32_x87_attr_t",
1137 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1138 irn_flags => [ "not_scheduled" ],
1139 reg_req => { out => [ "xmm_NOREG:I" ] },
1148 op_flags => [ "constlike" ],
1149 irn_flags => [ "not_scheduled" ],
1150 reg_req => { out => [ "fpcw:I" ] },
1154 modified_flags => $fpcw_flags
1158 op_flags => [ "labeled" ],
1160 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1161 ins => [ "base", "index", "mem" ],
1163 emit => ". fldcw %AM",
1166 modified_flags => $fpcw_flags
1170 op_flags => [ "labeled" ],
1172 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1173 ins => [ "base", "index", "mem", "fpcw" ],
1175 emit => ". fnstcw %AM",
1181 op_flags => [ "labeled" ],
1183 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1191 # we should not rematrialize this node. It has very strict constraints.
1192 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1193 ins => [ "val", "clobbered" ],
1202 # Note that we add additional latency values depending on address mode, so a
1203 # lateny of 0 for load is correct
1206 op_flags => [ "fragile", "labeled" ],
1207 state => "exc_pinned",
1208 reg_req => { in => [ "gp", "gp", "none" ],
1209 out => [ "gp", "none", "none", "none", "none" ] },
1210 ins => [ "base", "index", "mem" ],
1211 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
1213 emit => ". mov%EX%.l %AM, %D0",
1218 op_flags => [ "fragile", "labeled" ],
1219 state => "exc_pinned",
1220 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1221 out => [ "none", "none", "none" ] },
1222 ins => [ "base", "index", "mem", "val" ],
1223 outs => [ "M", "X_regular", "X_except" ],
1224 emit => '. mov%M %SI3, %AM',
1230 op_flags => [ "fragile", "labeled" ],
1231 state => "exc_pinned",
1232 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
1233 out => ["none", "none", "none" ] },
1234 ins => [ "base", "index", "mem", "val" ],
1235 outs => [ "M", "X_regular", "X_except" ],
1236 emit => '. mov%M %SB3, %AM',
1242 irn_flags => [ "rematerializable" ],
1243 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1244 ins => [ "base", "index" ],
1245 emit => '. leal %AM, %D0',
1249 # lea doesn't modify the flags, but setting this seems advantageous since it
1250 # increases chances that the Lea is transformed back to an Add
1251 modified_flags => 1,
1255 state => "exc_pinned",
1256 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1257 ins => [ "base", "index", "mem", "val", "stack" ],
1258 emit => '. push%M %unop3',
1259 outs => [ "stack", "M" ],
1260 am => "source,unary",
1266 state => "exc_pinned",
1267 reg_req => { in => [ "esp" ], out => [ "esp:I|S" ] },
1269 outs => [ "stack" ],
1270 emit => '. pushl %%eax',
1277 state => "exc_pinned",
1278 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1279 ins => [ "mem", "stack" ],
1280 outs => [ "res", "M", "unused", "stack" ],
1281 emit => '. pop%M %D0',
1282 latency => 3, # Pop is more expensive than Push on Athlon
1287 state => "exc_pinned",
1288 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1289 ins => [ "mem", "stack" ],
1290 outs => [ "res", "M", "unused", "stack" ],
1291 emit => '. pop%M %D0',
1292 latency => 3, # Pop is more expensive than Push on Athlon
1297 state => "exc_pinned",
1298 reg_req => { in => [ "ebp" ], out => [ "esp:I|S" ] },
1301 emit => '. movl %S0, %D0',
1308 state => "exc_pinned",
1309 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1310 ins => [ "base", "index", "mem", "stack" ],
1311 outs => [ "unused0", "M", "unused1", "stack" ],
1312 emit => '. pop%M %AM',
1313 latency => 3, # Pop is more expensive than Push on Athlon
1318 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1320 outs => [ "frame", "stack", "M" ],
1326 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1328 outs => [ "frame", "stack" ],
1331 state => "exc_pinned",
1336 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1337 ins => [ "base", "index", "mem", "stack", "size" ],
1338 am => "source,binary",
1339 emit => '. addl %binop',
1341 outs => [ "stack", "M" ],
1343 modified_flags => $status_flags
1348 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1349 ins => [ "base", "index", "mem", "stack", "size" ],
1350 am => "source,binary",
1351 emit => ". subl %binop\n".
1352 ". movl %%esp, %D1",
1354 outs => [ "stack", "addr", "M" ],
1356 modified_flags => $status_flags
1360 op_flags => [ "keep" ],
1368 irn_flags => [ "rematerializable" ],
1369 reg_req => { out => [ "gp" ] },
1371 emit => ". movl %%gs:0, %D0",
1377 # BT supports source address mode, but this is unused yet
1380 irn_flags => [ "rematerializable" ],
1381 state => "exc_pinned",
1382 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1383 ins => [ "left", "right" ],
1384 emit => '. bt%M %S1, %S0',
1387 mode => $mode_flags,
1388 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1392 irn_flags => [ "rematerializable" ],
1393 state => "exc_pinned",
1394 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1395 out => [ "gp", "flags", "none" ] },
1396 ins => [ "base", "index", "mem", "operand" ],
1397 outs => [ "res", "flags", "M" ],
1398 am => "source,binary",
1399 emit => '. bsf%M %unop3, %D0',
1403 modified_flags => $status_flags
1407 irn_flags => [ "rematerializable" ],
1408 state => "exc_pinned",
1409 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1410 out => [ "gp", "flags", "none" ] },
1411 ins => [ "base", "index", "mem", "operand" ],
1412 outs => [ "res", "flags", "M" ],
1413 am => "source,binary",
1414 emit => '. bsr%M %unop3, %D0',
1418 modified_flags => $status_flags
1422 # SSE4.2 or SSE4a popcnt instruction
1425 irn_flags => [ "rematerializable" ],
1426 state => "exc_pinned",
1427 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1428 out => [ "gp", "flags", "none" ] },
1429 ins => [ "base", "index", "mem", "operand" ],
1430 outs => [ "res", "flags", "M" ],
1431 am => "source,binary",
1432 emit => '. popcnt%M %unop3, %D0',
1436 modified_flags => $status_flags
1440 op_flags => [ "fragile" ],
1441 state => "exc_pinned",
1443 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1444 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" ]
1446 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1447 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" ],
1448 attr_type => "ia32_call_attr_t",
1449 attr => "unsigned pop, ir_type *call_tp",
1450 am => "source,unary",
1451 units => [ "BRANCH" ],
1452 latency => 4, # random number
1453 modified_flags => $status_flags
1457 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1459 # PS: try gcc __builtin_frame_address(100000) :-)
1462 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1463 ins => [ "frame", "cnt", "tmp" ],
1465 latency => 4, # random number
1466 attr_type => "ia32_climbframe_attr_t",
1467 attr => "unsigned count",
1476 irn_flags => [ "rematerializable" ],
1477 reg_req => { in => [ "gp" ],
1478 out => [ "in_r1" ] },
1479 emit => '. bswap%M %S0',
1487 # bswap16, use xchg here
1490 irn_flags => [ "rematerializable" ],
1491 reg_req => { in => [ "eax ebx ecx edx" ],
1492 out => [ "in_r1" ] },
1493 emit => '. xchg %SB0, %SH0',
1505 reg_req => { in => [ "none" ], out => [ "none" ] },
1514 # Undefined Instruction on ALL x86 CPU's
1518 reg_req => { in => [ "none" ], out => [ "none" ] },
1521 emit => ". .value 0x0b0f",
1530 irn_flags => [ "rematerializable" ],
1532 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1533 ins => [ "port", "value", "mem" ],
1534 emit => '. out%M %SS0, %SI1',
1538 modified_flags => $status_flags
1545 irn_flags => [ "rematerializable" ],
1547 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1548 ins => [ "port", "mem" ],
1549 outs => [ "res", "M" ],
1550 emit => '. in%M %DS0, %SS0',
1554 modified_flags => $status_flags
1558 # Intel style prefetching
1561 op_flags => [ "labeled" ],
1562 state => "exc_pinned",
1563 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1564 ins => [ "base", "index", "mem" ],
1567 emit => ". prefetcht0 %AM",
1572 op_flags => [ "labeled" ],
1573 state => "exc_pinned",
1574 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1575 ins => [ "base", "index", "mem" ],
1578 emit => ". prefetcht1 %AM",
1583 op_flags => [ "labeled" ],
1584 state => "exc_pinned",
1585 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1586 ins => [ "base", "index", "mem" ],
1589 emit => ". prefetcht2 %AM",
1594 op_flags => [ "labeled" ],
1595 state => "exc_pinned",
1596 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1597 ins => [ "base", "index", "mem" ],
1600 emit => ". prefetchnta %AM",
1605 # 3DNow! prefetch instructions
1608 op_flags => [ "labeled" ],
1609 state => "exc_pinned",
1610 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1611 ins => [ "base", "index", "mem" ],
1614 emit => ". prefetch %AM",
1619 op_flags => [ "labeled" ],
1620 state => "exc_pinned",
1621 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1622 ins => [ "base", "index", "mem" ],
1625 emit => ". prefetchw %AM",
1631 irn_flags => [ "rematerializable" ],
1632 reg_req => { out => [ "xmm" ] },
1633 emit => '. xorp%XSD %D0, %D0',
1640 op_flags => [ "constlike" ],
1641 irn_flags => [ "rematerializable" ],
1642 reg_req => { out => [ "xmm" ] },
1649 irn_flags => [ "rematerializable" ],
1650 reg_req => { out => [ "xmm" ] },
1651 emit => '. pxor %D0, %D0',
1657 # produces all 1 bits
1659 irn_flags => [ "rematerializable" ],
1660 reg_req => { out => [ "xmm" ] },
1661 emit => '. pcmpeqb %D0, %D0',
1667 # integer shift left, dword
1669 irn_flags => [ "rematerializable" ],
1670 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1671 emit => '. pslld %SI1, %D0',
1677 # integer shift left, qword
1679 irn_flags => [ "rematerializable" ],
1680 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1681 emit => '. psllq %SI1, %D0',
1687 # integer shift right, dword
1689 irn_flags => [ "rematerializable" ],
1690 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1691 emit => '. psrld %SI1, %D0',
1697 # mov from integer to SSE register
1699 irn_flags => [ "rematerializable" ],
1700 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1701 emit => '. movd %S0, %D0',
1708 irn_flags => [ "rematerializable" ],
1709 state => "exc_pinned",
1710 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1711 out => [ "in_r4 in_r5", "flags", "none" ] },
1712 ins => [ "base", "index", "mem", "left", "right" ],
1713 outs => [ "res", "flags", "M" ],
1714 am => "source,binary",
1715 emit => '. add%XXM %binop',
1722 irn_flags => [ "rematerializable" ],
1723 state => "exc_pinned",
1724 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1725 out => [ "in_r4 in_r5", "flags", "none" ] },
1726 ins => [ "base", "index", "mem", "left", "right" ],
1727 outs => [ "res", "flags", "M" ],
1728 am => "source,binary",
1729 emit => '. mul%XXM %binop',
1736 irn_flags => [ "rematerializable" ],
1737 state => "exc_pinned",
1738 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1739 out => [ "in_r4 in_r5", "flags", "none" ] },
1740 ins => [ "base", "index", "mem", "left", "right" ],
1741 outs => [ "res", "flags", "M" ],
1742 am => "source,binary",
1743 emit => '. max%XXM %binop',
1750 irn_flags => [ "rematerializable" ],
1751 state => "exc_pinned",
1752 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1753 out => [ "in_r4 in_r5", "flags", "none" ] },
1754 ins => [ "base", "index", "mem", "left", "right" ],
1755 outs => [ "res", "flags", "M" ],
1756 am => "source,binary",
1757 emit => '. min%XXM %binop',
1764 irn_flags => [ "rematerializable" ],
1765 state => "exc_pinned",
1766 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1767 out => [ "in_r4 in_r5", "flags", "none" ] },
1768 ins => [ "base", "index", "mem", "left", "right" ],
1769 outs => [ "res", "flags", "M" ],
1770 am => "source,binary",
1771 emit => '. andp%XSD %binop',
1778 irn_flags => [ "rematerializable" ],
1779 state => "exc_pinned",
1780 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1781 out => [ "in_r4 in_r5", "flags", "none" ] },
1782 ins => [ "base", "index", "mem", "left", "right" ],
1783 outs => [ "res", "flags", "M" ],
1784 am => "source,binary",
1785 emit => '. orp%XSD %binop',
1792 irn_flags => [ "rematerializable" ],
1793 state => "exc_pinned",
1794 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1795 out => [ "in_r4 in_r5", "flags", "none" ] },
1796 ins => [ "base", "index", "mem", "left", "right" ],
1797 outs => [ "res", "flags", "M" ],
1798 am => "source,binary",
1799 emit => '. xorp%XSD %binop',
1806 irn_flags => [ "rematerializable" ],
1807 state => "exc_pinned",
1808 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1809 out => [ "in_r4 !in_r5", "flags", "none" ] },
1810 ins => [ "base", "index", "mem", "left", "right" ],
1811 outs => [ "res", "flags", "M" ],
1812 am => "source,binary",
1813 emit => '. andnp%XSD %binop',
1820 irn_flags => [ "rematerializable" ],
1821 state => "exc_pinned",
1822 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1823 out => [ "in_r4", "flags", "none" ] },
1824 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1825 outs => [ "res", "flags", "M" ],
1826 am => "source,binary",
1827 emit => '. sub%XXM %binop',
1834 irn_flags => [ "rematerializable" ],
1835 state => "exc_pinned",
1836 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1837 out => [ "in_r4 !in_r5", "flags", "none" ] },
1838 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1839 outs => [ "res", "flags", "M" ],
1840 am => "source,binary",
1841 emit => '. div%XXM %binop',
1847 irn_flags => [ "rematerializable" ],
1848 state => "exc_pinned",
1849 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1850 out => [ "eflags" ] },
1851 ins => [ "base", "index", "mem", "left", "right" ],
1852 outs => [ "flags" ],
1853 am => "source,binary",
1854 attr => "bool ins_permuted",
1855 init_attr => "attr->data.ins_permuted = ins_permuted;",
1856 emit => ' .ucomi%XXM %binop',
1859 mode => $mode_flags,
1860 modified_flags => 1,
1864 op_flags => [ "fragile", "labeled" ],
1865 state => "exc_pinned",
1866 reg_req => { in => [ "gp", "gp", "none" ],
1867 out => [ "xmm", "none", "none", "none", "none" ] },
1868 ins => [ "base", "index", "mem" ],
1869 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
1870 emit => '. mov%XXM %AM, %D0',
1871 attr => "ir_mode *load_mode",
1872 init_attr => "attr->ls_mode = load_mode;",
1878 op_flags => [ "fragile", "labeled" ],
1879 state => "exc_pinned",
1880 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
1881 out => [ "none", "none", "none" ] },
1882 ins => [ "base", "index", "mem", "val" ],
1883 outs => [ "M", "X_regular", "X_except" ],
1884 emit => '. mov%XXM %S3, %AM',
1890 op_flags => [ "fragile", "labeled" ],
1891 state => "exc_pinned",
1892 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
1893 out => [ "none", "none", "none" ] },
1894 ins => [ "base", "index", "mem", "val" ],
1895 outs => [ "M", "X_regular", "X_except" ],
1896 emit => '. mov%XXM %S3, %AM',
1902 op_flags => [ "labeled" ],
1903 state => "exc_pinned",
1904 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1905 ins => [ "base", "index", "mem", "val" ],
1906 am => "source,unary",
1907 emit => '. cvtsi2ss %unop3, %D0',
1914 op_flags => [ "labeled" ],
1915 state => "exc_pinned",
1916 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1917 ins => [ "base", "index", "mem", "val" ],
1918 am => "source,unary",
1919 emit => '. cvtsi2sd %unop3, %D0',
1927 ins => [ "val_high", "val_low" ],
1929 dump_func => "NULL",
1934 outs => [ "res_high", "res_low" ],
1936 dump_func => "NULL",
1940 op_flags => [ "fragile" ],
1942 reg_req => { in => [ "edi", "esi", "ecx", "none" ],
1943 out => [ "edi", "esi", "ecx", "none", "none", "none" ] },
1944 ins => [ "dest", "source", "count", "mem" ],
1945 outs => [ "dest", "source", "count", "M", "X_regular", "X_except" ],
1946 attr_type => "ia32_copyb_attr_t",
1947 attr => "unsigned size",
1950 # we don't care about this flag, so no need to mark this node
1951 # modified_flags => [ "DF" ]
1955 op_flags => [ "fragile" ],
1957 reg_req => { in => [ "edi", "esi", "none" ],
1958 out => [ "edi", "esi", "none", "none", "none" ] },
1959 ins => [ "dest", "source", "mem" ],
1960 outs => [ "dest", "source", "M", "X_regular", "X_except" ],
1961 attr_type => "ia32_copyb_attr_t",
1962 attr => "unsigned size",
1965 # we don't care about this flag, so no need to mark this node
1966 # modified_flags => [ "DF" ]
1970 state => "exc_pinned",
1971 reg_req => { in => [ "eax" ], out => [ "eax" ] },
1981 op_flags => [ "fragile" ],
1982 state => "exc_pinned",
1983 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1984 out => [ "gp", "none", "none", "none", "none" ] },
1985 ins => [ "base", "index", "mem", "val" ],
1986 outs => [ "res", "flags", "M", "X_regular", "X_except" ],
1987 am => "source,unary",
1990 attr => "ir_mode *smaller_mode",
1991 init_attr => "attr->ls_mode = smaller_mode;",
1996 op_flags => [ "fragile" ],
1997 state => "exc_pinned",
1998 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
1999 out => [ "gp", "none", "none", "none", "none" ] },
2000 ins => [ "base", "index", "mem", "val" ],
2001 outs => [ "res", "flags", "M", "X_regular", "X_except" ],
2002 am => "source,unary",
2005 attr => "ir_mode *smaller_mode",
2006 init_attr => "attr->ls_mode = smaller_mode;",
2011 state => "exc_pinned",
2012 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2013 ins => [ "base", "index", "mem", "val" ],
2014 am => "source,unary",
2021 state => "exc_pinned",
2022 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2023 ins => [ "base", "index", "mem", "val" ],
2024 am => "source,unary",
2031 state => "exc_pinned",
2032 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2033 ins => [ "base", "index", "mem", "val" ],
2034 am => "source,unary",
2040 # rematerialisation disabled for all float nodes for now, because the fpcw
2041 # handler runs before spilling and we might end up with wrong fpcw then
2044 # irn_flags => [ "rematerializable" ],
2045 state => "exc_pinned",
2046 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2047 out => [ "vfp", "none", "none" ] },
2048 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2049 outs => [ "res", "dummy", "M" ],
2050 am => "source,binary",
2054 attr_type => "ia32_x87_attr_t",
2058 # irn_flags => [ "rematerializable" ],
2059 state => "exc_pinned",
2060 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2061 out => [ "vfp", "none", "none" ] },
2062 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2063 outs => [ "res", "dummy", "M" ],
2064 am => "source,binary",
2068 attr_type => "ia32_x87_attr_t",
2072 # irn_flags => [ "rematerializable" ],
2073 state => "exc_pinned",
2074 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2075 out => [ "vfp", "none", "none" ] },
2076 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2077 outs => [ "res", "dummy", "M" ],
2078 am => "source,binary",
2082 attr_type => "ia32_x87_attr_t",
2086 state => "exc_pinned",
2087 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2088 out => [ "vfp", "none", "none" ] },
2089 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2090 outs => [ "res", "dummy", "M" ],
2091 am => "source,binary",
2094 attr_type => "ia32_x87_attr_t",
2098 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2099 ins => [ "left", "right", "fpcw" ],
2103 attr_type => "ia32_x87_attr_t",
2107 irn_flags => [ "rematerializable" ],
2108 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2113 attr_type => "ia32_x87_attr_t",
2117 irn_flags => [ "rematerializable" ],
2118 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2123 attr_type => "ia32_x87_attr_t",
2127 irn_flags => [ "rematerializable" ],
2128 op_flags => [ "fragile", "labeled" ],
2129 state => "exc_pinned",
2130 reg_req => { in => [ "gp", "gp", "none" ],
2131 out => [ "vfp", "none", "none", "none", "none" ] },
2132 ins => [ "base", "index", "mem" ],
2133 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
2134 attr => "ir_mode *load_mode",
2135 init_attr => "attr->attr.ls_mode = load_mode;",
2138 attr_type => "ia32_x87_attr_t",
2142 irn_flags => [ "rematerializable" ],
2143 op_flags => [ "fragile", "labeled" ],
2144 state => "exc_pinned",
2145 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2146 out => [ "none", "none", "none" ] },
2147 ins => [ "base", "index", "mem", "val" ],
2148 outs => [ "M", "X_regular", "X_except" ],
2149 attr => "ir_mode *store_mode",
2150 init_attr => "attr->attr.ls_mode = store_mode;",
2153 attr_type => "ia32_x87_attr_t",
2157 state => "exc_pinned",
2158 reg_req => { in => [ "gp", "gp", "none" ],
2159 out => [ "vfp", "none", "none" ] },
2160 outs => [ "res", "unused", "M" ],
2161 ins => [ "base", "index", "mem" ],
2164 attr_type => "ia32_x87_attr_t",
2168 op_flags => [ "fragile" ],
2169 state => "exc_pinned",
2170 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ],
2171 out => [ "none", "none", "none", "none" ] },
2172 ins => [ "base", "index", "mem", "val", "fpcw" ],
2173 outs => [ "dummy", "M", "X_regular", "X_except" ],
2176 attr_type => "ia32_x87_attr_t",
2179 # SSE3 fisttp instruction
2181 op_flags => [ "fragile" ],
2182 state => "exc_pinned",
2183 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2184 out => [ "in_r4", "none", "none", "none" ]},
2185 ins => [ "base", "index", "mem", "val" ],
2186 outs => [ "res", "M", "X_regular", "X_except" ],
2189 attr_type => "ia32_x87_attr_t",
2193 irn_flags => [ "rematerializable" ],
2194 reg_req => { out => [ "vfp" ] },
2199 attr_type => "ia32_x87_attr_t",
2203 irn_flags => [ "rematerializable" ],
2204 reg_req => { out => [ "vfp" ] },
2209 attr_type => "ia32_x87_attr_t",
2213 irn_flags => [ "rematerializable" ],
2214 reg_req => { out => [ "vfp" ] },
2219 attr_type => "ia32_x87_attr_t",
2223 irn_flags => [ "rematerializable" ],
2224 reg_req => { out => [ "vfp" ] },
2229 attr_type => "ia32_x87_attr_t",
2233 irn_flags => [ "rematerializable" ],
2234 reg_req => { out => [ "vfp" ] },
2239 attr_type => "ia32_x87_attr_t",
2243 irn_flags => [ "rematerializable" ],
2244 reg_req => { out => [ "vfp" ] },
2249 attr_type => "ia32_x87_attr_t",
2253 irn_flags => [ "rematerializable" ],
2254 reg_req => { out => [ "vfp" ] },
2259 attr_type => "ia32_x87_attr_t",
2263 # we can't allow to rematerialize this node so we don't
2264 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2265 # irn_flags => [ "rematerializable" ],
2266 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2267 ins => [ "left", "right" ],
2268 outs => [ "flags" ],
2269 attr => "bool ins_permuted",
2270 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2273 attr_type => "ia32_x87_attr_t",
2278 irn_flags => [ "rematerializable" ],
2279 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2280 ins => [ "left", "right" ],
2281 outs => [ "flags" ],
2282 attr => "bool ins_permuted",
2283 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2286 attr_type => "ia32_x87_attr_t",
2291 # irn_flags => [ "rematerializable" ],
2292 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2294 outs => [ "flags" ],
2295 attr => "bool ins_permuted",
2296 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2299 attr_type => "ia32_x87_attr_t",
2304 irn_flags => [ "rematerializable" ],
2305 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2307 outs => [ "flags" ],
2311 mode => $mode_flags,
2315 state => "exc_pinned",
2316 emit => '. fadd%XM %x87_binop',
2318 attr_type => "ia32_x87_attr_t",
2323 state => "exc_pinned",
2324 emit => '. faddp%XM %x87_binop',
2326 attr_type => "ia32_x87_attr_t",
2331 state => "exc_pinned",
2332 emit => '. fmul%XM %x87_binop',
2334 attr_type => "ia32_x87_attr_t",
2339 state => "exc_pinned",
2340 emit => '. fmulp%XM %x87_binop',,
2342 attr_type => "ia32_x87_attr_t",
2347 state => "exc_pinned",
2348 emit => '. fsub%XM %x87_binop',
2350 attr_type => "ia32_x87_attr_t",
2354 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2355 # are swapped, we work this around in the emitter...
2358 state => "exc_pinned",
2359 # see note about gas bugs
2360 emit => '. fsubrp%XM %x87_binop',
2362 attr_type => "ia32_x87_attr_t",
2367 state => "exc_pinned",
2368 irn_flags => [ "rematerializable" ],
2369 emit => '. fsubr%XM %x87_binop',
2371 attr_type => "ia32_x87_attr_t",
2376 state => "exc_pinned",
2377 irn_flags => [ "rematerializable" ],
2378 # see note about gas bugs before fsubp
2379 emit => '. fsubp%XM %x87_binop',
2381 attr_type => "ia32_x87_attr_t",
2388 attr_type => "ia32_x87_attr_t",
2392 # this node is just here, to keep the simulator running
2393 # we can omit this when a fprem simulation function exists
2395 emit => '. fprem1\n'.
2398 attr_type => "ia32_x87_attr_t",
2403 state => "exc_pinned",
2404 emit => '. fdiv%XM %x87_binop',
2406 attr_type => "ia32_x87_attr_t",
2411 state => "exc_pinned",
2412 # see note about gas bugs before fsubp
2413 emit => '. fdivrp%XM %x87_binop',
2415 attr_type => "ia32_x87_attr_t",
2420 state => "exc_pinned",
2421 emit => '. fdivr%XM %x87_binop',
2423 attr_type => "ia32_x87_attr_t",
2428 state => "exc_pinned",
2429 # see note about gas bugs before fsubp
2430 emit => '. fdivp%XM %x87_binop',
2432 attr_type => "ia32_x87_attr_t",
2439 attr_type => "ia32_x87_attr_t",
2444 op_flags => [ "keep" ],
2445 irn_flags => [ "rematerializable" ],
2448 attr_type => "ia32_x87_attr_t",
2453 irn_flags => [ "rematerializable" ],
2454 op_flags => [ "labeled" ],
2455 state => "exc_pinned",
2456 emit => '. fld%XM %AM',
2457 attr_type => "ia32_x87_attr_t",
2463 irn_flags => [ "rematerializable" ],
2464 op_flags => [ "labeled" ],
2465 state => "exc_pinned",
2466 emit => '. fst%XM %AM',
2468 attr_type => "ia32_x87_attr_t",
2474 irn_flags => [ "rematerializable" ],
2475 op_flags => [ "labeled" ],
2476 state => "exc_pinned",
2477 emit => '. fstp%XM %AM',
2479 attr_type => "ia32_x87_attr_t",
2485 state => "exc_pinned",
2486 emit => '. fild%XM %AM',
2487 attr_type => "ia32_x87_attr_t",
2493 state => "exc_pinned",
2494 emit => '. fist%XM %AM',
2496 attr_type => "ia32_x87_attr_t",
2502 state => "exc_pinned",
2503 emit => '. fistp%XM %AM',
2505 attr_type => "ia32_x87_attr_t",
2510 # SSE3 fisttp instruction
2512 state => "exc_pinned",
2513 emit => '. fisttp%XM %AM',
2515 attr_type => "ia32_x87_attr_t",
2521 op_flags => [ "constlike", "keep" ],
2522 irn_flags => [ "rematerializable" ],
2523 reg_req => { out => [ "vfp" ] },
2525 attr_type => "ia32_x87_attr_t",
2530 op_flags => [ "constlike", "keep" ],
2531 irn_flags => [ "rematerializable" ],
2532 reg_req => { out => [ "vfp" ] },
2534 attr_type => "ia32_x87_attr_t",
2539 op_flags => [ "constlike", "keep" ],
2540 irn_flags => [ "rematerializable" ],
2541 reg_req => { out => [ "vfp" ] },
2543 attr_type => "ia32_x87_attr_t",
2548 op_flags => [ "constlike", "keep" ],
2549 irn_flags => [ "rematerializable" ],
2550 reg_req => { out => [ "vfp" ] },
2552 attr_type => "ia32_x87_attr_t",
2557 op_flags => [ "constlike", "keep" ],
2558 irn_flags => [ "rematerializable" ],
2559 reg_req => { out => [ "vfp" ] },
2561 attr_type => "ia32_x87_attr_t",
2566 op_flags => [ "constlike", "keep" ],
2567 irn_flags => [ "rematerializable" ],
2568 reg_req => { out => [ "vfp" ] },
2569 emit => '. fldll2t',
2570 attr_type => "ia32_x87_attr_t",
2575 op_flags => [ "constlike", "keep" ],
2576 irn_flags => [ "rematerializable" ],
2577 reg_req => { out => [ "vfp" ] },
2579 attr_type => "ia32_x87_attr_t",
2584 # Note that it is NEVER allowed to do CSE on these nodes
2585 # Moreover, note the virtual register requierements!
2588 op_flags => [ "keep" ],
2589 reg_req => { out => [ "none" ] },
2590 cmp_attr => "return 1;",
2591 emit => '. fxch %X0',
2592 attr_type => "ia32_x87_attr_t",
2598 op_flags => [ "keep" ],
2599 reg_req => { out => [ "none" ] },
2600 cmp_attr => "return 1;",
2601 emit => '. fld %X0',
2602 attr_type => "ia32_x87_attr_t",
2608 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2609 cmp_attr => "return 1;",
2610 emit => '. fld %X0',
2611 attr_type => "ia32_x87_attr_t",
2616 op_flags => [ "keep" ],
2617 reg_req => { out => [ "none" ] },
2618 cmp_attr => "return 1;",
2619 emit => '. fstp %X0',
2620 attr_type => "ia32_x87_attr_t",
2626 op_flags => [ "keep" ],
2627 reg_req => { out => [ "none" ] },
2628 cmp_attr => "return 1;",
2629 emit => '. ffreep %X0',
2630 attr_type => "ia32_x87_attr_t",
2636 op_flags => [ "keep" ],
2637 reg_req => { out => [ "none" ] },
2638 cmp_attr => "return 1;",
2640 attr_type => "ia32_x87_attr_t",
2646 op_flags => [ "keep" ],
2647 reg_req => { out => [ "none" ] },
2648 cmp_attr => "return 1;",
2650 attr_type => "ia32_x87_attr_t",
2657 emit => ". fucom %X1\n".
2659 attr_type => "ia32_x87_attr_t",
2665 emit => ". fucomp %X1\n".
2667 attr_type => "ia32_x87_attr_t",
2673 emit => ". fucompp\n".
2675 attr_type => "ia32_x87_attr_t",
2681 emit => '. fucomi %X1',
2682 attr_type => "ia32_x87_attr_t",
2688 emit => '. fucompi %X1',
2689 attr_type => "ia32_x87_attr_t",
2697 attr_type => "ia32_x87_attr_t",
2701 # Spilling and reloading of SSE registers, hardcoded, not generated #
2704 op_flags => [ "fragile", "labeled" ],
2705 state => "exc_pinned",
2706 reg_req => { in => [ "gp", "gp", "none" ],
2707 out => [ "xmm", "none", "none", "none" ] },
2708 emit => '. movdqu %D0, %AM',
2709 ins => [ "base", "index", "mem" ],
2710 outs => [ "res", "M", "X_regular", "X_except" ],
2716 op_flags => [ "fragile", "labeled" ],
2717 state => "exc_pinned",
2718 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
2719 out => [ "none", "none", "none" ] },
2720 ins => [ "base", "index", "mem", "val" ],
2721 outs => [ "M", "X_regular", "X_except" ],
2722 emit => '. movdqu %binop',
2729 # Transform some attributes
2730 foreach my $op (keys(%nodes)) {
2731 my $node = $nodes{$op};
2732 my $op_attr_init = $node->{op_attr_init};
2734 if(defined($op_attr_init)) {
2735 $op_attr_init .= "\n\t";
2740 if(!defined($node->{latency})) {
2742 $node->{latency} = 0;
2744 die("Latency missing for op $op");
2747 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2749 $node->{op_attr_init} = $op_attr_init;