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 { mode => "mode_Iu" }
123 { name => "mm0", type => 4 },
124 { name => "mm1", type => 4 },
125 { name => "mm2", type => 4 },
126 { name => "mm3", type => 4 },
127 { name => "mm4", type => 4 },
128 { name => "mm5", type => 4 },
129 { name => "mm6", type => 4 },
130 { name => "mm7", type => 4 },
131 { mode => "mode_E", flags => "manual_ra" }
134 { name => "xmm0", type => 1 },
135 { name => "xmm1", type => 1 },
136 { name => "xmm2", type => 1 },
137 { name => "xmm3", type => 1 },
138 { name => "xmm4", type => 1 },
139 { name => "xmm5", type => 1 },
140 { name => "xmm6", type => 1 },
141 { name => "xmm7", type => 1 },
142 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
146 { name => "vf0", type => 1 },
147 { name => "vf1", type => 1 },
148 { name => "vf2", type => 1 },
149 { name => "vf3", type => 1 },
150 { name => "vf4", type => 1 },
151 { name => "vf5", type => 1 },
152 { name => "vf6", type => 1 },
153 { name => "vf7", type => 1 },
154 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
158 { name => "st0", realname => "st", type => 4 },
159 { name => "st1", realname => "st(1)", type => 4 },
160 { name => "st2", realname => "st(2)", type => 4 },
161 { name => "st3", realname => "st(3)", type => 4 },
162 { name => "st4", realname => "st(4)", type => 4 },
163 { name => "st5", realname => "st(5)", type => 4 },
164 { name => "st6", realname => "st(6)", type => 4 },
165 { name => "st7", realname => "st(7)", type => 4 },
166 { mode => "mode_E", flags => "manual_ra" }
168 fp_cw => [ # the floating point control word
169 { name => "fpcw", type => 4|32 },
170 { mode => "mode_fpcw", flags => "manual_ra|state" }
173 { name => "eflags", type => 0 },
174 { mode => "mode_Iu", flags => "manual_ra" }
179 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
180 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
181 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
182 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
187 bundels_per_cycle => 1
191 S0 => "${arch}_emit_source_register(node, 0);",
192 S1 => "${arch}_emit_source_register(node, 1);",
193 S2 => "${arch}_emit_source_register(node, 2);",
194 S3 => "${arch}_emit_source_register(node, 3);",
195 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
196 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
197 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
198 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
199 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
200 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
201 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
202 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
203 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
204 D0 => "${arch}_emit_dest_register(node, 0);",
205 D1 => "${arch}_emit_dest_register(node, 1);",
206 DS0 => "${arch}_emit_dest_register_size(node, 0);",
207 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
208 X0 => "${arch}_emit_x87_register(node, 0);",
209 X1 => "${arch}_emit_x87_register(node, 1);",
210 EX => "${arch}_emit_extend_suffix(node);",
211 M => "${arch}_emit_mode_suffix(node);",
212 XM => "${arch}_emit_x87_mode_suffix(node);",
213 XXM => "${arch}_emit_xmm_mode_suffix(node);",
214 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
215 AM => "${arch}_emit_am(node);",
216 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
217 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
218 binop => "${arch}_emit_binop(node);",
219 x87_binop => "${arch}_emit_x87_binop(node);",
220 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
226 $default_op_attr_type = "ia32_op_attr_t";
227 $default_attr_type = "ia32_attr_t";
228 $default_copy_attr = "ia32_copy_attr";
230 sub ia32_custom_init_attr {
236 if(defined($node->{modified_flags})) {
237 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
239 if(defined($node->{am})) {
240 my $am = $node->{am};
241 if($am eq "source,unary") {
242 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
243 } elsif($am eq "source,binary") {
244 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
245 } elsif($am eq "none") {
248 die("Invalid address mode '$am' specified on op $name");
251 if($node->{state} ne "exc_pinned"
252 and $node->{state} ne "pinned") {
253 die("AM nodes must have pinned or AM pinned state ($name)");
259 $custom_init_attr_func = \&ia32_custom_init_attr;
263 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
264 "\tinit_ia32_x87_attributes(res);".
265 "\tinit_ia32_asm_attributes(res);",
267 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);",
269 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
270 "\tinit_ia32_call_attributes(res, pop, call_tp);",
271 ia32_condcode_attr_t =>
272 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
273 "\tinit_ia32_condcode_attributes(res, pnc);",
275 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
276 "\tinit_ia32_copyb_attributes(res, size);",
277 ia32_immediate_attr_t =>
278 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
279 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
281 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
282 "\tinit_ia32_x87_attributes(res);",
283 ia32_climbframe_attr_t =>
284 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
285 "\tinit_ia32_climbframe_attributes(res, count);",
289 ia32_asm_attr_t => "ia32_compare_asm_attr",
290 ia32_attr_t => "ia32_compare_nodes_attr",
291 ia32_call_attr_t => "ia32_compare_call_attr",
292 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
293 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
294 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
295 ia32_x87_attr_t => "ia32_compare_x87_attr",
296 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
302 $mode_xmm = "mode_E";
303 $mode_gp = "mode_Iu";
304 $mode_flags = "mode_Iu";
305 $mode_fpcw = "mode_fpcw";
306 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
307 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
308 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
309 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
316 reg_req => { out => [ "gp_NOREG:I" ] },
317 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
318 attr_type => "ia32_immediate_attr_t",
319 hash_func => "ia32_hash_Immediate",
327 out_arity => "variable",
328 attr_type => "ia32_asm_attr_t",
329 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
330 init_attr => "attr->asm_text = asm_text;\n".
331 "\tattr->register_map = register_map;\n",
333 modified_flags => $status_flags,
336 # "allocates" a free register
340 reg_req => { out => [ "gp" ] },
345 cmp_attr => "return 1;",
350 state => "exc_pinned",
351 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
352 out => [ "in_r4 in_r5", "flags", "none" ] },
353 ins => [ "base", "index", "mem", "left", "right" ],
354 outs => [ "res", "flags", "M" ],
355 emit => '. add%M %binop',
356 am => "source,binary",
360 modified_flags => $status_flags
365 state => "exc_pinned",
366 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
367 ins => [ "base", "index", "mem", "val" ],
368 emit => ". add%M %SI3, %AM",
372 modified_flags => $status_flags
377 state => "exc_pinned",
378 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
379 ins => [ "base", "index", "mem", "val" ],
380 emit => ". add%M %SB3, %AM",
384 modified_flags => $status_flags
388 state => "exc_pinned",
389 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
390 out => [ "in_r4 in_r5", "flags", "none" ] },
391 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
392 outs => [ "res", "flags", "M" ],
393 emit => '. adc%M %binop',
394 am => "source,binary",
398 modified_flags => $status_flags
403 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
404 ins => [ "left", "right" ],
408 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
409 ins => [ "left", "right", "eflags" ],
413 # we should not rematrialize this node. It produces 2 results and has
414 # very strict constraints
415 state => "exc_pinned",
416 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
417 out => [ "eax", "flags", "none", "edx" ] },
418 ins => [ "base", "index", "mem", "left", "right" ],
419 emit => '. mul%M %unop4',
420 outs => [ "res_low", "flags", "M", "res_high" ],
421 am => "source,binary",
424 modified_flags => $status_flags
428 # we should not rematrialize this node. It produces 2 results and has
429 # very strict constraints
431 cmp_attr => "return 1;",
432 reg_req => { in => [ "none", "none" ],
433 out => [ "none", "none", "none", "none" ] },
434 ins => [ "left", "right" ],
435 outs => [ "res_low", "flags", "M", "res_high" ],
440 state => "exc_pinned",
441 # TODO: adjust out requirements for the 3 operand form
442 # (no need for should_be_same then)
443 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
444 out => [ "in_r4 in_r5", "flags", "none" ] },
445 ins => [ "base", "index", "mem", "left", "right" ],
446 outs => [ "res", "flags", "M" ],
447 am => "source,binary",
451 modified_flags => $status_flags
456 state => "exc_pinned",
457 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
458 out => [ "eax", "flags", "none", "edx" ] },
459 ins => [ "base", "index", "mem", "left", "right" ],
460 emit => '. imul%M %unop4',
461 outs => [ "res_low", "flags", "M", "res_high" ],
462 am => "source,binary",
465 modified_flags => $status_flags
470 cmp_attr => "return 1;",
471 reg_req => { in => [ "none", "none" ],
472 out => [ "none", "none", "none", "none" ] },
473 ins => [ "left", "right" ],
474 outs => [ "res_low", "flags", "M", "res_high" ],
479 state => "exc_pinned",
480 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
481 out => [ "in_r4 in_r5", "flags", "none" ] },
482 ins => [ "base", "index", "mem", "left", "right" ],
483 outs => [ "res", "flags", "M" ],
484 am => "source,binary",
485 emit => '. and%M %binop',
489 modified_flags => $status_flags
494 state => "exc_pinned",
495 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
496 ins => [ "base", "index", "mem", "val" ],
497 emit => '. and%M %SI3, %AM',
501 modified_flags => $status_flags
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 => '. and%M %SB3, %AM',
513 modified_flags => $status_flags
518 state => "exc_pinned",
519 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
520 out => [ "in_r4 in_r5", "flags", "none" ] },
521 ins => [ "base", "index", "mem", "left", "right" ],
522 outs => [ "res", "flags", "M" ],
523 am => "source,binary",
524 emit => '. or%M %binop',
528 modified_flags => $status_flags
533 state => "exc_pinned",
534 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
535 ins => [ "base", "index", "mem", "val" ],
536 emit => '. or%M %SI3, %AM',
540 modified_flags => $status_flags
545 state => "exc_pinned",
546 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
547 ins => [ "base", "index", "mem", "val" ],
548 emit => '. or%M %SB3, %AM',
552 modified_flags => $status_flags
557 state => "exc_pinned",
558 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
559 out => [ "in_r4 in_r5", "flags", "none" ] },
560 ins => [ "base", "index", "mem", "left", "right" ],
561 outs => [ "res", "flags", "M" ],
562 am => "source,binary",
563 emit => '. xor%M %binop',
567 modified_flags => $status_flags
573 reg_req => { out => [ "gp", "flags" ] },
574 outs => [ "res", "flags" ],
575 emit => ". xor%M %D0, %D0",
579 modified_flags => $status_flags
584 state => "exc_pinned",
585 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
586 ins => [ "base", "index", "mem", "val" ],
587 emit => '. xor%M %SI3, %AM',
591 modified_flags => $status_flags
596 state => "exc_pinned",
597 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
598 ins => [ "base", "index", "mem", "val" ],
599 emit => '. xor%M %SB3, %AM',
603 modified_flags => $status_flags
608 state => "exc_pinned",
609 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
610 out => [ "in_r4", "flags", "none" ] },
611 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
612 outs => [ "res", "flags", "M" ],
613 am => "source,binary",
614 emit => '. sub%M %binop',
618 modified_flags => $status_flags
623 state => "exc_pinned",
624 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
625 ins => [ "base", "index", "mem", "subtrahend" ],
626 emit => '. sub%M %SI3, %AM',
630 modified_flags => $status_flags
635 state => "exc_pinned",
636 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
637 ins => [ "base", "index", "mem", "subtrahend" ],
638 emit => '. sub%M %SB3, %AM',
642 modified_flags => $status_flags
646 state => "exc_pinned",
647 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
648 out => [ "in_r4 !in_r5", "flags", "none" ] },
649 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
650 outs => [ "res", "flags", "M" ],
651 am => "source,binary",
652 emit => '. sbb%M %binop',
656 modified_flags => $status_flags
660 # Spiller currently fails when rematerializing flag consumers
662 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
663 outs => [ "res", "flags" ],
664 emit => ". sbb%M %D0, %D0",
668 modified_flags => $status_flags
672 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
673 ins => [ "minuend", "subtrahend" ],
677 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
678 ins => [ "minuend", "subtrahend", "eflags" ],
683 state => "exc_pinned",
684 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
685 out => [ "eax", "flags", "none", "edx", "none" ] },
686 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
687 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
688 am => "source,unary",
689 emit => ". idiv%M %unop3",
692 modified_flags => $status_flags
697 state => "exc_pinned",
698 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
699 out => [ "eax", "flags", "none", "edx", "none" ] },
700 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
701 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
702 am => "source,unary",
703 emit => ". div%M %unop3",
706 modified_flags => $status_flags
711 reg_req => { in => [ "gp", "ecx" ],
712 out => [ "in_r1 !in_r2", "flags" ] },
713 ins => [ "val", "count" ],
714 outs => [ "res", "flags" ],
715 emit => '. shl%M %SB1, %S0',
719 modified_flags => $status_flags
724 state => "exc_pinned",
725 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
726 ins => [ "base", "index", "mem", "count" ],
727 emit => '. shl%M %SB3, %AM',
731 modified_flags => $status_flags
735 cmp_attr => "return 1;",
736 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
737 ins => [ "val", "count", "dep" ],
742 reg_req => { in => [ "gp", "gp", "ecx" ],
743 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
744 ins => [ "val_high", "val_low", "count" ],
745 outs => [ "res", "flags" ],
746 emit => ". shld%M %SB2, %S1, %D0",
750 modified_flags => $status_flags
754 cmp_attr => "return 1;",
755 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
756 ins => [ "val_high", "val_low", "count" ],
761 reg_req => { in => [ "gp", "ecx" ],
762 out => [ "in_r1 !in_r2", "flags" ] },
763 ins => [ "val", "count" ],
764 outs => [ "res", "flags" ],
765 emit => '. shr%M %SB1, %S0',
769 modified_flags => $status_flags
774 state => "exc_pinned",
775 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
776 ins => [ "base", "index", "mem", "count" ],
777 emit => '. shr%M %SB3, %AM',
781 modified_flags => $status_flags
785 cmp_attr => "return 1;",
786 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
787 ins => [ "val", "count", "dep" ],
792 reg_req => { in => [ "gp", "gp", "ecx" ],
793 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
794 ins => [ "val_high", "val_low", "count" ],
795 outs => [ "res", "flags" ],
796 emit => ". shrd%M %SB2, %S1, %D0",
800 modified_flags => $status_flags
804 cmp_attr => "return 1;",
805 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
806 ins => [ "val_high", "val_low", "count" ],
811 reg_req => { in => [ "gp", "ecx" ],
812 out => [ "in_r1 !in_r2", "flags" ] },
813 ins => [ "val", "count" ],
814 outs => [ "res", "flags" ],
815 emit => '. sar%M %SB1, %S0',
819 modified_flags => $status_flags
824 state => "exc_pinned",
825 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
826 ins => [ "base", "index", "mem", "count" ],
827 emit => '. sar%M %SB3, %AM',
831 modified_flags => $status_flags
835 cmp_attr => "return 1;",
836 ins => [ "val", "count", "dep" ],
837 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
842 reg_req => { in => [ "gp", "ecx" ],
843 out => [ "in_r1 !in_r2", "flags" ] },
844 ins => [ "val", "count" ],
845 outs => [ "res", "flags" ],
846 emit => '. ror%M %SB1, %S0',
850 modified_flags => $status_flags
855 state => "exc_pinned",
856 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
857 ins => [ "base", "index", "mem", "count" ],
858 emit => '. ror%M %SB3, %AM',
862 modified_flags => $status_flags
867 reg_req => { in => [ "gp", "ecx" ],
868 out => [ "in_r1 !in_r2", "flags" ] },
869 ins => [ "val", "count" ],
870 outs => [ "res", "flags" ],
871 emit => '. rol%M %SB1, %S0',
875 modified_flags => $status_flags
880 state => "exc_pinned",
881 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
882 ins => [ "base", "index", "mem", "count" ],
883 emit => '. rol%M %SB3, %AM',
887 modified_flags => $status_flags
892 reg_req => { in => [ "gp" ],
893 out => [ "in_r1", "flags" ] },
894 emit => '. neg%M %S0',
896 outs => [ "res", "flags" ],
900 modified_flags => $status_flags
905 state => "exc_pinned",
906 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
907 ins => [ "base", "index", "mem" ],
908 emit => '. neg%M %AM',
912 modified_flags => $status_flags
917 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
918 outs => [ "low_res", "high_res" ],
921 modified_flags => $status_flags
927 reg_req => { in => [ "gp" ],
928 out => [ "in_r1", "flags" ] },
930 outs => [ "res", "flags" ],
931 emit => '. inc%M %S0',
935 modified_flags => $status_flags_wo_cf
940 state => "exc_pinned",
941 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
942 ins => [ "base", "index", "mem" ],
943 emit => '. inc%M %AM',
947 modified_flags => $status_flags_wo_cf
952 reg_req => { in => [ "gp" ],
953 out => [ "in_r1", "flags" ] },
955 outs => [ "res", "flags" ],
956 emit => '. dec%M %S0',
960 modified_flags => $status_flags_wo_cf
965 state => "exc_pinned",
966 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
967 ins => [ "base", "index", "mem" ],
968 emit => '. dec%M %AM',
972 modified_flags => $status_flags_wo_cf
977 reg_req => { in => [ "gp" ],
978 out => [ "in_r1" ] },
981 emit => '. not%M %S0',
990 state => "exc_pinned",
991 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
992 ins => [ "base", "index", "mem" ],
993 emit => '. not%M %AM',
1001 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1005 mode => $mode_flags,
1006 modified_flags => $status_flags
1010 reg_req => { out => [ "flags" ] },
1014 mode => $mode_flags,
1015 modified_flags => $status_flags
1020 state => "exc_pinned",
1021 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1022 out => [ "flags", "none", "none" ] },
1023 ins => [ "base", "index", "mem", "left", "right" ],
1024 outs => [ "eflags", "unused", "M" ],
1025 am => "source,binary",
1026 emit => '. cmp%M %binop',
1027 attr => "int ins_permuted, int cmp_unsigned",
1028 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1029 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1032 mode => $mode_flags,
1033 modified_flags => $status_flags
1038 state => "exc_pinned",
1039 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1040 out => [ "flags", "none", "none" ] },
1041 ins => [ "base", "index", "mem", "left", "right" ],
1042 outs => [ "eflags", "unused", "M" ],
1043 am => "source,binary",
1044 emit => '. cmpb %binop',
1045 attr => "int ins_permuted, int cmp_unsigned",
1046 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1047 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1050 mode => $mode_flags,
1051 modified_flags => $status_flags
1056 state => "exc_pinned",
1057 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
1058 out => [ "flags", "none", "none" ] },
1059 ins => [ "base", "index", "mem", "left", "right" ],
1060 outs => [ "eflags", "unused", "M" ],
1061 am => "source,binary",
1062 emit => '. test%M %binop',
1063 attr => "int ins_permuted, int cmp_unsigned",
1064 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1065 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1068 mode => $mode_flags,
1069 modified_flags => $status_flags
1074 state => "exc_pinned",
1075 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1076 out => [ "flags", "none", "none" ] },
1077 ins => [ "base", "index", "mem", "left", "right" ],
1078 outs => [ "eflags", "unused", "M" ],
1079 am => "source,binary",
1080 emit => '. testb %binop',
1081 attr => "int ins_permuted, int cmp_unsigned",
1082 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1083 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1086 mode => $mode_flags,
1087 modified_flags => $status_flags
1092 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1093 ins => [ "eflags" ],
1095 attr_type => "ia32_condcode_attr_t",
1096 attr => "pn_Cmp pnc",
1097 # The way we handle Setcc with float nodes (potentially) destroys the flags
1098 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
1099 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
1100 . "\tif ((pnc & ia32_pn_Cmp_float) && ((pnc & 0xf) != pn_Cmp_Uo) && ((pnc & 0xf) != pn_Cmp_Leg)) {\n"
1101 . "\t\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n"
1102 . "\t\t/* attr->latency = 3; */\n"
1111 state => "exc_pinned",
1112 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1113 ins => [ "base", "index", "mem","eflags" ],
1114 attr_type => "ia32_condcode_attr_t",
1115 attr => "pn_Cmp pnc",
1116 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1117 emit => '. set%CMP3 %AM',
1125 state => "exc_pinned",
1126 # (note: leave the false,true order intact to make it compatible with other
1128 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1129 out => [ "in_r4 in_r5", "flags", "none" ] },
1130 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1131 outs => [ "res", "flags", "M" ],
1132 am => "source,binary",
1133 attr_type => "ia32_condcode_attr_t",
1134 attr => "pn_Cmp pnc",
1142 op_flags => "L|X|Y",
1143 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1144 ins => [ "eflags" ],
1145 outs => [ "false", "true" ],
1146 attr_type => "ia32_condcode_attr_t",
1147 attr => "pn_Cmp pnc",
1149 units => [ "BRANCH" ],
1154 op_flags => "L|X|Y",
1155 reg_req => { in => [ "gp" ] },
1157 attr_type => "ia32_condcode_attr_t",
1160 units => [ "BRANCH" ],
1161 modified_flags => $status_flags,
1162 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1169 reg_req => { out => [ "none" ] },
1171 units => [ "BRANCH" ],
1178 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1179 ins => [ "base", "index", "mem", "target" ],
1180 am => "source,unary",
1181 emit => '. jmp *%unop3',
1183 units => [ "BRANCH" ],
1185 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1191 reg_req => { out => [ "gp" ] },
1193 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1194 attr_type => "ia32_immediate_attr_t",
1202 reg_req => { out => [ "gp" ] },
1210 reg_req => { out => [ "gp" ] },
1214 modified_flags => $status_flags,
1219 op_flags => "c|NB|NI",
1220 reg_req => { out => [ "gp_NOREG:I" ] },
1229 op_flags => "c|NB|NI",
1230 reg_req => { out => [ "vfp_NOREG:I" ] },
1235 attr_type => "ia32_x87_attr_t",
1240 op_flags => "c|NB|NI",
1241 reg_req => { out => [ "xmm_NOREG:I" ] },
1251 reg_req => { out => [ "fpcw:I" ] },
1255 modified_flags => $fpcw_flags
1261 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1262 ins => [ "base", "index", "mem" ],
1264 emit => ". fldcw %AM",
1267 modified_flags => $fpcw_flags
1273 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1274 ins => [ "base", "index", "mem", "fpcw" ],
1276 emit => ". fnstcw %AM",
1284 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1292 # we should not rematrialize this node. It has very strict constraints.
1293 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1294 ins => [ "val", "clobbered" ],
1303 # Note that we add additional latency values depending on address mode, so a
1304 # lateny of 0 for load is correct
1308 state => "exc_pinned",
1309 reg_req => { in => [ "gp", "gp", "none" ],
1310 out => [ "gp", "none", "none", "none" ] },
1311 ins => [ "base", "index", "mem" ],
1312 outs => [ "res", "unused", "M", "X_exc" ],
1314 emit => ". mov%EX%.l %AM, %D0",
1320 state => "exc_pinned",
1321 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1322 ins => [ "base", "index", "mem", "val" ],
1323 outs => [ "M", "X_exc" ],
1324 emit => '. mov%M %SI3, %AM',
1332 state => "exc_pinned",
1333 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1334 ins => [ "base", "index", "mem", "val" ],
1335 outs => [ "M", "X_exc" ],
1336 emit => '. mov%M %SB3, %AM',
1344 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1345 ins => [ "base", "index" ],
1346 emit => '. leal %AM, %D0',
1350 # lea doesn't modify the flags, but setting this seems advantageous since it
1351 # increases chances that the Lea is transformed back to an Add
1352 modified_flags => 1,
1356 state => "exc_pinned",
1357 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1358 ins => [ "base", "index", "mem", "val", "stack" ],
1359 emit => '. push%M %unop3',
1360 outs => [ "stack", "M" ],
1361 am => "source,unary",
1367 state => "exc_pinned",
1368 reg_req => { in => [ "esp" ], out => [ "esp:I|S" ] },
1370 outs => [ "stack" ],
1371 emit => '. pushl %%eax',
1378 state => "exc_pinned",
1379 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1380 ins => [ "mem", "stack" ],
1381 outs => [ "res", "M", "unused", "stack" ],
1382 emit => '. pop%M %D0',
1383 latency => 3, # Pop is more expensive than Push on Athlon
1388 state => "exc_pinned",
1389 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1390 ins => [ "mem", "stack" ],
1391 outs => [ "res", "M", "unused", "stack" ],
1392 emit => '. pop%M %D0',
1393 latency => 3, # Pop is more expensive than Push on Athlon
1398 state => "exc_pinned",
1399 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1400 ins => [ "base", "index", "mem", "stack" ],
1401 outs => [ "unused0", "M", "unused1", "stack" ],
1402 emit => '. pop%M %AM',
1403 latency => 3, # Pop is more expensive than Push on Athlon
1408 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1410 outs => [ "frame", "stack", "M" ],
1416 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1418 outs => [ "frame", "stack" ],
1425 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1426 ins => [ "base", "index", "mem", "stack", "size" ],
1427 am => "source,binary",
1428 emit => '. addl %binop',
1430 outs => [ "stack", "M" ],
1432 modified_flags => $status_flags
1437 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1438 ins => [ "base", "index", "mem", "stack", "size" ],
1439 am => "source,binary",
1440 emit => ". subl %binop\n".
1441 ". movl %%esp, %D1",
1443 outs => [ "stack", "addr", "M" ],
1445 modified_flags => $status_flags
1458 reg_req => { out => [ "gp" ] },
1464 # BT supports source address mode, but this is unused yet
1468 state => "exc_pinned",
1469 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1470 ins => [ "left", "right" ],
1471 emit => '. bt%M %S1, %S0',
1474 mode => $mode_flags,
1475 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1480 state => "exc_pinned",
1481 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1482 out => [ "gp", "flags", "none" ] },
1483 ins => [ "base", "index", "mem", "operand" ],
1484 outs => [ "res", "flags", "M" ],
1485 am => "source,binary",
1486 emit => '. bsf%M %unop3, %D0',
1490 modified_flags => $status_flags
1495 state => "exc_pinned",
1496 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1497 out => [ "gp", "flags", "none" ] },
1498 ins => [ "base", "index", "mem", "operand" ],
1499 outs => [ "res", "flags", "M" ],
1500 am => "source,binary",
1501 emit => '. bsr%M %unop3, %D0',
1505 modified_flags => $status_flags
1509 # SSE4.2 or SSE4a popcnt instruction
1513 state => "exc_pinned",
1514 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1515 out => [ "gp", "flags", "none" ] },
1516 ins => [ "base", "index", "mem", "operand" ],
1517 outs => [ "res", "flags", "M" ],
1518 am => "source,binary",
1519 emit => '. popcnt%M %unop3, %D0',
1523 modified_flags => $status_flags
1527 state => "exc_pinned",
1529 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1530 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" ]
1532 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1533 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1534 attr_type => "ia32_call_attr_t",
1535 attr => "unsigned pop, ir_type *call_tp",
1536 am => "source,unary",
1537 units => [ "BRANCH" ],
1538 latency => 4, # random number
1539 modified_flags => $status_flags
1543 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1545 # PS: try gcc __builtin_frame_address(100000) :-)
1548 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1549 ins => [ "frame", "cnt", "tmp" ],
1551 latency => 4, # random number
1552 attr_type => "ia32_climbframe_attr_t",
1553 attr => "unsigned count",
1563 reg_req => { in => [ "gp" ],
1564 out => [ "in_r1" ] },
1565 emit => '. bswap%M %S0',
1573 # bswap16, use xchg here
1577 reg_req => { in => [ "eax ebx ecx edx" ],
1578 out => [ "in_r1" ] },
1579 emit => '. xchg %SB0, %SH0',
1591 reg_req => { in => [ "none" ], out => [ "none" ] },
1600 # Undefined Instruction on ALL x86 CPU's
1604 reg_req => { in => [ "none" ], out => [ "none" ] },
1607 emit => ". .value 0x0b0f",
1618 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1619 ins => [ "port", "value", "mem" ],
1620 emit => '. out%M %SS0, %SI1',
1624 modified_flags => $status_flags
1633 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1634 ins => [ "port", "mem" ],
1635 outs => [ "res", "M" ],
1636 emit => '. in%M %DS0, %SS0',
1640 modified_flags => $status_flags
1644 # Intel style prefetching
1648 state => "exc_pinned",
1649 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1650 ins => [ "base", "index", "mem" ],
1653 emit => ". prefetcht0 %AM",
1659 state => "exc_pinned",
1660 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1661 ins => [ "base", "index", "mem" ],
1664 emit => ". prefetcht1 %AM",
1670 state => "exc_pinned",
1671 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1672 ins => [ "base", "index", "mem" ],
1675 emit => ". prefetcht2 %AM",
1681 state => "exc_pinned",
1682 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1683 ins => [ "base", "index", "mem" ],
1686 emit => ". prefetchnta %AM",
1691 # 3DNow! prefetch instructions
1695 state => "exc_pinned",
1696 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1697 ins => [ "base", "index", "mem" ],
1700 emit => ". prefetch %AM",
1706 state => "exc_pinned",
1707 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1708 ins => [ "base", "index", "mem" ],
1711 emit => ". prefetchw %AM",
1718 reg_req => { out => [ "xmm" ] },
1719 emit => '. xorp%XSD %D0, %D0',
1728 reg_req => { out => [ "xmm" ] },
1736 reg_req => { out => [ "xmm" ] },
1737 emit => '. pxor %D0, %D0',
1743 # produces all 1 bits
1746 reg_req => { out => [ "xmm" ] },
1747 emit => '. pcmpeqb %D0, %D0',
1753 # integer shift left, dword
1756 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1757 emit => '. pslld %SI1, %D0',
1763 # integer shift left, qword
1766 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1767 emit => '. psllq %SI1, %D0',
1773 # integer shift right, dword
1776 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1777 emit => '. psrld %SI1, %D0',
1783 # mov from integer to SSE register
1786 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1787 emit => '. movd %S0, %D0',
1795 state => "exc_pinned",
1796 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1797 out => [ "in_r4 in_r5", "flags", "none" ] },
1798 ins => [ "base", "index", "mem", "left", "right" ],
1799 outs => [ "res", "flags", "M" ],
1800 am => "source,binary",
1801 emit => '. add%XXM %binop',
1809 state => "exc_pinned",
1810 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1811 out => [ "in_r4 in_r5", "flags", "none" ] },
1812 ins => [ "base", "index", "mem", "left", "right" ],
1813 outs => [ "res", "flags", "M" ],
1814 am => "source,binary",
1815 emit => '. mul%XXM %binop',
1823 state => "exc_pinned",
1824 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1825 out => [ "in_r4 in_r5", "flags", "none" ] },
1826 ins => [ "base", "index", "mem", "left", "right" ],
1827 outs => [ "res", "flags", "M" ],
1828 am => "source,binary",
1829 emit => '. max%XXM %binop',
1837 state => "exc_pinned",
1838 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1839 out => [ "in_r4 in_r5", "flags", "none" ] },
1840 ins => [ "base", "index", "mem", "left", "right" ],
1841 outs => [ "res", "flags", "M" ],
1842 am => "source,binary",
1843 emit => '. min%XXM %binop',
1851 state => "exc_pinned",
1852 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1853 out => [ "in_r4 in_r5", "flags", "none" ] },
1854 ins => [ "base", "index", "mem", "left", "right" ],
1855 outs => [ "res", "flags", "M" ],
1856 am => "source,binary",
1857 emit => '. andp%XSD %binop',
1865 state => "exc_pinned",
1866 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1867 out => [ "in_r4 in_r5", "flags", "none" ] },
1868 ins => [ "base", "index", "mem", "left", "right" ],
1869 outs => [ "res", "flags", "M" ],
1870 am => "source,binary",
1871 emit => '. orp%XSD %binop',
1879 state => "exc_pinned",
1880 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1881 out => [ "in_r4 in_r5", "flags", "none" ] },
1882 ins => [ "base", "index", "mem", "left", "right" ],
1883 outs => [ "res", "flags", "M" ],
1884 am => "source,binary",
1885 emit => '. xorp%XSD %binop',
1893 state => "exc_pinned",
1894 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1895 out => [ "in_r4 !in_r5", "flags", "none" ] },
1896 ins => [ "base", "index", "mem", "left", "right" ],
1897 outs => [ "res", "flags", "M" ],
1898 am => "source,binary",
1899 emit => '. andnp%XSD %binop',
1907 state => "exc_pinned",
1908 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1909 out => [ "in_r4", "flags", "none" ] },
1910 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1911 outs => [ "res", "flags", "M" ],
1912 am => "source,binary",
1913 emit => '. sub%XXM %binop',
1921 state => "exc_pinned",
1922 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1923 out => [ "in_r4 !in_r5", "flags", "none" ] },
1924 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1925 outs => [ "res", "flags", "M" ],
1926 am => "source,binary",
1927 emit => '. div%XXM %binop',
1934 state => "exc_pinned",
1935 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1936 out => [ "eflags" ] },
1937 ins => [ "base", "index", "mem", "left", "right" ],
1938 outs => [ "flags" ],
1939 am => "source,binary",
1940 attr => "int ins_permuted",
1941 init_attr => "attr->data.ins_permuted = ins_permuted;",
1942 emit => ' .ucomi%XXM %binop',
1945 mode => $mode_flags,
1946 modified_flags => 1,
1951 state => "exc_pinned",
1952 reg_req => { in => [ "gp", "gp", "none" ],
1953 out => [ "xmm", "none", "none", "none" ] },
1954 ins => [ "base", "index", "mem" ],
1955 outs => [ "res", "unused", "M", "X_exc" ],
1956 emit => '. mov%XXM %AM, %D0',
1957 attr => "ir_mode *load_mode",
1958 init_attr => "attr->ls_mode = load_mode;",
1965 state => "exc_pinned",
1966 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1967 ins => [ "base", "index", "mem", "val" ],
1968 outs => [ "M", "X_exc" ],
1969 emit => '. mov%XXM %S3, %AM',
1977 state => "exc_pinned",
1978 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
1979 ins => [ "base", "index", "mem", "val" ],
1981 emit => '. mov%XXM %S3, %AM',
1989 state => "exc_pinned",
1990 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1991 ins => [ "base", "index", "mem", "val" ],
1992 am => "source,unary",
1993 emit => '. cvtsi2ss %unop3, %D0',
2001 state => "exc_pinned",
2002 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2003 ins => [ "base", "index", "mem", "val" ],
2004 am => "source,unary",
2005 emit => '. cvtsi2sd %unop3, %D0',
2014 cmp_attr => "return 1;",
2015 ins => [ "val_high", "val_low" ],
2016 reg_req => { in => [ "none", "none" ], out => [ "none" ] }
2021 cmp_attr => "return 1;",
2023 outs => [ "res_high", "res_low" ],
2024 reg_req => { in => [ "none" ], out => [ "none", "none" ] }
2030 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2031 outs => [ "DST", "SRC", "CNT", "M" ],
2032 attr_type => "ia32_copyb_attr_t",
2033 attr => "unsigned size",
2036 # we don't care about this flag, so no need to mark this node
2037 # modified_flags => [ "DF" ]
2043 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2044 outs => [ "DST", "SRC", "M" ],
2045 attr_type => "ia32_copyb_attr_t",
2046 attr => "unsigned size",
2049 # we don't care about this flag, so no need to mark this node
2050 # modified_flags => [ "DF" ]
2054 state => "exc_pinned",
2055 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2065 state => "exc_pinned",
2066 reg_req => { in => [ "gp", "gp", "none", "gp" ],
2067 out => [ "gp", "none", "none" ] },
2068 ins => [ "base", "index", "mem", "val" ],
2069 outs => [ "res", "flags", "M" ],
2070 am => "source,unary",
2073 attr => "ir_mode *smaller_mode",
2074 init_attr => "attr->ls_mode = smaller_mode;",
2079 state => "exc_pinned",
2080 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2081 out => [ "gp", "none", "none" ] },
2082 ins => [ "base", "index", "mem", "val" ],
2083 outs => [ "res", "flags", "M" ],
2084 am => "source,unary",
2087 attr => "ir_mode *smaller_mode",
2088 init_attr => "attr->ls_mode = smaller_mode;",
2093 state => "exc_pinned",
2094 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2095 ins => [ "base", "index", "mem", "val" ],
2096 am => "source,unary",
2103 state => "exc_pinned",
2104 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2105 ins => [ "base", "index", "mem", "val" ],
2106 am => "source,unary",
2113 state => "exc_pinned",
2114 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2115 ins => [ "base", "index", "mem", "val" ],
2116 am => "source,unary",
2122 # rematerialisation disabled for all float nodes for now, because the fpcw
2123 # handler runs before spilling and we might end up with wrong fpcw then
2127 state => "exc_pinned",
2128 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2129 out => [ "vfp", "none", "none" ] },
2130 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2131 outs => [ "res", "dummy", "M" ],
2132 am => "source,binary",
2136 attr_type => "ia32_x87_attr_t",
2141 state => "exc_pinned",
2142 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2143 out => [ "vfp", "none", "none" ] },
2144 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2145 outs => [ "res", "dummy", "M" ],
2146 am => "source,binary",
2150 attr_type => "ia32_x87_attr_t",
2155 state => "exc_pinned",
2156 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2157 out => [ "vfp", "none", "none" ] },
2158 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2159 outs => [ "res", "dummy", "M" ],
2160 am => "source,binary",
2164 attr_type => "ia32_x87_attr_t",
2168 state => "exc_pinned",
2169 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2170 out => [ "vfp", "none", "none" ] },
2171 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2172 outs => [ "res", "dummy", "M" ],
2173 am => "source,binary",
2176 attr_type => "ia32_x87_attr_t",
2180 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2181 ins => [ "left", "right", "fpcw" ],
2185 attr_type => "ia32_x87_attr_t",
2190 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2195 attr_type => "ia32_x87_attr_t",
2200 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2205 attr_type => "ia32_x87_attr_t",
2211 state => "exc_pinned",
2212 reg_req => { in => [ "gp", "gp", "none" ],
2213 out => [ "vfp", "none", "none", "none" ] },
2214 ins => [ "base", "index", "mem" ],
2215 outs => [ "res", "unused", "M", "X_exc" ],
2216 attr => "ir_mode *load_mode",
2217 init_attr => "attr->attr.ls_mode = load_mode;",
2220 attr_type => "ia32_x87_attr_t",
2226 state => "exc_pinned",
2227 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2228 out => [ "none", "none" ] },
2229 ins => [ "base", "index", "mem", "val" ],
2230 outs => [ "M", "X_exc" ],
2231 attr => "ir_mode *store_mode",
2232 init_attr => "attr->attr.ls_mode = store_mode;",
2236 attr_type => "ia32_x87_attr_t",
2240 state => "exc_pinned",
2241 reg_req => { in => [ "gp", "gp", "none" ],
2242 out => [ "vfp", "none", "none" ] },
2243 outs => [ "res", "unused", "M" ],
2244 ins => [ "base", "index", "mem" ],
2247 attr_type => "ia32_x87_attr_t",
2251 state => "exc_pinned",
2252 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2253 ins => [ "base", "index", "mem", "val", "fpcw" ],
2258 attr_type => "ia32_x87_attr_t",
2261 # SSE3 fisttp instruction
2263 state => "exc_pinned",
2264 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2265 ins => [ "base", "index", "mem", "val" ],
2266 outs => [ "res", "M" ],
2269 attr_type => "ia32_x87_attr_t",
2274 reg_req => { out => [ "vfp" ] },
2279 attr_type => "ia32_x87_attr_t",
2284 reg_req => { out => [ "vfp" ] },
2289 attr_type => "ia32_x87_attr_t",
2294 reg_req => { out => [ "vfp" ] },
2299 attr_type => "ia32_x87_attr_t",
2304 reg_req => { out => [ "vfp" ] },
2309 attr_type => "ia32_x87_attr_t",
2314 reg_req => { out => [ "vfp" ] },
2319 attr_type => "ia32_x87_attr_t",
2324 reg_req => { out => [ "vfp" ] },
2329 attr_type => "ia32_x87_attr_t",
2334 reg_req => { out => [ "vfp" ] },
2339 attr_type => "ia32_x87_attr_t",
2343 # we can't allow to rematerialize this node so we don't
2344 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2346 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2347 ins => [ "left", "right" ],
2348 outs => [ "flags" ],
2349 attr => "int ins_permuted",
2350 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2353 attr_type => "ia32_x87_attr_t",
2359 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2360 ins => [ "left", "right" ],
2361 outs => [ "flags" ],
2362 attr => "int ins_permuted",
2363 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2366 attr_type => "ia32_x87_attr_t",
2372 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2374 outs => [ "flags" ],
2375 attr => "int ins_permuted",
2376 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2379 attr_type => "ia32_x87_attr_t",
2385 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2387 outs => [ "flags" ],
2391 mode => $mode_flags,
2395 state => "exc_pinned",
2396 emit => '. fadd%XM %x87_binop',
2398 attr_type => "ia32_x87_attr_t",
2403 state => "exc_pinned",
2404 emit => '. faddp%XM %x87_binop',
2406 attr_type => "ia32_x87_attr_t",
2411 state => "exc_pinned",
2412 emit => '. fmul%XM %x87_binop',
2414 attr_type => "ia32_x87_attr_t",
2419 state => "exc_pinned",
2420 emit => '. fmulp%XM %x87_binop',,
2422 attr_type => "ia32_x87_attr_t",
2427 state => "exc_pinned",
2428 emit => '. fsub%XM %x87_binop',
2430 attr_type => "ia32_x87_attr_t",
2434 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2435 # are swapped, we work this around in the emitter...
2438 state => "exc_pinned",
2439 # see note about gas bugs
2440 emit => '. fsubrp%XM %x87_binop',
2442 attr_type => "ia32_x87_attr_t",
2447 state => "exc_pinned",
2449 emit => '. fsubr%XM %x87_binop',
2451 attr_type => "ia32_x87_attr_t",
2456 state => "exc_pinned",
2458 # see note about gas bugs before fsubp
2459 emit => '. fsubp%XM %x87_binop',
2461 attr_type => "ia32_x87_attr_t",
2468 attr_type => "ia32_x87_attr_t",
2472 # this node is just here, to keep the simulator running
2473 # we can omit this when a fprem simulation function exists
2475 emit => '. fprem1\n'.
2478 attr_type => "ia32_x87_attr_t",
2483 state => "exc_pinned",
2484 emit => '. fdiv%XM %x87_binop',
2486 attr_type => "ia32_x87_attr_t",
2491 state => "exc_pinned",
2492 # see note about gas bugs before fsubp
2493 emit => '. fdivrp%XM %x87_binop',
2495 attr_type => "ia32_x87_attr_t",
2500 state => "exc_pinned",
2501 emit => '. fdivr%XM %x87_binop',
2503 attr_type => "ia32_x87_attr_t",
2508 state => "exc_pinned",
2509 # see note about gas bugs before fsubp
2510 emit => '. fdivp%XM %x87_binop',
2512 attr_type => "ia32_x87_attr_t",
2519 attr_type => "ia32_x87_attr_t",
2527 attr_type => "ia32_x87_attr_t",
2532 op_flags => "R|L|F",
2533 state => "exc_pinned",
2534 emit => '. fld%XM %AM',
2535 attr_type => "ia32_x87_attr_t",
2541 op_flags => "R|L|F",
2542 state => "exc_pinned",
2543 emit => '. fst%XM %AM',
2545 attr_type => "ia32_x87_attr_t",
2551 op_flags => "R|L|F",
2552 state => "exc_pinned",
2553 emit => '. fstp%XM %AM',
2555 attr_type => "ia32_x87_attr_t",
2561 state => "exc_pinned",
2562 emit => '. fild%XM %AM',
2563 attr_type => "ia32_x87_attr_t",
2569 state => "exc_pinned",
2570 emit => '. fist%XM %AM',
2572 attr_type => "ia32_x87_attr_t",
2578 state => "exc_pinned",
2579 emit => '. fistp%XM %AM',
2581 attr_type => "ia32_x87_attr_t",
2586 # SSE3 fisttp instruction
2588 state => "exc_pinned",
2589 emit => '. fisttp%XM %AM',
2591 attr_type => "ia32_x87_attr_t",
2597 op_flags => "R|c|K",
2599 reg_req => { out => [ "vfp" ] },
2601 attr_type => "ia32_x87_attr_t",
2606 op_flags => "R|c|K",
2608 reg_req => { out => [ "vfp" ] },
2610 attr_type => "ia32_x87_attr_t",
2615 op_flags => "R|c|K",
2617 reg_req => { out => [ "vfp" ] },
2619 attr_type => "ia32_x87_attr_t",
2624 op_flags => "R|c|K",
2626 reg_req => { out => [ "vfp" ] },
2628 attr_type => "ia32_x87_attr_t",
2633 op_flags => "R|c|K",
2635 reg_req => { out => [ "vfp" ] },
2637 attr_type => "ia32_x87_attr_t",
2642 op_flags => "R|c|K",
2644 reg_req => { out => [ "vfp" ] },
2645 emit => '. fldll2t',
2646 attr_type => "ia32_x87_attr_t",
2651 op_flags => "R|c|K",
2653 reg_req => { out => [ "vfp" ] },
2655 attr_type => "ia32_x87_attr_t",
2660 # Note that it is NEVER allowed to do CSE on these nodes
2661 # Moreover, note the virtual register requierements!
2665 reg_req => { out => [ "none" ] },
2666 cmp_attr => "return 1;",
2667 emit => '. fxch %X0',
2668 attr_type => "ia32_x87_attr_t",
2675 reg_req => { out => [ "none" ] },
2676 cmp_attr => "return 1;",
2677 emit => '. fld %X0',
2678 attr_type => "ia32_x87_attr_t",
2684 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2685 cmp_attr => "return 1;",
2686 emit => '. fld %X0',
2687 attr_type => "ia32_x87_attr_t",
2693 reg_req => { out => [ "none" ] },
2694 cmp_attr => "return 1;",
2695 emit => '. fstp %X0',
2696 attr_type => "ia32_x87_attr_t",
2703 reg_req => { out => [ "none" ] },
2704 cmp_attr => "return 1;",
2705 emit => '. ffreep %X0',
2706 attr_type => "ia32_x87_attr_t",
2713 reg_req => { out => [ "none" ] },
2714 cmp_attr => "return 1;",
2716 attr_type => "ia32_x87_attr_t",
2723 reg_req => { out => [ "none" ] },
2724 cmp_attr => "return 1;",
2726 attr_type => "ia32_x87_attr_t",
2733 emit => ". fucom %X1\n".
2735 attr_type => "ia32_x87_attr_t",
2741 emit => ". fucomp %X1\n".
2743 attr_type => "ia32_x87_attr_t",
2749 emit => ". fucompp\n".
2751 attr_type => "ia32_x87_attr_t",
2757 emit => '. fucomi %X1',
2758 attr_type => "ia32_x87_attr_t",
2764 emit => '. fucompi %X1',
2765 attr_type => "ia32_x87_attr_t",
2773 attr_type => "ia32_x87_attr_t",
2777 # Spilling and reloading of SSE registers, hardcoded, not generated #
2781 state => "exc_pinned",
2782 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2783 emit => '. movdqu %D0, %AM',
2784 outs => [ "res", "M" ],
2791 state => "exc_pinned",
2792 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2793 ins => [ "base", "index", "mem", "val" ],
2794 emit => '. movdqu %binop',
2802 # Transform some attributes
2803 foreach my $op (keys(%nodes)) {
2804 my $node = $nodes{$op};
2805 my $op_attr_init = $node->{op_attr_init};
2807 if(defined($op_attr_init)) {
2808 $op_attr_init .= "\n\t";
2813 if(!defined($node->{latency})) {
2815 $node->{latency} = 0;
2817 die("Latency missing for op $op");
2820 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2822 $node->{op_attr_init} = $op_attr_init;