3 # This is the specification for the ia32 assembler Firm-operations
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
13 # The node description is done as a perl hash initializer with the
14 # following structure:
19 # op_flags => "N|L|C|X|I|F|Y|H|c|K",
21 # arity => "0|1|2|3 ... |variable|dynamic|any",
22 # state => "floats|pinned|mem_pinned|exc_pinned",
24 # { type => "type 1", name => "name 1" },
25 # { type => "type 2", name => "name 2" },
28 # comment => "any comment for constructor",
29 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 # cmp_attr => "c source code for comparing node attributes",
31 # outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts
32 # ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts
33 # mode => "mode_Iu" # optional, predefines the mode
34 # emit => "emit code with templates",
35 # attr => "additional attribute arguments for constructor",
36 # init_attr => "emit attribute initialization template",
37 # rd_constructor => "c source code which constructs an ir_node",
38 # hash_func => "name of the hash function for this operation",
39 # latency => "latency of this operation (can be float)"
40 # attr_type => "name of the attribute struct",
41 # modified_flags => [ "CF", ... ] # optional, list of modified flags
44 # ... # (all nodes you need to describe)
46 # ); # close the %nodes initializer
48 # op_flags: flags for the operation, OPTIONAL (default is "N")
49 # the op_flags correspond to the firm irop_flags:
52 # C irop_flag_commutative
53 # X irop_flag_cfopcode
54 # I irop_flag_ip_cfopcode
57 # H irop_flag_highlevel
58 # c irop_flag_constlike
60 # NB irop_flag_dump_noblock
61 # NI irop_flag_dump_noinput
63 # irn_flags: special node flags, OPTIONAL (default is 0)
64 # following irn_flags are supported:
68 # state: state of the operation, OPTIONAL (default is "floats")
70 # arity: arity of the operation, MUST NOT BE OMITTED
72 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
73 # are always the first 3 arguments and are always autmatically
75 # If this key is missing the following arguments will be created:
76 # for i = 1 .. arity: ir_node *op_i
79 # outs: if a node defines more than one output, the names of the projections
80 # nodes having outs having automatically the mode mode_T
81 # example: [ "frame", "stack", "M" ]
83 # comment: OPTIONAL comment for the node constructor
85 # rd_constructor: for every operation there will be a
86 # new_rd_<arch>_<op-name> function with the arguments from above
87 # which creates the ir_node corresponding to the defined operation
88 # you can either put the complete source code of this function here
90 # This key is OPTIONAL. If omitted, the following constructor will
92 # if (!op_<arch>_<op-name>) assert(0);
96 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
99 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
103 # 0 - no special type
104 # 1 - caller save (register must be saved by the caller of a function)
105 # 2 - callee save (register must be saved by the called function)
106 # 4 - ignore (do not assign this register)
107 # 8 - emitter can choose an arbitrary register of this class
108 # 16 - the register is a virtual one
109 # 32 - register represents a state
110 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
113 { name => "edx", type => 1 },
114 { name => "ecx", type => 1 },
115 { name => "eax", type => 1 },
116 { name => "ebx", type => 2 },
117 { name => "esi", type => 2 },
118 { name => "edi", type => 2 },
119 { name => "ebp", type => 2 },
120 { name => "esp", type => 4 },
121 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
122 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
123 { mode => "mode_Iu" }
126 { name => "mm0", type => 4 },
127 { name => "mm1", type => 4 },
128 { name => "mm2", type => 4 },
129 { name => "mm3", type => 4 },
130 { name => "mm4", type => 4 },
131 { name => "mm5", type => 4 },
132 { name => "mm6", type => 4 },
133 { name => "mm7", type => 4 },
134 { mode => "mode_E", flags => "manual_ra" }
137 { name => "xmm0", type => 1 },
138 { name => "xmm1", type => 1 },
139 { name => "xmm2", type => 1 },
140 { name => "xmm3", type => 1 },
141 { name => "xmm4", type => 1 },
142 { name => "xmm5", type => 1 },
143 { name => "xmm6", type => 1 },
144 { name => "xmm7", type => 1 },
145 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
146 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
150 { name => "vf0", type => 1 },
151 { name => "vf1", type => 1 },
152 { name => "vf2", type => 1 },
153 { name => "vf3", type => 1 },
154 { name => "vf4", type => 1 },
155 { name => "vf5", type => 1 },
156 { name => "vf6", type => 1 },
157 { name => "vf7", type => 1 },
158 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
159 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
163 { name => "st0", realname => "st", type => 4 },
164 { name => "st1", realname => "st(1)", type => 4 },
165 { name => "st2", realname => "st(2)", type => 4 },
166 { name => "st3", realname => "st(3)", type => 4 },
167 { name => "st4", realname => "st(4)", type => 4 },
168 { name => "st5", realname => "st(5)", type => 4 },
169 { name => "st6", realname => "st(6)", type => 4 },
170 { name => "st7", realname => "st(7)", type => 4 },
171 { mode => "mode_E", flags => "manual_ra" }
173 fp_cw => [ # the floating point control word
174 { name => "fpcw", type => 4|32 },
175 { mode => "mode_fpcw", flags => "manual_ra|state" }
178 { name => "eflags", type => 0 },
179 { mode => "mode_Iu", flags => "manual_ra" }
184 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
185 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
186 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
187 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
192 bundels_per_cycle => 1
196 S0 => "${arch}_emit_source_register(node, 0);",
197 S1 => "${arch}_emit_source_register(node, 1);",
198 S2 => "${arch}_emit_source_register(node, 2);",
199 S3 => "${arch}_emit_source_register(node, 3);",
200 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
201 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
202 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
203 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
204 SH0 => "${arch}_emit_8bit_high_source_register(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 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
210 X0 => "${arch}_emit_x87_register(node, 0);",
211 X1 => "${arch}_emit_x87_register(node, 1);",
212 EX => "${arch}_emit_extend_suffix(node);",
213 M => "${arch}_emit_mode_suffix(node);",
214 XM => "${arch}_emit_x87_mode_suffix(node);",
215 XXM => "${arch}_emit_xmm_mode_suffix(node);",
216 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
217 AM => "${arch}_emit_am(node);",
218 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
219 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
220 binop => "${arch}_emit_binop(node);",
221 x87_binop => "${arch}_emit_x87_binop(node);",
222 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
223 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
226 #--------------------------------------------------#
229 # _ __ _____ __ _ _ __ ___ _ __ ___ #
230 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
231 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
232 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
235 #--------------------------------------------------#
237 $default_op_attr_type = "ia32_op_attr_t";
238 $default_attr_type = "ia32_attr_t";
239 $default_copy_attr = "ia32_copy_attr";
241 sub ia32_custom_init_attr {
246 if(defined($node->{modified_flags})) {
247 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
249 if(defined($node->{am})) {
250 my $am = $node->{am};
251 if($am eq "source,unary") {
252 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
253 } elsif($am eq "source,binary") {
254 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
255 } elsif($am eq "none") {
258 die("Invalid address mode '$am' specified on op $name");
261 if($node->{state} ne "exc_pinned"
262 and $node->{state} ne "pinned") {
263 die("AM nodes must have pinned or AM pinned state ($name)");
269 $custom_init_attr_func = \&ia32_custom_init_attr;
273 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
274 "\tinit_ia32_x87_attributes(res);".
275 "\tinit_ia32_asm_attributes(res);",
277 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
279 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
280 "\tinit_ia32_call_attributes(res, pop, call_tp);",
281 ia32_condcode_attr_t =>
282 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
283 "\tinit_ia32_condcode_attributes(res, pnc);",
285 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_copyb_attributes(res, size);",
287 ia32_immediate_attr_t =>
288 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
289 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
291 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_x87_attributes(res);",
293 ia32_climbframe_attr_t =>
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_climbframe_attributes(res, count);",
299 ia32_asm_attr_t => "ia32_compare_asm_attr",
300 ia32_attr_t => "ia32_compare_nodes_attr",
301 ia32_call_attr_t => "ia32_compare_call_attr",
302 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
303 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
304 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
305 ia32_x87_attr_t => "ia32_compare_x87_attr",
306 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
312 $mode_xmm = "mode_E";
313 $mode_gp = "mode_Iu";
314 $mode_flags = "mode_Iu";
315 $mode_fpcw = "mode_fpcw";
316 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
317 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
318 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
319 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
326 reg_req => { out => [ "gp_NOREG:I" ] },
327 attr => "ir_entity *symconst, int symconst_sign, long offset",
328 attr_type => "ia32_immediate_attr_t",
329 hash_func => "ia32_hash_Immediate",
337 out_arity => "variable",
338 attr_type => "ia32_asm_attr_t",
339 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
340 init_attr => "attr->asm_text = asm_text;\n".
341 "\tattr->register_map = register_map;\n",
343 modified_flags => $status_flags,
346 # "allocates" a free register
350 reg_req => { out => [ "gp" ] },
355 cmp_attr => "return 1;",
358 #-----------------------------------------------------------------#
361 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
362 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
363 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
364 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
367 #-----------------------------------------------------------------#
369 # commutative operations
373 state => "exc_pinned",
374 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
375 out => [ "in_r4 in_r5", "flags", "none" ] },
376 ins => [ "base", "index", "mem", "left", "right" ],
377 outs => [ "res", "flags", "M" ],
378 emit => '. add%M %binop',
379 am => "source,binary",
383 modified_flags => $status_flags
388 state => "exc_pinned",
389 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
390 ins => [ "base", "index", "mem", "val" ],
391 emit => ". add%M %SI3, %AM",
395 modified_flags => $status_flags
400 state => "exc_pinned",
401 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
402 ins => [ "base", "index", "mem", "val" ],
403 emit => ". add%M %SB3, %AM",
407 modified_flags => $status_flags
411 state => "exc_pinned",
412 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
413 out => [ "in_r4 in_r5", "flags", "none" ] },
414 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
415 outs => [ "res", "flags", "M" ],
416 emit => '. adc%M %binop',
417 am => "source,binary",
421 modified_flags => $status_flags
426 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
427 ins => [ "left", "right" ],
431 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
432 ins => [ "left", "right", "eflags" ],
436 # we should not rematrialize this node. It produces 2 results and has
437 # very strict constraints
438 state => "exc_pinned",
439 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
440 out => [ "eax", "flags", "edx", "none" ] },
441 ins => [ "base", "index", "mem", "left", "right" ],
442 emit => '. mul%M %unop4',
443 outs => [ "res_low", "flags", "res_high", "M" ],
444 am => "source,binary",
447 modified_flags => $status_flags
451 # we should not rematrialize this node. It produces 2 results and has
452 # very strict constraints
454 cmp_attr => "return 1;",
455 outs => [ "EAX", "flags", "EDX", "M" ],
461 state => "exc_pinned",
462 # TODO: adjust out requirements for the 3 operand form
463 # (no need for should_be_same then)
464 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
465 out => [ "in_r4 in_r5", "flags", "none" ] },
466 ins => [ "base", "index", "mem", "left", "right" ],
467 outs => [ "res", "flags", "M" ],
468 am => "source,binary",
472 modified_flags => $status_flags
477 state => "exc_pinned",
478 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
479 out => [ "eax", "flags", "edx", "none" ] },
480 ins => [ "base", "index", "mem", "left", "right" ],
481 emit => '. imul%M %unop4',
482 outs => [ "res_low", "flags", "res_high", "M" ],
483 am => "source,binary",
486 modified_flags => $status_flags
491 cmp_attr => "return 1;",
492 outs => [ "res_low", "res_high", "M" ],
498 state => "exc_pinned",
499 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
500 out => [ "in_r4 in_r5", "flags", "none" ] },
501 ins => [ "base", "index", "mem", "left", "right" ],
502 outs => [ "res", "flags", "M" ],
503 op_modes => "commutative | am | immediate | mode_neutral",
504 am => "source,binary",
505 emit => '. and%M %binop',
509 modified_flags => $status_flags
514 state => "exc_pinned",
515 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
516 ins => [ "base", "index", "mem", "val" ],
517 emit => '. and%M %SI3, %AM',
521 modified_flags => $status_flags
526 state => "exc_pinned",
527 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
528 ins => [ "base", "index", "mem", "val" ],
529 emit => '. and%M %SB3, %AM',
533 modified_flags => $status_flags
538 state => "exc_pinned",
539 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
540 out => [ "in_r4 in_r5", "flags", "none" ] },
541 ins => [ "base", "index", "mem", "left", "right" ],
542 outs => [ "res", "flags", "M" ],
543 am => "source,binary",
544 emit => '. or%M %binop',
548 modified_flags => $status_flags
553 state => "exc_pinned",
554 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
555 ins => [ "base", "index", "mem", "val" ],
556 emit => '. or%M %SI3, %AM',
560 modified_flags => $status_flags
565 state => "exc_pinned",
566 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
567 ins => [ "base", "index", "mem", "val" ],
568 emit => '. or%M %SB3, %AM',
572 modified_flags => $status_flags
577 state => "exc_pinned",
578 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
579 out => [ "in_r4 in_r5", "flags", "none" ] },
580 ins => [ "base", "index", "mem", "left", "right" ],
581 outs => [ "res", "flags", "M" ],
582 am => "source,binary",
583 emit => '. xor%M %binop',
587 modified_flags => $status_flags
593 reg_req => { out => [ "gp", "flags" ] },
594 outs => [ "res", "flags" ],
595 emit => ". xor%M %D0, %D0",
599 modified_flags => $status_flags
604 state => "exc_pinned",
605 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
606 ins => [ "base", "index", "mem", "val" ],
607 emit => '. xor%M %SI3, %AM',
611 modified_flags => $status_flags
616 state => "exc_pinned",
617 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
618 ins => [ "base", "index", "mem", "val" ],
619 emit => '. xor%M %SB3, %AM',
623 modified_flags => $status_flags
626 # not commutative operations
630 state => "exc_pinned",
631 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
632 out => [ "in_r4", "flags", "none" ] },
633 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
634 outs => [ "res", "flags", "M" ],
635 am => "source,binary",
636 emit => '. sub%M %binop',
640 modified_flags => $status_flags
645 state => "exc_pinned",
646 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
647 ins => [ "base", "index", "mem", "subtrahend" ],
648 emit => '. sub%M %SI3, %AM',
652 modified_flags => $status_flags
657 state => "exc_pinned",
658 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
659 ins => [ "base", "index", "mem", "subtrahend" ],
660 emit => '. sub%M %SB3, %AM',
664 modified_flags => $status_flags
668 state => "exc_pinned",
669 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
670 out => [ "in_r4 !in_r5", "flags", "none" ] },
671 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
672 outs => [ "res", "flags", "M" ],
673 am => "source,binary",
674 emit => '. sbb%M %binop',
678 modified_flags => $status_flags
683 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
684 outs => [ "res", "flags" ],
685 emit => ". sbb%M %D0, %D0",
689 modified_flags => $status_flags
693 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
694 ins => [ "minuend", "subtrahend" ],
698 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
699 ins => [ "minuend", "subtrahend", "eflags" ],
704 state => "exc_pinned",
705 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
706 out => [ "eax", "flags", "none", "edx", "none" ] },
707 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
708 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
709 am => "source,unary",
710 emit => ". idiv%M %unop3",
713 modified_flags => $status_flags
718 state => "exc_pinned",
719 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
720 out => [ "eax", "flags", "none", "edx", "none" ] },
721 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
722 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
723 am => "source,unary",
724 emit => ". div%M %unop3",
727 modified_flags => $status_flags
732 reg_req => { in => [ "gp", "ecx" ],
733 out => [ "in_r1 !in_r2", "flags" ] },
734 ins => [ "val", "count" ],
735 outs => [ "res", "flags" ],
736 emit => '. shl%M %SB1, %S0',
740 modified_flags => $status_flags
745 state => "exc_pinned",
746 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
747 ins => [ "base", "index", "mem", "count" ],
748 emit => '. shl%M %SB3, %AM',
752 modified_flags => $status_flags
756 cmp_attr => "return 1;",
757 ins => [ "val", "count", "dep" ],
763 reg_req => { in => [ "gp", "gp", "ecx" ],
764 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
765 ins => [ "val_high", "val_low", "count" ],
766 outs => [ "res", "flags" ],
767 emit => ". shld%M %SB2, %S1, %D0",
771 modified_flags => $status_flags
775 cmp_attr => "return 1;",
776 ins => [ "val_high", "val_low", "count" ],
782 reg_req => { in => [ "gp", "ecx" ],
783 out => [ "in_r1 !in_r2", "flags" ] },
784 ins => [ "val", "count" ],
785 outs => [ "res", "flags" ],
786 emit => '. shr%M %SB1, %S0',
790 modified_flags => $status_flags
795 state => "exc_pinned",
796 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
797 ins => [ "base", "index", "mem", "count" ],
798 emit => '. shr%M %SB3, %AM',
802 modified_flags => $status_flags
806 cmp_attr => "return 1;",
807 ins => [ "val", "count", "dep" ],
813 reg_req => { in => [ "gp", "gp", "ecx" ],
814 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
815 ins => [ "val_high", "val_low", "count" ],
816 outs => [ "res", "flags" ],
817 emit => ". shrd%M %SB2, %S1, %D0",
821 modified_flags => $status_flags
825 cmp_attr => "return 1;",
827 ins => [ "val_high", "val_low", "count" ],
832 reg_req => { in => [ "gp", "ecx" ],
833 out => [ "in_r1 !in_r2", "flags" ] },
834 ins => [ "val", "count" ],
835 outs => [ "res", "flags" ],
836 emit => '. sar%M %SB1, %S0',
840 modified_flags => $status_flags
845 state => "exc_pinned",
846 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
847 ins => [ "base", "index", "mem", "count" ],
848 emit => '. sar%M %SB3, %AM',
852 modified_flags => $status_flags
856 cmp_attr => "return 1;",
857 ins => [ "val", "count", "dep" ],
863 reg_req => { in => [ "gp", "ecx" ],
864 out => [ "in_r1 !in_r2", "flags" ] },
865 ins => [ "val", "count" ],
866 outs => [ "res", "flags" ],
867 emit => '. ror%M %SB1, %S0',
871 modified_flags => $status_flags
876 state => "exc_pinned",
877 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
878 ins => [ "base", "index", "mem", "count" ],
879 emit => '. ror%M %SB3, %AM',
883 modified_flags => $status_flags
888 reg_req => { in => [ "gp", "ecx" ],
889 out => [ "in_r1 !in_r2", "flags" ] },
890 ins => [ "val", "count" ],
891 outs => [ "res", "flags" ],
892 emit => '. rol%M %SB1, %S0',
896 modified_flags => $status_flags
901 state => "exc_pinned",
902 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
903 ins => [ "base", "index", "mem", "count" ],
904 emit => '. rol%M %SB3, %AM',
908 modified_flags => $status_flags
915 reg_req => { in => [ "gp" ],
916 out => [ "in_r1", "flags" ] },
917 emit => '. neg%M %S0',
919 outs => [ "res", "flags" ],
923 modified_flags => $status_flags
928 state => "exc_pinned",
929 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
930 ins => [ "base", "index", "mem" ],
931 emit => '. neg%M %AM',
935 modified_flags => $status_flags
940 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
941 outs => [ "low_res", "high_res" ],
944 modified_flags => $status_flags
950 reg_req => { in => [ "gp" ],
951 out => [ "in_r1", "flags" ] },
953 outs => [ "res", "flags" ],
954 emit => '. inc%M %S0',
958 modified_flags => $status_flags_wo_cf
963 state => "exc_pinned",
964 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
965 ins => [ "base", "index", "mem" ],
966 emit => '. inc%M %AM',
970 modified_flags => $status_flags_wo_cf
975 reg_req => { in => [ "gp" ],
976 out => [ "in_r1", "flags" ] },
978 outs => [ "res", "flags" ],
979 emit => '. dec%M %S0',
983 modified_flags => $status_flags_wo_cf
988 state => "exc_pinned",
989 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
990 ins => [ "base", "index", "mem" ],
991 emit => '. dec%M %AM',
995 modified_flags => $status_flags_wo_cf
1000 reg_req => { in => [ "gp" ],
1001 out => [ "in_r1", "flags" ] },
1003 outs => [ "res", "flags" ],
1004 emit => '. not%M %S0',
1013 state => "exc_pinned",
1014 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1015 ins => [ "base", "index", "mem" ],
1016 emit => '. not%M %AM',
1024 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1028 mode => $mode_flags,
1029 modified_flags => $status_flags
1033 reg_req => { out => [ "flags" ] },
1037 mode => $mode_flags,
1038 modified_flags => $status_flags
1045 state => "exc_pinned",
1046 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1047 out => [ "flags", "none", "none" ] },
1048 ins => [ "base", "index", "mem", "left", "right" ],
1049 outs => [ "eflags", "unused", "M" ],
1050 am => "source,binary",
1051 emit => '. cmp%M %binop',
1052 attr => "int ins_permuted, int cmp_unsigned",
1053 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1054 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1057 mode => $mode_flags,
1058 modified_flags => $status_flags
1063 state => "exc_pinned",
1064 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1065 ins => [ "base", "index", "mem", "left", "right" ],
1066 outs => [ "eflags" ],
1067 am => "source,binary",
1068 emit => '. cmpb %binop',
1069 attr => "int ins_permuted, int cmp_unsigned",
1070 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1071 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1074 mode => $mode_flags,
1075 modified_flags => $status_flags
1080 state => "exc_pinned",
1081 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1082 ins => [ "base", "index", "mem", "left", "right" ],
1083 outs => [ "eflags" ],
1084 am => "source,binary",
1085 emit => '. test%M %binop',
1086 attr => "int ins_permuted, int cmp_unsigned",
1087 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1088 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1091 mode => $mode_flags,
1092 modified_flags => $status_flags
1097 state => "exc_pinned",
1098 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1099 ins => [ "base", "index", "mem", "left", "right" ],
1100 outs => [ "eflags" ],
1101 am => "source,binary",
1102 emit => '. testb %binop',
1103 attr => "int ins_permuted, int cmp_unsigned",
1104 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1105 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1108 mode => $mode_flags,
1109 modified_flags => $status_flags
1114 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1115 ins => [ "eflags" ],
1116 attr_type => "ia32_condcode_attr_t",
1117 attr => "pn_Cmp pnc, int ins_permuted",
1118 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1119 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1120 emit => '. set%CMP0 %DB0',
1128 state => "exc_pinned",
1129 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1130 ins => [ "base", "index", "mem","eflags" ],
1131 attr_type => "ia32_condcode_attr_t",
1132 attr => "pn_Cmp pnc, int ins_permuted",
1133 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1134 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1135 emit => '. set%CMP3 %AM',
1143 # (note: leave the false,true order intact to make it compatible with other
1145 state => "exc_pinned",
1146 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1147 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1148 am => "source,binary",
1149 attr_type => "ia32_condcode_attr_t",
1150 attr => "int ins_permuted, pn_Cmp pnc",
1151 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1159 op_flags => "L|X|Y",
1160 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1161 ins => [ "eflags" ],
1162 outs => [ "false", "true" ],
1163 attr_type => "ia32_condcode_attr_t",
1164 attr => "pn_Cmp pnc",
1166 units => [ "BRANCH" ],
1171 op_flags => "L|X|Y",
1172 reg_req => { in => [ "gp" ], out => [ "none" ] },
1174 attr_type => "ia32_condcode_attr_t",
1177 units => [ "BRANCH" ],
1178 modified_flags => $status_flags,
1184 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1185 ins => [ "base", "index", "mem", "target" ],
1186 am => "source,unary",
1187 emit => '. jmp *%unop3',
1189 units => [ "BRANCH" ],
1196 reg_req => { out => [ "gp" ] },
1198 attr => "ir_entity *symconst, int symconst_sign, long offset",
1199 attr_type => "ia32_immediate_attr_t",
1206 reg_req => { out => [ "gp" ] },
1210 modified_flags => $status_flags,
1216 reg_req => { out => [ "gp_UKNWN:I" ] },
1226 reg_req => { out => [ "vfp_UKNWN:I" ] },
1231 attr_type => "ia32_x87_attr_t",
1237 reg_req => { out => [ "xmm_UKNWN:I" ] },
1246 op_flags => "c|NB|NI",
1247 reg_req => { out => [ "gp_NOREG:I" ] },
1256 op_flags => "c|NB|NI",
1257 reg_req => { out => [ "vfp_NOREG:I" ] },
1262 attr_type => "ia32_x87_attr_t",
1267 op_flags => "c|NB|NI",
1268 reg_req => { out => [ "xmm_NOREG:I" ] },
1278 reg_req => { out => [ "fpcw:I" ] },
1282 modified_flags => $fpcw_flags
1288 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1289 ins => [ "base", "index", "mem" ],
1291 emit => ". fldcw %AM",
1294 modified_flags => $fpcw_flags
1300 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1301 ins => [ "base", "index", "mem", "fpcw" ],
1303 emit => ". fnstcw %AM",
1311 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1319 # we should not rematrialize this node. It has very strict constraints.
1320 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1321 ins => [ "val", "clobbered" ],
1330 # Note that we add additional latency values depending on address mode, so a
1331 # lateny of 0 for load is correct
1335 state => "exc_pinned",
1336 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1337 ins => [ "base", "index", "mem" ],
1338 outs => [ "res", "M", "X_exc" ],
1340 emit => ". mov%EX%.l %AM, %D0",
1346 state => "exc_pinned",
1347 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1348 ins => [ "base", "index", "mem", "val" ],
1349 outs => [ "M", "X_exc" ],
1350 emit => '. mov%M %SI3, %AM',
1358 state => "exc_pinned",
1359 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1360 ins => [ "base", "index", "mem", "val" ],
1361 outs => [ "M", "X_exc" ],
1362 emit => '. mov%M %SB3, %AM',
1370 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1371 ins => [ "base", "index" ],
1372 emit => '. leal %AM, %D0',
1376 # lea doesn't modify the flags, but setting this seems advantageous since it
1377 # increases chances that the Lea is transformed back to an Add
1378 modified_flags => 1,
1382 state => "exc_pinned",
1383 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1384 ins => [ "base", "index", "mem", "val", "stack" ],
1385 emit => '. push%M %unop3',
1386 outs => [ "stack", "M" ],
1387 am => "source,unary",
1393 state => "exc_pinned",
1394 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1395 ins => [ "mem", "stack" ],
1396 outs => [ "res", "M", "unused", "stack" ],
1397 emit => '. pop%M %D0',
1398 latency => 3, # Pop is more expensive than Push on Athlon
1403 state => "exc_pinned",
1404 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1405 ins => [ "mem", "stack" ],
1406 outs => [ "res", "M", "unused", "stack" ],
1407 emit => '. pop%M %D0',
1408 latency => 3, # Pop is more expensive than Push on Athlon
1413 state => "exc_pinned",
1414 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1415 ins => [ "base", "index", "mem", "stack" ],
1416 outs => [ "unused0", "M", "unused1", "stack" ],
1417 emit => '. pop%M %AM',
1418 latency => 3, # Pop is more expensive than Push on Athlon
1423 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1425 outs => [ "frame", "stack", "M" ],
1431 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1433 outs => [ "frame", "stack" ],
1440 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1441 ins => [ "base", "index", "mem", "stack", "size" ],
1442 am => "source,binary",
1443 emit => '. addl %binop',
1445 outs => [ "stack", "M" ],
1447 modified_flags => $status_flags
1452 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1453 ins => [ "base", "index", "mem", "stack", "size" ],
1454 am => "source,binary",
1455 emit => ". subl %binop\n".
1456 ". movl %%esp, %D1",
1458 outs => [ "stack", "addr", "M" ],
1460 modified_flags => $status_flags
1473 reg_req => { out => [ "gp" ] },
1479 # BT supports source address mode, but this is unused yet
1483 state => "exc_pinned",
1484 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1485 ins => [ "left", "right" ],
1486 emit => '. bt%M %S1, %S0',
1489 mode => $mode_flags,
1490 modified_flags => $status_flags # only CF is set, but the other flags are undefined
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 => '. bsf%M %unop3, %D0',
1505 modified_flags => $status_flags
1510 state => "exc_pinned",
1511 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1512 out => [ "gp", "flags", "none" ] },
1513 ins => [ "base", "index", "mem", "operand" ],
1514 outs => [ "res", "flags", "M" ],
1515 am => "source,binary",
1516 emit => '. bsr%M %unop3, %D0',
1520 modified_flags => $status_flags
1524 # SSE4.2 or SSE4a popcnt instruction
1528 state => "exc_pinned",
1529 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1530 out => [ "gp", "flags", "none" ] },
1531 ins => [ "base", "index", "mem", "operand" ],
1532 outs => [ "res", "flags", "M" ],
1533 am => "source,binary",
1534 emit => '. popcnt%M %unop3, %D0',
1538 modified_flags => $status_flags
1542 state => "exc_pinned",
1544 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1545 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" ]
1547 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1548 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1549 attr_type => "ia32_call_attr_t",
1550 attr => "unsigned pop, ir_type *call_tp",
1551 am => "source,unary",
1552 units => [ "BRANCH" ],
1553 latency => 4, # random number
1554 modified_flags => $status_flags
1558 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1560 # PS: try gcc __builtin_frame_address(100000) :-)
1563 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1564 ins => [ "frame", "cnt", "tmp" ],
1566 latency => 4, # random number
1567 attr_type => "ia32_climbframe_attr_t",
1568 attr => "unsigned count",
1578 reg_req => { in => [ "gp" ],
1579 out => [ "in_r1" ] },
1580 emit => '. bswap%M %S0',
1588 # bswap16, use xchg here
1592 reg_req => { in => [ "eax ebx ecx edx" ],
1593 out => [ "in_r1" ] },
1594 emit => '. xchg %SB0, %SH0',
1606 reg_req => { in => [ "none" ], out => [ "none" ] },
1615 # Undefined Instruction on ALL x86 CPU's
1619 reg_req => { in => [ "none" ], out => [ "none" ] },
1622 emit => ". .value 0x0b0f",
1628 # Intel style prefetching
1632 state => "exc_pinned",
1633 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1634 ins => [ "base", "index", "mem" ],
1637 emit => ". prefetcht0 %AM",
1643 state => "exc_pinned",
1644 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1645 ins => [ "base", "index", "mem" ],
1648 emit => ". prefetcht1 %AM",
1654 state => "exc_pinned",
1655 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1656 ins => [ "base", "index", "mem" ],
1659 emit => ". prefetcht2 %AM",
1665 state => "exc_pinned",
1666 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1667 ins => [ "base", "index", "mem" ],
1670 emit => ". prefetchnta %AM",
1675 # 3DNow! prefetch instructions
1679 state => "exc_pinned",
1680 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1681 ins => [ "base", "index", "mem" ],
1684 emit => ". prefetch %AM",
1690 state => "exc_pinned",
1691 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1692 ins => [ "base", "index", "mem" ],
1695 emit => ". prefetchw %AM",
1699 #-----------------------------------------------------------------------------#
1700 # _____ _____ ______ __ _ _ _ #
1701 # / ____/ ____| ____| / _| | | | | | #
1702 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1703 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1704 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1705 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1706 #-----------------------------------------------------------------------------#
1711 reg_req => { out => [ "xmm" ] },
1712 emit => '. xorp%XSD %D0, %D0',
1720 reg_req => { out => [ "xmm" ] },
1721 emit => '. pxor %D0, %D0',
1727 # produces all 1 bits
1730 reg_req => { out => [ "xmm" ] },
1731 emit => '. pcmpeqb %D0, %D0',
1737 # integer shift left, dword
1740 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1741 emit => '. pslld %SI1, %D0',
1747 # integer shift left, qword
1750 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1751 emit => '. psllq %SI1, %D0',
1757 # integer shift right, dword
1760 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1761 emit => '. psrld %SI1, %D0',
1767 # mov from integer to SSE register
1770 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1771 emit => '. movd %S0, %D0',
1777 # commutative operations
1781 state => "exc_pinned",
1782 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1783 ins => [ "base", "index", "mem", "left", "right" ],
1784 am => "source,binary",
1785 emit => '. add%XXM %binop',
1793 state => "exc_pinned",
1794 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1795 ins => [ "base", "index", "mem", "left", "right" ],
1796 am => "source,binary",
1797 emit => '. mul%XXM %binop',
1805 state => "exc_pinned",
1806 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1807 ins => [ "base", "index", "mem", "left", "right" ],
1808 am => "source,binary",
1809 emit => '. max%XXM %binop',
1817 state => "exc_pinned",
1818 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1819 ins => [ "base", "index", "mem", "left", "right" ],
1820 am => "source,binary",
1821 emit => '. min%XXM %binop',
1829 state => "exc_pinned",
1830 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1831 ins => [ "base", "index", "mem", "left", "right" ],
1832 am => "source,binary",
1833 emit => '. andp%XSD %binop',
1841 state => "exc_pinned",
1842 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1843 ins => [ "base", "index", "mem", "left", "right" ],
1844 am => "source,binary",
1845 emit => '. orp%XSD %binop',
1853 state => "exc_pinned",
1854 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1855 ins => [ "base", "index", "mem", "left", "right" ],
1856 am => "source,binary",
1857 emit => '. xorp%XSD %binop',
1863 # not commutative operations
1867 state => "exc_pinned",
1868 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1869 ins => [ "base", "index", "mem", "left", "right" ],
1870 am => "source,binary",
1871 emit => '. andnp%XSD %binop',
1879 state => "exc_pinned",
1880 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1881 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1882 am => "source,binary",
1883 emit => '. sub%XXM %binop',
1891 state => "exc_pinned",
1892 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1893 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1894 am => "source,binary",
1895 outs => [ "res", "M" ],
1896 emit => '. div%XXM %binop',
1905 state => "exc_pinned",
1906 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1907 ins => [ "base", "index", "mem", "left", "right" ],
1908 outs => [ "flags" ],
1909 am => "source,binary",
1910 attr => "int ins_permuted",
1911 init_attr => "attr->data.ins_permuted = ins_permuted;",
1912 emit => ' .ucomi%XXM %binop',
1915 mode => $mode_flags,
1916 modified_flags => 1,
1923 state => "exc_pinned",
1924 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1925 ins => [ "base", "index", "mem" ],
1926 outs => [ "res", "M", "X_exc" ],
1927 emit => '. mov%XXM %AM, %D0',
1928 attr => "ir_mode *load_mode",
1929 init_attr => "attr->ls_mode = load_mode;",
1936 state => "exc_pinned",
1937 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1938 ins => [ "base", "index", "mem", "val" ],
1939 outs => [ "M", "X_exc" ],
1940 emit => '. mov%XXM %S3, %AM',
1948 state => "exc_pinned",
1949 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1950 ins => [ "base", "index", "mem", "val" ],
1951 emit => '. mov%XXM %S3, %AM',
1959 state => "exc_pinned",
1960 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1961 ins => [ "base", "index", "mem", "val" ],
1962 am => "source,unary",
1963 emit => '. cvtsi2ss %unop3, %D0',
1971 state => "exc_pinned",
1972 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1973 ins => [ "base", "index", "mem", "val" ],
1974 am => "source,unary",
1975 emit => '. cvtsi2sd %unop3, %D0',
1984 cmp_attr => "return 1;",
1985 ins => [ "val_high", "val_low" ],
1990 cmp_attr => "return 1;",
1992 outs => [ "res_high", "res_low" ],
2000 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2001 outs => [ "DST", "SRC", "CNT", "M" ],
2002 attr_type => "ia32_copyb_attr_t",
2003 attr => "unsigned size",
2006 # we don't care about this flag, so no need to mark this node
2007 # modified_flags => [ "DF" ]
2013 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2014 outs => [ "DST", "SRC", "M" ],
2015 attr_type => "ia32_copyb_attr_t",
2016 attr => "unsigned size",
2019 # we don't care about this flag, so no need to mark this node
2020 # modified_flags => [ "DF" ]
2026 state => "exc_pinned",
2027 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2037 state => "exc_pinned",
2038 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
2039 ins => [ "base", "index", "mem", "val" ],
2040 outs => [ "res", "M" ],
2041 am => "source,unary",
2044 attr => "ir_mode *smaller_mode",
2045 init_attr => "attr->ls_mode = smaller_mode;",
2050 state => "exc_pinned",
2051 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
2052 ins => [ "base", "index", "mem", "val" ],
2053 am => "source,unary",
2056 attr => "ir_mode *smaller_mode",
2057 init_attr => "attr->ls_mode = smaller_mode;",
2062 state => "exc_pinned",
2063 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2064 ins => [ "base", "index", "mem", "val" ],
2065 am => "source,unary",
2072 state => "exc_pinned",
2073 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2074 ins => [ "base", "index", "mem", "val" ],
2075 am => "source,unary",
2082 state => "exc_pinned",
2083 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2084 ins => [ "base", "index", "mem", "val" ],
2085 am => "source,unary",
2091 #----------------------------------------------------------#
2093 # (_) | | | | / _| | | | #
2094 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
2095 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
2096 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
2097 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
2099 # _ __ ___ __| | ___ ___ #
2100 # | '_ \ / _ \ / _` |/ _ \/ __| #
2101 # | | | | (_) | (_| | __/\__ \ #
2102 # |_| |_|\___/ \__,_|\___||___/ #
2103 #----------------------------------------------------------#
2105 # rematerialisation disabled for all float nodes for now, because the fpcw
2106 # handler runs before spilling and we might end up with wrong fpcw then
2110 state => "exc_pinned",
2111 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2112 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2113 am => "source,binary",
2117 attr_type => "ia32_x87_attr_t",
2122 state => "exc_pinned",
2123 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2124 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2125 am => "source,binary",
2129 attr_type => "ia32_x87_attr_t",
2134 state => "exc_pinned",
2135 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2136 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2137 am => "source,binary",
2141 attr_type => "ia32_x87_attr_t",
2145 state => "exc_pinned",
2146 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
2147 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2148 am => "source,binary",
2149 outs => [ "res", "M" ],
2152 attr_type => "ia32_x87_attr_t",
2156 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2157 ins => [ "left", "right", "fpcw" ],
2161 attr_type => "ia32_x87_attr_t",
2166 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2171 attr_type => "ia32_x87_attr_t",
2176 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2181 attr_type => "ia32_x87_attr_t",
2184 # virtual Load and Store
2189 state => "exc_pinned",
2190 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
2191 ins => [ "base", "index", "mem" ],
2192 outs => [ "res", "M", "X_exc" ],
2193 attr => "ir_mode *load_mode",
2194 init_attr => "attr->attr.ls_mode = load_mode;",
2197 attr_type => "ia32_x87_attr_t",
2203 state => "exc_pinned",
2204 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
2205 ins => [ "base", "index", "mem", "val" ],
2206 outs => [ "M", "X_exc" ],
2207 attr => "ir_mode *store_mode",
2208 init_attr => "attr->attr.ls_mode = store_mode;",
2212 attr_type => "ia32_x87_attr_t",
2218 state => "exc_pinned",
2219 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
2220 outs => [ "res", "M" ],
2221 ins => [ "base", "index", "mem" ],
2224 attr_type => "ia32_x87_attr_t",
2228 state => "exc_pinned",
2229 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2230 ins => [ "base", "index", "mem", "val", "fpcw" ],
2234 attr_type => "ia32_x87_attr_t",
2237 # SSE3 fisttp instruction
2239 state => "exc_pinned",
2240 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2241 ins => [ "base", "index", "mem", "val" ],
2242 outs => [ "res", "M" ],
2245 attr_type => "ia32_x87_attr_t",
2253 reg_req => { out => [ "vfp" ] },
2258 attr_type => "ia32_x87_attr_t",
2263 reg_req => { out => [ "vfp" ] },
2268 attr_type => "ia32_x87_attr_t",
2273 reg_req => { out => [ "vfp" ] },
2278 attr_type => "ia32_x87_attr_t",
2283 reg_req => { out => [ "vfp" ] },
2288 attr_type => "ia32_x87_attr_t",
2293 reg_req => { out => [ "vfp" ] },
2298 attr_type => "ia32_x87_attr_t",
2303 reg_req => { out => [ "vfp" ] },
2308 attr_type => "ia32_x87_attr_t",
2313 reg_req => { out => [ "vfp" ] },
2318 attr_type => "ia32_x87_attr_t",
2324 # we can't allow to rematerialize this node so we don't have
2325 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2327 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2328 ins => [ "left", "right" ],
2329 outs => [ "flags" ],
2330 attr => "int ins_permuted",
2331 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2334 attr_type => "ia32_x87_attr_t",
2340 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2341 ins => [ "left", "right" ],
2342 outs => [ "flags" ],
2343 attr => "int ins_permuted",
2344 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2347 attr_type => "ia32_x87_attr_t",
2353 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2355 outs => [ "flags" ],
2356 attr => "int ins_permuted",
2357 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2360 attr_type => "ia32_x87_attr_t",
2366 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2368 outs => [ "flags" ],
2372 mode => $mode_flags,
2375 #------------------------------------------------------------------------#
2376 # ___ _____ __ _ _ _ #
2377 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2378 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2379 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2380 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2381 #------------------------------------------------------------------------#
2383 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2384 # are swapped, we work this around in the emitter...
2387 state => "exc_pinned",
2388 rd_constructor => "NONE",
2390 emit => '. fadd%XM %x87_binop',
2392 attr_type => "ia32_x87_attr_t",
2396 state => "exc_pinned",
2397 rd_constructor => "NONE",
2399 emit => '. faddp%XM %x87_binop',
2401 attr_type => "ia32_x87_attr_t",
2405 state => "exc_pinned",
2406 rd_constructor => "NONE",
2408 emit => '. fmul%XM %x87_binop',
2410 attr_type => "ia32_x87_attr_t",
2414 state => "exc_pinned",
2415 rd_constructor => "NONE",
2417 emit => '. fmulp%XM %x87_binop',,
2419 attr_type => "ia32_x87_attr_t",
2423 state => "exc_pinned",
2424 rd_constructor => "NONE",
2426 emit => '. fsub%XM %x87_binop',
2428 attr_type => "ia32_x87_attr_t",
2432 state => "exc_pinned",
2433 rd_constructor => "NONE",
2435 # see note about gas bugs
2436 emit => '. fsubrp%XM %x87_binop',
2438 attr_type => "ia32_x87_attr_t",
2442 state => "exc_pinned",
2443 rd_constructor => "NONE",
2446 emit => '. fsubr%XM %x87_binop',
2448 attr_type => "ia32_x87_attr_t",
2452 state => "exc_pinned",
2453 rd_constructor => "NONE",
2456 # see note about gas bugs
2457 emit => '. fsubp%XM %x87_binop',
2459 attr_type => "ia32_x87_attr_t",
2463 rd_constructor => "NONE",
2467 attr_type => "ia32_x87_attr_t",
2470 # this node is just here, to keep the simulator running
2471 # we can omit this when a fprem simulation function exists
2473 rd_constructor => "NONE",
2475 emit => '. fprem1\n'.
2478 attr_type => "ia32_x87_attr_t",
2482 state => "exc_pinned",
2483 rd_constructor => "NONE",
2485 emit => '. fdiv%XM %x87_binop',
2487 attr_type => "ia32_x87_attr_t",
2491 state => "exc_pinned",
2492 rd_constructor => "NONE",
2494 # see note about gas bugs
2495 emit => '. fdivrp%XM %x87_binop',
2497 attr_type => "ia32_x87_attr_t",
2501 state => "exc_pinned",
2502 rd_constructor => "NONE",
2504 emit => '. fdivr%XM %x87_binop',
2506 attr_type => "ia32_x87_attr_t",
2510 state => "exc_pinned",
2511 rd_constructor => "NONE",
2513 # see note about gas bugs
2514 emit => '. fdivp%XM %x87_binop',
2516 attr_type => "ia32_x87_attr_t",
2520 rd_constructor => "NONE",
2524 attr_type => "ia32_x87_attr_t",
2529 rd_constructor => "NONE",
2533 attr_type => "ia32_x87_attr_t",
2536 # x87 Load and Store
2539 rd_constructor => "NONE",
2540 op_flags => "R|L|F",
2541 state => "exc_pinned",
2543 emit => '. fld%XM %AM',
2544 attr_type => "ia32_x87_attr_t",
2549 rd_constructor => "NONE",
2550 op_flags => "R|L|F",
2551 state => "exc_pinned",
2553 emit => '. fst%XM %AM',
2555 attr_type => "ia32_x87_attr_t",
2560 rd_constructor => "NONE",
2561 op_flags => "R|L|F",
2562 state => "exc_pinned",
2564 emit => '. fstp%XM %AM',
2566 attr_type => "ia32_x87_attr_t",
2573 state => "exc_pinned",
2574 rd_constructor => "NONE",
2576 emit => '. fild%XM %AM',
2577 attr_type => "ia32_x87_attr_t",
2582 state => "exc_pinned",
2583 rd_constructor => "NONE",
2585 emit => '. fist%XM %AM',
2587 attr_type => "ia32_x87_attr_t",
2592 state => "exc_pinned",
2593 rd_constructor => "NONE",
2595 emit => '. fistp%XM %AM',
2597 attr_type => "ia32_x87_attr_t",
2601 # SSE3 firsttp instruction
2603 state => "exc_pinned",
2604 rd_constructor => "NONE",
2606 emit => '. fisttp%XM %AM',
2608 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" ] },
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 op_flags => "R|c|K",
2662 reg_req => { out => [ "vfp" ] },
2663 emit => '. fldll2t',
2664 attr_type => "ia32_x87_attr_t",
2669 op_flags => "R|c|K",
2671 reg_req => { out => [ "vfp" ] },
2673 attr_type => "ia32_x87_attr_t",
2678 # Note that it is NEVER allowed to do CSE on these nodes
2679 # Moreover, note the virtual register requierements!
2684 cmp_attr => "return 1;",
2685 emit => '. fxch %X0',
2686 attr_type => "ia32_x87_attr_t",
2694 cmp_attr => "return 1;",
2695 emit => '. fld %X0',
2696 attr_type => "ia32_x87_attr_t",
2702 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2703 cmp_attr => "return 1;",
2704 emit => '. fld %X0',
2705 attr_type => "ia32_x87_attr_t",
2712 cmp_attr => "return 1;",
2713 emit => '. fstp %X0',
2714 attr_type => "ia32_x87_attr_t",
2722 cmp_attr => "return 1;",
2723 emit => '. ffreep %X0',
2724 attr_type => "ia32_x87_attr_t",
2732 cmp_attr => "return 1;",
2734 attr_type => "ia32_x87_attr_t",
2742 cmp_attr => "return 1;",
2744 attr_type => "ia32_x87_attr_t",
2753 emit => ". fucom %X1\n".
2755 attr_type => "ia32_x87_attr_t",
2761 emit => ". fucomp %X1\n".
2763 attr_type => "ia32_x87_attr_t",
2769 emit => ". fucompp\n".
2771 attr_type => "ia32_x87_attr_t",
2777 emit => '. fucomi %X1',
2778 attr_type => "ia32_x87_attr_t",
2784 emit => '. fucompi %X1',
2785 attr_type => "ia32_x87_attr_t",
2793 attr_type => "ia32_x87_attr_t",
2798 # -------------------------------------------------------------------------------- #
2799 # ____ ____ _____ _ _ #
2800 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2801 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2802 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2803 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2805 # -------------------------------------------------------------------------------- #
2808 # Spilling and reloading of SSE registers, hardcoded, not generated #
2812 state => "exc_pinned",
2813 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2814 emit => '. movdqu %D0, %AM',
2815 outs => [ "res", "M" ],
2822 state => "exc_pinned",
2823 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2824 ins => [ "base", "index", "mem", "val" ],
2825 emit => '. movdqu %binop',
2833 # Include the generated SIMD node specification written by the SIMD optimization
2834 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2835 unless ($return = do $my_script_name) {
2836 warn "couldn't parse $my_script_name: $@" if $@;
2837 warn "couldn't do $my_script_name: $!" unless defined $return;
2838 warn "couldn't run $my_script_name" unless $return;
2841 # Transform some attributes
2842 foreach my $op (keys(%nodes)) {
2843 my $node = $nodes{$op};
2844 my $op_attr_init = $node->{op_attr_init};
2846 if(defined($op_attr_init)) {
2847 $op_attr_init .= "\n\t";
2852 if(!defined($node->{latency})) {
2854 $node->{latency} = 0;
2856 die("Latency missing for op $op");
2859 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2861 $node->{op_attr_init} = $op_attr_init;