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", "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
1477 #-----------------------------------------------------------------------------#
1478 # _____ _____ ______ __ _ _ _ #
1479 # / ____/ ____| ____| / _| | | | | | #
1480 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1481 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1482 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1483 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1484 #-----------------------------------------------------------------------------#
1489 reg_req => { out => [ "xmm" ] },
1490 emit => '. xorp%XSD %D0, %D0',
1498 reg_req => { out => [ "xmm" ] },
1499 emit => '. pxor %D0, %D0',
1505 # produces all 1 bits
1508 reg_req => { out => [ "xmm" ] },
1509 emit => '. pcmpeqb %D0, %D0',
1515 # integer shift left, dword
1518 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1519 emit => '. pslld %SI1, %D0',
1525 # integer shift left, qword
1528 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1529 emit => '. psllq %SI1, %D0',
1535 # integer shift right, dword
1538 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1539 emit => '. psrld %SI1, %D0',
1545 # mov from integer to SSE register
1548 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1549 emit => '. movd %S0, %D0',
1555 # commutative operations
1559 state => "exc_pinned",
1560 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1561 ins => [ "base", "index", "mem", "left", "right" ],
1562 am => "source,binary",
1563 emit => '. add%XXM %binop',
1571 state => "exc_pinned",
1572 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1573 ins => [ "base", "index", "mem", "left", "right" ],
1574 am => "source,binary",
1575 emit => '. mul%XXM %binop',
1583 state => "exc_pinned",
1584 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1585 ins => [ "base", "index", "mem", "left", "right" ],
1586 am => "source,binary",
1587 emit => '. max%XXM %binop',
1595 state => "exc_pinned",
1596 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1597 ins => [ "base", "index", "mem", "left", "right" ],
1598 am => "source,binary",
1599 emit => '. min%XXM %binop',
1607 state => "exc_pinned",
1608 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1609 ins => [ "base", "index", "mem", "left", "right" ],
1610 am => "source,binary",
1611 emit => '. andp%XSD %binop',
1619 state => "exc_pinned",
1620 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1621 ins => [ "base", "index", "mem", "left", "right" ],
1622 am => "source,binary",
1623 emit => '. orp%XSD %binop',
1631 state => "exc_pinned",
1632 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1633 ins => [ "base", "index", "mem", "left", "right" ],
1634 am => "source,binary",
1635 emit => '. xorp%XSD %binop',
1641 # not commutative operations
1645 state => "exc_pinned",
1646 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1647 ins => [ "base", "index", "mem", "left", "right" ],
1648 am => "source,binary",
1649 emit => '. andnp%XSD %binop',
1657 state => "exc_pinned",
1658 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1659 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1660 am => "source,binary",
1661 emit => '. sub%XXM %binop',
1669 state => "exc_pinned",
1670 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1671 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1672 am => "source,binary",
1673 outs => [ "res", "M" ],
1674 emit => '. div%XXM %binop',
1683 state => "exc_pinned",
1684 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1685 ins => [ "base", "index", "mem", "left", "right" ],
1686 outs => [ "flags" ],
1687 am => "source,binary",
1688 attr => "int ins_permuted",
1689 init_attr => "attr->data.ins_permuted = ins_permuted;",
1690 emit => ' .ucomi%XXM %binop',
1693 mode => $mode_flags,
1694 modified_flags => 1,
1701 state => "exc_pinned",
1702 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1703 ins => [ "base", "index", "mem" ],
1704 outs => [ "res", "M", "X_exc" ],
1705 emit => '. mov%XXM %AM, %D0',
1706 attr => "ir_mode *load_mode",
1707 init_attr => "attr->ls_mode = load_mode;",
1714 state => "exc_pinned",
1715 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1716 ins => [ "base", "index", "mem", "val" ],
1717 outs => [ "M", "X_exc" ],
1718 emit => '. mov%XXM %S3, %AM',
1726 state => "exc_pinned",
1727 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1728 ins => [ "base", "index", "mem", "val" ],
1729 emit => '. mov%XXM %S3, %AM',
1737 state => "exc_pinned",
1738 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1739 ins => [ "base", "index", "mem", "val" ],
1740 am => "source,unary",
1741 emit => '. cvtsi2ss %unop3, %D0',
1749 state => "exc_pinned",
1750 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1751 ins => [ "base", "index", "mem", "val" ],
1752 am => "source,unary",
1753 emit => '. cvtsi2sd %unop3, %D0',
1762 cmp_attr => "return 1;",
1763 ins => [ "val_high", "val_low" ],
1768 cmp_attr => "return 1;",
1770 outs => [ "res_high", "res_low" ],
1778 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1779 outs => [ "DST", "SRC", "CNT", "M" ],
1780 attr_type => "ia32_copyb_attr_t",
1781 attr => "unsigned size",
1784 # we don't care about this flag, so no need to mark this node
1785 # modified_flags => [ "DF" ]
1791 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1792 outs => [ "DST", "SRC", "M" ],
1793 attr_type => "ia32_copyb_attr_t",
1794 attr => "unsigned size",
1797 # we don't care about this flag, so no need to mark this node
1798 # modified_flags => [ "DF" ]
1804 state => "exc_pinned",
1805 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1806 ins => [ "base", "index", "mem", "val" ],
1807 am => "source,unary",
1810 attr => "ir_mode *smaller_mode",
1811 init_attr => "attr->ls_mode = smaller_mode;",
1816 state => "exc_pinned",
1817 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1818 ins => [ "base", "index", "mem", "val" ],
1819 am => "source,unary",
1822 attr => "ir_mode *smaller_mode",
1823 init_attr => "attr->ls_mode = smaller_mode;",
1828 state => "exc_pinned",
1829 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1830 ins => [ "base", "index", "mem", "val" ],
1831 am => "source,unary",
1838 state => "exc_pinned",
1839 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1840 ins => [ "base", "index", "mem", "val" ],
1841 am => "source,unary",
1848 state => "exc_pinned",
1849 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1850 ins => [ "base", "index", "mem", "val" ],
1851 am => "source,unary",
1857 #----------------------------------------------------------#
1859 # (_) | | | | / _| | | | #
1860 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1861 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1862 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1863 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1865 # _ __ ___ __| | ___ ___ #
1866 # | '_ \ / _ \ / _` |/ _ \/ __| #
1867 # | | | | (_) | (_| | __/\__ \ #
1868 # |_| |_|\___/ \__,_|\___||___/ #
1869 #----------------------------------------------------------#
1871 # rematerialisation disabled for all float nodes for now, because the fpcw
1872 # handler runs before spilling and we might end up with wrong fpcw then
1876 state => "exc_pinned",
1877 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1878 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1879 am => "source,binary",
1883 attr_type => "ia32_x87_attr_t",
1888 state => "exc_pinned",
1889 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1890 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1891 am => "source,binary",
1895 attr_type => "ia32_x87_attr_t",
1900 state => "exc_pinned",
1901 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1902 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1903 am => "source,binary",
1907 attr_type => "ia32_x87_attr_t",
1911 state => "exc_pinned",
1912 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1913 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1914 am => "source,binary",
1915 outs => [ "res", "M" ],
1918 attr_type => "ia32_x87_attr_t",
1922 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1923 ins => [ "left", "right", "fpcw" ],
1927 attr_type => "ia32_x87_attr_t",
1932 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1937 attr_type => "ia32_x87_attr_t",
1942 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1947 attr_type => "ia32_x87_attr_t",
1950 # virtual Load and Store
1955 state => "exc_pinned",
1956 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1957 ins => [ "base", "index", "mem" ],
1958 outs => [ "res", "M", "X_exc" ],
1959 attr => "ir_mode *load_mode",
1960 init_attr => "attr->attr.ls_mode = load_mode;",
1963 attr_type => "ia32_x87_attr_t",
1969 state => "exc_pinned",
1970 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1971 ins => [ "base", "index", "mem", "val" ],
1972 outs => [ "M", "X_exc" ],
1973 attr => "ir_mode *store_mode",
1974 init_attr => "attr->attr.ls_mode = store_mode;",
1978 attr_type => "ia32_x87_attr_t",
1984 state => "exc_pinned",
1985 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1986 outs => [ "res", "M" ],
1987 ins => [ "base", "index", "mem" ],
1990 attr_type => "ia32_x87_attr_t",
1994 state => "exc_pinned",
1995 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1996 ins => [ "base", "index", "mem", "val", "fpcw" ],
2000 attr_type => "ia32_x87_attr_t",
2003 # SSE3 fisttp instruction
2005 state => "exc_pinned",
2006 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2007 ins => [ "base", "index", "mem", "val" ],
2008 outs => [ "res", "M" ],
2011 attr_type => "ia32_x87_attr_t",
2019 reg_req => { out => [ "vfp" ] },
2024 attr_type => "ia32_x87_attr_t",
2029 reg_req => { out => [ "vfp" ] },
2034 attr_type => "ia32_x87_attr_t",
2039 reg_req => { out => [ "vfp" ] },
2044 attr_type => "ia32_x87_attr_t",
2049 reg_req => { out => [ "vfp" ] },
2054 attr_type => "ia32_x87_attr_t",
2059 reg_req => { out => [ "vfp" ] },
2064 attr_type => "ia32_x87_attr_t",
2069 reg_req => { out => [ "vfp" ] },
2074 attr_type => "ia32_x87_attr_t",
2079 reg_req => { out => [ "vfp" ] },
2084 attr_type => "ia32_x87_attr_t",
2090 # we can't allow to rematerialize this node so we don't have
2091 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2093 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2094 ins => [ "left", "right" ],
2095 outs => [ "flags" ],
2096 attr => "int ins_permuted",
2097 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2100 attr_type => "ia32_x87_attr_t",
2106 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2107 ins => [ "left", "right" ],
2108 outs => [ "flags" ],
2109 attr => "int ins_permuted",
2110 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2113 attr_type => "ia32_x87_attr_t",
2119 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2121 outs => [ "flags" ],
2122 attr => "int ins_permuted",
2123 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2126 attr_type => "ia32_x87_attr_t",
2132 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2134 outs => [ "flags" ],
2138 mode => $mode_flags,
2141 #------------------------------------------------------------------------#
2142 # ___ _____ __ _ _ _ #
2143 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2144 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2145 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2146 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2147 #------------------------------------------------------------------------#
2149 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2150 # are swapped, we work this around in the emitter...
2153 state => "exc_pinned",
2154 rd_constructor => "NONE",
2156 emit => '. fadd%XM %x87_binop',
2158 attr_type => "ia32_x87_attr_t",
2162 state => "exc_pinned",
2163 rd_constructor => "NONE",
2165 emit => '. faddp%XM %x87_binop',
2167 attr_type => "ia32_x87_attr_t",
2171 state => "exc_pinned",
2172 rd_constructor => "NONE",
2174 emit => '. fmul%XM %x87_binop',
2176 attr_type => "ia32_x87_attr_t",
2180 state => "exc_pinned",
2181 rd_constructor => "NONE",
2183 emit => '. fmulp%XM %x87_binop',,
2185 attr_type => "ia32_x87_attr_t",
2189 state => "exc_pinned",
2190 rd_constructor => "NONE",
2192 emit => '. fsub%XM %x87_binop',
2194 attr_type => "ia32_x87_attr_t",
2198 state => "exc_pinned",
2199 rd_constructor => "NONE",
2201 # see note about gas bugs
2202 emit => '. fsubrp%XM %x87_binop',
2204 attr_type => "ia32_x87_attr_t",
2208 state => "exc_pinned",
2209 rd_constructor => "NONE",
2212 emit => '. fsubr%XM %x87_binop',
2214 attr_type => "ia32_x87_attr_t",
2218 state => "exc_pinned",
2219 rd_constructor => "NONE",
2222 # see note about gas bugs
2223 emit => '. fsubp%XM %x87_binop',
2225 attr_type => "ia32_x87_attr_t",
2229 rd_constructor => "NONE",
2233 attr_type => "ia32_x87_attr_t",
2236 # this node is just here, to keep the simulator running
2237 # we can omit this when a fprem simulation function exists
2239 rd_constructor => "NONE",
2241 emit => '. fprem1\n'.
2244 attr_type => "ia32_x87_attr_t",
2248 state => "exc_pinned",
2249 rd_constructor => "NONE",
2251 emit => '. fdiv%XM %x87_binop',
2253 attr_type => "ia32_x87_attr_t",
2257 state => "exc_pinned",
2258 rd_constructor => "NONE",
2260 # see note about gas bugs
2261 emit => '. fdivrp%XM %x87_binop',
2263 attr_type => "ia32_x87_attr_t",
2267 state => "exc_pinned",
2268 rd_constructor => "NONE",
2270 emit => '. fdivr%XM %x87_binop',
2272 attr_type => "ia32_x87_attr_t",
2276 state => "exc_pinned",
2277 rd_constructor => "NONE",
2279 # see note about gas bugs
2280 emit => '. fdivp%XM %x87_binop',
2282 attr_type => "ia32_x87_attr_t",
2286 rd_constructor => "NONE",
2290 attr_type => "ia32_x87_attr_t",
2295 rd_constructor => "NONE",
2299 attr_type => "ia32_x87_attr_t",
2302 # x87 Load and Store
2305 rd_constructor => "NONE",
2306 op_flags => "R|L|F",
2307 state => "exc_pinned",
2309 emit => '. fld%XM %AM',
2310 attr_type => "ia32_x87_attr_t",
2315 rd_constructor => "NONE",
2316 op_flags => "R|L|F",
2317 state => "exc_pinned",
2319 emit => '. fst%XM %AM',
2321 attr_type => "ia32_x87_attr_t",
2326 rd_constructor => "NONE",
2327 op_flags => "R|L|F",
2328 state => "exc_pinned",
2330 emit => '. fstp%XM %AM',
2332 attr_type => "ia32_x87_attr_t",
2339 state => "exc_pinned",
2340 rd_constructor => "NONE",
2342 emit => '. fild%XM %AM',
2343 attr_type => "ia32_x87_attr_t",
2348 state => "exc_pinned",
2349 rd_constructor => "NONE",
2351 emit => '. fist%XM %AM',
2353 attr_type => "ia32_x87_attr_t",
2358 state => "exc_pinned",
2359 rd_constructor => "NONE",
2361 emit => '. fistp%XM %AM',
2363 attr_type => "ia32_x87_attr_t",
2367 # SSE3 firsttp instruction
2369 state => "exc_pinned",
2370 rd_constructor => "NONE",
2372 emit => '. fisttp%XM %AM',
2374 attr_type => "ia32_x87_attr_t",
2381 op_flags => "R|c|K",
2383 reg_req => { out => [ "vfp" ] },
2385 attr_type => "ia32_x87_attr_t",
2390 op_flags => "R|c|K",
2392 reg_req => { out => [ "vfp" ] },
2394 attr_type => "ia32_x87_attr_t",
2399 op_flags => "R|c|K",
2401 reg_req => { out => [ "vfp" ] },
2403 attr_type => "ia32_x87_attr_t",
2408 op_flags => "R|c|K",
2410 reg_req => { out => [ "vfp" ] },
2412 attr_type => "ia32_x87_attr_t",
2417 op_flags => "R|c|K",
2419 reg_req => { out => [ "vfp" ] },
2421 attr_type => "ia32_x87_attr_t",
2426 op_flags => "R|c|K",
2428 reg_req => { out => [ "vfp" ] },
2429 emit => '. fldll2t',
2430 attr_type => "ia32_x87_attr_t",
2435 op_flags => "R|c|K",
2437 reg_req => { out => [ "vfp" ] },
2439 attr_type => "ia32_x87_attr_t",
2444 # Note that it is NEVER allowed to do CSE on these nodes
2445 # Moreover, note the virtual register requierements!
2450 cmp_attr => "return 1;",
2451 emit => '. fxch %X0',
2452 attr_type => "ia32_x87_attr_t",
2460 cmp_attr => "return 1;",
2461 emit => '. fld %X0',
2462 attr_type => "ia32_x87_attr_t",
2468 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2469 cmp_attr => "return 1;",
2470 emit => '. fld %X0',
2471 attr_type => "ia32_x87_attr_t",
2478 cmp_attr => "return 1;",
2479 emit => '. fstp %X0',
2480 attr_type => "ia32_x87_attr_t",
2488 cmp_attr => "return 1;",
2489 emit => '. ffreep %X0',
2490 attr_type => "ia32_x87_attr_t",
2498 cmp_attr => "return 1;",
2500 attr_type => "ia32_x87_attr_t",
2508 cmp_attr => "return 1;",
2510 attr_type => "ia32_x87_attr_t",
2519 emit => ". fucom %X1\n".
2521 attr_type => "ia32_x87_attr_t",
2527 emit => ". fucomp %X1\n".
2529 attr_type => "ia32_x87_attr_t",
2535 emit => ". fucompp\n".
2537 attr_type => "ia32_x87_attr_t",
2543 emit => '. fucomi %X1',
2544 attr_type => "ia32_x87_attr_t",
2550 emit => '. fucompi %X1',
2551 attr_type => "ia32_x87_attr_t",
2559 attr_type => "ia32_x87_attr_t",
2564 # -------------------------------------------------------------------------------- #
2565 # ____ ____ _____ _ _ #
2566 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2567 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2568 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2569 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2571 # -------------------------------------------------------------------------------- #
2574 # Spilling and reloading of SSE registers, hardcoded, not generated #
2578 state => "exc_pinned",
2579 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2580 emit => '. movdqu %D0, %AM',
2581 outs => [ "res", "M" ],
2588 state => "exc_pinned",
2589 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2590 ins => [ "base", "index", "mem", "val" ],
2591 emit => '. movdqu %binop',
2599 # Include the generated SIMD node specification written by the SIMD optimization
2600 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2601 unless ($return = do $my_script_name) {
2602 warn "couldn't parse $my_script_name: $@" if $@;
2603 warn "couldn't do $my_script_name: $!" unless defined $return;
2604 warn "couldn't run $my_script_name" unless $return;
2607 # Transform some attributes
2608 foreach my $op (keys(%nodes)) {
2609 my $node = $nodes{$op};
2610 my $op_attr_init = $node->{op_attr_init};
2612 if(defined($op_attr_init)) {
2613 $op_attr_init .= "\n\t";
2618 if(!defined($node->{latency})) {
2620 $node->{latency} = 0;
2622 die("Latency missing for op $op");
2625 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2627 $node->{op_attr_init} = $op_attr_init;