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 => "attitional 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",
43 # ... # (all nodes you need to describe)
45 # ); # close the %nodes initializer
47 # op_flags: flags for the operation, OPTIONAL (default is "N")
48 # the op_flags correspond to the firm irop_flags:
51 # C irop_flag_commutative
52 # X irop_flag_cfopcode
53 # I irop_flag_ip_cfopcode
56 # H irop_flag_highlevel
57 # c irop_flag_constlike
59 # NB irop_flag_dump_noblock
60 # NI irop_flag_dump_noinput
62 # irn_flags: special node flags, OPTIONAL (default is 0)
63 # following irn_flags are supported:
67 # state: state of the operation, OPTIONAL (default is "floats")
69 # arity: arity of the operation, MUST NOT BE OMITTED
71 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
72 # are always the first 3 arguments and are always autmatically
74 # If this key is missing the following arguments will be created:
75 # for i = 1 .. arity: ir_node *op_i
78 # outs: if a node defines more than one output, the names of the projections
79 # nodes having outs having automatically the mode mode_T
80 # example: [ "frame", "stack", "M" ]
82 # comment: OPTIONAL comment for the node constructor
84 # rd_constructor: for every operation there will be a
85 # new_rd_<arch>_<op-name> function with the arguments from above
86 # which creates the ir_node corresponding to the defined operation
87 # you can either put the complete source code of this function here
89 # This key is OPTIONAL. If omitted, the following constructor will
91 # if (!op_<arch>_<op-name>) assert(0);
95 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
98 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
102 # 0 - no special type
103 # 1 - caller save (register must be saved by the caller of a function)
104 # 2 - callee save (register must be saved by the called function)
105 # 4 - ignore (do not assign this register)
106 # 8 - emitter can choose an arbitrary register of this class
107 # 16 - the register is a virtual one
108 # 32 - register represents a state
109 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
112 { name => "edx", type => 1 },
113 { name => "ecx", type => 1 },
114 { name => "eax", type => 1 },
115 { name => "ebx", type => 2 },
116 { name => "esi", type => 2 },
117 { name => "edi", type => 2 },
118 { name => "ebp", type => 2 },
119 { name => "esp", type => 4 },
120 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
121 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
122 { mode => "mode_Iu" }
125 { name => "mm0", type => 4 },
126 { name => "mm1", type => 4 },
127 { name => "mm2", type => 4 },
128 { name => "mm3", type => 4 },
129 { name => "mm4", type => 4 },
130 { name => "mm5", type => 4 },
131 { name => "mm6", type => 4 },
132 { name => "mm7", type => 4 },
133 { mode => "mode_E", flags => "manual_ra" }
136 { name => "xmm0", type => 1 },
137 { name => "xmm1", type => 1 },
138 { name => "xmm2", type => 1 },
139 { name => "xmm3", type => 1 },
140 { name => "xmm4", type => 1 },
141 { name => "xmm5", type => 1 },
142 { name => "xmm6", type => 1 },
143 { name => "xmm7", type => 1 },
144 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
145 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
149 { name => "vf0", type => 1 },
150 { name => "vf1", type => 1 },
151 { name => "vf2", type => 1 },
152 { name => "vf3", type => 1 },
153 { name => "vf4", type => 1 },
154 { name => "vf5", type => 1 },
155 { name => "vf6", type => 1 },
156 { name => "vf7", type => 1 },
157 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
158 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
162 { name => "st0", realname => "st", type => 4 },
163 { name => "st1", realname => "st(1)", type => 4 },
164 { name => "st2", realname => "st(2)", type => 4 },
165 { name => "st3", realname => "st(3)", type => 4 },
166 { name => "st4", realname => "st(4)", type => 4 },
167 { name => "st5", realname => "st(5)", type => 4 },
168 { name => "st6", realname => "st(6)", type => 4 },
169 { name => "st7", realname => "st(7)", type => 4 },
170 { mode => "mode_E", flags => "manual_ra" }
172 fp_cw => [ # the floating point control word
173 { name => "fpcw", type => 4|32 },
174 { mode => "mode_fpcw", flags => "manual_ra|state" }
177 { name => "eflags", type => 0 },
178 { mode => "mode_Iu", flags => "manual_ra" }
183 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
184 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
185 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
186 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
191 bundels_per_cycle => 1
195 S0 => "${arch}_emit_source_register(node, 0);",
196 S1 => "${arch}_emit_source_register(node, 1);",
197 S2 => "${arch}_emit_source_register(node, 2);",
198 S3 => "${arch}_emit_source_register(node, 3);",
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 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
203 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
204 D0 => "${arch}_emit_dest_register(node, 0);",
205 D1 => "${arch}_emit_dest_register(node, 1);",
206 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
207 X0 => "${arch}_emit_x87_register(node, 0);",
208 X1 => "${arch}_emit_x87_register(node, 1);",
209 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
210 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
211 ia32_emit_mode_suffix(node);",
212 M => "${arch}_emit_mode_suffix(node);",
213 XM => "${arch}_emit_x87_mode_suffix(node);",
214 XXM => "${arch}_emit_xmm_mode_suffix(node);",
215 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
216 AM => "${arch}_emit_am(node);",
217 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
218 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
219 binop => "${arch}_emit_binop(node);",
220 x87_binop => "${arch}_emit_x87_binop(node);",
221 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
222 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
225 #--------------------------------------------------#
228 # _ __ _____ __ _ _ __ ___ _ __ ___ #
229 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
230 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
231 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
234 #--------------------------------------------------#
236 $default_op_attr_type = "ia32_op_attr_t";
237 $default_attr_type = "ia32_attr_t";
238 $default_copy_attr = "ia32_copy_attr";
240 sub ia32_custom_init_attr {
245 if(defined($node->{modified_flags})) {
246 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
248 if(defined($node->{am})) {
249 my $am = $node->{am};
250 if($am eq "source,unary") {
251 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
252 } elsif($am eq "source,binary") {
253 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
254 } elsif($am eq "none") {
257 die("Invalid address mode '$am' specified on op $name");
260 if($node->{state} ne "exc_pinned"
261 and $node->{state} ne "pinned") {
262 die("AM nodes must have pinned or AM pinned state ($name)");
268 $custom_init_attr_func = \&ia32_custom_init_attr;
272 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
273 "\tinit_ia32_x87_attributes(res);".
274 "\tinit_ia32_asm_attributes(res);",
276 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
278 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
279 "\tinit_ia32_call_attributes(res, pop, call_tp);",
280 ia32_condcode_attr_t =>
281 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
282 "\tinit_ia32_condcode_attributes(res, pnc);",
284 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
285 "\tinit_ia32_copyb_attributes(res, size);",
286 ia32_immediate_attr_t =>
287 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
288 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
290 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
291 "\tinit_ia32_x87_attributes(res);",
295 ia32_asm_attr_t => "ia32_compare_asm_attr",
296 ia32_attr_t => "ia32_compare_nodes_attr",
297 ia32_call_attr_t => "ia32_compare_call_attr",
298 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
299 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
300 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
301 ia32_x87_attr_t => "ia32_compare_x87_attr",
307 $mode_xmm = "mode_E";
308 $mode_gp = "mode_Iu";
309 $mode_flags = "mode_Iu";
310 $mode_fpcw = "mode_fpcw";
311 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
312 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
313 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
314 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
321 reg_req => { out => [ "gp_NOREG:I" ] },
322 attr => "ir_entity *symconst, int symconst_sign, long offset",
323 attr_type => "ia32_immediate_attr_t",
324 hash_func => "ia32_hash_Immediate",
332 out_arity => "variable",
333 attr_type => "ia32_asm_attr_t",
334 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
335 init_attr => "attr->asm_text = asm_text;\n".
336 "\tattr->register_map = register_map;\n",
341 # "allocates" a free register
345 reg_req => { out => [ "gp" ] },
350 cmp_attr => "return 1;",
353 #-----------------------------------------------------------------#
356 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
357 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
358 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
359 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
362 #-----------------------------------------------------------------#
364 # commutative operations
368 state => "exc_pinned",
369 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
370 out => [ "in_r4 in_r5", "flags", "none" ] },
371 ins => [ "base", "index", "mem", "left", "right" ],
372 outs => [ "res", "flags", "M" ],
373 emit => '. add%M %binop',
374 am => "source,binary",
378 modified_flags => $status_flags
383 state => "exc_pinned",
384 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
385 ins => [ "base", "index", "mem", "val" ],
386 emit => ". add%M %SI3, %AM",
390 modified_flags => $status_flags
395 state => "exc_pinned",
396 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
397 ins => [ "base", "index", "mem", "val" ],
398 emit => ". add%M %SB3, %AM",
402 modified_flags => $status_flags
406 state => "exc_pinned",
407 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
408 out => [ "in_r4 in_r5", "flags", "none" ] },
409 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
410 outs => [ "res", "flags", "M" ],
411 emit => '. adc%M %binop',
412 am => "source,binary",
416 modified_flags => $status_flags
421 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
422 ins => [ "left", "right" ],
426 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
427 ins => [ "left", "right", "eflags" ],
431 # we should not rematrialize this node. It produces 2 results and has
432 # very strict constraints
433 state => "exc_pinned",
434 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
435 out => [ "eax", "flags", "edx", "none" ] },
436 ins => [ "base", "index", "mem", "left", "right" ],
437 emit => '. mul%M %unop4',
438 outs => [ "res_low", "flags", "res_high", "M" ],
439 am => "source,binary",
442 modified_flags => $status_flags
446 # we should not rematrialize this node. It produces 2 results and has
447 # very strict constraints
449 cmp_attr => "return 1;",
450 outs => [ "EAX", "flags", "EDX", "M" ],
456 state => "exc_pinned",
457 # TODO: adjust out requirements for the 3 operand form
458 # (no need for should_be_same then)
459 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
460 out => [ "in_r4 in_r5", "flags", "none" ] },
461 ins => [ "base", "index", "mem", "left", "right" ],
462 outs => [ "res", "flags", "M" ],
463 am => "source,binary",
467 modified_flags => $status_flags
472 state => "exc_pinned",
473 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
474 out => [ "eax", "edx", "none" ] },
475 ins => [ "base", "index", "mem", "left", "right" ],
476 emit => '. imul%M %unop4',
477 outs => [ "res_low", "res_high", "M" ],
478 am => "source,binary",
481 modified_flags => $status_flags
486 cmp_attr => "return 1;",
487 outs => [ "res_low", "res_high", "M" ],
493 state => "exc_pinned",
494 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
495 out => [ "in_r4 in_r5", "flags", "none" ] },
496 ins => [ "base", "index", "mem", "left", "right" ],
497 outs => [ "res", "flags", "M" ],
498 op_modes => "commutative | am | immediate | mode_neutral",
499 am => "source,binary",
500 emit => '. and%M %binop',
504 modified_flags => $status_flags
509 state => "exc_pinned",
510 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
511 ins => [ "base", "index", "mem", "val" ],
512 emit => '. and%M %SI3, %AM',
516 modified_flags => $status_flags
521 state => "exc_pinned",
522 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
523 ins => [ "base", "index", "mem", "val" ],
524 emit => '. and%M %SB3, %AM',
528 modified_flags => $status_flags
533 state => "exc_pinned",
534 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
535 out => [ "in_r4 in_r5", "flags", "none" ] },
536 ins => [ "base", "index", "mem", "left", "right" ],
537 outs => [ "res", "flags", "M" ],
538 am => "source,binary",
539 emit => '. or%M %binop',
543 modified_flags => $status_flags
548 state => "exc_pinned",
549 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
550 ins => [ "base", "index", "mem", "val" ],
551 emit => '. or%M %SI3, %AM',
555 modified_flags => $status_flags
560 state => "exc_pinned",
561 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
562 ins => [ "base", "index", "mem", "val" ],
563 emit => '. or%M %SB3, %AM',
567 modified_flags => $status_flags
572 state => "exc_pinned",
573 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
574 out => [ "in_r4 in_r5", "flags", "none" ] },
575 ins => [ "base", "index", "mem", "left", "right" ],
576 outs => [ "res", "flags", "M" ],
577 am => "source,binary",
578 emit => '. xor%M %binop',
582 modified_flags => $status_flags
587 state => "exc_pinned",
588 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
589 ins => [ "base", "index", "mem", "val" ],
590 emit => '. xor%M %SI3, %AM',
594 modified_flags => $status_flags
599 state => "exc_pinned",
600 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
601 ins => [ "base", "index", "mem", "val" ],
602 emit => '. xor%M %SB3, %AM',
606 modified_flags => $status_flags
609 # not commutative operations
613 state => "exc_pinned",
614 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
615 out => [ "in_r4", "flags", "none" ] },
616 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
617 outs => [ "res", "flags", "M" ],
618 am => "source,binary",
619 emit => '. sub%M %binop',
623 modified_flags => $status_flags
628 state => "exc_pinned",
629 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
630 ins => [ "base", "index", "mem", "subtrahend" ],
631 emit => '. sub%M %SI3, %AM',
635 modified_flags => $status_flags
640 state => "exc_pinned",
641 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
642 ins => [ "base", "index", "mem", "subtrahend" ],
643 emit => '. sub%M %SB3, %AM',
647 modified_flags => $status_flags
651 state => "exc_pinned",
652 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
653 out => [ "in_r4 !in_r5", "flags", "none" ] },
654 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
655 outs => [ "res", "flags", "M" ],
656 am => "source,binary",
657 emit => '. sbb%M %binop',
661 modified_flags => $status_flags
665 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
666 ins => [ "minuend", "subtrahend" ],
670 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
671 ins => [ "minuend", "subtrahend", "eflags" ],
676 state => "exc_pinned",
677 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
678 out => [ "eax", "flags", "none", "edx", "none" ] },
679 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
680 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
681 am => "source,unary",
682 emit => ". idiv%M %unop3",
685 modified_flags => $status_flags
690 state => "exc_pinned",
691 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
692 out => [ "eax", "flags", "none", "edx", "none" ] },
693 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
694 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
695 am => "source,unary",
696 emit => ". div%M %unop3",
699 modified_flags => $status_flags
704 reg_req => { in => [ "gp", "ecx" ],
705 out => [ "in_r1 !in_r2", "flags" ] },
706 ins => [ "val", "count" ],
707 outs => [ "res", "flags" ],
708 emit => '. shl %SB1, %S0',
712 modified_flags => $status_flags
717 state => "exc_pinned",
718 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
719 ins => [ "base", "index", "mem", "count" ],
720 emit => '. shl%M %SB3, %AM',
724 modified_flags => $status_flags
728 cmp_attr => "return 1;",
729 ins => [ "val", "count", "dep" ],
735 reg_req => { in => [ "gp", "gp", "ecx" ],
736 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
737 ins => [ "val_high", "val_low", "count" ],
738 outs => [ "res", "flags" ],
739 emit => ". shld%M %SB2, %S1, %D0",
743 modified_flags => $status_flags
747 cmp_attr => "return 1;",
748 ins => [ "val_high", "val_low", "count" ],
754 reg_req => { in => [ "gp", "ecx" ],
755 out => [ "in_r1 !in_r2", "flags" ] },
756 ins => [ "val", "count" ],
757 outs => [ "res", "flags" ],
758 emit => '. shr %SB1, %S0',
762 modified_flags => $status_flags
767 state => "exc_pinned",
768 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
769 ins => [ "base", "index", "mem", "count" ],
770 emit => '. shr%M %SB3, %AM',
774 modified_flags => $status_flags
778 cmp_attr => "return 1;",
779 ins => [ "val", "count", "dep" ],
785 reg_req => { in => [ "gp", "gp", "ecx" ],
786 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
787 ins => [ "val_high", "val_low", "count" ],
788 outs => [ "res", "flags" ],
789 emit => ". shrd%M %SB2, %S1, %D0",
793 modified_flags => $status_flags
797 cmp_attr => "return 1;",
799 ins => [ "val_high", "val_low", "count" ],
804 reg_req => { in => [ "gp", "ecx" ],
805 out => [ "in_r1 !in_r2", "flags" ] },
806 ins => [ "val", "count" ],
807 outs => [ "res", "flags" ],
808 emit => '. sar %SB1, %S0',
812 modified_flags => $status_flags
817 state => "exc_pinned",
818 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
819 ins => [ "base", "index", "mem", "count" ],
820 emit => '. sar%M %SB3, %AM',
824 modified_flags => $status_flags
828 cmp_attr => "return 1;",
829 ins => [ "val", "count", "dep" ],
835 reg_req => { in => [ "gp", "ecx" ],
836 out => [ "in_r1 !in_r2", "flags" ] },
837 ins => [ "val", "count" ],
838 outs => [ "res", "flags" ],
839 emit => '. ror %SB1, %S0',
843 modified_flags => $status_flags
848 state => "exc_pinned",
849 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
850 ins => [ "base", "index", "mem", "count" ],
851 emit => '. ror%M %SB3, %AM',
855 modified_flags => $status_flags
860 reg_req => { in => [ "gp", "ecx" ],
861 out => [ "in_r1 !in_r2", "flags" ] },
862 ins => [ "val", "count" ],
863 outs => [ "res", "flags" ],
864 emit => '. rol %SB1, %S0',
868 modified_flags => $status_flags
873 state => "exc_pinned",
874 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
875 ins => [ "base", "index", "mem", "count" ],
876 emit => '. rol%M %SB3, %AM',
880 modified_flags => $status_flags
887 reg_req => { in => [ "gp" ],
888 out => [ "in_r1", "flags" ] },
891 outs => [ "res", "flags" ],
895 modified_flags => $status_flags
900 state => "exc_pinned",
901 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
902 ins => [ "base", "index", "mem" ],
903 emit => '. neg%M %AM',
907 modified_flags => $status_flags
912 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
913 outs => [ "low_res", "high_res" ],
916 modified_flags => $status_flags
922 reg_req => { in => [ "gp" ],
923 out => [ "in_r1", "flags" ] },
925 outs => [ "res", "flags" ],
930 modified_flags => $status_flags_wo_cf
935 state => "exc_pinned",
936 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
937 ins => [ "base", "index", "mem" ],
938 emit => '. inc%M %AM',
942 modified_flags => $status_flags_wo_cf
947 reg_req => { in => [ "gp" ],
948 out => [ "in_r1", "flags" ] },
950 outs => [ "res", "flags" ],
955 modified_flags => $status_flags_wo_cf
960 state => "exc_pinned",
961 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
962 ins => [ "base", "index", "mem" ],
963 emit => '. dec%M %AM',
967 modified_flags => $status_flags_wo_cf
972 reg_req => { in => [ "gp" ],
973 out => [ "in_r1", "flags" ] },
975 outs => [ "res", "flags" ],
985 state => "exc_pinned",
986 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
987 ins => [ "base", "index", "mem" ],
988 emit => '. not%M %AM',
996 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1000 mode => $mode_flags,
1001 modified_flags => $status_flags
1005 reg_req => { out => [ "flags" ] },
1009 mode => $mode_flags,
1010 modified_flags => $status_flags
1017 state => "exc_pinned",
1018 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1019 out => [ "flags", "none", "none" ] },
1020 ins => [ "base", "index", "mem", "left", "right" ],
1021 outs => [ "eflags", "unused", "M" ],
1022 am => "source,binary",
1023 emit => '. cmp%M %binop',
1024 attr => "int ins_permuted, int cmp_unsigned",
1025 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1026 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1029 mode => $mode_flags,
1030 modified_flags => $status_flags
1035 state => "exc_pinned",
1036 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1037 ins => [ "base", "index", "mem", "left", "right" ],
1038 outs => [ "eflags" ],
1039 am => "source,binary",
1040 emit => '. cmpb %binop',
1041 attr => "int ins_permuted, int cmp_unsigned",
1042 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1043 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1046 mode => $mode_flags,
1047 modified_flags => $status_flags
1052 state => "exc_pinned",
1053 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1054 ins => [ "base", "index", "mem", "left", "right" ],
1055 outs => [ "eflags" ],
1056 am => "source,binary",
1057 emit => '. test%M %binop',
1058 attr => "int ins_permuted, int cmp_unsigned",
1059 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1060 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1063 mode => $mode_flags,
1064 modified_flags => $status_flags
1069 state => "exc_pinned",
1070 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1071 ins => [ "base", "index", "mem", "left", "right" ],
1072 outs => [ "eflags" ],
1073 am => "source,binary",
1074 emit => '. testb %binop',
1075 attr => "int ins_permuted, int cmp_unsigned",
1076 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1077 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1080 mode => $mode_flags,
1081 modified_flags => $status_flags
1086 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1087 ins => [ "eflags" ],
1088 attr_type => "ia32_condcode_attr_t",
1089 attr => "pn_Cmp pnc, int ins_permuted",
1090 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1091 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1092 emit => '. set%CMP0 %DB0',
1100 state => "exc_pinned",
1101 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1102 ins => [ "base", "index", "mem","eflags" ],
1103 attr_type => "ia32_condcode_attr_t",
1104 attr => "pn_Cmp pnc, int ins_permuted",
1105 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1106 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1107 emit => '. set%CMP3 %AM',
1115 # (note: leave the false,true order intact to make it compatible with other
1117 state => "exc_pinned",
1118 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1119 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1120 am => "source,binary",
1121 attr_type => "ia32_condcode_attr_t",
1122 attr => "int ins_permuted, pn_Cmp pnc",
1123 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1131 op_flags => "L|X|Y",
1132 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1133 ins => [ "eflags" ],
1134 outs => [ "false", "true" ],
1135 attr_type => "ia32_condcode_attr_t",
1136 attr => "pn_Cmp pnc",
1138 units => [ "BRANCH" ],
1143 op_flags => "L|X|Y",
1144 reg_req => { in => [ "gp" ], out => [ "none" ] },
1146 attr_type => "ia32_condcode_attr_t",
1149 units => [ "BRANCH" ],
1150 modified_flags => $status_flags,
1156 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1157 ins => [ "base", "index", "mem", "target" ],
1158 am => "source,unary",
1159 emit => '. jmp *%unop3',
1161 units => [ "BRANCH" ],
1168 reg_req => { out => [ "gp" ] },
1170 attr => "ir_entity *symconst, int symconst_sign, long offset",
1171 attr_type => "ia32_immediate_attr_t",
1178 reg_req => { out => [ "gp" ] },
1182 modified_flags => $status_flags,
1188 reg_req => { out => [ "gp_UKNWN:I" ] },
1198 reg_req => { out => [ "vfp_UKNWN:I" ] },
1203 attr_type => "ia32_x87_attr_t",
1209 reg_req => { out => [ "xmm_UKNWN:I" ] },
1218 op_flags => "c|NB|NI",
1219 reg_req => { out => [ "gp_NOREG:I" ] },
1228 op_flags => "c|NB|NI",
1229 reg_req => { out => [ "vfp_NOREG:I" ] },
1234 attr_type => "ia32_x87_attr_t",
1239 op_flags => "c|NB|NI",
1240 reg_req => { out => [ "xmm_NOREG:I" ] },
1250 reg_req => { out => [ "fpcw:I" ] },
1254 modified_flags => $fpcw_flags
1260 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1261 ins => [ "base", "index", "mem" ],
1263 emit => ". fldcw %AM",
1266 modified_flags => $fpcw_flags
1272 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1273 ins => [ "base", "index", "mem", "fpcw" ],
1275 emit => ". fnstcw %AM",
1283 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1291 # we should not rematrialize this node. It has very strict constraints.
1292 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1293 ins => [ "val", "clobbered" ],
1302 # Note that we add additional latency values depending on address mode, so a
1303 # lateny of 0 for load is correct
1307 state => "exc_pinned",
1308 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1309 ins => [ "base", "index", "mem" ],
1310 outs => [ "res", "M", "X_exc" ],
1312 emit => ". mov%SE%ME%.l %AM, %D0",
1318 state => "exc_pinned",
1319 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1320 ins => [ "base", "index", "mem", "val" ],
1321 outs => [ "M", "X_exc" ],
1322 emit => '. mov%M %SI3, %AM',
1330 state => "exc_pinned",
1331 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1332 ins => [ "base", "index", "mem", "val" ],
1333 outs => [ "M", "X_exc" ],
1334 emit => '. mov%M %SB3, %AM',
1342 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1343 ins => [ "base", "index" ],
1344 emit => '. leal %AM, %D0',
1348 # lea doesn't modify the flags, but setting this seems advantageous since it
1349 # increases chances that the Lea is transformed back to an Add
1350 modified_flags => 1,
1354 state => "exc_pinned",
1355 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1356 ins => [ "base", "index", "mem", "val", "stack" ],
1357 emit => '. push%M %unop3',
1358 outs => [ "stack", "M" ],
1359 am => "source,unary",
1365 state => "exc_pinned",
1366 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1367 ins => [ "mem", "stack" ],
1368 outs => [ "res", "M", "unused", "stack" ],
1369 emit => '. pop%M %D0',
1370 latency => 3, # Pop is more expensive than Push on Athlon
1375 state => "exc_pinned",
1376 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1377 ins => [ "mem", "stack" ],
1378 outs => [ "res", "M", "unused", "stack" ],
1379 emit => '. pop%M %D0',
1380 latency => 3, # Pop is more expensive than Push on Athlon
1385 state => "exc_pinned",
1386 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1387 ins => [ "base", "index", "mem", "stack" ],
1388 outs => [ "unused0", "M", "unused1", "stack" ],
1389 emit => '. pop%M %AM',
1390 latency => 3, # Pop is more expensive than Push on Athlon
1395 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1397 outs => [ "frame", "stack", "M" ],
1403 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1405 outs => [ "frame", "stack" ],
1412 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1413 ins => [ "base", "index", "mem", "stack", "size" ],
1414 am => "source,binary",
1415 emit => '. addl %binop',
1417 outs => [ "stack", "M" ],
1419 modified_flags => $status_flags
1424 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1425 ins => [ "base", "index", "mem", "stack", "size" ],
1426 am => "source,binary",
1427 emit => ". subl %binop\n".
1428 ". movl %%esp, %D1",
1430 outs => [ "stack", "addr", "M" ],
1432 modified_flags => $status_flags
1445 reg_req => { out => [ "gp" ] },
1452 state => "exc_pinned",
1453 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1454 ins => [ "left", "right" ],
1455 emit => '. bt%M %S1, %S0',
1458 mode => $mode_flags,
1459 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1463 state => "exc_pinned",
1465 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1466 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" ]
1468 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1469 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1470 attr_type => "ia32_call_attr_t",
1471 attr => "unsigned pop, ir_type *call_tp",
1472 am => "source,unary",
1473 units => [ "BRANCH" ],
1474 latency => 4, # random number
1475 modified_flags => $status_flags
1478 #-----------------------------------------------------------------------------#
1479 # _____ _____ ______ __ _ _ _ #
1480 # / ____/ ____| ____| / _| | | | | | #
1481 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1482 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1483 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1484 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1485 #-----------------------------------------------------------------------------#
1490 reg_req => { out => [ "xmm" ] },
1491 emit => '. xorp%XSD %D0, %D0',
1499 reg_req => { out => [ "xmm" ] },
1500 emit => '. pxor %D0, %D0',
1506 # produces all 1 bits
1509 reg_req => { out => [ "xmm" ] },
1510 emit => '. pcmpeqb %D0, %D0',
1516 # integer shift left, dword
1519 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1520 emit => '. pslld %SI1, %D0',
1526 # integer shift left, qword
1529 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1530 emit => '. psllq %SI1, %D0',
1536 # integer shift right, dword
1539 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1540 emit => '. psrld %SI1, %D0',
1546 # mov from integer to SSE register
1549 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1550 emit => '. movd %S0, %D0',
1556 # commutative operations
1560 state => "exc_pinned",
1561 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1562 ins => [ "base", "index", "mem", "left", "right" ],
1563 am => "source,binary",
1564 emit => '. add%XXM %binop',
1572 state => "exc_pinned",
1573 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1574 ins => [ "base", "index", "mem", "left", "right" ],
1575 am => "source,binary",
1576 emit => '. mul%XXM %binop',
1584 state => "exc_pinned",
1585 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1586 ins => [ "base", "index", "mem", "left", "right" ],
1587 am => "source,binary",
1588 emit => '. max%XXM %binop',
1596 state => "exc_pinned",
1597 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1598 ins => [ "base", "index", "mem", "left", "right" ],
1599 am => "source,binary",
1600 emit => '. min%XXM %binop',
1608 state => "exc_pinned",
1609 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1610 ins => [ "base", "index", "mem", "left", "right" ],
1611 am => "source,binary",
1612 emit => '. andp%XSD %binop',
1620 state => "exc_pinned",
1621 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1622 ins => [ "base", "index", "mem", "left", "right" ],
1623 am => "source,binary",
1624 emit => '. orp%XSD %binop',
1632 state => "exc_pinned",
1633 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1634 ins => [ "base", "index", "mem", "left", "right" ],
1635 am => "source,binary",
1636 emit => '. xorp%XSD %binop',
1642 # not commutative operations
1646 state => "exc_pinned",
1647 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1648 ins => [ "base", "index", "mem", "left", "right" ],
1649 am => "source,binary",
1650 emit => '. andnp%XSD %binop',
1658 state => "exc_pinned",
1659 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1660 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1661 am => "source,binary",
1662 emit => '. sub%XXM %binop',
1670 state => "exc_pinned",
1671 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1672 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1673 am => "source,binary",
1674 outs => [ "res", "M" ],
1675 emit => '. div%XXM %binop',
1684 state => "exc_pinned",
1685 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1686 ins => [ "base", "index", "mem", "left", "right" ],
1687 outs => [ "flags" ],
1688 am => "source,binary",
1689 attr => "int ins_permuted",
1690 init_attr => "attr->data.ins_permuted = ins_permuted;",
1691 emit => ' .ucomi%XXM %binop',
1694 mode => $mode_flags,
1695 modified_flags => 1,
1702 state => "exc_pinned",
1703 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1704 ins => [ "base", "index", "mem" ],
1705 outs => [ "res", "M", "X_exc" ],
1706 emit => '. mov%XXM %AM, %D0',
1707 attr => "ir_mode *load_mode",
1708 init_attr => "attr->ls_mode = load_mode;",
1715 state => "exc_pinned",
1716 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1717 ins => [ "base", "index", "mem", "val" ],
1718 outs => [ "M", "X_exc" ],
1719 emit => '. mov%XXM %S3, %AM',
1727 state => "exc_pinned",
1728 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1729 ins => [ "base", "index", "mem", "val" ],
1730 emit => '. mov%XXM %S3, %AM',
1738 state => "exc_pinned",
1739 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1740 ins => [ "base", "index", "mem", "val" ],
1741 am => "source,unary",
1742 emit => '. cvtsi2ss %unop3, %D0',
1750 state => "exc_pinned",
1751 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1752 ins => [ "base", "index", "mem", "val" ],
1753 am => "source,unary",
1754 emit => '. cvtsi2sd %unop3, %D0',
1763 cmp_attr => "return 1;",
1764 ins => [ "val_high", "val_low" ],
1769 cmp_attr => "return 1;",
1771 outs => [ "res_high", "res_low" ],
1779 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1780 outs => [ "DST", "SRC", "CNT", "M" ],
1781 attr_type => "ia32_copyb_attr_t",
1782 attr => "unsigned size",
1785 # we don't care about this flag, so no need to mark this node
1786 # modified_flags => [ "DF" ]
1792 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1793 outs => [ "DST", "SRC", "M" ],
1794 attr_type => "ia32_copyb_attr_t",
1795 attr => "unsigned size",
1798 # we don't care about this flag, so no need to mark this node
1799 # modified_flags => [ "DF" ]
1805 state => "exc_pinned",
1806 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1807 ins => [ "base", "index", "mem", "val" ],
1808 am => "source,unary",
1811 attr => "ir_mode *smaller_mode",
1812 init_attr => "attr->ls_mode = smaller_mode;",
1817 state => "exc_pinned",
1818 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1819 ins => [ "base", "index", "mem", "val" ],
1820 am => "source,unary",
1823 attr => "ir_mode *smaller_mode",
1824 init_attr => "attr->ls_mode = smaller_mode;",
1829 state => "exc_pinned",
1830 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1831 ins => [ "base", "index", "mem", "val" ],
1832 am => "source,unary",
1839 state => "exc_pinned",
1840 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1841 ins => [ "base", "index", "mem", "val" ],
1842 am => "source,unary",
1849 state => "exc_pinned",
1850 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1851 ins => [ "base", "index", "mem", "val" ],
1852 am => "source,unary",
1858 #----------------------------------------------------------#
1860 # (_) | | | | / _| | | | #
1861 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1862 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1863 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1864 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1866 # _ __ ___ __| | ___ ___ #
1867 # | '_ \ / _ \ / _` |/ _ \/ __| #
1868 # | | | | (_) | (_| | __/\__ \ #
1869 # |_| |_|\___/ \__,_|\___||___/ #
1870 #----------------------------------------------------------#
1872 # rematerialisation disabled for all float nodes for now, because the fpcw
1873 # handler runs before spilling and we might end up with wrong fpcw then
1877 state => "exc_pinned",
1878 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1879 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1880 am => "source,binary",
1884 attr_type => "ia32_x87_attr_t",
1889 state => "exc_pinned",
1890 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1891 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1892 am => "source,binary",
1896 attr_type => "ia32_x87_attr_t",
1901 state => "exc_pinned",
1902 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1903 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1904 am => "source,binary",
1908 attr_type => "ia32_x87_attr_t",
1912 state => "exc_pinned",
1913 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1914 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1915 am => "source,binary",
1916 outs => [ "res", "M" ],
1919 attr_type => "ia32_x87_attr_t",
1923 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1924 ins => [ "left", "right", "fpcw" ],
1928 attr_type => "ia32_x87_attr_t",
1933 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1938 attr_type => "ia32_x87_attr_t",
1943 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1948 attr_type => "ia32_x87_attr_t",
1951 # virtual Load and Store
1956 state => "exc_pinned",
1957 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1958 ins => [ "base", "index", "mem" ],
1959 outs => [ "res", "M", "X_exc" ],
1960 attr => "ir_mode *load_mode",
1961 init_attr => "attr->attr.ls_mode = load_mode;",
1964 attr_type => "ia32_x87_attr_t",
1970 state => "exc_pinned",
1971 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1972 ins => [ "base", "index", "mem", "val" ],
1973 outs => [ "M", "X_exc" ],
1974 attr => "ir_mode *store_mode",
1975 init_attr => "attr->attr.ls_mode = store_mode;",
1979 attr_type => "ia32_x87_attr_t",
1985 state => "exc_pinned",
1986 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1987 outs => [ "res", "M" ],
1988 ins => [ "base", "index", "mem" ],
1991 attr_type => "ia32_x87_attr_t",
1995 state => "exc_pinned",
1996 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1997 ins => [ "base", "index", "mem", "val", "fpcw" ],
2001 attr_type => "ia32_x87_attr_t",
2004 # SSE3 fisttp instruction
2006 state => "exc_pinned",
2007 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2008 ins => [ "base", "index", "mem", "val" ],
2009 outs => [ "res", "M" ],
2012 attr_type => "ia32_x87_attr_t",
2020 reg_req => { out => [ "vfp" ] },
2025 attr_type => "ia32_x87_attr_t",
2030 reg_req => { out => [ "vfp" ] },
2035 attr_type => "ia32_x87_attr_t",
2040 reg_req => { out => [ "vfp" ] },
2045 attr_type => "ia32_x87_attr_t",
2050 reg_req => { out => [ "vfp" ] },
2055 attr_type => "ia32_x87_attr_t",
2060 reg_req => { out => [ "vfp" ] },
2065 attr_type => "ia32_x87_attr_t",
2070 reg_req => { out => [ "vfp" ] },
2075 attr_type => "ia32_x87_attr_t",
2080 reg_req => { out => [ "vfp" ] },
2085 attr_type => "ia32_x87_attr_t",
2091 # we can't allow to rematerialize this node so we don't have
2092 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2094 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2095 ins => [ "left", "right" ],
2096 outs => [ "flags" ],
2097 attr => "int ins_permuted",
2098 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2101 attr_type => "ia32_x87_attr_t",
2107 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2108 ins => [ "left", "right" ],
2109 outs => [ "flags" ],
2110 attr => "int ins_permuted",
2111 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2114 attr_type => "ia32_x87_attr_t",
2120 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2122 outs => [ "flags" ],
2123 attr => "int ins_permuted",
2124 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2127 attr_type => "ia32_x87_attr_t",
2133 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2135 outs => [ "flags" ],
2139 mode => $mode_flags,
2142 #------------------------------------------------------------------------#
2143 # ___ _____ __ _ _ _ #
2144 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2145 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2146 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2147 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2148 #------------------------------------------------------------------------#
2150 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2151 # are swapped, we work this around in the emitter...
2154 state => "exc_pinned",
2155 rd_constructor => "NONE",
2157 emit => '. fadd%XM %x87_binop',
2159 attr_type => "ia32_x87_attr_t",
2163 state => "exc_pinned",
2164 rd_constructor => "NONE",
2166 emit => '. faddp%XM %x87_binop',
2168 attr_type => "ia32_x87_attr_t",
2172 state => "exc_pinned",
2173 rd_constructor => "NONE",
2175 emit => '. fmul%XM %x87_binop',
2177 attr_type => "ia32_x87_attr_t",
2181 state => "exc_pinned",
2182 rd_constructor => "NONE",
2184 emit => '. fmulp%XM %x87_binop',,
2186 attr_type => "ia32_x87_attr_t",
2190 state => "exc_pinned",
2191 rd_constructor => "NONE",
2193 emit => '. fsub%XM %x87_binop',
2195 attr_type => "ia32_x87_attr_t",
2199 state => "exc_pinned",
2200 rd_constructor => "NONE",
2202 # see note about gas bugs
2203 emit => '. fsubrp%XM %x87_binop',
2205 attr_type => "ia32_x87_attr_t",
2209 state => "exc_pinned",
2210 rd_constructor => "NONE",
2213 emit => '. fsubr%XM %x87_binop',
2215 attr_type => "ia32_x87_attr_t",
2219 state => "exc_pinned",
2220 rd_constructor => "NONE",
2223 # see note about gas bugs
2224 emit => '. fsubp%XM %x87_binop',
2226 attr_type => "ia32_x87_attr_t",
2230 rd_constructor => "NONE",
2234 attr_type => "ia32_x87_attr_t",
2237 # this node is just here, to keep the simulator running
2238 # we can omit this when a fprem simulation function exists
2240 rd_constructor => "NONE",
2242 emit => '. fprem1\n'.
2245 attr_type => "ia32_x87_attr_t",
2249 state => "exc_pinned",
2250 rd_constructor => "NONE",
2252 emit => '. fdiv%XM %x87_binop',
2254 attr_type => "ia32_x87_attr_t",
2258 state => "exc_pinned",
2259 rd_constructor => "NONE",
2261 # see note about gas bugs
2262 emit => '. fdivrp%XM %x87_binop',
2264 attr_type => "ia32_x87_attr_t",
2268 state => "exc_pinned",
2269 rd_constructor => "NONE",
2271 emit => '. fdivr%XM %x87_binop',
2273 attr_type => "ia32_x87_attr_t",
2277 state => "exc_pinned",
2278 rd_constructor => "NONE",
2280 # see note about gas bugs
2281 emit => '. fdivp%XM %x87_binop',
2283 attr_type => "ia32_x87_attr_t",
2287 rd_constructor => "NONE",
2291 attr_type => "ia32_x87_attr_t",
2296 rd_constructor => "NONE",
2300 attr_type => "ia32_x87_attr_t",
2303 # x87 Load and Store
2306 rd_constructor => "NONE",
2307 op_flags => "R|L|F",
2308 state => "exc_pinned",
2310 emit => '. fld%XM %AM',
2311 attr_type => "ia32_x87_attr_t",
2316 rd_constructor => "NONE",
2317 op_flags => "R|L|F",
2318 state => "exc_pinned",
2320 emit => '. fst%XM %AM',
2322 attr_type => "ia32_x87_attr_t",
2327 rd_constructor => "NONE",
2328 op_flags => "R|L|F",
2329 state => "exc_pinned",
2331 emit => '. fstp%XM %AM',
2333 attr_type => "ia32_x87_attr_t",
2340 state => "exc_pinned",
2341 rd_constructor => "NONE",
2343 emit => '. fild%XM %AM',
2344 attr_type => "ia32_x87_attr_t",
2349 state => "exc_pinned",
2350 rd_constructor => "NONE",
2352 emit => '. fist%XM %AM',
2354 attr_type => "ia32_x87_attr_t",
2359 state => "exc_pinned",
2360 rd_constructor => "NONE",
2362 emit => '. fistp%XM %AM',
2364 attr_type => "ia32_x87_attr_t",
2368 # SSE3 firsttp instruction
2370 state => "exc_pinned",
2371 rd_constructor => "NONE",
2373 emit => '. fisttp%XM %AM',
2375 attr_type => "ia32_x87_attr_t",
2382 op_flags => "R|c|K",
2384 reg_req => { out => [ "vfp" ] },
2386 attr_type => "ia32_x87_attr_t",
2391 op_flags => "R|c|K",
2393 reg_req => { out => [ "vfp" ] },
2395 attr_type => "ia32_x87_attr_t",
2400 op_flags => "R|c|K",
2402 reg_req => { out => [ "vfp" ] },
2404 attr_type => "ia32_x87_attr_t",
2409 op_flags => "R|c|K",
2411 reg_req => { out => [ "vfp" ] },
2413 attr_type => "ia32_x87_attr_t",
2418 op_flags => "R|c|K",
2420 reg_req => { out => [ "vfp" ] },
2422 attr_type => "ia32_x87_attr_t",
2427 op_flags => "R|c|K",
2429 reg_req => { out => [ "vfp" ] },
2430 emit => '. fldll2t',
2431 attr_type => "ia32_x87_attr_t",
2436 op_flags => "R|c|K",
2438 reg_req => { out => [ "vfp" ] },
2440 attr_type => "ia32_x87_attr_t",
2445 # Note that it is NEVER allowed to do CSE on these nodes
2446 # Moreover, note the virtual register requierements!
2451 cmp_attr => "return 1;",
2452 emit => '. fxch %X0',
2453 attr_type => "ia32_x87_attr_t",
2461 cmp_attr => "return 1;",
2462 emit => '. fld %X0',
2463 attr_type => "ia32_x87_attr_t",
2469 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2470 cmp_attr => "return 1;",
2471 emit => '. fld %X0',
2472 attr_type => "ia32_x87_attr_t",
2479 cmp_attr => "return 1;",
2480 emit => '. fstp %X0',
2481 attr_type => "ia32_x87_attr_t",
2489 cmp_attr => "return 1;",
2490 emit => '. ffreep %X0',
2491 attr_type => "ia32_x87_attr_t",
2499 cmp_attr => "return 1;",
2501 attr_type => "ia32_x87_attr_t",
2509 cmp_attr => "return 1;",
2511 attr_type => "ia32_x87_attr_t",
2520 emit => ". fucom %X1\n".
2522 attr_type => "ia32_x87_attr_t",
2528 emit => ". fucomp %X1\n".
2530 attr_type => "ia32_x87_attr_t",
2536 emit => ". fucompp\n".
2538 attr_type => "ia32_x87_attr_t",
2544 emit => '. fucomi %X1',
2545 attr_type => "ia32_x87_attr_t",
2551 emit => '. fucompi %X1',
2552 attr_type => "ia32_x87_attr_t",
2560 attr_type => "ia32_x87_attr_t",
2565 # -------------------------------------------------------------------------------- #
2566 # ____ ____ _____ _ _ #
2567 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2568 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2569 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2570 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2572 # -------------------------------------------------------------------------------- #
2575 # Spilling and reloading of SSE registers, hardcoded, not generated #
2579 state => "exc_pinned",
2580 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2581 emit => '. movdqu %D0, %AM',
2582 outs => [ "res", "M" ],
2589 state => "exc_pinned",
2590 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2591 ins => [ "base", "index", "mem", "val" ],
2592 emit => '. movdqu %binop',
2600 # Include the generated SIMD node specification written by the SIMD optimization
2601 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2602 unless ($return = do $my_script_name) {
2603 warn "couldn't parse $my_script_name: $@" if $@;
2604 warn "couldn't do $my_script_name: $!" unless defined $return;
2605 warn "couldn't run $my_script_name" unless $return;
2608 # Transform some attributes
2609 foreach my $op (keys(%nodes)) {
2610 my $node = $nodes{$op};
2611 my $op_attr_init = $node->{op_attr_init};
2613 if(defined($op_attr_init)) {
2614 $op_attr_init .= "\n\t";
2619 if(!defined($node->{latency})) {
2621 $node->{latency} = 0;
2623 die("Latency missing for op $op");
2626 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2628 $node->{op_attr_init} = $op_attr_init;