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_irn_add_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, 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, flags, in_reqs, exec_units, n_res);",
174 "\tinit_ia32_attributes(res, 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, 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, flags, in_reqs, exec_units, n_res);\n".
181 "\tinit_ia32_switch_attributes(res, default_pn);",
183 "\tinit_ia32_attributes(res, 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, 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, flags, in_reqs, exec_units, n_res);\n".
190 "\tinit_ia32_x87_attributes(res);",
191 ia32_climbframe_attr_t =>
192 "\tinit_ia32_attributes(res, 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 op_flags => [ "constlike" ],
313 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
314 ins => [ "left", "right" ],
318 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
319 ins => [ "left", "right", "eflags" ],
323 # we should not rematrialize this node. It produces 2 results and has
324 # very strict constraints
325 state => "exc_pinned",
326 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
327 out => [ "eax", "flags", "none", "edx" ] },
328 ins => [ "base", "index", "mem", "left", "right" ],
329 emit => '. mul%M %unop4',
330 outs => [ "res_low", "flags", "M", "res_high" ],
331 am => "source,binary",
334 modified_flags => $status_flags
338 # we should not rematrialize this node. It produces 2 results and has
339 # very strict constraints
340 op_flags => [ "constlike" ],
341 cmp_attr => "return 1;",
342 reg_req => { in => [ "none", "none" ],
343 out => [ "none", "none", "none", "none" ] },
344 ins => [ "left", "right" ],
345 outs => [ "res_low", "flags", "M", "res_high" ],
349 irn_flags => [ "rematerializable" ],
350 state => "exc_pinned",
351 # TODO: adjust out requirements for the 3 operand form
352 # (no need for should_be_same then)
353 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
354 out => [ "in_r4 in_r5", "flags", "none" ] },
355 ins => [ "base", "index", "mem", "left", "right" ],
356 outs => [ "res", "flags", "M" ],
357 am => "source,binary",
361 modified_flags => $status_flags
365 irn_flags => [ "rematerializable" ],
366 state => "exc_pinned",
367 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
368 out => [ "eax", "flags", "none", "edx" ] },
369 ins => [ "base", "index", "mem", "left", "right" ],
370 emit => '. imul%M %unop4',
371 outs => [ "res_low", "flags", "M", "res_high" ],
372 am => "source,binary",
375 modified_flags => $status_flags
379 op_flags => [ "constlike" ],
380 cmp_attr => "return 1;",
381 reg_req => { in => [ "none", "none" ],
382 out => [ "none", "none", "none", "none" ] },
383 ins => [ "left", "right" ],
384 outs => [ "res_low", "flags", "M", "res_high" ],
388 irn_flags => [ "rematerializable" ],
389 state => "exc_pinned",
390 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
391 out => [ "in_r4 in_r5", "flags", "none" ] },
392 ins => [ "base", "index", "mem", "left", "right" ],
393 outs => [ "res", "flags", "M" ],
394 am => "source,binary",
395 emit => '. and%M %binop',
399 modified_flags => $status_flags
403 irn_flags => [ "rematerializable" ],
404 state => "exc_pinned",
405 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
406 ins => [ "base", "index", "mem", "val" ],
407 emit => '. and%M %SI3, %AM',
411 modified_flags => $status_flags
415 irn_flags => [ "rematerializable" ],
416 state => "exc_pinned",
417 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
418 ins => [ "base", "index", "mem", "val" ],
419 emit => '. and%M %SB3, %AM',
423 modified_flags => $status_flags
427 irn_flags => [ "rematerializable" ],
428 state => "exc_pinned",
429 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
430 out => [ "in_r4 in_r5", "flags", "none" ] },
431 ins => [ "base", "index", "mem", "left", "right" ],
432 outs => [ "res", "flags", "M" ],
433 am => "source,binary",
434 emit => '. or%M %binop',
438 modified_flags => $status_flags
442 irn_flags => [ "rematerializable" ],
443 state => "exc_pinned",
444 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
445 ins => [ "base", "index", "mem", "val" ],
446 emit => '. or%M %SI3, %AM',
450 modified_flags => $status_flags
454 irn_flags => [ "rematerializable" ],
455 state => "exc_pinned",
456 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
457 ins => [ "base", "index", "mem", "val" ],
458 emit => '. or%M %SB3, %AM',
462 modified_flags => $status_flags
466 irn_flags => [ "rematerializable" ],
467 state => "exc_pinned",
468 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
469 out => [ "in_r4 in_r5", "flags", "none" ] },
470 ins => [ "base", "index", "mem", "left", "right" ],
471 outs => [ "res", "flags", "M" ],
472 am => "source,binary",
473 emit => '. xor%M %binop',
477 modified_flags => $status_flags
481 op_flags => [ "constlike" ],
482 irn_flags => [ "rematerializable" ],
483 reg_req => { out => [ "gp", "flags" ] },
484 outs => [ "res", "flags" ],
485 emit => ". xor%M %D0, %D0",
489 modified_flags => $status_flags
493 irn_flags => [ "rematerializable" ],
494 state => "exc_pinned",
495 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
496 ins => [ "base", "index", "mem", "val" ],
497 emit => '. xor%M %SI3, %AM',
501 modified_flags => $status_flags
505 irn_flags => [ "rematerializable" ],
506 state => "exc_pinned",
507 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
508 ins => [ "base", "index", "mem", "val" ],
509 emit => '. xor%M %SB3, %AM',
513 modified_flags => $status_flags
517 irn_flags => [ "rematerializable" ],
518 state => "exc_pinned",
519 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
520 out => [ "in_r4", "flags", "none" ] },
521 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
522 outs => [ "res", "flags", "M" ],
523 am => "source,binary",
524 emit => '. sub%M %binop',
528 modified_flags => $status_flags
532 irn_flags => [ "rematerializable" ],
533 state => "exc_pinned",
534 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
535 ins => [ "base", "index", "mem", "subtrahend" ],
536 emit => '. sub%M %SI3, %AM',
540 modified_flags => $status_flags
544 irn_flags => [ "rematerializable" ],
545 state => "exc_pinned",
546 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
547 ins => [ "base", "index", "mem", "subtrahend" ],
548 emit => '. sub%M %SB3, %AM',
552 modified_flags => $status_flags
556 state => "exc_pinned",
557 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
558 out => [ "in_r4", "flags", "none" ] },
559 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
560 outs => [ "res", "flags", "M" ],
561 am => "source,binary",
562 emit => '. sbb%M %binop',
566 modified_flags => $status_flags
570 # Spiller currently fails when rematerializing flag consumers
571 # irn_flags => [ "rematerializable" ],
572 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
573 outs => [ "res", "flags" ],
574 emit => ". sbb%M %D0, %D0",
578 modified_flags => $status_flags
582 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
583 ins => [ "minuend", "subtrahend" ],
587 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
588 ins => [ "minuend", "subtrahend", "eflags" ],
592 op_flags => [ "fragile", "labeled" ],
593 state => "exc_pinned",
594 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
595 out => [ "eax", "flags", "none", "edx", "none", "none" ] },
596 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
597 outs => [ "div_res", "flags", "M", "mod_res", "X_regular", "X_except" ],
598 am => "source,unary",
599 emit => ". idiv%M %unop3",
602 modified_flags => $status_flags
606 op_flags => [ "fragile", "labeled" ],
607 state => "exc_pinned",
608 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
609 out => [ "eax", "flags", "none", "edx", "none", "none" ] },
610 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
611 outs => [ "div_res", "flags", "M", "mod_res", "X_regular", "X_except" ],
612 am => "source,unary",
613 emit => ". div%M %unop3",
616 modified_flags => $status_flags
620 irn_flags => [ "rematerializable" ],
621 reg_req => { in => [ "gp", "ecx" ],
622 out => [ "in_r1 !in_r2", "flags" ] },
623 ins => [ "val", "count" ],
624 outs => [ "res", "flags" ],
625 emit => '. shl%M %SB1, %S0',
629 modified_flags => $status_flags
633 irn_flags => [ "rematerializable" ],
634 state => "exc_pinned",
635 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
636 ins => [ "base", "index", "mem", "count" ],
637 emit => '. shl%M %SB3, %AM',
641 modified_flags => $status_flags
645 irn_flags => [ "rematerializable" ],
646 reg_req => { in => [ "gp", "gp", "ecx" ],
647 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
648 ins => [ "val_high", "val_low", "count" ],
649 outs => [ "res", "flags" ],
650 emit => ". shld%M %SB2, %S1, %D0",
654 modified_flags => $status_flags
658 irn_flags => [ "rematerializable" ],
659 reg_req => { in => [ "gp", "ecx" ],
660 out => [ "in_r1 !in_r2", "flags" ] },
661 ins => [ "val", "count" ],
662 outs => [ "res", "flags" ],
663 emit => '. shr%M %SB1, %S0',
667 modified_flags => $status_flags
671 irn_flags => [ "rematerializable" ],
672 state => "exc_pinned",
673 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
674 ins => [ "base", "index", "mem", "count" ],
675 emit => '. shr%M %SB3, %AM',
679 modified_flags => $status_flags
683 irn_flags => [ "rematerializable" ],
684 reg_req => { in => [ "gp", "gp", "ecx" ],
685 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
686 ins => [ "val_high", "val_low", "count" ],
687 outs => [ "res", "flags" ],
688 emit => ". shrd%M %SB2, %S1, %D0",
692 modified_flags => $status_flags
696 irn_flags => [ "rematerializable" ],
697 reg_req => { in => [ "gp", "ecx" ],
698 out => [ "in_r1 !in_r2", "flags" ] },
699 ins => [ "val", "count" ],
700 outs => [ "res", "flags" ],
701 emit => '. sar%M %SB1, %S0',
705 modified_flags => $status_flags
709 irn_flags => [ "rematerializable" ],
710 state => "exc_pinned",
711 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
712 ins => [ "base", "index", "mem", "count" ],
713 emit => '. sar%M %SB3, %AM',
717 modified_flags => $status_flags
721 irn_flags => [ "rematerializable" ],
722 reg_req => { in => [ "gp", "ecx" ],
723 out => [ "in_r1 !in_r2", "flags" ] },
724 ins => [ "val", "count" ],
725 outs => [ "res", "flags" ],
726 emit => '. ror%M %SB1, %S0',
730 modified_flags => $status_flags
734 irn_flags => [ "rematerializable" ],
735 state => "exc_pinned",
736 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
737 ins => [ "base", "index", "mem", "count" ],
738 emit => '. ror%M %SB3, %AM',
742 modified_flags => $status_flags
746 irn_flags => [ "rematerializable" ],
747 reg_req => { in => [ "gp", "ecx" ],
748 out => [ "in_r1 !in_r2", "flags" ] },
749 ins => [ "val", "count" ],
750 outs => [ "res", "flags" ],
751 emit => '. rol%M %SB1, %S0',
755 modified_flags => $status_flags
759 irn_flags => [ "rematerializable" ],
760 state => "exc_pinned",
761 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
762 ins => [ "base", "index", "mem", "count" ],
763 emit => '. rol%M %SB3, %AM',
767 modified_flags => $status_flags
771 irn_flags => [ "rematerializable" ],
772 reg_req => { in => [ "gp" ],
773 out => [ "in_r1", "flags" ] },
774 emit => '. neg%M %S0',
776 outs => [ "res", "flags" ],
780 modified_flags => $status_flags
784 irn_flags => [ "rematerializable" ],
785 state => "exc_pinned",
786 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
787 ins => [ "base", "index", "mem" ],
788 emit => '. neg%M %AM',
792 modified_flags => $status_flags
796 irn_flags => [ "rematerializable" ],
797 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
798 outs => [ "low_res", "high_res" ],
801 modified_flags => $status_flags
806 irn_flags => [ "rematerializable" ],
807 reg_req => { in => [ "gp" ],
808 out => [ "in_r1", "flags" ] },
810 outs => [ "res", "flags" ],
811 emit => '. inc%M %S0',
815 modified_flags => $status_flags_wo_cf
819 irn_flags => [ "rematerializable" ],
820 state => "exc_pinned",
821 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
822 ins => [ "base", "index", "mem" ],
823 emit => '. inc%M %AM',
827 modified_flags => $status_flags_wo_cf
831 irn_flags => [ "rematerializable" ],
832 reg_req => { in => [ "gp" ],
833 out => [ "in_r1", "flags" ] },
835 outs => [ "res", "flags" ],
836 emit => '. dec%M %S0',
840 modified_flags => $status_flags_wo_cf
844 irn_flags => [ "rematerializable" ],
845 state => "exc_pinned",
846 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
847 ins => [ "base", "index", "mem" ],
848 emit => '. dec%M %AM',
852 modified_flags => $status_flags_wo_cf
856 irn_flags => [ "rematerializable" ],
857 reg_req => { in => [ "gp" ],
858 out => [ "in_r1" ] },
861 emit => '. not%M %S0',
869 irn_flags => [ "rematerializable" ],
870 state => "exc_pinned",
871 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
872 ins => [ "base", "index", "mem" ],
873 emit => '. not%M %AM',
881 reg_req => { in => [ "flags" ], out => [ "flags" ] },
886 modified_flags => $status_flags
890 reg_req => { out => [ "flags" ] },
895 modified_flags => $status_flags
899 irn_flags => [ "rematerializable" ],
900 state => "exc_pinned",
901 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
902 out => [ "flags", "none", "none" ] },
903 ins => [ "base", "index", "mem", "left", "right" ],
904 outs => [ "eflags", "unused", "M" ],
905 am => "source,binary",
906 emit => '. cmp%M %binop',
907 attr => "bool ins_permuted",
908 init_attr => "attr->data.ins_permuted = ins_permuted;",
912 modified_flags => $status_flags
916 irn_flags => [ "rematerializable" ],
917 state => "exc_pinned",
918 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
919 out => [ "flags", "none", "none" ] },
920 ins => [ "base", "index", "mem", "left", "right" ],
921 outs => [ "eflags", "unused", "M" ],
922 am => "source,binary",
923 emit => '. cmpb %binop',
924 attr => "bool ins_permuted",
925 init_attr => "attr->data.ins_permuted = ins_permuted;",
929 modified_flags => $status_flags
933 irn_flags => [ "rematerializable" ],
934 state => "exc_pinned",
935 reg_req => { in => [ "eax ebx ecx edx" ],
936 out => [ "in_r1", "flags" ] },
937 emit => '. xorb %SH0, %SB0',
939 outs => [ "res", "flags" ],
943 modified_flags => $status_flags,
947 irn_flags => [ "rematerializable" ],
948 state => "exc_pinned",
949 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
950 out => [ "flags", "none", "none" ] },
951 ins => [ "base", "index", "mem", "left", "right" ],
952 outs => [ "eflags", "unused", "M" ],
953 am => "source,binary",
954 emit => '. test%M %binop',
955 attr => "bool ins_permuted",
956 init_attr => "attr->data.ins_permuted = ins_permuted;",
960 modified_flags => $status_flags
964 irn_flags => [ "rematerializable" ],
965 state => "exc_pinned",
966 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
967 out => [ "flags", "none", "none" ] },
968 ins => [ "base", "index", "mem", "left", "right" ],
969 outs => [ "eflags", "unused", "M" ],
970 am => "source,binary",
971 emit => '. testb %binop',
972 attr => "bool ins_permuted",
973 init_attr => "attr->data.ins_permuted = ins_permuted;",
977 modified_flags => $status_flags
981 #irn_flags => [ "rematerializable" ],
982 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
985 attr_type => "ia32_condcode_attr_t",
986 attr => "ia32_condition_code_t condition_code",
987 # The way we handle Setcc with float nodes (potentially) destroys the flags
988 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
989 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
990 . "\tif (condition_code & ia32_cc_additional_float_cases) {\n"
991 . "\t\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n"
992 . "\t\t/* attr->latency = 3; */\n"
1000 #irn_flags => [ "rematerializable" ],
1001 state => "exc_pinned",
1002 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1003 ins => [ "base", "index", "mem","eflags" ],
1004 attr_type => "ia32_condcode_attr_t",
1005 attr => "ia32_condition_code_t condition_code",
1006 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1007 emit => '. set%CMP3 %AM',
1014 #irn_flags => [ "rematerializable" ],
1015 state => "exc_pinned",
1016 # (note: leave the false,true order intact to make it compatible with other
1018 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1019 out => [ "in_r4 in_r5", "flags", "none" ] },
1020 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1021 outs => [ "res", "flags", "M" ],
1022 am => "source,binary",
1023 attr_type => "ia32_condcode_attr_t",
1024 attr => "ia32_condition_code_t condition_code",
1032 op_flags => [ "labeled", "cfopcode", "forking" ],
1033 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1034 ins => [ "eflags" ],
1035 outs => [ "false", "true" ],
1036 attr_type => "ia32_condcode_attr_t",
1037 attr => "ia32_condition_code_t condition_code",
1039 units => [ "BRANCH" ],
1044 op_flags => [ "labeled", "cfopcode", "forking" ],
1045 reg_req => { in => [ "gp", "gp" ] },
1046 ins => [ "base", "index" ],
1048 attr_type => "ia32_switch_attr_t",
1049 attr => "long default_pn",
1051 units => [ "BRANCH" ],
1052 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1057 irn_flags => [ "simple_jump" ],
1058 op_flags => [ "cfopcode" ],
1059 reg_req => { out => [ "none" ] },
1061 units => [ "BRANCH" ],
1067 op_flags => [ "cfopcode", "unknown_jump" ],
1068 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1069 ins => [ "base", "index", "mem", "target" ],
1070 am => "source,unary",
1071 emit => '. jmp *%unop3',
1073 units => [ "BRANCH" ],
1075 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1079 op_flags => [ "constlike" ],
1080 irn_flags => [ "rematerializable" ],
1081 reg_req => { out => [ "gp" ] },
1083 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1084 attr_type => "ia32_immediate_attr_t",
1090 op_flags => [ "constlike" ],
1091 irn_flags => [ "rematerializable" ],
1092 reg_req => { out => [ "gp" ] },
1099 op_flags => [ "constlike" ],
1100 reg_req => { out => [ "gp" ] },
1104 modified_flags => $status_flags,
1109 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1110 irn_flags => [ "not_scheduled" ],
1111 reg_req => { out => [ "gp_NOREG:I" ] },
1120 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1121 irn_flags => [ "not_scheduled" ],
1122 reg_req => { out => [ "vfp_NOREG:I" ] },
1127 attr_type => "ia32_x87_attr_t",
1132 op_flags => [ "constlike", "dump_noblock", "dump_noinput" ],
1133 irn_flags => [ "not_scheduled" ],
1134 reg_req => { out => [ "xmm_NOREG:I" ] },
1143 op_flags => [ "constlike" ],
1144 irn_flags => [ "not_scheduled" ],
1145 reg_req => { out => [ "fpcw:I" ] },
1149 modified_flags => $fpcw_flags
1153 op_flags => [ "labeled" ],
1155 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1156 ins => [ "base", "index", "mem" ],
1158 emit => ". fldcw %AM",
1161 modified_flags => $fpcw_flags
1165 op_flags => [ "labeled" ],
1167 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1168 ins => [ "base", "index", "mem", "fpcw" ],
1170 emit => ". fnstcw %AM",
1176 op_flags => [ "labeled" ],
1178 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1186 # we should not rematrialize this node. It has very strict constraints.
1187 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1188 ins => [ "val", "clobbered" ],
1197 # Note that we add additional latency values depending on address mode, so a
1198 # lateny of 0 for load is correct
1201 op_flags => [ "fragile", "labeled" ],
1202 state => "exc_pinned",
1203 reg_req => { in => [ "gp", "gp", "none" ],
1204 out => [ "gp", "none", "none", "none", "none" ] },
1205 ins => [ "base", "index", "mem" ],
1206 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
1208 emit => ". mov%EX%.l %AM, %D0",
1213 op_flags => [ "fragile", "labeled" ],
1214 state => "exc_pinned",
1215 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1216 out => [ "none", "none", "none" ] },
1217 ins => [ "base", "index", "mem", "val" ],
1218 outs => [ "M", "X_regular", "X_except" ],
1219 emit => '. mov%M %SI3, %AM',
1225 op_flags => [ "fragile", "labeled" ],
1226 state => "exc_pinned",
1227 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
1228 out => ["none", "none", "none" ] },
1229 ins => [ "base", "index", "mem", "val" ],
1230 outs => [ "M", "X_regular", "X_except" ],
1231 emit => '. mov%M %SB3, %AM',
1237 irn_flags => [ "rematerializable" ],
1238 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1239 ins => [ "base", "index" ],
1240 emit => '. leal %AM, %D0',
1244 # lea doesn't modify the flags, but setting this seems advantageous since it
1245 # increases chances that the Lea is transformed back to an Add
1246 modified_flags => 1,
1250 state => "exc_pinned",
1251 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1252 ins => [ "base", "index", "mem", "val", "stack" ],
1253 emit => '. push%M %unop3',
1254 outs => [ "stack", "M" ],
1255 am => "source,unary",
1261 state => "exc_pinned",
1262 reg_req => { in => [ "esp" ], out => [ "esp:I|S" ] },
1264 outs => [ "stack" ],
1265 emit => '. pushl %%eax',
1272 state => "exc_pinned",
1273 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1274 ins => [ "mem", "stack" ],
1275 outs => [ "res", "M", "unused", "stack" ],
1276 emit => '. pop%M %D0',
1277 latency => 3, # Pop is more expensive than Push on Athlon
1282 state => "exc_pinned",
1283 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1284 ins => [ "mem", "stack" ],
1285 outs => [ "res", "M", "unused", "stack" ],
1286 emit => '. pop%M %D0',
1287 latency => 3, # Pop is more expensive than Push on Athlon
1292 state => "exc_pinned",
1293 reg_req => { in => [ "ebp" ], out => [ "esp:I|S" ] },
1296 emit => '. movl %S0, %D0',
1303 state => "exc_pinned",
1304 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1305 ins => [ "base", "index", "mem", "stack" ],
1306 outs => [ "unused0", "M", "unused1", "stack" ],
1307 emit => '. pop%M %AM',
1308 latency => 3, # Pop is more expensive than Push on Athlon
1313 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1315 outs => [ "frame", "stack", "M" ],
1321 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1323 outs => [ "frame", "stack" ],
1326 state => "exc_pinned",
1331 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1332 ins => [ "base", "index", "mem", "stack", "size" ],
1333 am => "source,binary",
1334 emit => '. addl %binop',
1336 outs => [ "stack", "M" ],
1338 modified_flags => $status_flags
1343 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1344 ins => [ "base", "index", "mem", "stack", "size" ],
1345 am => "source,binary",
1346 emit => ". subl %binop\n".
1347 ". movl %%esp, %D1",
1349 outs => [ "stack", "addr", "M" ],
1351 modified_flags => $status_flags
1355 op_flags => [ "keep" ],
1363 irn_flags => [ "rematerializable" ],
1364 reg_req => { out => [ "gp" ] },
1366 emit => ". movl %%gs:0, %D0",
1372 # BT supports source address mode, but this is unused yet
1375 irn_flags => [ "rematerializable" ],
1376 state => "exc_pinned",
1377 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1378 ins => [ "left", "right" ],
1379 emit => '. bt%M %S1, %S0',
1382 mode => $mode_flags,
1383 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1387 irn_flags => [ "rematerializable" ],
1388 state => "exc_pinned",
1389 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1390 out => [ "gp", "flags", "none" ] },
1391 ins => [ "base", "index", "mem", "operand" ],
1392 outs => [ "res", "flags", "M" ],
1393 am => "source,binary",
1394 emit => '. bsf%M %unop3, %D0',
1398 modified_flags => $status_flags
1402 irn_flags => [ "rematerializable" ],
1403 state => "exc_pinned",
1404 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1405 out => [ "gp", "flags", "none" ] },
1406 ins => [ "base", "index", "mem", "operand" ],
1407 outs => [ "res", "flags", "M" ],
1408 am => "source,binary",
1409 emit => '. bsr%M %unop3, %D0',
1413 modified_flags => $status_flags
1417 # SSE4.2 or SSE4a popcnt instruction
1420 irn_flags => [ "rematerializable" ],
1421 state => "exc_pinned",
1422 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1423 out => [ "gp", "flags", "none" ] },
1424 ins => [ "base", "index", "mem", "operand" ],
1425 outs => [ "res", "flags", "M" ],
1426 am => "source,binary",
1427 emit => '. popcnt%M %unop3, %D0',
1431 modified_flags => $status_flags
1435 op_flags => [ "fragile" ],
1436 state => "exc_pinned",
1438 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1439 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" ]
1441 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1442 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" ],
1443 attr_type => "ia32_call_attr_t",
1444 attr => "unsigned pop, ir_type *call_tp",
1445 am => "source,unary",
1446 units => [ "BRANCH" ],
1447 latency => 4, # random number
1448 modified_flags => $status_flags
1452 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1454 # PS: try gcc __builtin_frame_address(100000) :-)
1457 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1458 ins => [ "frame", "cnt", "tmp" ],
1460 latency => 4, # random number
1461 attr_type => "ia32_climbframe_attr_t",
1462 attr => "unsigned count",
1471 irn_flags => [ "rematerializable" ],
1472 reg_req => { in => [ "gp" ],
1473 out => [ "in_r1" ] },
1474 emit => '. bswap%M %S0',
1482 # bswap16, use xchg here
1485 irn_flags => [ "rematerializable" ],
1486 reg_req => { in => [ "eax ebx ecx edx" ],
1487 out => [ "in_r1" ] },
1488 emit => '. xchg %SB0, %SH0',
1500 reg_req => { in => [ "none" ], out => [ "none" ] },
1509 # Undefined Instruction on ALL x86 CPU's
1513 reg_req => { in => [ "none" ], out => [ "none" ] },
1516 emit => ". .value 0x0b0f",
1525 irn_flags => [ "rematerializable" ],
1527 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1528 ins => [ "port", "value", "mem" ],
1529 emit => '. out%M %SS0, %SI1',
1533 modified_flags => $status_flags
1540 irn_flags => [ "rematerializable" ],
1542 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1543 ins => [ "port", "mem" ],
1544 outs => [ "res", "M" ],
1545 emit => '. in%M %DS0, %SS0',
1549 modified_flags => $status_flags
1553 # Intel style prefetching
1556 op_flags => [ "labeled" ],
1557 state => "exc_pinned",
1558 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1559 ins => [ "base", "index", "mem" ],
1562 emit => ". prefetcht0 %AM",
1567 op_flags => [ "labeled" ],
1568 state => "exc_pinned",
1569 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1570 ins => [ "base", "index", "mem" ],
1573 emit => ". prefetcht1 %AM",
1578 op_flags => [ "labeled" ],
1579 state => "exc_pinned",
1580 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1581 ins => [ "base", "index", "mem" ],
1584 emit => ". prefetcht2 %AM",
1589 op_flags => [ "labeled" ],
1590 state => "exc_pinned",
1591 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1592 ins => [ "base", "index", "mem" ],
1595 emit => ". prefetchnta %AM",
1600 # 3DNow! prefetch instructions
1603 op_flags => [ "labeled" ],
1604 state => "exc_pinned",
1605 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1606 ins => [ "base", "index", "mem" ],
1609 emit => ". prefetch %AM",
1614 op_flags => [ "labeled" ],
1615 state => "exc_pinned",
1616 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1617 ins => [ "base", "index", "mem" ],
1620 emit => ". prefetchw %AM",
1626 irn_flags => [ "rematerializable" ],
1627 reg_req => { out => [ "xmm" ] },
1628 emit => '. xorp%XSD %D0, %D0',
1635 op_flags => [ "constlike" ],
1636 irn_flags => [ "rematerializable" ],
1637 reg_req => { out => [ "xmm" ] },
1644 irn_flags => [ "rematerializable" ],
1645 reg_req => { out => [ "xmm" ] },
1646 emit => '. pxor %D0, %D0',
1652 # produces all 1 bits
1654 irn_flags => [ "rematerializable" ],
1655 reg_req => { out => [ "xmm" ] },
1656 emit => '. pcmpeqb %D0, %D0',
1662 # integer shift left, dword
1664 irn_flags => [ "rematerializable" ],
1665 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1666 emit => '. pslld %SI1, %D0',
1672 # integer shift left, qword
1674 irn_flags => [ "rematerializable" ],
1675 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1676 emit => '. psllq %SI1, %D0',
1682 # integer shift right, dword
1684 irn_flags => [ "rematerializable" ],
1685 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1686 emit => '. psrld %SI1, %D0',
1692 # mov from integer to SSE register
1694 irn_flags => [ "rematerializable" ],
1695 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1696 emit => '. movd %S0, %D0',
1703 irn_flags => [ "rematerializable" ],
1704 state => "exc_pinned",
1705 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1706 out => [ "in_r4 in_r5", "flags", "none" ] },
1707 ins => [ "base", "index", "mem", "left", "right" ],
1708 outs => [ "res", "flags", "M" ],
1709 am => "source,binary",
1710 emit => '. add%XXM %binop',
1717 irn_flags => [ "rematerializable" ],
1718 state => "exc_pinned",
1719 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1720 out => [ "in_r4 in_r5", "flags", "none" ] },
1721 ins => [ "base", "index", "mem", "left", "right" ],
1722 outs => [ "res", "flags", "M" ],
1723 am => "source,binary",
1724 emit => '. mul%XXM %binop',
1731 irn_flags => [ "rematerializable" ],
1732 state => "exc_pinned",
1733 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1734 out => [ "in_r4 in_r5", "flags", "none" ] },
1735 ins => [ "base", "index", "mem", "left", "right" ],
1736 outs => [ "res", "flags", "M" ],
1737 am => "source,binary",
1738 emit => '. max%XXM %binop',
1745 irn_flags => [ "rematerializable" ],
1746 state => "exc_pinned",
1747 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1748 out => [ "in_r4 in_r5", "flags", "none" ] },
1749 ins => [ "base", "index", "mem", "left", "right" ],
1750 outs => [ "res", "flags", "M" ],
1751 am => "source,binary",
1752 emit => '. min%XXM %binop',
1759 irn_flags => [ "rematerializable" ],
1760 state => "exc_pinned",
1761 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1762 out => [ "in_r4 in_r5", "flags", "none" ] },
1763 ins => [ "base", "index", "mem", "left", "right" ],
1764 outs => [ "res", "flags", "M" ],
1765 am => "source,binary",
1766 emit => '. andp%XSD %binop',
1773 irn_flags => [ "rematerializable" ],
1774 state => "exc_pinned",
1775 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1776 out => [ "in_r4 in_r5", "flags", "none" ] },
1777 ins => [ "base", "index", "mem", "left", "right" ],
1778 outs => [ "res", "flags", "M" ],
1779 am => "source,binary",
1780 emit => '. orp%XSD %binop',
1787 irn_flags => [ "rematerializable" ],
1788 state => "exc_pinned",
1789 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1790 out => [ "in_r4 in_r5", "flags", "none" ] },
1791 ins => [ "base", "index", "mem", "left", "right" ],
1792 outs => [ "res", "flags", "M" ],
1793 am => "source,binary",
1794 emit => '. xorp%XSD %binop',
1801 irn_flags => [ "rematerializable" ],
1802 state => "exc_pinned",
1803 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1804 out => [ "in_r4 !in_r5", "flags", "none" ] },
1805 ins => [ "base", "index", "mem", "left", "right" ],
1806 outs => [ "res", "flags", "M" ],
1807 am => "source,binary",
1808 emit => '. andnp%XSD %binop',
1815 irn_flags => [ "rematerializable" ],
1816 state => "exc_pinned",
1817 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1818 out => [ "in_r4", "flags", "none" ] },
1819 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1820 outs => [ "res", "flags", "M" ],
1821 am => "source,binary",
1822 emit => '. sub%XXM %binop',
1829 irn_flags => [ "rematerializable" ],
1830 state => "exc_pinned",
1831 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1832 out => [ "in_r4 !in_r5", "flags", "none" ] },
1833 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1834 outs => [ "res", "flags", "M" ],
1835 am => "source,binary",
1836 emit => '. div%XXM %binop',
1842 irn_flags => [ "rematerializable" ],
1843 state => "exc_pinned",
1844 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1845 out => [ "eflags" ] },
1846 ins => [ "base", "index", "mem", "left", "right" ],
1847 outs => [ "flags" ],
1848 am => "source,binary",
1849 attr => "bool ins_permuted",
1850 init_attr => "attr->data.ins_permuted = ins_permuted;",
1851 emit => ' .ucomi%XXM %binop',
1854 mode => $mode_flags,
1855 modified_flags => 1,
1859 op_flags => [ "fragile", "labeled" ],
1860 state => "exc_pinned",
1861 reg_req => { in => [ "gp", "gp", "none" ],
1862 out => [ "xmm", "none", "none", "none", "none" ] },
1863 ins => [ "base", "index", "mem" ],
1864 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
1865 emit => '. mov%XXM %AM, %D0',
1866 attr => "ir_mode *load_mode",
1867 init_attr => "attr->ls_mode = load_mode;",
1873 op_flags => [ "fragile", "labeled" ],
1874 state => "exc_pinned",
1875 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
1876 out => [ "none", "none", "none" ] },
1877 ins => [ "base", "index", "mem", "val" ],
1878 outs => [ "M", "X_regular", "X_except" ],
1879 emit => '. mov%XXM %S3, %AM',
1885 op_flags => [ "fragile", "labeled" ],
1886 state => "exc_pinned",
1887 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
1888 out => [ "none", "none", "none" ] },
1889 ins => [ "base", "index", "mem", "val" ],
1890 outs => [ "M", "X_regular", "X_except" ],
1891 emit => '. mov%XXM %S3, %AM',
1897 op_flags => [ "labeled" ],
1898 state => "exc_pinned",
1899 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1900 ins => [ "base", "index", "mem", "val" ],
1901 am => "source,unary",
1902 emit => '. cvtsi2ss %unop3, %D0',
1909 op_flags => [ "labeled" ],
1910 state => "exc_pinned",
1911 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1912 ins => [ "base", "index", "mem", "val" ],
1913 am => "source,unary",
1914 emit => '. cvtsi2sd %unop3, %D0',
1922 op_flags => [ "labeled" ],
1923 cmp_attr => "return 1;",
1924 ins => [ "val_high", "val_low" ],
1925 reg_req => { in => [ "none", "none" ], out => [ "none" ] }
1929 op_flags => [ "labeled" ],
1930 cmp_attr => "return 1;",
1932 outs => [ "res_high", "res_low" ],
1933 reg_req => { in => [ "none" ], out => [ "none", "none" ] }
1937 op_flags => [ "fragile" ],
1939 reg_req => { in => [ "edi", "esi", "ecx", "none" ],
1940 out => [ "edi", "esi", "ecx", "none", "none", "none" ] },
1941 ins => [ "dest", "source", "count", "mem" ],
1942 outs => [ "dest", "source", "count", "M", "X_regular", "X_except" ],
1943 attr_type => "ia32_copyb_attr_t",
1944 attr => "unsigned size",
1947 # we don't care about this flag, so no need to mark this node
1948 # modified_flags => [ "DF" ]
1952 op_flags => [ "fragile" ],
1954 reg_req => { in => [ "edi", "esi", "none" ],
1955 out => [ "edi", "esi", "none", "none", "none" ] },
1956 ins => [ "dest", "source", "mem" ],
1957 outs => [ "dest", "source", "M", "X_regular", "X_except" ],
1958 attr_type => "ia32_copyb_attr_t",
1959 attr => "unsigned size",
1962 # we don't care about this flag, so no need to mark this node
1963 # modified_flags => [ "DF" ]
1967 state => "exc_pinned",
1968 reg_req => { in => [ "eax" ], out => [ "eax" ] },
1978 op_flags => [ "fragile" ],
1979 state => "exc_pinned",
1980 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1981 out => [ "gp", "none", "none", "none", "none" ] },
1982 ins => [ "base", "index", "mem", "val" ],
1983 outs => [ "res", "flags", "M", "X_regular", "X_except" ],
1984 am => "source,unary",
1987 attr => "ir_mode *smaller_mode",
1988 init_attr => "attr->ls_mode = smaller_mode;",
1993 op_flags => [ "fragile" ],
1994 state => "exc_pinned",
1995 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
1996 out => [ "gp", "none", "none", "none", "none" ] },
1997 ins => [ "base", "index", "mem", "val" ],
1998 outs => [ "res", "flags", "M", "X_regular", "X_except" ],
1999 am => "source,unary",
2002 attr => "ir_mode *smaller_mode",
2003 init_attr => "attr->ls_mode = smaller_mode;",
2008 state => "exc_pinned",
2009 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2010 ins => [ "base", "index", "mem", "val" ],
2011 am => "source,unary",
2018 state => "exc_pinned",
2019 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2020 ins => [ "base", "index", "mem", "val" ],
2021 am => "source,unary",
2028 state => "exc_pinned",
2029 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2030 ins => [ "base", "index", "mem", "val" ],
2031 am => "source,unary",
2037 # rematerialisation disabled for all float nodes for now, because the fpcw
2038 # handler runs before spilling and we might end up with wrong fpcw then
2041 # irn_flags => [ "rematerializable" ],
2042 state => "exc_pinned",
2043 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2044 out => [ "vfp", "none", "none" ] },
2045 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2046 outs => [ "res", "dummy", "M" ],
2047 am => "source,binary",
2051 attr_type => "ia32_x87_attr_t",
2055 # irn_flags => [ "rematerializable" ],
2056 state => "exc_pinned",
2057 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2058 out => [ "vfp", "none", "none" ] },
2059 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2060 outs => [ "res", "dummy", "M" ],
2061 am => "source,binary",
2065 attr_type => "ia32_x87_attr_t",
2069 # irn_flags => [ "rematerializable" ],
2070 state => "exc_pinned",
2071 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2072 out => [ "vfp", "none", "none" ] },
2073 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2074 outs => [ "res", "dummy", "M" ],
2075 am => "source,binary",
2079 attr_type => "ia32_x87_attr_t",
2083 state => "exc_pinned",
2084 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2085 out => [ "vfp", "none", "none" ] },
2086 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2087 outs => [ "res", "dummy", "M" ],
2088 am => "source,binary",
2091 attr_type => "ia32_x87_attr_t",
2095 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2096 ins => [ "left", "right", "fpcw" ],
2100 attr_type => "ia32_x87_attr_t",
2104 irn_flags => [ "rematerializable" ],
2105 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2110 attr_type => "ia32_x87_attr_t",
2114 irn_flags => [ "rematerializable" ],
2115 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2120 attr_type => "ia32_x87_attr_t",
2124 irn_flags => [ "rematerializable" ],
2125 op_flags => [ "fragile", "labeled" ],
2126 state => "exc_pinned",
2127 reg_req => { in => [ "gp", "gp", "none" ],
2128 out => [ "vfp", "none", "none", "none", "none" ] },
2129 ins => [ "base", "index", "mem" ],
2130 outs => [ "res", "unused", "M", "X_regular", "X_except" ],
2131 attr => "ir_mode *load_mode",
2132 init_attr => "attr->attr.ls_mode = load_mode;",
2135 attr_type => "ia32_x87_attr_t",
2139 irn_flags => [ "rematerializable" ],
2140 op_flags => [ "fragile", "labeled" ],
2141 state => "exc_pinned",
2142 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2143 out => [ "none", "none", "none" ] },
2144 ins => [ "base", "index", "mem", "val" ],
2145 outs => [ "M", "X_regular", "X_except" ],
2146 attr => "ir_mode *store_mode",
2147 init_attr => "attr->attr.ls_mode = store_mode;",
2150 attr_type => "ia32_x87_attr_t",
2154 state => "exc_pinned",
2155 reg_req => { in => [ "gp", "gp", "none" ],
2156 out => [ "vfp", "none", "none" ] },
2157 outs => [ "res", "unused", "M" ],
2158 ins => [ "base", "index", "mem" ],
2161 attr_type => "ia32_x87_attr_t",
2165 op_flags => [ "fragile" ],
2166 state => "exc_pinned",
2167 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ],
2168 out => [ "none", "none", "none", "none" ] },
2169 ins => [ "base", "index", "mem", "val", "fpcw" ],
2170 outs => [ "dummy", "M", "X_regular", "X_except" ],
2173 attr_type => "ia32_x87_attr_t",
2176 # SSE3 fisttp instruction
2178 op_flags => [ "fragile" ],
2179 state => "exc_pinned",
2180 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2181 out => [ "in_r4", "none", "none", "none" ]},
2182 ins => [ "base", "index", "mem", "val" ],
2183 outs => [ "res", "M", "X_regular", "X_except" ],
2186 attr_type => "ia32_x87_attr_t",
2190 irn_flags => [ "rematerializable" ],
2191 reg_req => { out => [ "vfp" ] },
2196 attr_type => "ia32_x87_attr_t",
2200 irn_flags => [ "rematerializable" ],
2201 reg_req => { out => [ "vfp" ] },
2206 attr_type => "ia32_x87_attr_t",
2210 irn_flags => [ "rematerializable" ],
2211 reg_req => { out => [ "vfp" ] },
2216 attr_type => "ia32_x87_attr_t",
2220 irn_flags => [ "rematerializable" ],
2221 reg_req => { out => [ "vfp" ] },
2226 attr_type => "ia32_x87_attr_t",
2230 irn_flags => [ "rematerializable" ],
2231 reg_req => { out => [ "vfp" ] },
2236 attr_type => "ia32_x87_attr_t",
2240 irn_flags => [ "rematerializable" ],
2241 reg_req => { out => [ "vfp" ] },
2246 attr_type => "ia32_x87_attr_t",
2250 irn_flags => [ "rematerializable" ],
2251 reg_req => { out => [ "vfp" ] },
2256 attr_type => "ia32_x87_attr_t",
2260 # we can't allow to rematerialize this node so we don't
2261 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2262 # irn_flags => [ "rematerializable" ],
2263 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2264 ins => [ "left", "right" ],
2265 outs => [ "flags" ],
2266 attr => "bool ins_permuted",
2267 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2270 attr_type => "ia32_x87_attr_t",
2275 irn_flags => [ "rematerializable" ],
2276 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2277 ins => [ "left", "right" ],
2278 outs => [ "flags" ],
2279 attr => "bool ins_permuted",
2280 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2283 attr_type => "ia32_x87_attr_t",
2288 # irn_flags => [ "rematerializable" ],
2289 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2291 outs => [ "flags" ],
2292 attr => "bool ins_permuted",
2293 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2296 attr_type => "ia32_x87_attr_t",
2301 irn_flags => [ "rematerializable" ],
2302 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2304 outs => [ "flags" ],
2308 mode => $mode_flags,
2312 state => "exc_pinned",
2313 emit => '. fadd%XM %x87_binop',
2315 attr_type => "ia32_x87_attr_t",
2320 state => "exc_pinned",
2321 emit => '. faddp%XM %x87_binop',
2323 attr_type => "ia32_x87_attr_t",
2328 state => "exc_pinned",
2329 emit => '. fmul%XM %x87_binop',
2331 attr_type => "ia32_x87_attr_t",
2336 state => "exc_pinned",
2337 emit => '. fmulp%XM %x87_binop',,
2339 attr_type => "ia32_x87_attr_t",
2344 state => "exc_pinned",
2345 emit => '. fsub%XM %x87_binop',
2347 attr_type => "ia32_x87_attr_t",
2351 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2352 # are swapped, we work this around in the emitter...
2355 state => "exc_pinned",
2356 # see note about gas bugs
2357 emit => '. fsubrp%XM %x87_binop',
2359 attr_type => "ia32_x87_attr_t",
2364 state => "exc_pinned",
2365 irn_flags => [ "rematerializable" ],
2366 emit => '. fsubr%XM %x87_binop',
2368 attr_type => "ia32_x87_attr_t",
2373 state => "exc_pinned",
2374 irn_flags => [ "rematerializable" ],
2375 # see note about gas bugs before fsubp
2376 emit => '. fsubp%XM %x87_binop',
2378 attr_type => "ia32_x87_attr_t",
2385 attr_type => "ia32_x87_attr_t",
2389 # this node is just here, to keep the simulator running
2390 # we can omit this when a fprem simulation function exists
2392 emit => '. fprem1\n'.
2395 attr_type => "ia32_x87_attr_t",
2400 state => "exc_pinned",
2401 emit => '. fdiv%XM %x87_binop',
2403 attr_type => "ia32_x87_attr_t",
2408 state => "exc_pinned",
2409 # see note about gas bugs before fsubp
2410 emit => '. fdivrp%XM %x87_binop',
2412 attr_type => "ia32_x87_attr_t",
2417 state => "exc_pinned",
2418 emit => '. fdivr%XM %x87_binop',
2420 attr_type => "ia32_x87_attr_t",
2425 state => "exc_pinned",
2426 # see note about gas bugs before fsubp
2427 emit => '. fdivp%XM %x87_binop',
2429 attr_type => "ia32_x87_attr_t",
2436 attr_type => "ia32_x87_attr_t",
2441 op_flags => [ "keep" ],
2442 irn_flags => [ "rematerializable" ],
2445 attr_type => "ia32_x87_attr_t",
2450 irn_flags => [ "rematerializable" ],
2451 op_flags => [ "labeled" ],
2452 state => "exc_pinned",
2453 emit => '. fld%XM %AM',
2454 attr_type => "ia32_x87_attr_t",
2460 irn_flags => [ "rematerializable" ],
2461 op_flags => [ "labeled" ],
2462 state => "exc_pinned",
2463 emit => '. fst%XM %AM',
2465 attr_type => "ia32_x87_attr_t",
2471 irn_flags => [ "rematerializable" ],
2472 op_flags => [ "labeled" ],
2473 state => "exc_pinned",
2474 emit => '. fstp%XM %AM',
2476 attr_type => "ia32_x87_attr_t",
2482 state => "exc_pinned",
2483 emit => '. fild%XM %AM',
2484 attr_type => "ia32_x87_attr_t",
2490 state => "exc_pinned",
2491 emit => '. fist%XM %AM',
2493 attr_type => "ia32_x87_attr_t",
2499 state => "exc_pinned",
2500 emit => '. fistp%XM %AM',
2502 attr_type => "ia32_x87_attr_t",
2507 # SSE3 fisttp instruction
2509 state => "exc_pinned",
2510 emit => '. fisttp%XM %AM',
2512 attr_type => "ia32_x87_attr_t",
2518 op_flags => [ "constlike", "keep" ],
2519 irn_flags => [ "rematerializable" ],
2520 reg_req => { out => [ "vfp" ] },
2522 attr_type => "ia32_x87_attr_t",
2527 op_flags => [ "constlike", "keep" ],
2528 irn_flags => [ "rematerializable" ],
2529 reg_req => { out => [ "vfp" ] },
2531 attr_type => "ia32_x87_attr_t",
2536 op_flags => [ "constlike", "keep" ],
2537 irn_flags => [ "rematerializable" ],
2538 reg_req => { out => [ "vfp" ] },
2540 attr_type => "ia32_x87_attr_t",
2545 op_flags => [ "constlike", "keep" ],
2546 irn_flags => [ "rematerializable" ],
2547 reg_req => { out => [ "vfp" ] },
2549 attr_type => "ia32_x87_attr_t",
2554 op_flags => [ "constlike", "keep" ],
2555 irn_flags => [ "rematerializable" ],
2556 reg_req => { out => [ "vfp" ] },
2558 attr_type => "ia32_x87_attr_t",
2563 op_flags => [ "constlike", "keep" ],
2564 irn_flags => [ "rematerializable" ],
2565 reg_req => { out => [ "vfp" ] },
2566 emit => '. fldll2t',
2567 attr_type => "ia32_x87_attr_t",
2572 op_flags => [ "constlike", "keep" ],
2573 irn_flags => [ "rematerializable" ],
2574 reg_req => { out => [ "vfp" ] },
2576 attr_type => "ia32_x87_attr_t",
2581 # Note that it is NEVER allowed to do CSE on these nodes
2582 # Moreover, note the virtual register requierements!
2585 op_flags => [ "keep" ],
2586 reg_req => { out => [ "none" ] },
2587 cmp_attr => "return 1;",
2588 emit => '. fxch %X0',
2589 attr_type => "ia32_x87_attr_t",
2595 op_flags => [ "keep" ],
2596 reg_req => { out => [ "none" ] },
2597 cmp_attr => "return 1;",
2598 emit => '. fld %X0',
2599 attr_type => "ia32_x87_attr_t",
2605 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2606 cmp_attr => "return 1;",
2607 emit => '. fld %X0',
2608 attr_type => "ia32_x87_attr_t",
2613 op_flags => [ "keep" ],
2614 reg_req => { out => [ "none" ] },
2615 cmp_attr => "return 1;",
2616 emit => '. fstp %X0',
2617 attr_type => "ia32_x87_attr_t",
2623 op_flags => [ "keep" ],
2624 reg_req => { out => [ "none" ] },
2625 cmp_attr => "return 1;",
2626 emit => '. ffreep %X0',
2627 attr_type => "ia32_x87_attr_t",
2633 op_flags => [ "keep" ],
2634 reg_req => { out => [ "none" ] },
2635 cmp_attr => "return 1;",
2637 attr_type => "ia32_x87_attr_t",
2643 op_flags => [ "keep" ],
2644 reg_req => { out => [ "none" ] },
2645 cmp_attr => "return 1;",
2647 attr_type => "ia32_x87_attr_t",
2654 emit => ". fucom %X1\n".
2656 attr_type => "ia32_x87_attr_t",
2662 emit => ". fucomp %X1\n".
2664 attr_type => "ia32_x87_attr_t",
2670 emit => ". fucompp\n".
2672 attr_type => "ia32_x87_attr_t",
2678 emit => '. fucomi %X1',
2679 attr_type => "ia32_x87_attr_t",
2685 emit => '. fucompi %X1',
2686 attr_type => "ia32_x87_attr_t",
2694 attr_type => "ia32_x87_attr_t",
2698 # Spilling and reloading of SSE registers, hardcoded, not generated #
2701 op_flags => [ "fragile", "labeled" ],
2702 state => "exc_pinned",
2703 reg_req => { in => [ "gp", "gp", "none" ],
2704 out => [ "xmm", "none", "none", "none" ] },
2705 emit => '. movdqu %D0, %AM',
2706 ins => [ "base", "index", "mem" ],
2707 outs => [ "res", "M", "X_regular", "X_except" ],
2713 op_flags => [ "fragile", "labeled" ],
2714 state => "exc_pinned",
2715 reg_req => { in => [ "gp", "gp", "none", "xmm" ],
2716 out => [ "none", "none", "none" ] },
2717 ins => [ "base", "index", "mem", "val" ],
2718 outs => [ "M", "X_regular", "X_except" ],
2719 emit => '. movdqu %binop',
2726 # Transform some attributes
2727 foreach my $op (keys(%nodes)) {
2728 my $node = $nodes{$op};
2729 my $op_attr_init = $node->{op_attr_init};
2731 if(defined($op_attr_init)) {
2732 $op_attr_init .= "\n\t";
2737 if(!defined($node->{latency})) {
2739 $node->{latency} = 0;
2741 die("Latency missing for op $op");
2744 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2746 $node->{op_attr_init} = $op_attr_init;