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 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
224 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
230 $default_op_attr_type = "ia32_op_attr_t";
231 $default_attr_type = "ia32_attr_t";
232 $default_copy_attr = "ia32_copy_attr";
234 sub ia32_custom_init_attr {
240 if(defined($node->{modified_flags})) {
241 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
243 if(defined($node->{am})) {
244 my $am = $node->{am};
245 if($am eq "source,unary") {
246 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
247 } elsif($am eq "source,binary") {
248 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
249 } elsif($am eq "none") {
252 die("Invalid address mode '$am' specified on op $name");
255 if($node->{state} ne "exc_pinned"
256 and $node->{state} ne "pinned") {
257 die("AM nodes must have pinned or AM pinned state ($name)");
263 $custom_init_attr_func = \&ia32_custom_init_attr;
267 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
268 "\tinit_ia32_x87_attributes(res);".
269 "\tinit_ia32_asm_attributes(res);",
271 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);",
273 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
274 "\tinit_ia32_call_attributes(res, pop, call_tp);",
275 ia32_condcode_attr_t =>
276 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
277 "\tinit_ia32_condcode_attributes(res, pnc);",
279 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
280 "\tinit_ia32_copyb_attributes(res, size);",
281 ia32_immediate_attr_t =>
282 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
283 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
285 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_x87_attributes(res);",
287 ia32_climbframe_attr_t =>
288 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
289 "\tinit_ia32_climbframe_attributes(res, count);",
293 ia32_asm_attr_t => "ia32_compare_asm_attr",
294 ia32_attr_t => "ia32_compare_nodes_attr",
295 ia32_call_attr_t => "ia32_compare_call_attr",
296 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
297 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
298 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
299 ia32_x87_attr_t => "ia32_compare_x87_attr",
300 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
306 $mode_xmm = "mode_E";
307 $mode_gp = "mode_Iu";
308 $mode_flags = "mode_Iu";
309 $mode_fpcw = "mode_fpcw";
310 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
311 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
312 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
313 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
320 reg_req => { out => [ "gp_NOREG:I" ] },
321 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
322 attr_type => "ia32_immediate_attr_t",
323 hash_func => "ia32_hash_Immediate",
331 out_arity => "variable",
332 attr_type => "ia32_asm_attr_t",
333 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
334 init_attr => "attr->asm_text = asm_text;\n".
335 "\tattr->register_map = register_map;\n",
337 modified_flags => $status_flags,
340 # "allocates" a free register
344 reg_req => { out => [ "gp" ] },
349 cmp_attr => "return 1;",
354 state => "exc_pinned",
355 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
356 out => [ "in_r4 in_r5", "flags", "none" ] },
357 ins => [ "base", "index", "mem", "left", "right" ],
358 outs => [ "res", "flags", "M" ],
359 emit => '. add%M %binop',
360 am => "source,binary",
364 modified_flags => $status_flags
369 state => "exc_pinned",
370 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
371 ins => [ "base", "index", "mem", "val" ],
372 emit => ". add%M %SI3, %AM",
376 modified_flags => $status_flags
381 state => "exc_pinned",
382 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
383 ins => [ "base", "index", "mem", "val" ],
384 emit => ". add%M %SB3, %AM",
388 modified_flags => $status_flags
392 state => "exc_pinned",
393 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
394 out => [ "in_r4 in_r5", "flags", "none" ] },
395 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
396 outs => [ "res", "flags", "M" ],
397 emit => '. adc%M %binop',
398 am => "source,binary",
402 modified_flags => $status_flags
407 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
408 ins => [ "left", "right" ],
412 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
413 ins => [ "left", "right", "eflags" ],
417 # we should not rematrialize this node. It produces 2 results and has
418 # very strict constraints
419 state => "exc_pinned",
420 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
421 out => [ "eax", "flags", "none", "edx" ] },
422 ins => [ "base", "index", "mem", "left", "right" ],
423 emit => '. mul%M %unop4',
424 outs => [ "res_low", "flags", "M", "res_high" ],
425 am => "source,binary",
428 modified_flags => $status_flags
432 # we should not rematrialize this node. It produces 2 results and has
433 # very strict constraints
435 cmp_attr => "return 1;",
436 reg_req => { in => [ "none", "none" ],
437 out => [ "none", "none", "none", "none" ] },
438 ins => [ "left", "right" ],
439 outs => [ "res_low", "flags", "M", "res_high" ],
444 state => "exc_pinned",
445 # TODO: adjust out requirements for the 3 operand form
446 # (no need for should_be_same then)
447 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
448 out => [ "in_r4 in_r5", "flags", "none" ] },
449 ins => [ "base", "index", "mem", "left", "right" ],
450 outs => [ "res", "flags", "M" ],
451 am => "source,binary",
455 modified_flags => $status_flags
460 state => "exc_pinned",
461 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
462 out => [ "eax", "flags", "none", "edx" ] },
463 ins => [ "base", "index", "mem", "left", "right" ],
464 emit => '. imul%M %unop4',
465 outs => [ "res_low", "flags", "M", "res_high" ],
466 am => "source,binary",
469 modified_flags => $status_flags
474 cmp_attr => "return 1;",
475 reg_req => { in => [ "none", "none" ],
476 out => [ "none", "none", "none", "none" ] },
477 ins => [ "left", "right" ],
478 outs => [ "res_low", "flags", "M", "res_high" ],
483 state => "exc_pinned",
484 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
485 out => [ "in_r4 in_r5", "flags", "none" ] },
486 ins => [ "base", "index", "mem", "left", "right" ],
487 outs => [ "res", "flags", "M" ],
488 am => "source,binary",
489 emit => '. and%M %binop',
493 modified_flags => $status_flags
498 state => "exc_pinned",
499 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
500 ins => [ "base", "index", "mem", "val" ],
501 emit => '. and%M %SI3, %AM',
505 modified_flags => $status_flags
510 state => "exc_pinned",
511 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
512 ins => [ "base", "index", "mem", "val" ],
513 emit => '. and%M %SB3, %AM',
517 modified_flags => $status_flags
522 state => "exc_pinned",
523 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
524 out => [ "in_r4 in_r5", "flags", "none" ] },
525 ins => [ "base", "index", "mem", "left", "right" ],
526 outs => [ "res", "flags", "M" ],
527 am => "source,binary",
528 emit => '. or%M %binop',
532 modified_flags => $status_flags
537 state => "exc_pinned",
538 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
539 ins => [ "base", "index", "mem", "val" ],
540 emit => '. or%M %SI3, %AM',
544 modified_flags => $status_flags
549 state => "exc_pinned",
550 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
551 ins => [ "base", "index", "mem", "val" ],
552 emit => '. or%M %SB3, %AM',
556 modified_flags => $status_flags
561 state => "exc_pinned",
562 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
563 out => [ "in_r4 in_r5", "flags", "none" ] },
564 ins => [ "base", "index", "mem", "left", "right" ],
565 outs => [ "res", "flags", "M" ],
566 am => "source,binary",
567 emit => '. xor%M %binop',
571 modified_flags => $status_flags
577 reg_req => { out => [ "gp", "flags" ] },
578 outs => [ "res", "flags" ],
579 emit => ". xor%M %D0, %D0",
583 modified_flags => $status_flags
588 state => "exc_pinned",
589 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
590 ins => [ "base", "index", "mem", "val" ],
591 emit => '. xor%M %SI3, %AM',
595 modified_flags => $status_flags
600 state => "exc_pinned",
601 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
602 ins => [ "base", "index", "mem", "val" ],
603 emit => '. xor%M %SB3, %AM',
607 modified_flags => $status_flags
612 state => "exc_pinned",
613 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
614 out => [ "in_r4", "flags", "none" ] },
615 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
616 outs => [ "res", "flags", "M" ],
617 am => "source,binary",
618 emit => '. sub%M %binop',
622 modified_flags => $status_flags
627 state => "exc_pinned",
628 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
629 ins => [ "base", "index", "mem", "subtrahend" ],
630 emit => '. sub%M %SI3, %AM',
634 modified_flags => $status_flags
639 state => "exc_pinned",
640 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
641 ins => [ "base", "index", "mem", "subtrahend" ],
642 emit => '. sub%M %SB3, %AM',
646 modified_flags => $status_flags
650 state => "exc_pinned",
651 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
652 out => [ "in_r4 !in_r5", "flags", "none" ] },
653 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
654 outs => [ "res", "flags", "M" ],
655 am => "source,binary",
656 emit => '. sbb%M %binop',
660 modified_flags => $status_flags
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, int ins_permuted",
1100 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1101 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1109 state => "exc_pinned",
1110 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1111 ins => [ "base", "index", "mem","eflags" ],
1112 attr_type => "ia32_condcode_attr_t",
1113 attr => "pn_Cmp pnc, int ins_permuted",
1114 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1115 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1116 emit => '. set%CMP3 %AM',
1124 # (note: leave the false,true order intact to make it compatible with other
1126 state => "exc_pinned",
1127 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1128 out => [ "in_r4 in_r5", "flags", "none" ] },
1129 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1130 outs => [ "res", "flags", "M" ],
1131 am => "source,binary",
1132 attr_type => "ia32_condcode_attr_t",
1133 attr => "int ins_permuted, pn_Cmp pnc",
1134 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
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",
1201 reg_req => { out => [ "gp" ] },
1205 modified_flags => $status_flags,
1211 reg_req => { out => [ "gp_UKNWN:I" ] },
1221 reg_req => { out => [ "vfp_UKNWN:I" ] },
1226 attr_type => "ia32_x87_attr_t",
1232 reg_req => { out => [ "xmm_UKNWN:I" ] },
1241 op_flags => "c|NB|NI",
1242 reg_req => { out => [ "gp_NOREG:I" ] },
1251 op_flags => "c|NB|NI",
1252 reg_req => { out => [ "vfp_NOREG:I" ] },
1257 attr_type => "ia32_x87_attr_t",
1262 op_flags => "c|NB|NI",
1263 reg_req => { out => [ "xmm_NOREG:I" ] },
1273 reg_req => { out => [ "fpcw:I" ] },
1277 modified_flags => $fpcw_flags
1283 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1284 ins => [ "base", "index", "mem" ],
1286 emit => ". fldcw %AM",
1289 modified_flags => $fpcw_flags
1295 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1296 ins => [ "base", "index", "mem", "fpcw" ],
1298 emit => ". fnstcw %AM",
1306 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1314 # we should not rematrialize this node. It has very strict constraints.
1315 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1316 ins => [ "val", "clobbered" ],
1325 # Note that we add additional latency values depending on address mode, so a
1326 # lateny of 0 for load is correct
1330 state => "exc_pinned",
1331 reg_req => { in => [ "gp", "gp", "none" ],
1332 out => [ "gp", "none", "none", "none" ] },
1333 ins => [ "base", "index", "mem" ],
1334 outs => [ "res", "unused", "M", "X_exc" ],
1336 emit => ". mov%EX%.l %AM, %D0",
1342 state => "exc_pinned",
1343 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1344 ins => [ "base", "index", "mem", "val" ],
1345 outs => [ "M", "X_exc" ],
1346 emit => '. mov%M %SI3, %AM',
1354 state => "exc_pinned",
1355 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1356 ins => [ "base", "index", "mem", "val" ],
1357 outs => [ "M", "X_exc" ],
1358 emit => '. mov%M %SB3, %AM',
1366 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1367 ins => [ "base", "index" ],
1368 emit => '. leal %AM, %D0',
1372 # lea doesn't modify the flags, but setting this seems advantageous since it
1373 # increases chances that the Lea is transformed back to an Add
1374 modified_flags => 1,
1378 state => "exc_pinned",
1379 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1380 ins => [ "base", "index", "mem", "val", "stack" ],
1381 emit => '. push%M %unop3',
1382 outs => [ "stack", "M" ],
1383 am => "source,unary",
1389 state => "exc_pinned",
1390 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1391 ins => [ "mem", "stack" ],
1392 outs => [ "res", "M", "unused", "stack" ],
1393 emit => '. pop%M %D0',
1394 latency => 3, # Pop is more expensive than Push on Athlon
1399 state => "exc_pinned",
1400 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1401 ins => [ "mem", "stack" ],
1402 outs => [ "res", "M", "unused", "stack" ],
1403 emit => '. pop%M %D0',
1404 latency => 3, # Pop is more expensive than Push on Athlon
1409 state => "exc_pinned",
1410 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1411 ins => [ "base", "index", "mem", "stack" ],
1412 outs => [ "unused0", "M", "unused1", "stack" ],
1413 emit => '. pop%M %AM',
1414 latency => 3, # Pop is more expensive than Push on Athlon
1419 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1421 outs => [ "frame", "stack", "M" ],
1427 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1429 outs => [ "frame", "stack" ],
1436 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1437 ins => [ "base", "index", "mem", "stack", "size" ],
1438 am => "source,binary",
1439 emit => '. addl %binop',
1441 outs => [ "stack", "M" ],
1443 modified_flags => $status_flags
1448 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1449 ins => [ "base", "index", "mem", "stack", "size" ],
1450 am => "source,binary",
1451 emit => ". subl %binop\n".
1452 ". movl %%esp, %D1",
1454 outs => [ "stack", "addr", "M" ],
1456 modified_flags => $status_flags
1469 reg_req => { out => [ "gp" ] },
1475 # BT supports source address mode, but this is unused yet
1479 state => "exc_pinned",
1480 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1481 ins => [ "left", "right" ],
1482 emit => '. bt%M %S1, %S0',
1485 mode => $mode_flags,
1486 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1491 state => "exc_pinned",
1492 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1493 out => [ "gp", "flags", "none" ] },
1494 ins => [ "base", "index", "mem", "operand" ],
1495 outs => [ "res", "flags", "M" ],
1496 am => "source,binary",
1497 emit => '. bsf%M %unop3, %D0',
1501 modified_flags => $status_flags
1506 state => "exc_pinned",
1507 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1508 out => [ "gp", "flags", "none" ] },
1509 ins => [ "base", "index", "mem", "operand" ],
1510 outs => [ "res", "flags", "M" ],
1511 am => "source,binary",
1512 emit => '. bsr%M %unop3, %D0',
1516 modified_flags => $status_flags
1520 # SSE4.2 or SSE4a popcnt instruction
1524 state => "exc_pinned",
1525 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1526 out => [ "gp", "flags", "none" ] },
1527 ins => [ "base", "index", "mem", "operand" ],
1528 outs => [ "res", "flags", "M" ],
1529 am => "source,binary",
1530 emit => '. popcnt%M %unop3, %D0',
1534 modified_flags => $status_flags
1538 state => "exc_pinned",
1540 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1541 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" ]
1543 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1544 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1545 attr_type => "ia32_call_attr_t",
1546 attr => "unsigned pop, ir_type *call_tp",
1547 am => "source,unary",
1548 units => [ "BRANCH" ],
1549 latency => 4, # random number
1550 modified_flags => $status_flags
1554 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1556 # PS: try gcc __builtin_frame_address(100000) :-)
1559 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1560 ins => [ "frame", "cnt", "tmp" ],
1562 latency => 4, # random number
1563 attr_type => "ia32_climbframe_attr_t",
1564 attr => "unsigned count",
1574 reg_req => { in => [ "gp" ],
1575 out => [ "in_r1" ] },
1576 emit => '. bswap%M %S0',
1584 # bswap16, use xchg here
1588 reg_req => { in => [ "eax ebx ecx edx" ],
1589 out => [ "in_r1" ] },
1590 emit => '. xchg %SB0, %SH0',
1602 reg_req => { in => [ "none" ], out => [ "none" ] },
1611 # Undefined Instruction on ALL x86 CPU's
1615 reg_req => { in => [ "none" ], out => [ "none" ] },
1618 emit => ". .value 0x0b0f",
1629 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1630 ins => [ "port", "value", "mem" ],
1631 emit => '. out%M %SS0, %SI1',
1635 modified_flags => $status_flags
1644 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1645 ins => [ "port", "mem" ],
1646 outs => [ "res", "M" ],
1647 emit => '. in%M %DS0, %SS0',
1651 modified_flags => $status_flags
1655 # Intel style prefetching
1659 state => "exc_pinned",
1660 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1661 ins => [ "base", "index", "mem" ],
1664 emit => ". prefetcht0 %AM",
1670 state => "exc_pinned",
1671 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1672 ins => [ "base", "index", "mem" ],
1675 emit => ". prefetcht1 %AM",
1681 state => "exc_pinned",
1682 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1683 ins => [ "base", "index", "mem" ],
1686 emit => ". prefetcht2 %AM",
1692 state => "exc_pinned",
1693 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1694 ins => [ "base", "index", "mem" ],
1697 emit => ". prefetchnta %AM",
1702 # 3DNow! prefetch instructions
1706 state => "exc_pinned",
1707 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1708 ins => [ "base", "index", "mem" ],
1711 emit => ". prefetch %AM",
1717 state => "exc_pinned",
1718 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1719 ins => [ "base", "index", "mem" ],
1722 emit => ". prefetchw %AM",
1729 reg_req => { out => [ "xmm" ] },
1730 emit => '. xorp%XSD %D0, %D0',
1738 reg_req => { out => [ "xmm" ] },
1739 emit => '. pxor %D0, %D0',
1745 # produces all 1 bits
1748 reg_req => { out => [ "xmm" ] },
1749 emit => '. pcmpeqb %D0, %D0',
1755 # integer shift left, dword
1758 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1759 emit => '. pslld %SI1, %D0',
1765 # integer shift left, qword
1768 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1769 emit => '. psllq %SI1, %D0',
1775 # integer shift right, dword
1778 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1779 emit => '. psrld %SI1, %D0',
1785 # mov from integer to SSE register
1788 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1789 emit => '. movd %S0, %D0',
1797 state => "exc_pinned",
1798 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1799 out => [ "in_r4 in_r5", "flags", "none" ] },
1800 ins => [ "base", "index", "mem", "left", "right" ],
1801 outs => [ "res", "flags", "M" ],
1802 am => "source,binary",
1803 emit => '. add%XXM %binop',
1811 state => "exc_pinned",
1812 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1813 out => [ "in_r4 in_r5", "flags", "none" ] },
1814 ins => [ "base", "index", "mem", "left", "right" ],
1815 outs => [ "res", "flags", "M" ],
1816 am => "source,binary",
1817 emit => '. mul%XXM %binop',
1825 state => "exc_pinned",
1826 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1827 out => [ "in_r4 in_r5", "flags", "none" ] },
1828 ins => [ "base", "index", "mem", "left", "right" ],
1829 outs => [ "res", "flags", "M" ],
1830 am => "source,binary",
1831 emit => '. max%XXM %binop',
1839 state => "exc_pinned",
1840 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1841 out => [ "in_r4 in_r5", "flags", "none" ] },
1842 ins => [ "base", "index", "mem", "left", "right" ],
1843 outs => [ "res", "flags", "M" ],
1844 am => "source,binary",
1845 emit => '. min%XXM %binop',
1853 state => "exc_pinned",
1854 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1855 out => [ "in_r4 in_r5", "flags", "none" ] },
1856 ins => [ "base", "index", "mem", "left", "right" ],
1857 outs => [ "res", "flags", "M" ],
1858 am => "source,binary",
1859 emit => '. andp%XSD %binop',
1867 state => "exc_pinned",
1868 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1869 out => [ "in_r4 in_r5", "flags", "none" ] },
1870 ins => [ "base", "index", "mem", "left", "right" ],
1871 outs => [ "res", "flags", "M" ],
1872 am => "source,binary",
1873 emit => '. orp%XSD %binop',
1881 state => "exc_pinned",
1882 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1883 out => [ "in_r4 in_r5", "flags", "none" ] },
1884 ins => [ "base", "index", "mem", "left", "right" ],
1885 outs => [ "res", "flags", "M" ],
1886 am => "source,binary",
1887 emit => '. xorp%XSD %binop',
1895 state => "exc_pinned",
1896 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1897 out => [ "in_r4 !in_r5", "flags", "none" ] },
1898 ins => [ "base", "index", "mem", "left", "right" ],
1899 outs => [ "res", "flags", "M" ],
1900 am => "source,binary",
1901 emit => '. andnp%XSD %binop',
1909 state => "exc_pinned",
1910 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1911 out => [ "in_r4", "flags", "none" ] },
1912 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1913 outs => [ "res", "flags", "M" ],
1914 am => "source,binary",
1915 emit => '. sub%XXM %binop',
1923 state => "exc_pinned",
1924 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1925 out => [ "in_r4 !in_r5", "flags", "none" ] },
1926 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1927 outs => [ "res", "flags", "M" ],
1928 am => "source,binary",
1929 emit => '. div%XXM %binop',
1936 state => "exc_pinned",
1937 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1938 out => [ "eflags" ] },
1939 ins => [ "base", "index", "mem", "left", "right" ],
1940 outs => [ "flags" ],
1941 am => "source,binary",
1942 attr => "int ins_permuted",
1943 init_attr => "attr->data.ins_permuted = ins_permuted;",
1944 emit => ' .ucomi%XXM %binop',
1947 mode => $mode_flags,
1948 modified_flags => 1,
1953 state => "exc_pinned",
1954 reg_req => { in => [ "gp", "gp", "none" ],
1955 out => [ "xmm", "none", "none", "none" ] },
1956 ins => [ "base", "index", "mem" ],
1957 outs => [ "res", "unused", "M", "X_exc" ],
1958 emit => '. mov%XXM %AM, %D0',
1959 attr => "ir_mode *load_mode",
1960 init_attr => "attr->ls_mode = load_mode;",
1967 state => "exc_pinned",
1968 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1969 ins => [ "base", "index", "mem", "val" ],
1970 outs => [ "M", "X_exc" ],
1971 emit => '. mov%XXM %S3, %AM',
1979 state => "exc_pinned",
1980 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
1981 ins => [ "base", "index", "mem", "val" ],
1983 emit => '. mov%XXM %S3, %AM',
1991 state => "exc_pinned",
1992 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1993 ins => [ "base", "index", "mem", "val" ],
1994 am => "source,unary",
1995 emit => '. cvtsi2ss %unop3, %D0',
2003 state => "exc_pinned",
2004 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2005 ins => [ "base", "index", "mem", "val" ],
2006 am => "source,unary",
2007 emit => '. cvtsi2sd %unop3, %D0',
2016 cmp_attr => "return 1;",
2017 ins => [ "val_high", "val_low" ],
2018 reg_req => { in => [ "none", "none" ], out => [ "none" ] }
2023 cmp_attr => "return 1;",
2025 outs => [ "res_high", "res_low" ],
2026 reg_req => { in => [ "none" ], out => [ "none", "none" ] }
2032 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2033 outs => [ "DST", "SRC", "CNT", "M" ],
2034 attr_type => "ia32_copyb_attr_t",
2035 attr => "unsigned size",
2038 # we don't care about this flag, so no need to mark this node
2039 # modified_flags => [ "DF" ]
2045 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2046 outs => [ "DST", "SRC", "M" ],
2047 attr_type => "ia32_copyb_attr_t",
2048 attr => "unsigned size",
2051 # we don't care about this flag, so no need to mark this node
2052 # modified_flags => [ "DF" ]
2056 state => "exc_pinned",
2057 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2067 state => "exc_pinned",
2068 reg_req => { in => [ "gp", "gp", "none", "gp" ],
2069 out => [ "gp", "none", "none" ] },
2070 ins => [ "base", "index", "mem", "val" ],
2071 outs => [ "res", "flags", "M" ],
2072 am => "source,unary",
2075 attr => "ir_mode *smaller_mode",
2076 init_attr => "attr->ls_mode = smaller_mode;",
2081 state => "exc_pinned",
2082 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2083 out => [ "gp", "none", "none" ] },
2084 ins => [ "base", "index", "mem", "val" ],
2085 outs => [ "res", "flags", "M" ],
2086 am => "source,unary",
2089 attr => "ir_mode *smaller_mode",
2090 init_attr => "attr->ls_mode = smaller_mode;",
2095 state => "exc_pinned",
2096 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2097 ins => [ "base", "index", "mem", "val" ],
2098 am => "source,unary",
2105 state => "exc_pinned",
2106 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2107 ins => [ "base", "index", "mem", "val" ],
2108 am => "source,unary",
2115 state => "exc_pinned",
2116 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2117 ins => [ "base", "index", "mem", "val" ],
2118 am => "source,unary",
2124 # rematerialisation disabled for all float nodes for now, because the fpcw
2125 # handler runs before spilling and we might end up with wrong fpcw then
2129 state => "exc_pinned",
2130 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2131 out => [ "vfp", "none", "none" ] },
2132 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2133 outs => [ "res", "dummy", "M" ],
2134 am => "source,binary",
2138 attr_type => "ia32_x87_attr_t",
2143 state => "exc_pinned",
2144 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2145 out => [ "vfp", "none", "none" ] },
2146 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2147 outs => [ "res", "dummy", "M" ],
2148 am => "source,binary",
2152 attr_type => "ia32_x87_attr_t",
2157 state => "exc_pinned",
2158 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2159 out => [ "vfp", "none", "none" ] },
2160 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2161 outs => [ "res", "dummy", "M" ],
2162 am => "source,binary",
2166 attr_type => "ia32_x87_attr_t",
2170 state => "exc_pinned",
2171 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2172 out => [ "vfp", "none", "none" ] },
2173 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2174 outs => [ "res", "dummy", "M" ],
2175 am => "source,binary",
2178 attr_type => "ia32_x87_attr_t",
2182 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2183 ins => [ "left", "right", "fpcw" ],
2187 attr_type => "ia32_x87_attr_t",
2192 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2197 attr_type => "ia32_x87_attr_t",
2202 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2207 attr_type => "ia32_x87_attr_t",
2213 state => "exc_pinned",
2214 reg_req => { in => [ "gp", "gp", "none" ],
2215 out => [ "vfp", "none", "none", "none" ] },
2216 ins => [ "base", "index", "mem" ],
2217 outs => [ "res", "unused", "M", "X_exc" ],
2218 attr => "ir_mode *load_mode",
2219 init_attr => "attr->attr.ls_mode = load_mode;",
2222 attr_type => "ia32_x87_attr_t",
2228 state => "exc_pinned",
2229 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2230 out => [ "none", "none" ] },
2231 ins => [ "base", "index", "mem", "val" ],
2232 outs => [ "M", "X_exc" ],
2233 attr => "ir_mode *store_mode",
2234 init_attr => "attr->attr.ls_mode = store_mode;",
2238 attr_type => "ia32_x87_attr_t",
2242 state => "exc_pinned",
2243 reg_req => { in => [ "gp", "gp", "none" ],
2244 out => [ "vfp", "none", "none" ] },
2245 outs => [ "res", "unused", "M" ],
2246 ins => [ "base", "index", "mem" ],
2249 attr_type => "ia32_x87_attr_t",
2253 state => "exc_pinned",
2254 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2255 ins => [ "base", "index", "mem", "val", "fpcw" ],
2260 attr_type => "ia32_x87_attr_t",
2263 # SSE3 fisttp instruction
2265 state => "exc_pinned",
2266 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2267 ins => [ "base", "index", "mem", "val" ],
2268 outs => [ "res", "M" ],
2271 attr_type => "ia32_x87_attr_t",
2276 reg_req => { out => [ "vfp" ] },
2281 attr_type => "ia32_x87_attr_t",
2286 reg_req => { out => [ "vfp" ] },
2291 attr_type => "ia32_x87_attr_t",
2296 reg_req => { out => [ "vfp" ] },
2301 attr_type => "ia32_x87_attr_t",
2306 reg_req => { out => [ "vfp" ] },
2311 attr_type => "ia32_x87_attr_t",
2316 reg_req => { out => [ "vfp" ] },
2321 attr_type => "ia32_x87_attr_t",
2326 reg_req => { out => [ "vfp" ] },
2331 attr_type => "ia32_x87_attr_t",
2336 reg_req => { out => [ "vfp" ] },
2341 attr_type => "ia32_x87_attr_t",
2345 # we can't allow to rematerialize this node so we don't
2346 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2348 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2349 ins => [ "left", "right" ],
2350 outs => [ "flags" ],
2351 attr => "int ins_permuted",
2352 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2355 attr_type => "ia32_x87_attr_t",
2361 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2362 ins => [ "left", "right" ],
2363 outs => [ "flags" ],
2364 attr => "int ins_permuted",
2365 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2368 attr_type => "ia32_x87_attr_t",
2374 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2376 outs => [ "flags" ],
2377 attr => "int ins_permuted",
2378 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2381 attr_type => "ia32_x87_attr_t",
2387 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2389 outs => [ "flags" ],
2393 mode => $mode_flags,
2397 state => "exc_pinned",
2398 emit => '. fadd%XM %x87_binop',
2400 attr_type => "ia32_x87_attr_t",
2405 state => "exc_pinned",
2406 emit => '. faddp%XM %x87_binop',
2408 attr_type => "ia32_x87_attr_t",
2413 state => "exc_pinned",
2414 emit => '. fmul%XM %x87_binop',
2416 attr_type => "ia32_x87_attr_t",
2421 state => "exc_pinned",
2422 emit => '. fmulp%XM %x87_binop',,
2424 attr_type => "ia32_x87_attr_t",
2429 state => "exc_pinned",
2430 emit => '. fsub%XM %x87_binop',
2432 attr_type => "ia32_x87_attr_t",
2436 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2437 # are swapped, we work this around in the emitter...
2440 state => "exc_pinned",
2441 # see note about gas bugs
2442 emit => '. fsubrp%XM %x87_binop',
2444 attr_type => "ia32_x87_attr_t",
2449 state => "exc_pinned",
2451 emit => '. fsubr%XM %x87_binop',
2453 attr_type => "ia32_x87_attr_t",
2458 state => "exc_pinned",
2460 # see note about gas bugs before fsubp
2461 emit => '. fsubp%XM %x87_binop',
2463 attr_type => "ia32_x87_attr_t",
2470 attr_type => "ia32_x87_attr_t",
2474 # this node is just here, to keep the simulator running
2475 # we can omit this when a fprem simulation function exists
2477 emit => '. fprem1\n'.
2480 attr_type => "ia32_x87_attr_t",
2485 state => "exc_pinned",
2486 emit => '. fdiv%XM %x87_binop',
2488 attr_type => "ia32_x87_attr_t",
2493 state => "exc_pinned",
2494 # see note about gas bugs before fsubp
2495 emit => '. fdivrp%XM %x87_binop',
2497 attr_type => "ia32_x87_attr_t",
2502 state => "exc_pinned",
2503 emit => '. fdivr%XM %x87_binop',
2505 attr_type => "ia32_x87_attr_t",
2510 state => "exc_pinned",
2511 # see note about gas bugs before fsubp
2512 emit => '. fdivp%XM %x87_binop',
2514 attr_type => "ia32_x87_attr_t",
2521 attr_type => "ia32_x87_attr_t",
2529 attr_type => "ia32_x87_attr_t",
2534 op_flags => "R|L|F",
2535 state => "exc_pinned",
2536 emit => '. fld%XM %AM',
2537 attr_type => "ia32_x87_attr_t",
2543 op_flags => "R|L|F",
2544 state => "exc_pinned",
2545 emit => '. fst%XM %AM',
2547 attr_type => "ia32_x87_attr_t",
2553 op_flags => "R|L|F",
2554 state => "exc_pinned",
2555 emit => '. fstp%XM %AM',
2557 attr_type => "ia32_x87_attr_t",
2563 state => "exc_pinned",
2564 emit => '. fild%XM %AM',
2565 attr_type => "ia32_x87_attr_t",
2571 state => "exc_pinned",
2572 emit => '. fist%XM %AM',
2574 attr_type => "ia32_x87_attr_t",
2580 state => "exc_pinned",
2581 emit => '. fistp%XM %AM',
2583 attr_type => "ia32_x87_attr_t",
2588 # SSE3 fisttp instruction
2590 state => "exc_pinned",
2591 emit => '. fisttp%XM %AM',
2593 attr_type => "ia32_x87_attr_t",
2599 op_flags => "R|c|K",
2601 reg_req => { out => [ "vfp" ] },
2603 attr_type => "ia32_x87_attr_t",
2608 op_flags => "R|c|K",
2610 reg_req => { out => [ "vfp" ] },
2612 attr_type => "ia32_x87_attr_t",
2617 op_flags => "R|c|K",
2619 reg_req => { out => [ "vfp" ] },
2621 attr_type => "ia32_x87_attr_t",
2626 op_flags => "R|c|K",
2628 reg_req => { out => [ "vfp" ] },
2630 attr_type => "ia32_x87_attr_t",
2635 op_flags => "R|c|K",
2637 reg_req => { out => [ "vfp" ] },
2639 attr_type => "ia32_x87_attr_t",
2644 op_flags => "R|c|K",
2646 reg_req => { out => [ "vfp" ] },
2647 emit => '. fldll2t',
2648 attr_type => "ia32_x87_attr_t",
2653 op_flags => "R|c|K",
2655 reg_req => { out => [ "vfp" ] },
2657 attr_type => "ia32_x87_attr_t",
2662 # Note that it is NEVER allowed to do CSE on these nodes
2663 # Moreover, note the virtual register requierements!
2667 reg_req => { out => [ "none" ] },
2668 cmp_attr => "return 1;",
2669 emit => '. fxch %X0',
2670 attr_type => "ia32_x87_attr_t",
2677 reg_req => { out => [ "none" ] },
2678 cmp_attr => "return 1;",
2679 emit => '. fld %X0',
2680 attr_type => "ia32_x87_attr_t",
2686 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2687 cmp_attr => "return 1;",
2688 emit => '. fld %X0',
2689 attr_type => "ia32_x87_attr_t",
2695 reg_req => { out => [ "none" ] },
2696 cmp_attr => "return 1;",
2697 emit => '. fstp %X0',
2698 attr_type => "ia32_x87_attr_t",
2705 reg_req => { out => [ "none" ] },
2706 cmp_attr => "return 1;",
2707 emit => '. ffreep %X0',
2708 attr_type => "ia32_x87_attr_t",
2715 reg_req => { out => [ "none" ] },
2716 cmp_attr => "return 1;",
2718 attr_type => "ia32_x87_attr_t",
2725 reg_req => { out => [ "none" ] },
2726 cmp_attr => "return 1;",
2728 attr_type => "ia32_x87_attr_t",
2735 emit => ". fucom %X1\n".
2737 attr_type => "ia32_x87_attr_t",
2743 emit => ". fucomp %X1\n".
2745 attr_type => "ia32_x87_attr_t",
2751 emit => ". fucompp\n".
2753 attr_type => "ia32_x87_attr_t",
2759 emit => '. fucomi %X1',
2760 attr_type => "ia32_x87_attr_t",
2766 emit => '. fucompi %X1',
2767 attr_type => "ia32_x87_attr_t",
2775 attr_type => "ia32_x87_attr_t",
2779 # Spilling and reloading of SSE registers, hardcoded, not generated #
2783 state => "exc_pinned",
2784 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2785 emit => '. movdqu %D0, %AM',
2786 outs => [ "res", "M" ],
2793 state => "exc_pinned",
2794 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2795 ins => [ "base", "index", "mem", "val" ],
2796 emit => '. movdqu %binop',
2804 # Transform some attributes
2805 foreach my $op (keys(%nodes)) {
2806 my $node = $nodes{$op};
2807 my $op_attr_init = $node->{op_attr_init};
2809 if(defined($op_attr_init)) {
2810 $op_attr_init .= "\n\t";
2815 if(!defined($node->{latency})) {
2817 $node->{latency} = 0;
2819 die("Latency missing for op $op");
2822 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2824 $node->{op_attr_init} = $op_attr_init;