3 # This is the specification for the ia32 assembler Firm-operations
9 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
12 # The node description is done as a perl hash initializer with the
13 # following structure:
18 # op_flags => "N|L|C|X|I|F|Y|H|c|K|n",
20 # arity => "0|1|2|3 ... |variable|dynamic|any",
21 # state => "floats|pinned|mem_pinned|exc_pinned",
23 # { type => "type 1", name => "name 1" },
24 # { type => "type 2", name => "name 2" },
27 # comment => "any comment for constructor",
28 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
29 # cmp_attr => "c source code for comparing node attributes",
30 # outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts
31 # ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts
32 # mode => "mode_Iu" # optional, predefines the mode
33 # emit => "emit code with templates",
34 # attr => "additional attribute arguments for constructor",
35 # init_attr => "emit attribute initialization template",
36 # hash_func => "name of the hash function for this operation",
37 # latency => "latency of this operation (can be float)"
38 # attr_type => "name of the attribute struct",
39 # modified_flags => [ "CF", ... ] # optional, list of modified flags
42 # ... # (all nodes you need to describe)
44 # ); # close the %nodes initializer
46 # op_flags: flags for the operation, OPTIONAL (default is "N")
47 # the op_flags correspond to the firm irop_flags:
50 # C irop_flag_commutative
51 # X irop_flag_cfopcode
52 # I irop_flag_ip_cfopcode
55 # H irop_flag_highlevel
56 # c irop_flag_constlike
58 # NB irop_flag_dump_noblock
59 # NI irop_flag_dump_noinput
61 # irn_flags: special node flags, OPTIONAL (default is 0)
62 # following irn_flags are supported:
66 # state: state of the operation, OPTIONAL (default is "floats")
68 # arity: arity of the operation, MUST NOT BE OMITTED
70 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
71 # are always the first 3 arguments and are always autmatically
73 # If this key is missing the following arguments will be created:
74 # for i = 1 .. arity: ir_node *op_i
77 # outs: if a node defines more than one output, the names of the projections
78 # nodes having outs having automatically the mode mode_T
79 # example: [ "frame", "stack", "M" ]
81 # comment: OPTIONAL comment for the node constructor
83 # rd_constructor: for every operation there will be a
84 # new_rd_<arch>_<op-name> function with the arguments from above
85 # which creates the ir_node corresponding to the defined operation
86 # you can either put the complete source code of this function here
88 # This key is OPTIONAL. If omitted, the following constructor will
90 # if (!op_<arch>_<op-name>) assert(0);
94 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
101 # 0 - no special type
102 # 1 - caller save (register must be saved by the caller of a function)
103 # 2 - callee save (register must be saved by the called function)
104 # 4 - ignore (do not automatically assign this register)
105 # 8 - emitter can choose an arbitrary register of this class
106 # 16 - the register is a virtual one
107 # 32 - register represents a state
108 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
111 { name => "edx", type => 1 },
112 { name => "ecx", type => 1 },
113 { name => "eax", type => 1 },
114 { name => "ebx", type => 2 },
115 { name => "esi", type => 2 },
116 { name => "edi", type => 2 },
117 { name => "ebp", type => 2 },
118 { name => "esp", type => 4 },
119 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
120 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
121 { mode => "mode_Iu" }
124 { name => "mm0", type => 4 },
125 { name => "mm1", type => 4 },
126 { name => "mm2", type => 4 },
127 { name => "mm3", type => 4 },
128 { name => "mm4", type => 4 },
129 { name => "mm5", type => 4 },
130 { name => "mm6", type => 4 },
131 { name => "mm7", type => 4 },
132 { mode => "mode_E", flags => "manual_ra" }
135 { name => "xmm0", type => 1 },
136 { name => "xmm1", type => 1 },
137 { name => "xmm2", type => 1 },
138 { name => "xmm3", type => 1 },
139 { name => "xmm4", type => 1 },
140 { name => "xmm5", type => 1 },
141 { name => "xmm6", type => 1 },
142 { name => "xmm7", type => 1 },
143 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
144 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
148 { name => "vf0", type => 1 },
149 { name => "vf1", type => 1 },
150 { name => "vf2", type => 1 },
151 { name => "vf3", type => 1 },
152 { name => "vf4", type => 1 },
153 { name => "vf5", type => 1 },
154 { name => "vf6", type => 1 },
155 { name => "vf7", type => 1 },
156 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
157 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
161 { name => "st0", realname => "st", type => 4 },
162 { name => "st1", realname => "st(1)", type => 4 },
163 { name => "st2", realname => "st(2)", type => 4 },
164 { name => "st3", realname => "st(3)", type => 4 },
165 { name => "st4", realname => "st(4)", type => 4 },
166 { name => "st5", realname => "st(5)", type => 4 },
167 { name => "st6", realname => "st(6)", type => 4 },
168 { name => "st7", realname => "st(7)", type => 4 },
169 { mode => "mode_E", flags => "manual_ra" }
171 fp_cw => [ # the floating point control word
172 { name => "fpcw", type => 4|32 },
173 { mode => "mode_fpcw", flags => "manual_ra|state" }
176 { name => "eflags", type => 0 },
177 { mode => "mode_Iu", flags => "manual_ra" }
182 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
183 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
184 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
185 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
190 bundels_per_cycle => 1
194 S0 => "${arch}_emit_source_register(node, 0);",
195 S1 => "${arch}_emit_source_register(node, 1);",
196 S2 => "${arch}_emit_source_register(node, 2);",
197 S3 => "${arch}_emit_source_register(node, 3);",
198 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
199 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
200 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
201 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
202 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
203 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
204 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
205 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
206 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
207 D0 => "${arch}_emit_dest_register(node, 0);",
208 D1 => "${arch}_emit_dest_register(node, 1);",
209 DS0 => "${arch}_emit_dest_register_size(node, 0);",
210 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
211 X0 => "${arch}_emit_x87_register(node, 0);",
212 X1 => "${arch}_emit_x87_register(node, 1);",
213 EX => "${arch}_emit_extend_suffix(node);",
214 M => "${arch}_emit_mode_suffix(node);",
215 XM => "${arch}_emit_x87_mode_suffix(node);",
216 XXM => "${arch}_emit_xmm_mode_suffix(node);",
217 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
218 AM => "${arch}_emit_am(node);",
219 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
220 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
221 binop => "${arch}_emit_binop(node);",
222 x87_binop => "${arch}_emit_x87_binop(node);",
223 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
229 $default_op_attr_type = "ia32_op_attr_t";
230 $default_attr_type = "ia32_attr_t";
231 $default_copy_attr = "ia32_copy_attr";
233 sub ia32_custom_init_attr {
239 if(defined($node->{modified_flags})) {
240 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
242 if(defined($node->{am})) {
243 my $am = $node->{am};
244 if($am eq "source,unary") {
245 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
246 } elsif($am eq "source,binary") {
247 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
248 } elsif($am eq "none") {
251 die("Invalid address mode '$am' specified on op $name");
254 if($node->{state} ne "exc_pinned"
255 and $node->{state} ne "pinned") {
256 die("AM nodes must have pinned or AM pinned state ($name)");
262 $custom_init_attr_func = \&ia32_custom_init_attr;
266 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
267 "\tinit_ia32_x87_attributes(res);".
268 "\tinit_ia32_asm_attributes(res);",
270 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);",
272 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
273 "\tinit_ia32_call_attributes(res, pop, call_tp);",
274 ia32_condcode_attr_t =>
275 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
276 "\tinit_ia32_condcode_attributes(res, pnc);",
278 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
279 "\tinit_ia32_copyb_attributes(res, size);",
280 ia32_immediate_attr_t =>
281 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
282 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
284 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
285 "\tinit_ia32_x87_attributes(res);",
286 ia32_climbframe_attr_t =>
287 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
288 "\tinit_ia32_climbframe_attributes(res, count);",
292 ia32_asm_attr_t => "ia32_compare_asm_attr",
293 ia32_attr_t => "ia32_compare_nodes_attr",
294 ia32_call_attr_t => "ia32_compare_call_attr",
295 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
296 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
297 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
298 ia32_x87_attr_t => "ia32_compare_x87_attr",
299 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
305 $mode_xmm = "mode_E";
306 $mode_gp = "mode_Iu";
307 $mode_flags = "mode_Iu";
308 $mode_fpcw = "mode_fpcw";
309 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
310 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
311 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
312 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
319 reg_req => { out => [ "gp_NOREG:I" ] },
320 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
321 attr_type => "ia32_immediate_attr_t",
322 hash_func => "ia32_hash_Immediate",
330 out_arity => "variable",
331 attr_type => "ia32_asm_attr_t",
332 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
333 init_attr => "attr->asm_text = asm_text;\n".
334 "\tattr->register_map = register_map;\n",
336 modified_flags => $status_flags,
339 # "allocates" a free register
343 reg_req => { out => [ "gp" ] },
348 cmp_attr => "return 1;",
353 state => "exc_pinned",
354 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
355 out => [ "in_r4 in_r5", "flags", "none" ] },
356 ins => [ "base", "index", "mem", "left", "right" ],
357 outs => [ "res", "flags", "M" ],
358 emit => '. add%M %binop',
359 am => "source,binary",
363 modified_flags => $status_flags
368 state => "exc_pinned",
369 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
370 ins => [ "base", "index", "mem", "val" ],
371 emit => ". add%M %SI3, %AM",
375 modified_flags => $status_flags
380 state => "exc_pinned",
381 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
382 ins => [ "base", "index", "mem", "val" ],
383 emit => ". add%M %SB3, %AM",
387 modified_flags => $status_flags
391 state => "exc_pinned",
392 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
393 out => [ "in_r4 in_r5", "flags", "none" ] },
394 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
395 outs => [ "res", "flags", "M" ],
396 emit => '. adc%M %binop',
397 am => "source,binary",
401 modified_flags => $status_flags
406 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
407 ins => [ "left", "right" ],
411 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
412 ins => [ "left", "right", "eflags" ],
416 # we should not rematrialize this node. It produces 2 results and has
417 # very strict constraints
418 state => "exc_pinned",
419 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
420 out => [ "eax", "flags", "none", "edx" ] },
421 ins => [ "base", "index", "mem", "left", "right" ],
422 emit => '. mul%M %unop4',
423 outs => [ "res_low", "flags", "M", "res_high" ],
424 am => "source,binary",
427 modified_flags => $status_flags
431 # we should not rematrialize this node. It produces 2 results and has
432 # very strict constraints
434 cmp_attr => "return 1;",
435 reg_req => { in => [ "none", "none" ],
436 out => [ "none", "none", "none", "none" ] },
437 ins => [ "left", "right" ],
438 outs => [ "res_low", "flags", "M", "res_high" ],
443 state => "exc_pinned",
444 # TODO: adjust out requirements for the 3 operand form
445 # (no need for should_be_same then)
446 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
447 out => [ "in_r4 in_r5", "flags", "none" ] },
448 ins => [ "base", "index", "mem", "left", "right" ],
449 outs => [ "res", "flags", "M" ],
450 am => "source,binary",
454 modified_flags => $status_flags
459 state => "exc_pinned",
460 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
461 out => [ "eax", "flags", "none", "edx" ] },
462 ins => [ "base", "index", "mem", "left", "right" ],
463 emit => '. imul%M %unop4',
464 outs => [ "res_low", "flags", "M", "res_high" ],
465 am => "source,binary",
468 modified_flags => $status_flags
473 cmp_attr => "return 1;",
474 reg_req => { in => [ "none", "none" ],
475 out => [ "none", "none", "none", "none" ] },
476 ins => [ "left", "right" ],
477 outs => [ "res_low", "flags", "M", "res_high" ],
482 state => "exc_pinned",
483 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
484 out => [ "in_r4 in_r5", "flags", "none" ] },
485 ins => [ "base", "index", "mem", "left", "right" ],
486 outs => [ "res", "flags", "M" ],
487 am => "source,binary",
488 emit => '. and%M %binop',
492 modified_flags => $status_flags
497 state => "exc_pinned",
498 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
499 ins => [ "base", "index", "mem", "val" ],
500 emit => '. and%M %SI3, %AM',
504 modified_flags => $status_flags
509 state => "exc_pinned",
510 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
511 ins => [ "base", "index", "mem", "val" ],
512 emit => '. and%M %SB3, %AM',
516 modified_flags => $status_flags
521 state => "exc_pinned",
522 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
523 out => [ "in_r4 in_r5", "flags", "none" ] },
524 ins => [ "base", "index", "mem", "left", "right" ],
525 outs => [ "res", "flags", "M" ],
526 am => "source,binary",
527 emit => '. or%M %binop',
531 modified_flags => $status_flags
536 state => "exc_pinned",
537 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
538 ins => [ "base", "index", "mem", "val" ],
539 emit => '. or%M %SI3, %AM',
543 modified_flags => $status_flags
548 state => "exc_pinned",
549 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
550 ins => [ "base", "index", "mem", "val" ],
551 emit => '. or%M %SB3, %AM',
555 modified_flags => $status_flags
560 state => "exc_pinned",
561 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
562 out => [ "in_r4 in_r5", "flags", "none" ] },
563 ins => [ "base", "index", "mem", "left", "right" ],
564 outs => [ "res", "flags", "M" ],
565 am => "source,binary",
566 emit => '. xor%M %binop',
570 modified_flags => $status_flags
576 reg_req => { out => [ "gp", "flags" ] },
577 outs => [ "res", "flags" ],
578 emit => ". xor%M %D0, %D0",
582 modified_flags => $status_flags
587 state => "exc_pinned",
588 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
589 ins => [ "base", "index", "mem", "val" ],
590 emit => '. xor%M %SI3, %AM',
594 modified_flags => $status_flags
599 state => "exc_pinned",
600 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
601 ins => [ "base", "index", "mem", "val" ],
602 emit => '. xor%M %SB3, %AM',
606 modified_flags => $status_flags
611 state => "exc_pinned",
612 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
613 out => [ "in_r4", "flags", "none" ] },
614 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
615 outs => [ "res", "flags", "M" ],
616 am => "source,binary",
617 emit => '. sub%M %binop',
621 modified_flags => $status_flags
626 state => "exc_pinned",
627 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
628 ins => [ "base", "index", "mem", "subtrahend" ],
629 emit => '. sub%M %SI3, %AM',
633 modified_flags => $status_flags
638 state => "exc_pinned",
639 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
640 ins => [ "base", "index", "mem", "subtrahend" ],
641 emit => '. sub%M %SB3, %AM',
645 modified_flags => $status_flags
649 state => "exc_pinned",
650 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
651 out => [ "in_r4 !in_r5", "flags", "none" ] },
652 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
653 outs => [ "res", "flags", "M" ],
654 am => "source,binary",
655 emit => '. sbb%M %binop',
659 modified_flags => $status_flags
663 # Spiller currently fails when rematerializing flag consumers
665 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
666 outs => [ "res", "flags" ],
667 emit => ". sbb%M %D0, %D0",
671 modified_flags => $status_flags
675 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
676 ins => [ "minuend", "subtrahend" ],
680 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
681 ins => [ "minuend", "subtrahend", "eflags" ],
686 state => "exc_pinned",
687 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
688 out => [ "eax", "flags", "none", "edx", "none" ] },
689 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
690 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
691 am => "source,unary",
692 emit => ". idiv%M %unop3",
695 modified_flags => $status_flags
700 state => "exc_pinned",
701 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
702 out => [ "eax", "flags", "none", "edx", "none" ] },
703 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
704 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
705 am => "source,unary",
706 emit => ". div%M %unop3",
709 modified_flags => $status_flags
714 reg_req => { in => [ "gp", "ecx" ],
715 out => [ "in_r1 !in_r2", "flags" ] },
716 ins => [ "val", "count" ],
717 outs => [ "res", "flags" ],
718 emit => '. shl%M %SB1, %S0',
722 modified_flags => $status_flags
727 state => "exc_pinned",
728 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
729 ins => [ "base", "index", "mem", "count" ],
730 emit => '. shl%M %SB3, %AM',
734 modified_flags => $status_flags
738 cmp_attr => "return 1;",
739 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
740 ins => [ "val", "count", "dep" ],
745 reg_req => { in => [ "gp", "gp", "ecx" ],
746 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
747 ins => [ "val_high", "val_low", "count" ],
748 outs => [ "res", "flags" ],
749 emit => ". shld%M %SB2, %S1, %D0",
753 modified_flags => $status_flags
757 cmp_attr => "return 1;",
758 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
759 ins => [ "val_high", "val_low", "count" ],
764 reg_req => { in => [ "gp", "ecx" ],
765 out => [ "in_r1 !in_r2", "flags" ] },
766 ins => [ "val", "count" ],
767 outs => [ "res", "flags" ],
768 emit => '. shr%M %SB1, %S0',
772 modified_flags => $status_flags
777 state => "exc_pinned",
778 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
779 ins => [ "base", "index", "mem", "count" ],
780 emit => '. shr%M %SB3, %AM',
784 modified_flags => $status_flags
788 cmp_attr => "return 1;",
789 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
790 ins => [ "val", "count", "dep" ],
795 reg_req => { in => [ "gp", "gp", "ecx" ],
796 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
797 ins => [ "val_high", "val_low", "count" ],
798 outs => [ "res", "flags" ],
799 emit => ". shrd%M %SB2, %S1, %D0",
803 modified_flags => $status_flags
807 cmp_attr => "return 1;",
808 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
809 ins => [ "val_high", "val_low", "count" ],
814 reg_req => { in => [ "gp", "ecx" ],
815 out => [ "in_r1 !in_r2", "flags" ] },
816 ins => [ "val", "count" ],
817 outs => [ "res", "flags" ],
818 emit => '. sar%M %SB1, %S0',
822 modified_flags => $status_flags
827 state => "exc_pinned",
828 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
829 ins => [ "base", "index", "mem", "count" ],
830 emit => '. sar%M %SB3, %AM',
834 modified_flags => $status_flags
838 cmp_attr => "return 1;",
839 ins => [ "val", "count", "dep" ],
840 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
845 reg_req => { in => [ "gp", "ecx" ],
846 out => [ "in_r1 !in_r2", "flags" ] },
847 ins => [ "val", "count" ],
848 outs => [ "res", "flags" ],
849 emit => '. ror%M %SB1, %S0',
853 modified_flags => $status_flags
858 state => "exc_pinned",
859 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
860 ins => [ "base", "index", "mem", "count" ],
861 emit => '. ror%M %SB3, %AM',
865 modified_flags => $status_flags
870 reg_req => { in => [ "gp", "ecx" ],
871 out => [ "in_r1 !in_r2", "flags" ] },
872 ins => [ "val", "count" ],
873 outs => [ "res", "flags" ],
874 emit => '. rol%M %SB1, %S0',
878 modified_flags => $status_flags
883 state => "exc_pinned",
884 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
885 ins => [ "base", "index", "mem", "count" ],
886 emit => '. rol%M %SB3, %AM',
890 modified_flags => $status_flags
895 reg_req => { in => [ "gp" ],
896 out => [ "in_r1", "flags" ] },
897 emit => '. neg%M %S0',
899 outs => [ "res", "flags" ],
903 modified_flags => $status_flags
908 state => "exc_pinned",
909 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
910 ins => [ "base", "index", "mem" ],
911 emit => '. neg%M %AM',
915 modified_flags => $status_flags
920 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
921 outs => [ "low_res", "high_res" ],
924 modified_flags => $status_flags
930 reg_req => { in => [ "gp" ],
931 out => [ "in_r1", "flags" ] },
933 outs => [ "res", "flags" ],
934 emit => '. inc%M %S0',
938 modified_flags => $status_flags_wo_cf
943 state => "exc_pinned",
944 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
945 ins => [ "base", "index", "mem" ],
946 emit => '. inc%M %AM',
950 modified_flags => $status_flags_wo_cf
955 reg_req => { in => [ "gp" ],
956 out => [ "in_r1", "flags" ] },
958 outs => [ "res", "flags" ],
959 emit => '. dec%M %S0',
963 modified_flags => $status_flags_wo_cf
968 state => "exc_pinned",
969 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
970 ins => [ "base", "index", "mem" ],
971 emit => '. dec%M %AM',
975 modified_flags => $status_flags_wo_cf
980 reg_req => { in => [ "gp" ],
981 out => [ "in_r1", "flags" ] },
983 outs => [ "res", "flags" ],
984 emit => '. not%M %S0',
993 state => "exc_pinned",
994 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
995 ins => [ "base", "index", "mem" ],
996 emit => '. not%M %AM',
1004 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1008 mode => $mode_flags,
1009 modified_flags => $status_flags
1013 reg_req => { out => [ "flags" ] },
1017 mode => $mode_flags,
1018 modified_flags => $status_flags
1023 state => "exc_pinned",
1024 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1025 out => [ "flags", "none", "none" ] },
1026 ins => [ "base", "index", "mem", "left", "right" ],
1027 outs => [ "eflags", "unused", "M" ],
1028 am => "source,binary",
1029 emit => '. cmp%M %binop',
1030 attr => "int ins_permuted, int cmp_unsigned",
1031 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1032 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1035 mode => $mode_flags,
1036 modified_flags => $status_flags
1041 state => "exc_pinned",
1042 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1043 out => [ "flags", "none", "none" ] },
1044 ins => [ "base", "index", "mem", "left", "right" ],
1045 outs => [ "eflags", "unused", "M" ],
1046 am => "source,binary",
1047 emit => '. cmpb %binop',
1048 attr => "int ins_permuted, int cmp_unsigned",
1049 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1050 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1053 mode => $mode_flags,
1054 modified_flags => $status_flags
1059 state => "exc_pinned",
1060 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
1061 out => [ "flags", "none", "none" ] },
1062 ins => [ "base", "index", "mem", "left", "right" ],
1063 outs => [ "eflags", "unused", "M" ],
1064 am => "source,binary",
1065 emit => '. test%M %binop',
1066 attr => "int ins_permuted, int cmp_unsigned",
1067 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1068 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1071 mode => $mode_flags,
1072 modified_flags => $status_flags
1077 state => "exc_pinned",
1078 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1079 out => [ "flags", "none", "none" ] },
1080 ins => [ "base", "index", "mem", "left", "right" ],
1081 outs => [ "eflags", "unused", "M" ],
1082 am => "source,binary",
1083 emit => '. testb %binop',
1084 attr => "int ins_permuted, int cmp_unsigned",
1085 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1086 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1089 mode => $mode_flags,
1090 modified_flags => $status_flags
1095 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1096 ins => [ "eflags" ],
1098 attr_type => "ia32_condcode_attr_t",
1099 attr => "pn_Cmp pnc",
1100 # The way we handle Setcc with float nodes (potentially) destroys the flags
1101 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
1102 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
1103 . "\tif ((pnc & ia32_pn_Cmp_float) && ((pnc & 0xf) != pn_Cmp_Uo) && ((pnc & 0xf) != pn_Cmp_Leg)) {\n"
1104 . "\t\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n"
1105 . "\t\t/* attr->latency = 3; */\n"
1114 state => "exc_pinned",
1115 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1116 ins => [ "base", "index", "mem","eflags" ],
1117 attr_type => "ia32_condcode_attr_t",
1118 attr => "pn_Cmp pnc",
1119 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1120 emit => '. set%CMP3 %AM',
1128 state => "exc_pinned",
1129 # (note: leave the false,true order intact to make it compatible with other
1131 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1132 out => [ "in_r4 in_r5", "flags", "none" ] },
1133 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1134 outs => [ "res", "flags", "M" ],
1135 am => "source,binary",
1136 attr_type => "ia32_condcode_attr_t",
1137 attr => "pn_Cmp pnc",
1145 op_flags => "L|X|Y",
1146 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1147 ins => [ "eflags" ],
1148 outs => [ "false", "true" ],
1149 attr_type => "ia32_condcode_attr_t",
1150 attr => "pn_Cmp pnc",
1152 units => [ "BRANCH" ],
1157 op_flags => "L|X|Y",
1158 reg_req => { in => [ "gp" ] },
1160 attr_type => "ia32_condcode_attr_t",
1163 units => [ "BRANCH" ],
1164 modified_flags => $status_flags,
1165 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1172 reg_req => { out => [ "none" ] },
1174 units => [ "BRANCH" ],
1181 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1182 ins => [ "base", "index", "mem", "target" ],
1183 am => "source,unary",
1184 emit => '. jmp *%unop3',
1186 units => [ "BRANCH" ],
1188 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1194 reg_req => { out => [ "gp" ] },
1196 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1197 attr_type => "ia32_immediate_attr_t",
1204 reg_req => { out => [ "gp" ] },
1208 modified_flags => $status_flags,
1214 reg_req => { out => [ "gp_UKNWN:I" ] },
1224 reg_req => { out => [ "vfp_UKNWN:I" ] },
1229 attr_type => "ia32_x87_attr_t",
1235 reg_req => { out => [ "xmm_UKNWN:I" ] },
1244 op_flags => "c|NB|NI",
1245 reg_req => { out => [ "gp_NOREG:I" ] },
1254 op_flags => "c|NB|NI",
1255 reg_req => { out => [ "vfp_NOREG:I" ] },
1260 attr_type => "ia32_x87_attr_t",
1265 op_flags => "c|NB|NI",
1266 reg_req => { out => [ "xmm_NOREG:I" ] },
1276 reg_req => { out => [ "fpcw:I" ] },
1280 modified_flags => $fpcw_flags
1286 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1287 ins => [ "base", "index", "mem" ],
1289 emit => ". fldcw %AM",
1292 modified_flags => $fpcw_flags
1298 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1299 ins => [ "base", "index", "mem", "fpcw" ],
1301 emit => ". fnstcw %AM",
1309 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1317 # we should not rematrialize this node. It has very strict constraints.
1318 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1319 ins => [ "val", "clobbered" ],
1328 # Note that we add additional latency values depending on address mode, so a
1329 # lateny of 0 for load is correct
1333 state => "exc_pinned",
1334 reg_req => { in => [ "gp", "gp", "none" ],
1335 out => [ "gp", "none", "none", "none" ] },
1336 ins => [ "base", "index", "mem" ],
1337 outs => [ "res", "unused", "M", "X_exc" ],
1339 emit => ". mov%EX%.l %AM, %D0",
1345 state => "exc_pinned",
1346 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1347 ins => [ "base", "index", "mem", "val" ],
1348 outs => [ "M", "X_exc" ],
1349 emit => '. mov%M %SI3, %AM',
1357 state => "exc_pinned",
1358 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1359 ins => [ "base", "index", "mem", "val" ],
1360 outs => [ "M", "X_exc" ],
1361 emit => '. mov%M %SB3, %AM',
1369 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1370 ins => [ "base", "index" ],
1371 emit => '. leal %AM, %D0',
1375 # lea doesn't modify the flags, but setting this seems advantageous since it
1376 # increases chances that the Lea is transformed back to an Add
1377 modified_flags => 1,
1381 state => "exc_pinned",
1382 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1383 ins => [ "base", "index", "mem", "val", "stack" ],
1384 emit => '. push%M %unop3',
1385 outs => [ "stack", "M" ],
1386 am => "source,unary",
1392 state => "exc_pinned",
1393 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1394 ins => [ "mem", "stack" ],
1395 outs => [ "res", "M", "unused", "stack" ],
1396 emit => '. pop%M %D0',
1397 latency => 3, # Pop is more expensive than Push on Athlon
1402 state => "exc_pinned",
1403 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1404 ins => [ "mem", "stack" ],
1405 outs => [ "res", "M", "unused", "stack" ],
1406 emit => '. pop%M %D0',
1407 latency => 3, # Pop is more expensive than Push on Athlon
1412 state => "exc_pinned",
1413 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1414 ins => [ "base", "index", "mem", "stack" ],
1415 outs => [ "unused0", "M", "unused1", "stack" ],
1416 emit => '. pop%M %AM',
1417 latency => 3, # Pop is more expensive than Push on Athlon
1422 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1424 outs => [ "frame", "stack", "M" ],
1430 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1432 outs => [ "frame", "stack" ],
1439 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1440 ins => [ "base", "index", "mem", "stack", "size" ],
1441 am => "source,binary",
1442 emit => '. addl %binop',
1444 outs => [ "stack", "M" ],
1446 modified_flags => $status_flags
1451 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1452 ins => [ "base", "index", "mem", "stack", "size" ],
1453 am => "source,binary",
1454 emit => ". subl %binop\n".
1455 ". movl %%esp, %D1",
1457 outs => [ "stack", "addr", "M" ],
1459 modified_flags => $status_flags
1472 reg_req => { out => [ "gp" ] },
1478 # BT supports source address mode, but this is unused yet
1482 state => "exc_pinned",
1483 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1484 ins => [ "left", "right" ],
1485 emit => '. bt%M %S1, %S0',
1488 mode => $mode_flags,
1489 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1494 state => "exc_pinned",
1495 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1496 out => [ "gp", "flags", "none" ] },
1497 ins => [ "base", "index", "mem", "operand" ],
1498 outs => [ "res", "flags", "M" ],
1499 am => "source,binary",
1500 emit => '. bsf%M %unop3, %D0',
1504 modified_flags => $status_flags
1509 state => "exc_pinned",
1510 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1511 out => [ "gp", "flags", "none" ] },
1512 ins => [ "base", "index", "mem", "operand" ],
1513 outs => [ "res", "flags", "M" ],
1514 am => "source,binary",
1515 emit => '. bsr%M %unop3, %D0',
1519 modified_flags => $status_flags
1523 # SSE4.2 or SSE4a popcnt instruction
1527 state => "exc_pinned",
1528 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1529 out => [ "gp", "flags", "none" ] },
1530 ins => [ "base", "index", "mem", "operand" ],
1531 outs => [ "res", "flags", "M" ],
1532 am => "source,binary",
1533 emit => '. popcnt%M %unop3, %D0',
1537 modified_flags => $status_flags
1541 state => "exc_pinned",
1543 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1544 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" ]
1546 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1547 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1548 attr_type => "ia32_call_attr_t",
1549 attr => "unsigned pop, ir_type *call_tp",
1550 am => "source,unary",
1551 units => [ "BRANCH" ],
1552 latency => 4, # random number
1553 modified_flags => $status_flags
1557 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1559 # PS: try gcc __builtin_frame_address(100000) :-)
1562 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1563 ins => [ "frame", "cnt", "tmp" ],
1565 latency => 4, # random number
1566 attr_type => "ia32_climbframe_attr_t",
1567 attr => "unsigned count",
1577 reg_req => { in => [ "gp" ],
1578 out => [ "in_r1" ] },
1579 emit => '. bswap%M %S0',
1587 # bswap16, use xchg here
1591 reg_req => { in => [ "eax ebx ecx edx" ],
1592 out => [ "in_r1" ] },
1593 emit => '. xchg %SB0, %SH0',
1605 reg_req => { in => [ "none" ], out => [ "none" ] },
1614 # Undefined Instruction on ALL x86 CPU's
1618 reg_req => { in => [ "none" ], out => [ "none" ] },
1621 emit => ". .value 0x0b0f",
1632 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1633 ins => [ "port", "value", "mem" ],
1634 emit => '. out%M %SS0, %SI1',
1638 modified_flags => $status_flags
1647 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1648 ins => [ "port", "mem" ],
1649 outs => [ "res", "M" ],
1650 emit => '. in%M %DS0, %SS0',
1654 modified_flags => $status_flags
1658 # Intel style prefetching
1662 state => "exc_pinned",
1663 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1664 ins => [ "base", "index", "mem" ],
1667 emit => ". prefetcht0 %AM",
1673 state => "exc_pinned",
1674 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1675 ins => [ "base", "index", "mem" ],
1678 emit => ". prefetcht1 %AM",
1684 state => "exc_pinned",
1685 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1686 ins => [ "base", "index", "mem" ],
1689 emit => ". prefetcht2 %AM",
1695 state => "exc_pinned",
1696 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1697 ins => [ "base", "index", "mem" ],
1700 emit => ". prefetchnta %AM",
1705 # 3DNow! prefetch instructions
1709 state => "exc_pinned",
1710 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1711 ins => [ "base", "index", "mem" ],
1714 emit => ". prefetch %AM",
1720 state => "exc_pinned",
1721 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1722 ins => [ "base", "index", "mem" ],
1725 emit => ". prefetchw %AM",
1732 reg_req => { out => [ "xmm" ] },
1733 emit => '. xorp%XSD %D0, %D0',
1741 reg_req => { out => [ "xmm" ] },
1742 emit => '. pxor %D0, %D0',
1748 # produces all 1 bits
1751 reg_req => { out => [ "xmm" ] },
1752 emit => '. pcmpeqb %D0, %D0',
1758 # integer shift left, dword
1761 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1762 emit => '. pslld %SI1, %D0',
1768 # integer shift left, qword
1771 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1772 emit => '. psllq %SI1, %D0',
1778 # integer shift right, dword
1781 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1782 emit => '. psrld %SI1, %D0',
1788 # mov from integer to SSE register
1791 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1792 emit => '. movd %S0, %D0',
1800 state => "exc_pinned",
1801 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1802 out => [ "in_r4 in_r5", "flags", "none" ] },
1803 ins => [ "base", "index", "mem", "left", "right" ],
1804 outs => [ "res", "flags", "M" ],
1805 am => "source,binary",
1806 emit => '. add%XXM %binop',
1814 state => "exc_pinned",
1815 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1816 out => [ "in_r4 in_r5", "flags", "none" ] },
1817 ins => [ "base", "index", "mem", "left", "right" ],
1818 outs => [ "res", "flags", "M" ],
1819 am => "source,binary",
1820 emit => '. mul%XXM %binop',
1828 state => "exc_pinned",
1829 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1830 out => [ "in_r4 in_r5", "flags", "none" ] },
1831 ins => [ "base", "index", "mem", "left", "right" ],
1832 outs => [ "res", "flags", "M" ],
1833 am => "source,binary",
1834 emit => '. max%XXM %binop',
1842 state => "exc_pinned",
1843 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1844 out => [ "in_r4 in_r5", "flags", "none" ] },
1845 ins => [ "base", "index", "mem", "left", "right" ],
1846 outs => [ "res", "flags", "M" ],
1847 am => "source,binary",
1848 emit => '. min%XXM %binop',
1856 state => "exc_pinned",
1857 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1858 out => [ "in_r4 in_r5", "flags", "none" ] },
1859 ins => [ "base", "index", "mem", "left", "right" ],
1860 outs => [ "res", "flags", "M" ],
1861 am => "source,binary",
1862 emit => '. andp%XSD %binop',
1870 state => "exc_pinned",
1871 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1872 out => [ "in_r4 in_r5", "flags", "none" ] },
1873 ins => [ "base", "index", "mem", "left", "right" ],
1874 outs => [ "res", "flags", "M" ],
1875 am => "source,binary",
1876 emit => '. orp%XSD %binop',
1884 state => "exc_pinned",
1885 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1886 out => [ "in_r4 in_r5", "flags", "none" ] },
1887 ins => [ "base", "index", "mem", "left", "right" ],
1888 outs => [ "res", "flags", "M" ],
1889 am => "source,binary",
1890 emit => '. xorp%XSD %binop',
1898 state => "exc_pinned",
1899 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1900 out => [ "in_r4 !in_r5", "flags", "none" ] },
1901 ins => [ "base", "index", "mem", "left", "right" ],
1902 outs => [ "res", "flags", "M" ],
1903 am => "source,binary",
1904 emit => '. andnp%XSD %binop',
1912 state => "exc_pinned",
1913 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1914 out => [ "in_r4", "flags", "none" ] },
1915 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1916 outs => [ "res", "flags", "M" ],
1917 am => "source,binary",
1918 emit => '. sub%XXM %binop',
1926 state => "exc_pinned",
1927 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1928 out => [ "in_r4 !in_r5", "flags", "none" ] },
1929 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1930 outs => [ "res", "flags", "M" ],
1931 am => "source,binary",
1932 emit => '. div%XXM %binop',
1939 state => "exc_pinned",
1940 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1941 out => [ "eflags" ] },
1942 ins => [ "base", "index", "mem", "left", "right" ],
1943 outs => [ "flags" ],
1944 am => "source,binary",
1945 attr => "int ins_permuted",
1946 init_attr => "attr->data.ins_permuted = ins_permuted;",
1947 emit => ' .ucomi%XXM %binop',
1950 mode => $mode_flags,
1951 modified_flags => 1,
1956 state => "exc_pinned",
1957 reg_req => { in => [ "gp", "gp", "none" ],
1958 out => [ "xmm", "none", "none", "none" ] },
1959 ins => [ "base", "index", "mem" ],
1960 outs => [ "res", "unused", "M", "X_exc" ],
1961 emit => '. mov%XXM %AM, %D0',
1962 attr => "ir_mode *load_mode",
1963 init_attr => "attr->ls_mode = load_mode;",
1970 state => "exc_pinned",
1971 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1972 ins => [ "base", "index", "mem", "val" ],
1973 outs => [ "M", "X_exc" ],
1974 emit => '. mov%XXM %S3, %AM',
1982 state => "exc_pinned",
1983 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
1984 ins => [ "base", "index", "mem", "val" ],
1986 emit => '. mov%XXM %S3, %AM',
1994 state => "exc_pinned",
1995 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1996 ins => [ "base", "index", "mem", "val" ],
1997 am => "source,unary",
1998 emit => '. cvtsi2ss %unop3, %D0',
2006 state => "exc_pinned",
2007 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2008 ins => [ "base", "index", "mem", "val" ],
2009 am => "source,unary",
2010 emit => '. cvtsi2sd %unop3, %D0',
2019 cmp_attr => "return 1;",
2020 ins => [ "val_high", "val_low" ],
2021 reg_req => { in => [ "none", "none" ], out => [ "none" ] }
2026 cmp_attr => "return 1;",
2028 outs => [ "res_high", "res_low" ],
2029 reg_req => { in => [ "none" ], out => [ "none", "none" ] }
2035 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2036 outs => [ "DST", "SRC", "CNT", "M" ],
2037 attr_type => "ia32_copyb_attr_t",
2038 attr => "unsigned size",
2041 # we don't care about this flag, so no need to mark this node
2042 # modified_flags => [ "DF" ]
2048 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2049 outs => [ "DST", "SRC", "M" ],
2050 attr_type => "ia32_copyb_attr_t",
2051 attr => "unsigned size",
2054 # we don't care about this flag, so no need to mark this node
2055 # modified_flags => [ "DF" ]
2059 state => "exc_pinned",
2060 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2070 state => "exc_pinned",
2071 reg_req => { in => [ "gp", "gp", "none", "gp" ],
2072 out => [ "gp", "none", "none" ] },
2073 ins => [ "base", "index", "mem", "val" ],
2074 outs => [ "res", "flags", "M" ],
2075 am => "source,unary",
2078 attr => "ir_mode *smaller_mode",
2079 init_attr => "attr->ls_mode = smaller_mode;",
2084 state => "exc_pinned",
2085 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2086 out => [ "gp", "none", "none" ] },
2087 ins => [ "base", "index", "mem", "val" ],
2088 outs => [ "res", "flags", "M" ],
2089 am => "source,unary",
2092 attr => "ir_mode *smaller_mode",
2093 init_attr => "attr->ls_mode = smaller_mode;",
2098 state => "exc_pinned",
2099 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2100 ins => [ "base", "index", "mem", "val" ],
2101 am => "source,unary",
2108 state => "exc_pinned",
2109 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2110 ins => [ "base", "index", "mem", "val" ],
2111 am => "source,unary",
2118 state => "exc_pinned",
2119 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2120 ins => [ "base", "index", "mem", "val" ],
2121 am => "source,unary",
2127 # rematerialisation disabled for all float nodes for now, because the fpcw
2128 # handler runs before spilling and we might end up with wrong fpcw then
2132 state => "exc_pinned",
2133 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2134 out => [ "vfp", "none", "none" ] },
2135 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2136 outs => [ "res", "dummy", "M" ],
2137 am => "source,binary",
2141 attr_type => "ia32_x87_attr_t",
2146 state => "exc_pinned",
2147 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2148 out => [ "vfp", "none", "none" ] },
2149 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2150 outs => [ "res", "dummy", "M" ],
2151 am => "source,binary",
2155 attr_type => "ia32_x87_attr_t",
2160 state => "exc_pinned",
2161 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2162 out => [ "vfp", "none", "none" ] },
2163 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2164 outs => [ "res", "dummy", "M" ],
2165 am => "source,binary",
2169 attr_type => "ia32_x87_attr_t",
2173 state => "exc_pinned",
2174 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2175 out => [ "vfp", "none", "none" ] },
2176 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2177 outs => [ "res", "dummy", "M" ],
2178 am => "source,binary",
2181 attr_type => "ia32_x87_attr_t",
2185 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2186 ins => [ "left", "right", "fpcw" ],
2190 attr_type => "ia32_x87_attr_t",
2195 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2200 attr_type => "ia32_x87_attr_t",
2205 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2210 attr_type => "ia32_x87_attr_t",
2216 state => "exc_pinned",
2217 reg_req => { in => [ "gp", "gp", "none" ],
2218 out => [ "vfp", "none", "none", "none" ] },
2219 ins => [ "base", "index", "mem" ],
2220 outs => [ "res", "unused", "M", "X_exc" ],
2221 attr => "ir_mode *load_mode",
2222 init_attr => "attr->attr.ls_mode = load_mode;",
2225 attr_type => "ia32_x87_attr_t",
2231 state => "exc_pinned",
2232 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2233 out => [ "none", "none" ] },
2234 ins => [ "base", "index", "mem", "val" ],
2235 outs => [ "M", "X_exc" ],
2236 attr => "ir_mode *store_mode",
2237 init_attr => "attr->attr.ls_mode = store_mode;",
2241 attr_type => "ia32_x87_attr_t",
2245 state => "exc_pinned",
2246 reg_req => { in => [ "gp", "gp", "none" ],
2247 out => [ "vfp", "none", "none" ] },
2248 outs => [ "res", "unused", "M" ],
2249 ins => [ "base", "index", "mem" ],
2252 attr_type => "ia32_x87_attr_t",
2256 state => "exc_pinned",
2257 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2258 ins => [ "base", "index", "mem", "val", "fpcw" ],
2263 attr_type => "ia32_x87_attr_t",
2266 # SSE3 fisttp instruction
2268 state => "exc_pinned",
2269 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2270 ins => [ "base", "index", "mem", "val" ],
2271 outs => [ "res", "M" ],
2274 attr_type => "ia32_x87_attr_t",
2279 reg_req => { out => [ "vfp" ] },
2284 attr_type => "ia32_x87_attr_t",
2289 reg_req => { out => [ "vfp" ] },
2294 attr_type => "ia32_x87_attr_t",
2299 reg_req => { out => [ "vfp" ] },
2304 attr_type => "ia32_x87_attr_t",
2309 reg_req => { out => [ "vfp" ] },
2314 attr_type => "ia32_x87_attr_t",
2319 reg_req => { out => [ "vfp" ] },
2324 attr_type => "ia32_x87_attr_t",
2329 reg_req => { out => [ "vfp" ] },
2334 attr_type => "ia32_x87_attr_t",
2339 reg_req => { out => [ "vfp" ] },
2344 attr_type => "ia32_x87_attr_t",
2348 # we can't allow to rematerialize this node so we don't
2349 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2351 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2352 ins => [ "left", "right" ],
2353 outs => [ "flags" ],
2354 attr => "int ins_permuted",
2355 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2358 attr_type => "ia32_x87_attr_t",
2364 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2365 ins => [ "left", "right" ],
2366 outs => [ "flags" ],
2367 attr => "int ins_permuted",
2368 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2371 attr_type => "ia32_x87_attr_t",
2377 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2379 outs => [ "flags" ],
2380 attr => "int ins_permuted",
2381 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2384 attr_type => "ia32_x87_attr_t",
2390 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2392 outs => [ "flags" ],
2396 mode => $mode_flags,
2400 state => "exc_pinned",
2401 emit => '. fadd%XM %x87_binop',
2403 attr_type => "ia32_x87_attr_t",
2408 state => "exc_pinned",
2409 emit => '. faddp%XM %x87_binop',
2411 attr_type => "ia32_x87_attr_t",
2416 state => "exc_pinned",
2417 emit => '. fmul%XM %x87_binop',
2419 attr_type => "ia32_x87_attr_t",
2424 state => "exc_pinned",
2425 emit => '. fmulp%XM %x87_binop',,
2427 attr_type => "ia32_x87_attr_t",
2432 state => "exc_pinned",
2433 emit => '. fsub%XM %x87_binop',
2435 attr_type => "ia32_x87_attr_t",
2439 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2440 # are swapped, we work this around in the emitter...
2443 state => "exc_pinned",
2444 # see note about gas bugs
2445 emit => '. fsubrp%XM %x87_binop',
2447 attr_type => "ia32_x87_attr_t",
2452 state => "exc_pinned",
2454 emit => '. fsubr%XM %x87_binop',
2456 attr_type => "ia32_x87_attr_t",
2461 state => "exc_pinned",
2463 # see note about gas bugs before fsubp
2464 emit => '. fsubp%XM %x87_binop',
2466 attr_type => "ia32_x87_attr_t",
2473 attr_type => "ia32_x87_attr_t",
2477 # this node is just here, to keep the simulator running
2478 # we can omit this when a fprem simulation function exists
2480 emit => '. fprem1\n'.
2483 attr_type => "ia32_x87_attr_t",
2488 state => "exc_pinned",
2489 emit => '. fdiv%XM %x87_binop',
2491 attr_type => "ia32_x87_attr_t",
2496 state => "exc_pinned",
2497 # see note about gas bugs before fsubp
2498 emit => '. fdivrp%XM %x87_binop',
2500 attr_type => "ia32_x87_attr_t",
2505 state => "exc_pinned",
2506 emit => '. fdivr%XM %x87_binop',
2508 attr_type => "ia32_x87_attr_t",
2513 state => "exc_pinned",
2514 # see note about gas bugs before fsubp
2515 emit => '. fdivp%XM %x87_binop',
2517 attr_type => "ia32_x87_attr_t",
2524 attr_type => "ia32_x87_attr_t",
2532 attr_type => "ia32_x87_attr_t",
2537 op_flags => "R|L|F",
2538 state => "exc_pinned",
2539 emit => '. fld%XM %AM',
2540 attr_type => "ia32_x87_attr_t",
2546 op_flags => "R|L|F",
2547 state => "exc_pinned",
2548 emit => '. fst%XM %AM',
2550 attr_type => "ia32_x87_attr_t",
2556 op_flags => "R|L|F",
2557 state => "exc_pinned",
2558 emit => '. fstp%XM %AM',
2560 attr_type => "ia32_x87_attr_t",
2566 state => "exc_pinned",
2567 emit => '. fild%XM %AM',
2568 attr_type => "ia32_x87_attr_t",
2574 state => "exc_pinned",
2575 emit => '. fist%XM %AM',
2577 attr_type => "ia32_x87_attr_t",
2583 state => "exc_pinned",
2584 emit => '. fistp%XM %AM',
2586 attr_type => "ia32_x87_attr_t",
2591 # SSE3 fisttp instruction
2593 state => "exc_pinned",
2594 emit => '. fisttp%XM %AM',
2596 attr_type => "ia32_x87_attr_t",
2602 op_flags => "R|c|K",
2604 reg_req => { out => [ "vfp" ] },
2606 attr_type => "ia32_x87_attr_t",
2611 op_flags => "R|c|K",
2613 reg_req => { out => [ "vfp" ] },
2615 attr_type => "ia32_x87_attr_t",
2620 op_flags => "R|c|K",
2622 reg_req => { out => [ "vfp" ] },
2624 attr_type => "ia32_x87_attr_t",
2629 op_flags => "R|c|K",
2631 reg_req => { out => [ "vfp" ] },
2633 attr_type => "ia32_x87_attr_t",
2638 op_flags => "R|c|K",
2640 reg_req => { out => [ "vfp" ] },
2642 attr_type => "ia32_x87_attr_t",
2647 op_flags => "R|c|K",
2649 reg_req => { out => [ "vfp" ] },
2650 emit => '. fldll2t',
2651 attr_type => "ia32_x87_attr_t",
2656 op_flags => "R|c|K",
2658 reg_req => { out => [ "vfp" ] },
2660 attr_type => "ia32_x87_attr_t",
2665 # Note that it is NEVER allowed to do CSE on these nodes
2666 # Moreover, note the virtual register requierements!
2670 reg_req => { out => [ "none" ] },
2671 cmp_attr => "return 1;",
2672 emit => '. fxch %X0',
2673 attr_type => "ia32_x87_attr_t",
2680 reg_req => { out => [ "none" ] },
2681 cmp_attr => "return 1;",
2682 emit => '. fld %X0',
2683 attr_type => "ia32_x87_attr_t",
2689 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2690 cmp_attr => "return 1;",
2691 emit => '. fld %X0',
2692 attr_type => "ia32_x87_attr_t",
2698 reg_req => { out => [ "none" ] },
2699 cmp_attr => "return 1;",
2700 emit => '. fstp %X0',
2701 attr_type => "ia32_x87_attr_t",
2708 reg_req => { out => [ "none" ] },
2709 cmp_attr => "return 1;",
2710 emit => '. ffreep %X0',
2711 attr_type => "ia32_x87_attr_t",
2718 reg_req => { out => [ "none" ] },
2719 cmp_attr => "return 1;",
2721 attr_type => "ia32_x87_attr_t",
2728 reg_req => { out => [ "none" ] },
2729 cmp_attr => "return 1;",
2731 attr_type => "ia32_x87_attr_t",
2738 emit => ". fucom %X1\n".
2740 attr_type => "ia32_x87_attr_t",
2746 emit => ". fucomp %X1\n".
2748 attr_type => "ia32_x87_attr_t",
2754 emit => ". fucompp\n".
2756 attr_type => "ia32_x87_attr_t",
2762 emit => '. fucomi %X1',
2763 attr_type => "ia32_x87_attr_t",
2769 emit => '. fucompi %X1',
2770 attr_type => "ia32_x87_attr_t",
2778 attr_type => "ia32_x87_attr_t",
2782 # Spilling and reloading of SSE registers, hardcoded, not generated #
2786 state => "exc_pinned",
2787 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2788 emit => '. movdqu %D0, %AM',
2789 outs => [ "res", "M" ],
2796 state => "exc_pinned",
2797 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2798 ins => [ "base", "index", "mem", "val" ],
2799 emit => '. movdqu %binop',
2807 # Transform some attributes
2808 foreach my $op (keys(%nodes)) {
2809 my $node = $nodes{$op};
2810 my $op_attr_init = $node->{op_attr_init};
2812 if(defined($op_attr_init)) {
2813 $op_attr_init .= "\n\t";
2818 if(!defined($node->{latency})) {
2820 $node->{latency} = 0;
2822 die("Latency missing for op $op");
2825 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2827 $node->{op_attr_init} = $op_attr_init;