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",
20 # irn_flags => "R|N|I|S"
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:
66 # I ignore for register allocation
67 # S modifies stack pointer
69 # state: state of the operation, OPTIONAL (default is "floats")
71 # arity: arity of the operation, MUST NOT BE OMITTED
73 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
74 # are always the first 3 arguments and are always autmatically
76 # If this key is missing the following arguments will be created:
77 # for i = 1 .. arity: ir_node *op_i
80 # outs: if a node defines more than one output, the names of the projections
81 # nodes having outs having automatically the mode mode_T
82 # One can also annotate some flags for each out, additional to irn_flags.
83 # They are separated from name with a colon ':', and concatenated by pipe '|'
84 # Only I and S are available at the moment (same meaning as in irn_flags).
85 # example: [ "frame:I", "stack:I|S", "M" ]
87 # comment: OPTIONAL comment for the node constructor
89 # rd_constructor: for every operation there will be a
90 # new_rd_<arch>_<op-name> function with the arguments from above
91 # which creates the ir_node corresponding to the defined operation
92 # you can either put the complete source code of this function here
94 # This key is OPTIONAL. If omitted, the following constructor will
96 # if (!op_<arch>_<op-name>) assert(0);
100 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
103 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
107 # 0 - no special type
108 # 1 - caller save (register must be saved by the caller of a function)
109 # 2 - callee save (register must be saved by the called function)
110 # 4 - ignore (do not assign this register)
111 # 8 - emitter can choose an arbitrary register of this class
112 # 16 - the register is a virtual one
113 # 32 - register represents a state
114 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
117 { name => "edx", type => 1 },
118 { name => "ecx", type => 1 },
119 { name => "eax", type => 1 },
120 { name => "ebx", type => 2 },
121 { name => "esi", type => 2 },
122 { name => "edi", type => 2 },
123 { name => "ebp", type => 2 },
124 { name => "esp", type => 4 },
125 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
126 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
127 { mode => "mode_Iu" }
130 { name => "mm0", type => 4 },
131 { name => "mm1", type => 4 },
132 { name => "mm2", type => 4 },
133 { name => "mm3", type => 4 },
134 { name => "mm4", type => 4 },
135 { name => "mm5", type => 4 },
136 { name => "mm6", type => 4 },
137 { name => "mm7", type => 4 },
138 { mode => "mode_E", flags => "manual_ra" }
141 { name => "xmm0", type => 1 },
142 { name => "xmm1", type => 1 },
143 { name => "xmm2", type => 1 },
144 { name => "xmm3", type => 1 },
145 { name => "xmm4", type => 1 },
146 { name => "xmm5", type => 1 },
147 { name => "xmm6", type => 1 },
148 { name => "xmm7", type => 1 },
149 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
150 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
154 { name => "vf0", type => 1 },
155 { name => "vf1", type => 1 },
156 { name => "vf2", type => 1 },
157 { name => "vf3", type => 1 },
158 { name => "vf4", type => 1 },
159 { name => "vf5", type => 1 },
160 { name => "vf6", type => 1 },
161 { name => "vf7", type => 1 },
162 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
163 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
167 { name => "st0", realname => "st", type => 4 },
168 { name => "st1", realname => "st(1)", type => 4 },
169 { name => "st2", realname => "st(2)", type => 4 },
170 { name => "st3", realname => "st(3)", type => 4 },
171 { name => "st4", realname => "st(4)", type => 4 },
172 { name => "st5", realname => "st(5)", type => 4 },
173 { name => "st6", realname => "st(6)", type => 4 },
174 { name => "st7", realname => "st(7)", type => 4 },
175 { mode => "mode_E", flags => "manual_ra" }
177 fp_cw => [ # the floating point control word
178 { name => "fpcw", type => 4|32 },
179 { mode => "mode_fpcw", flags => "manual_ra|state" }
182 { name => "eflags", type => 0 },
183 { mode => "mode_Iu", flags => "manual_ra" }
188 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
189 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
190 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
191 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
196 bundels_per_cycle => 1
200 S0 => "${arch}_emit_source_register(node, 0);",
201 S1 => "${arch}_emit_source_register(node, 1);",
202 S2 => "${arch}_emit_source_register(node, 2);",
203 S3 => "${arch}_emit_source_register(node, 3);",
204 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
205 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
206 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
207 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
208 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
209 D0 => "${arch}_emit_dest_register(node, 0);",
210 D1 => "${arch}_emit_dest_register(node, 1);",
211 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
212 X0 => "${arch}_emit_x87_register(node, 0);",
213 X1 => "${arch}_emit_x87_register(node, 1);",
214 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
215 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
216 ia32_emit_mode_suffix(node);",
217 M => "${arch}_emit_mode_suffix(node);",
218 XM => "${arch}_emit_x87_mode_suffix(node);",
219 XXM => "${arch}_emit_xmm_mode_suffix(node);",
220 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
221 AM => "${arch}_emit_am(node);",
222 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
223 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
224 binop => "${arch}_emit_binop(node);",
225 x87_binop => "${arch}_emit_x87_binop(node);",
226 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
227 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
230 #--------------------------------------------------#
233 # _ __ _____ __ _ _ __ ___ _ __ ___ #
234 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
235 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
236 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
239 #--------------------------------------------------#
241 $default_op_attr_type = "ia32_op_attr_t";
242 $default_attr_type = "ia32_attr_t";
243 $default_copy_attr = "ia32_copy_attr";
245 sub ia32_custom_init_attr {
250 if(defined($node->{modified_flags})) {
251 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
253 if(defined($node->{am})) {
254 my $am = $node->{am};
255 if($am eq "source,unary") {
256 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
257 } elsif($am eq "source,binary") {
258 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
259 } elsif($am eq "none") {
262 die("Invalid address mode '$am' specified on op $name");
265 if($node->{state} ne "exc_pinned"
266 and $node->{state} ne "pinned") {
267 die("AM nodes must have pinned or AM pinned state ($name)");
273 $custom_init_attr_func = \&ia32_custom_init_attr;
277 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
278 "\tinit_ia32_x87_attributes(res);".
279 "\tinit_ia32_asm_attributes(res);",
281 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
284 "\tinit_ia32_call_attributes(res, pop, call_tp);",
285 ia32_condcode_attr_t =>
286 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
287 "\tinit_ia32_condcode_attributes(res, pnc);",
289 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
290 "\tinit_ia32_copyb_attributes(res, size);",
291 ia32_immediate_attr_t =>
292 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
293 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
295 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
296 "\tinit_ia32_x87_attributes(res);",
300 ia32_asm_attr_t => "ia32_compare_asm_attr",
301 ia32_attr_t => "ia32_compare_nodes_attr",
302 ia32_call_attr_t => "ia32_compare_call_attr",
303 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
304 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
305 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
306 ia32_x87_attr_t => "ia32_compare_x87_attr",
312 $mode_xmm = "mode_E";
313 $mode_gp = "mode_Iu";
314 $mode_flags = "mode_Iu";
315 $mode_fpcw = "mode_fpcw";
316 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
317 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
318 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
319 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
327 reg_req => { out => [ "gp_NOREG" ] },
328 attr => "ir_entity *symconst, int symconst_sign, long offset",
329 attr_type => "ia32_immediate_attr_t",
330 hash_func => "ia32_hash_Immediate",
338 out_arity => "variable",
339 attr_type => "ia32_asm_attr_t",
340 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
341 init_attr => "attr->asm_text = asm_text;\n".
342 "\tattr->register_map = register_map;\n",
347 # "allocates" a free register
351 reg_req => { out => [ "gp" ] },
356 cmp_attr => "return 1;",
359 #-----------------------------------------------------------------#
362 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
363 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
364 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
365 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
368 #-----------------------------------------------------------------#
370 # commutative operations
374 state => "exc_pinned",
375 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
376 out => [ "in_r4 in_r5", "flags", "none" ] },
377 ins => [ "base", "index", "mem", "left", "right" ],
378 outs => [ "res", "flags", "M" ],
379 emit => '. add%M %binop',
380 am => "source,binary",
384 modified_flags => $status_flags
389 state => "exc_pinned",
390 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
391 ins => [ "base", "index", "mem", "val" ],
392 emit => ". add%M %SI3, %AM",
396 modified_flags => $status_flags
401 state => "exc_pinned",
402 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
403 ins => [ "base", "index", "mem", "val" ],
404 emit => ". add%M %SB3, %AM",
408 modified_flags => $status_flags
412 state => "exc_pinned",
413 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
414 out => [ "in_r4 in_r5", "flags", "none" ] },
415 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
416 outs => [ "res", "flags", "M" ],
417 emit => '. adc%M %binop',
418 am => "source,binary",
422 modified_flags => $status_flags
427 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
428 ins => [ "left", "right" ],
432 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
433 ins => [ "left", "right", "eflags" ],
437 # we should not rematrialize this node. It produces 2 results and has
438 # very strict constraints
439 state => "exc_pinned",
440 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
441 out => [ "eax", "flags", "edx", "none" ] },
442 ins => [ "base", "index", "mem", "left", "right" ],
443 emit => '. mul%M %unop4',
444 outs => [ "res_low", "flags", "res_high", "M" ],
445 am => "source,binary",
448 modified_flags => $status_flags
452 # we should not rematrialize this node. It produces 2 results and has
453 # very strict constraints
455 cmp_attr => "return 1;",
456 outs => [ "EAX", "flags", "EDX", "M" ],
462 state => "exc_pinned",
463 # TODO: adjust out requirements for the 3 operand form
464 # (no need for should_be_same then)
465 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
466 out => [ "in_r4 in_r5", "flags", "none" ] },
467 ins => [ "base", "index", "mem", "left", "right" ],
468 outs => [ "res", "flags", "M" ],
469 am => "source,binary",
473 modified_flags => $status_flags
478 state => "exc_pinned",
479 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
480 out => [ "eax", "edx", "none" ] },
481 ins => [ "base", "index", "mem", "left", "right" ],
482 emit => '. imul%M %unop4',
483 outs => [ "res_low", "res_high", "M" ],
484 am => "source,binary",
487 modified_flags => $status_flags
492 cmp_attr => "return 1;",
493 outs => [ "res_low", "res_high", "M" ],
499 state => "exc_pinned",
500 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
501 out => [ "in_r4 in_r5", "flags", "none" ] },
502 ins => [ "base", "index", "mem", "left", "right" ],
503 outs => [ "res", "flags", "M" ],
504 op_modes => "commutative | am | immediate | mode_neutral",
505 am => "source,binary",
506 emit => '. and%M %binop',
510 modified_flags => $status_flags
515 state => "exc_pinned",
516 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
517 ins => [ "base", "index", "mem", "val" ],
518 emit => '. and%M %SI3, %AM',
522 modified_flags => $status_flags
527 state => "exc_pinned",
528 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
529 ins => [ "base", "index", "mem", "val" ],
530 emit => '. and%M %SB3, %AM',
534 modified_flags => $status_flags
539 state => "exc_pinned",
540 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
541 out => [ "in_r4 in_r5", "flags", "none" ] },
542 ins => [ "base", "index", "mem", "left", "right" ],
543 outs => [ "res", "flags", "M" ],
544 am => "source,binary",
545 emit => '. or%M %binop',
549 modified_flags => $status_flags
554 state => "exc_pinned",
555 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
556 ins => [ "base", "index", "mem", "val" ],
557 emit => '. or%M %SI3, %AM',
561 modified_flags => $status_flags
566 state => "exc_pinned",
567 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
568 ins => [ "base", "index", "mem", "val" ],
569 emit => '. or%M %SB3, %AM',
573 modified_flags => $status_flags
578 state => "exc_pinned",
579 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
580 out => [ "in_r4 in_r5", "flags", "none" ] },
581 ins => [ "base", "index", "mem", "left", "right" ],
582 outs => [ "res", "flags", "M" ],
583 am => "source,binary",
584 emit => '. xor%M %binop',
588 modified_flags => $status_flags
593 state => "exc_pinned",
594 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
595 ins => [ "base", "index", "mem", "val" ],
596 emit => '. xor%M %SI3, %AM',
600 modified_flags => $status_flags
605 state => "exc_pinned",
606 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
607 ins => [ "base", "index", "mem", "val" ],
608 emit => '. xor%M %SB3, %AM',
612 modified_flags => $status_flags
615 # not commutative operations
619 state => "exc_pinned",
620 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
621 out => [ "in_r4", "flags", "none" ] },
622 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
623 outs => [ "res", "flags", "M" ],
624 am => "source,binary",
625 emit => '. sub%M %binop',
629 modified_flags => $status_flags
634 state => "exc_pinned",
635 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
636 ins => [ "base", "index", "mem", "subtrahend" ],
637 emit => '. sub%M %SI3, %AM',
641 modified_flags => $status_flags
646 state => "exc_pinned",
647 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
648 ins => [ "base", "index", "mem", "subtrahend" ],
649 emit => '. sub%M %SB3, %AM',
653 modified_flags => $status_flags
657 state => "exc_pinned",
658 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
659 out => [ "in_r4 !in_r5", "flags", "none" ] },
660 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
661 outs => [ "res", "flags", "M" ],
662 am => "source,binary",
663 emit => '. sbb%M %binop',
667 modified_flags => $status_flags
671 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
672 ins => [ "minuend", "subtrahend" ],
676 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
677 ins => [ "minuend", "subtrahend", "eflags" ],
682 state => "exc_pinned",
683 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
684 out => [ "eax", "flags", "none", "edx", "none" ] },
685 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
686 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
687 am => "source,unary",
688 emit => ". idiv%M %unop3",
691 modified_flags => $status_flags
696 state => "exc_pinned",
697 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
698 out => [ "eax", "flags", "none", "edx", "none" ] },
699 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
700 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
701 am => "source,unary",
702 emit => ". div%M %unop3",
705 modified_flags => $status_flags
710 reg_req => { in => [ "gp", "ecx" ],
711 out => [ "in_r1 !in_r2", "flags" ] },
712 ins => [ "val", "count" ],
713 outs => [ "res", "flags" ],
714 emit => '. shl %SB1, %S0',
718 modified_flags => $status_flags
723 state => "exc_pinned",
724 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
725 ins => [ "base", "index", "mem", "count" ],
726 emit => '. shl%M %SB3, %AM',
730 modified_flags => $status_flags
734 cmp_attr => "return 1;",
735 ins => [ "val", "count", "dep" ],
741 reg_req => { in => [ "gp", "gp", "ecx" ],
742 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
743 ins => [ "val_high", "val_low", "count" ],
744 outs => [ "res", "flags" ],
745 emit => ". shld%M %SB2, %S1, %D0",
749 modified_flags => $status_flags
753 cmp_attr => "return 1;",
754 ins => [ "val_high", "val_low", "count" ],
760 reg_req => { in => [ "gp", "ecx" ],
761 out => [ "in_r1 !in_r2", "flags" ] },
762 ins => [ "val", "count" ],
763 outs => [ "res", "flags" ],
764 emit => '. shr %SB1, %S0',
768 modified_flags => $status_flags
773 state => "exc_pinned",
774 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
775 ins => [ "base", "index", "mem", "count" ],
776 emit => '. shr%M %SB3, %AM',
780 modified_flags => $status_flags
784 cmp_attr => "return 1;",
785 ins => [ "val", "count", "dep" ],
791 reg_req => { in => [ "gp", "gp", "ecx" ],
792 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
793 ins => [ "val_high", "val_low", "count" ],
794 outs => [ "res", "flags" ],
795 emit => ". shrd%M %SB2, %S1, %D0",
799 modified_flags => $status_flags
803 cmp_attr => "return 1;",
805 ins => [ "val_high", "val_low", "count" ],
810 reg_req => { in => [ "gp", "ecx" ],
811 out => [ "in_r1 !in_r2", "flags" ] },
812 ins => [ "val", "count" ],
813 outs => [ "res", "flags" ],
814 emit => '. sar %SB1, %S0',
818 modified_flags => $status_flags
823 state => "exc_pinned",
824 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
825 ins => [ "base", "index", "mem", "count" ],
826 emit => '. sar%M %SB3, %AM',
830 modified_flags => $status_flags
834 cmp_attr => "return 1;",
835 ins => [ "val", "count", "dep" ],
841 reg_req => { in => [ "gp", "ecx" ],
842 out => [ "in_r1 !in_r2", "flags" ] },
843 ins => [ "val", "count" ],
844 outs => [ "res", "flags" ],
845 emit => '. ror %SB1, %S0',
849 modified_flags => $status_flags
854 state => "exc_pinned",
855 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
856 ins => [ "base", "index", "mem", "count" ],
857 emit => '. ror%M %SB3, %AM',
861 modified_flags => $status_flags
866 reg_req => { in => [ "gp", "ecx" ],
867 out => [ "in_r1 !in_r2", "flags" ] },
868 ins => [ "val", "count" ],
869 outs => [ "res", "flags" ],
870 emit => '. rol %SB1, %S0',
874 modified_flags => $status_flags
879 state => "exc_pinned",
880 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
881 ins => [ "base", "index", "mem", "count" ],
882 emit => '. rol%M %SB3, %AM',
886 modified_flags => $status_flags
893 reg_req => { in => [ "gp" ],
894 out => [ "in_r1", "flags" ] },
897 outs => [ "res", "flags" ],
901 modified_flags => $status_flags
906 state => "exc_pinned",
907 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
908 ins => [ "base", "index", "mem" ],
909 emit => '. neg%M %AM',
913 modified_flags => $status_flags
918 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
919 outs => [ "low_res", "high_res" ],
922 modified_flags => $status_flags
928 reg_req => { in => [ "gp" ],
929 out => [ "in_r1", "flags" ] },
931 outs => [ "res", "flags" ],
936 modified_flags => $status_flags_wo_cf
941 state => "exc_pinned",
942 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
943 ins => [ "base", "index", "mem" ],
944 emit => '. inc%M %AM',
948 modified_flags => $status_flags_wo_cf
953 reg_req => { in => [ "gp" ],
954 out => [ "in_r1", "flags" ] },
956 outs => [ "res", "flags" ],
961 modified_flags => $status_flags_wo_cf
966 state => "exc_pinned",
967 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
968 ins => [ "base", "index", "mem" ],
969 emit => '. dec%M %AM',
973 modified_flags => $status_flags_wo_cf
978 reg_req => { in => [ "gp" ],
979 out => [ "in_r1", "flags" ] },
981 outs => [ "res", "flags" ],
991 state => "exc_pinned",
992 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
993 ins => [ "base", "index", "mem" ],
994 emit => '. not%M %AM',
1002 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1006 mode => $mode_flags,
1007 modified_flags => $status_flags
1011 reg_req => { out => [ "flags" ] },
1015 mode => $mode_flags,
1016 modified_flags => $status_flags
1023 state => "exc_pinned",
1024 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1025 out => [ "flags", "none", "none" ] },
1026 ins => [ "base", "index", "mem", "left", "right" ],
1027 outs => [ "eflags", "unused", "M" ],
1028 am => "source,binary",
1029 emit => '. cmp%M %binop',
1030 attr => "int ins_permuted, int cmp_unsigned",
1031 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1032 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1035 mode => $mode_flags,
1036 modified_flags => $status_flags
1041 state => "exc_pinned",
1042 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1043 ins => [ "base", "index", "mem", "left", "right" ],
1044 outs => [ "eflags" ],
1045 am => "source,binary",
1046 emit => '. cmpb %binop',
1047 attr => "int ins_permuted, int cmp_unsigned",
1048 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1049 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1052 mode => $mode_flags,
1053 modified_flags => $status_flags
1058 state => "exc_pinned",
1059 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1060 ins => [ "base", "index", "mem", "left", "right" ],
1061 outs => [ "eflags" ],
1062 am => "source,binary",
1063 emit => '. test%M %binop',
1064 attr => "int ins_permuted, int cmp_unsigned",
1065 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1066 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1069 mode => $mode_flags,
1070 modified_flags => $status_flags
1075 state => "exc_pinned",
1076 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1077 ins => [ "base", "index", "mem", "left", "right" ],
1078 outs => [ "eflags" ],
1079 am => "source,binary",
1080 emit => '. testb %binop',
1081 attr => "int ins_permuted, int cmp_unsigned",
1082 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1083 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1086 mode => $mode_flags,
1087 modified_flags => $status_flags
1092 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1093 ins => [ "eflags" ],
1094 attr_type => "ia32_condcode_attr_t",
1095 attr => "pn_Cmp pnc, int ins_permuted",
1096 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1097 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1098 emit => '. set%CMP0 %DB0',
1106 state => "exc_pinned",
1107 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1108 ins => [ "base", "index", "mem","eflags" ],
1109 attr_type => "ia32_condcode_attr_t",
1110 attr => "pn_Cmp pnc, int ins_permuted",
1111 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1112 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1113 emit => '. set%CMP3 %AM',
1121 # (note: leave the false,true order intact to make it compatible with other
1123 state => "exc_pinned",
1124 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1125 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1126 am => "source,binary",
1127 attr_type => "ia32_condcode_attr_t",
1128 attr => "int ins_permuted, pn_Cmp pnc",
1129 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1137 op_flags => "L|X|Y",
1138 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1139 ins => [ "eflags" ],
1140 outs => [ "false", "true" ],
1141 attr_type => "ia32_condcode_attr_t",
1142 attr => "pn_Cmp pnc",
1144 units => [ "BRANCH" ],
1149 op_flags => "L|X|Y",
1150 reg_req => { in => [ "gp" ], out => [ "none" ] },
1152 attr_type => "ia32_condcode_attr_t",
1155 units => [ "BRANCH" ],
1156 modified_flags => $status_flags,
1162 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1163 ins => [ "base", "index", "mem", "target" ],
1164 am => "source,unary",
1165 emit => '. jmp *%unop3',
1167 units => [ "BRANCH" ],
1174 reg_req => { out => [ "gp" ] },
1176 attr => "ir_entity *symconst, int symconst_sign, long offset",
1177 attr_type => "ia32_immediate_attr_t",
1184 reg_req => { out => [ "gp" ] },
1188 modified_flags => $status_flags,
1195 reg_req => { out => [ "gp_UKNWN" ] },
1206 reg_req => { out => [ "vfp_UKNWN" ] },
1211 attr_type => "ia32_x87_attr_t",
1218 reg_req => { out => [ "xmm_UKNWN" ] },
1227 op_flags => "c|NB|NI",
1229 reg_req => { out => [ "gp_NOREG" ] },
1238 op_flags => "c|NB|NI",
1240 reg_req => { out => [ "vfp_NOREG" ] },
1245 attr_type => "ia32_x87_attr_t",
1250 op_flags => "c|NB|NI",
1252 reg_req => { out => [ "xmm_NOREG" ] },
1263 reg_req => { out => [ "fp_cw" ] },
1267 modified_flags => $fpcw_flags
1273 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1274 ins => [ "base", "index", "mem" ],
1276 emit => ". fldcw %AM",
1279 modified_flags => $fpcw_flags
1285 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1286 ins => [ "base", "index", "mem", "fpcw" ],
1288 emit => ". fnstcw %AM",
1296 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1304 # we should not rematrialize this node. It has very strict constraints.
1305 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1306 ins => [ "val", "clobbered" ],
1315 # Note that we add additional latency values depending on address mode, so a
1316 # lateny of 0 for load is correct
1320 state => "exc_pinned",
1321 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1322 ins => [ "base", "index", "mem" ],
1323 outs => [ "res", "M", "X_exc" ],
1325 emit => ". mov%SE%ME%.l %AM, %D0",
1331 state => "exc_pinned",
1332 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1333 ins => [ "base", "index", "mem", "val" ],
1334 outs => [ "M", "X_exc" ],
1335 emit => '. mov%M %SI3, %AM',
1343 state => "exc_pinned",
1344 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1345 ins => [ "base", "index", "mem", "val" ],
1346 outs => [ "M", "X_exc" ],
1347 emit => '. mov%M %SB3, %AM',
1355 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1356 ins => [ "base", "index" ],
1357 emit => '. leal %AM, %D0',
1361 # lea doesn't modify the flags, but setting this seems advantageous since it
1362 # increases chances that the Lea is transformed back to an Add
1363 modified_flags => 1,
1367 state => "exc_pinned",
1368 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1369 ins => [ "base", "index", "mem", "val", "stack" ],
1370 emit => '. push%M %unop3',
1371 outs => [ "stack:I|S", "M" ],
1372 am => "source,unary",
1378 state => "exc_pinned",
1379 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1380 ins => [ "mem", "stack" ],
1381 outs => [ "res", "M", "unused", "stack:I|S" ],
1382 emit => '. pop%M %D0',
1383 latency => 3, # Pop is more expensive than Push on Athlon
1388 state => "exc_pinned",
1389 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1390 ins => [ "base", "index", "mem", "stack" ],
1391 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1392 emit => '. pop%M %AM',
1393 latency => 3, # Pop is more expensive than Push on Athlon
1398 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1400 outs => [ "frame:I", "stack:I|S", "M" ],
1406 reg_req => { in => [ "ebp" ], out => [ "ebp", "esp" ] },
1408 outs => [ "frame:I", "stack:I|S" ],
1416 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1417 ins => [ "base", "index", "mem", "stack", "size" ],
1418 am => "source,binary",
1419 emit => '. addl %binop',
1421 outs => [ "stack:I|S", "M" ],
1423 modified_flags => $status_flags
1429 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1430 ins => [ "base", "index", "mem", "stack", "size" ],
1431 am => "source,binary",
1432 emit => ". subl %binop\n".
1433 ". movl %%esp, %D1",
1435 outs => [ "stack:I|S", "addr", "M" ],
1437 modified_flags => $status_flags
1450 reg_req => { out => [ "gp" ] },
1457 state => "exc_pinned",
1458 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1459 ins => [ "left", "right" ],
1460 emit => '. bt%M %S1, %S0',
1463 mode => $mode_flags,
1464 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1468 state => "exc_pinned",
1470 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1471 out => [ "esp", "fpcw", "none", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ]
1473 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1474 outs => [ "stack:I|S", "fpcw:I", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1475 attr_type => "ia32_call_attr_t",
1476 attr => "unsigned pop, ir_type *call_tp",
1477 am => "source,unary",
1478 units => [ "BRANCH" ],
1479 latency => 4, # random number
1482 #-----------------------------------------------------------------------------#
1483 # _____ _____ ______ __ _ _ _ #
1484 # / ____/ ____| ____| / _| | | | | | #
1485 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1486 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1487 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1488 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1489 #-----------------------------------------------------------------------------#
1494 reg_req => { out => [ "xmm" ] },
1495 emit => '. xorp%XSD %D0, %D0',
1503 reg_req => { out => [ "xmm" ] },
1504 emit => '. pxor %D0, %D0',
1510 # produces all 1 bits
1513 reg_req => { out => [ "xmm" ] },
1514 emit => '. pcmpeqb %D0, %D0',
1520 # integer shift left, dword
1523 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1524 emit => '. pslld %SI1, %D0',
1530 # integer shift left, qword
1533 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1534 emit => '. psllq %SI1, %D0',
1540 # integer shift right, dword
1543 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1544 emit => '. psrld %SI1, %D0',
1550 # mov from integer to SSE register
1553 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1554 emit => '. movd %S0, %D0',
1560 # commutative operations
1564 state => "exc_pinned",
1565 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1566 ins => [ "base", "index", "mem", "left", "right" ],
1567 am => "source,binary",
1568 emit => '. add%XXM %binop',
1576 state => "exc_pinned",
1577 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1578 ins => [ "base", "index", "mem", "left", "right" ],
1579 am => "source,binary",
1580 emit => '. mul%XXM %binop',
1588 state => "exc_pinned",
1589 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1590 ins => [ "base", "index", "mem", "left", "right" ],
1591 am => "source,binary",
1592 emit => '. max%XXM %binop',
1600 state => "exc_pinned",
1601 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1602 ins => [ "base", "index", "mem", "left", "right" ],
1603 am => "source,binary",
1604 emit => '. min%XXM %binop',
1612 state => "exc_pinned",
1613 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1614 ins => [ "base", "index", "mem", "left", "right" ],
1615 am => "source,binary",
1616 emit => '. andp%XSD %binop',
1624 state => "exc_pinned",
1625 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1626 ins => [ "base", "index", "mem", "left", "right" ],
1627 am => "source,binary",
1628 emit => '. orp%XSD %binop',
1636 state => "exc_pinned",
1637 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1638 ins => [ "base", "index", "mem", "left", "right" ],
1639 am => "source,binary",
1640 emit => '. xorp%XSD %binop',
1646 # not commutative operations
1650 state => "exc_pinned",
1651 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1652 ins => [ "base", "index", "mem", "left", "right" ],
1653 am => "source,binary",
1654 emit => '. andnp%XSD %binop',
1662 state => "exc_pinned",
1663 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1664 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1665 am => "source,binary",
1666 emit => '. sub%XXM %binop',
1674 state => "exc_pinned",
1675 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1676 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1677 am => "source,binary",
1678 outs => [ "res", "M" ],
1679 emit => '. div%XXM %binop',
1688 state => "exc_pinned",
1689 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1690 ins => [ "base", "index", "mem", "left", "right" ],
1691 outs => [ "flags" ],
1692 am => "source,binary",
1693 attr => "int ins_permuted",
1694 init_attr => "attr->data.ins_permuted = ins_permuted;",
1695 emit => ' .ucomi%XXM %binop',
1698 mode => $mode_flags,
1699 modified_flags => 1,
1706 state => "exc_pinned",
1707 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1708 ins => [ "base", "index", "mem" ],
1709 outs => [ "res", "M", "X_exc" ],
1710 emit => '. mov%XXM %AM, %D0',
1711 attr => "ir_mode *load_mode",
1712 init_attr => "attr->ls_mode = load_mode;",
1719 state => "exc_pinned",
1720 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1721 ins => [ "base", "index", "mem", "val" ],
1722 outs => [ "M", "X_exc" ],
1723 emit => '. mov%XXM %S3, %AM',
1731 state => "exc_pinned",
1732 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1733 ins => [ "base", "index", "mem", "val" ],
1734 emit => '. mov%XXM %S3, %AM',
1742 state => "exc_pinned",
1743 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1744 ins => [ "base", "index", "mem", "val" ],
1745 am => "source,unary",
1746 emit => '. cvtsi2ss %unop3, %D0',
1754 state => "exc_pinned",
1755 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1756 ins => [ "base", "index", "mem", "val" ],
1757 am => "source,unary",
1758 emit => '. cvtsi2sd %unop3, %D0',
1767 cmp_attr => "return 1;",
1768 ins => [ "val_high", "val_low" ],
1773 cmp_attr => "return 1;",
1775 outs => [ "res_high", "res_low" ],
1783 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1784 outs => [ "DST", "SRC", "CNT", "M" ],
1785 attr_type => "ia32_copyb_attr_t",
1786 attr => "unsigned size",
1789 # we don't care about this flag, so no need to mark this node
1790 # modified_flags => [ "DF" ]
1796 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1797 outs => [ "DST", "SRC", "M" ],
1798 attr_type => "ia32_copyb_attr_t",
1799 attr => "unsigned size",
1802 # we don't care about this flag, so no need to mark this node
1803 # modified_flags => [ "DF" ]
1809 state => "exc_pinned",
1810 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1811 ins => [ "base", "index", "mem", "val" ],
1812 am => "source,unary",
1815 attr => "ir_mode *smaller_mode",
1816 init_attr => "attr->ls_mode = smaller_mode;",
1821 state => "exc_pinned",
1822 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1823 ins => [ "base", "index", "mem", "val" ],
1824 am => "source,unary",
1827 attr => "ir_mode *smaller_mode",
1828 init_attr => "attr->ls_mode = smaller_mode;",
1833 state => "exc_pinned",
1834 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1835 ins => [ "base", "index", "mem", "val" ],
1836 am => "source,unary",
1843 state => "exc_pinned",
1844 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1845 ins => [ "base", "index", "mem", "val" ],
1846 am => "source,unary",
1853 state => "exc_pinned",
1854 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1855 ins => [ "base", "index", "mem", "val" ],
1856 am => "source,unary",
1862 #----------------------------------------------------------#
1864 # (_) | | | | / _| | | | #
1865 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1866 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1867 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1868 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1870 # _ __ ___ __| | ___ ___ #
1871 # | '_ \ / _ \ / _` |/ _ \/ __| #
1872 # | | | | (_) | (_| | __/\__ \ #
1873 # |_| |_|\___/ \__,_|\___||___/ #
1874 #----------------------------------------------------------#
1876 # rematerialisation disabled for all float nodes for now, because the fpcw
1877 # handler runs before spilling and we might end up with wrong fpcw then
1881 state => "exc_pinned",
1882 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1883 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1884 am => "source,binary",
1888 attr_type => "ia32_x87_attr_t",
1893 state => "exc_pinned",
1894 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1895 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1896 am => "source,binary",
1900 attr_type => "ia32_x87_attr_t",
1905 state => "exc_pinned",
1906 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1907 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1908 am => "source,binary",
1912 attr_type => "ia32_x87_attr_t",
1916 state => "exc_pinned",
1917 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1918 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1919 am => "source,binary",
1920 outs => [ "res", "M" ],
1923 attr_type => "ia32_x87_attr_t",
1927 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1928 ins => [ "left", "right", "fpcw" ],
1932 attr_type => "ia32_x87_attr_t",
1937 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1942 attr_type => "ia32_x87_attr_t",
1947 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1952 attr_type => "ia32_x87_attr_t",
1955 # virtual Load and Store
1960 state => "exc_pinned",
1961 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1962 ins => [ "base", "index", "mem" ],
1963 outs => [ "res", "M", "X_exc" ],
1964 attr => "ir_mode *load_mode",
1965 init_attr => "attr->attr.ls_mode = load_mode;",
1968 attr_type => "ia32_x87_attr_t",
1974 state => "exc_pinned",
1975 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1976 ins => [ "base", "index", "mem", "val" ],
1977 outs => [ "M", "X_exc" ],
1978 attr => "ir_mode *store_mode",
1979 init_attr => "attr->attr.ls_mode = store_mode;",
1983 attr_type => "ia32_x87_attr_t",
1989 state => "exc_pinned",
1990 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1991 outs => [ "res", "M" ],
1992 ins => [ "base", "index", "mem" ],
1995 attr_type => "ia32_x87_attr_t",
1999 state => "exc_pinned",
2000 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2001 ins => [ "base", "index", "mem", "val", "fpcw" ],
2005 attr_type => "ia32_x87_attr_t",
2008 # SSE3 fisttp instruction
2010 state => "exc_pinned",
2011 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2012 ins => [ "base", "index", "mem", "val" ],
2013 outs => [ "res", "M" ],
2016 attr_type => "ia32_x87_attr_t",
2024 reg_req => { out => [ "vfp" ] },
2028 attr_type => "ia32_x87_attr_t",
2033 reg_req => { out => [ "vfp" ] },
2037 attr_type => "ia32_x87_attr_t",
2042 reg_req => { out => [ "vfp" ] },
2046 attr_type => "ia32_x87_attr_t",
2051 reg_req => { out => [ "vfp" ] },
2055 attr_type => "ia32_x87_attr_t",
2060 reg_req => { out => [ "vfp" ] },
2064 attr_type => "ia32_x87_attr_t",
2069 reg_req => { out => [ "vfp" ] },
2073 attr_type => "ia32_x87_attr_t",
2078 reg_req => { out => [ "vfp" ] },
2082 attr_type => "ia32_x87_attr_t",
2088 # we can't allow to rematerialize this node so we don't have
2089 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2091 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2092 ins => [ "left", "right" ],
2093 outs => [ "flags" ],
2094 attr => "int ins_permuted",
2095 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2098 attr_type => "ia32_x87_attr_t",
2104 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2105 ins => [ "left", "right" ],
2106 outs => [ "flags" ],
2107 attr => "int ins_permuted",
2108 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2111 attr_type => "ia32_x87_attr_t",
2117 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2119 outs => [ "flags" ],
2120 attr => "int ins_permuted",
2121 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2124 attr_type => "ia32_x87_attr_t",
2130 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2132 outs => [ "flags" ],
2136 mode => $mode_flags,
2139 #------------------------------------------------------------------------#
2140 # ___ _____ __ _ _ _ #
2141 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2142 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2143 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2144 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2145 #------------------------------------------------------------------------#
2147 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2148 # are swapped, we work this around in the emitter...
2151 state => "exc_pinned",
2152 rd_constructor => "NONE",
2154 emit => '. fadd%XM %x87_binop',
2156 attr_type => "ia32_x87_attr_t",
2160 state => "exc_pinned",
2161 rd_constructor => "NONE",
2163 emit => '. faddp%XM %x87_binop',
2165 attr_type => "ia32_x87_attr_t",
2169 state => "exc_pinned",
2170 rd_constructor => "NONE",
2172 emit => '. fmul%XM %x87_binop',
2174 attr_type => "ia32_x87_attr_t",
2178 state => "exc_pinned",
2179 rd_constructor => "NONE",
2181 emit => '. fmulp%XM %x87_binop',,
2183 attr_type => "ia32_x87_attr_t",
2187 state => "exc_pinned",
2188 rd_constructor => "NONE",
2190 emit => '. fsub%XM %x87_binop',
2192 attr_type => "ia32_x87_attr_t",
2196 state => "exc_pinned",
2197 rd_constructor => "NONE",
2199 # see note about gas bugs
2200 emit => '. fsubrp%XM %x87_binop',
2202 attr_type => "ia32_x87_attr_t",
2206 state => "exc_pinned",
2207 rd_constructor => "NONE",
2210 emit => '. fsubr%XM %x87_binop',
2212 attr_type => "ia32_x87_attr_t",
2216 state => "exc_pinned",
2217 rd_constructor => "NONE",
2220 # see note about gas bugs
2221 emit => '. fsubp%XM %x87_binop',
2223 attr_type => "ia32_x87_attr_t",
2227 rd_constructor => "NONE",
2231 attr_type => "ia32_x87_attr_t",
2234 # this node is just here, to keep the simulator running
2235 # we can omit this when a fprem simulation function exists
2237 rd_constructor => "NONE",
2239 emit => '. fprem1\n'.
2242 attr_type => "ia32_x87_attr_t",
2246 state => "exc_pinned",
2247 rd_constructor => "NONE",
2249 emit => '. fdiv%XM %x87_binop',
2251 attr_type => "ia32_x87_attr_t",
2255 state => "exc_pinned",
2256 rd_constructor => "NONE",
2258 # see note about gas bugs
2259 emit => '. fdivrp%XM %x87_binop',
2261 attr_type => "ia32_x87_attr_t",
2265 state => "exc_pinned",
2266 rd_constructor => "NONE",
2268 emit => '. fdivr%XM %x87_binop',
2270 attr_type => "ia32_x87_attr_t",
2274 state => "exc_pinned",
2275 rd_constructor => "NONE",
2277 # see note about gas bugs
2278 emit => '. fdivp%XM %x87_binop',
2280 attr_type => "ia32_x87_attr_t",
2284 rd_constructor => "NONE",
2288 attr_type => "ia32_x87_attr_t",
2293 rd_constructor => "NONE",
2297 attr_type => "ia32_x87_attr_t",
2300 # x87 Load and Store
2303 rd_constructor => "NONE",
2304 op_flags => "R|L|F",
2305 state => "exc_pinned",
2307 emit => '. fld%XM %AM',
2308 attr_type => "ia32_x87_attr_t",
2313 rd_constructor => "NONE",
2314 op_flags => "R|L|F",
2315 state => "exc_pinned",
2317 emit => '. fst%XM %AM',
2319 attr_type => "ia32_x87_attr_t",
2324 rd_constructor => "NONE",
2325 op_flags => "R|L|F",
2326 state => "exc_pinned",
2328 emit => '. fstp%XM %AM',
2330 attr_type => "ia32_x87_attr_t",
2337 state => "exc_pinned",
2338 rd_constructor => "NONE",
2340 emit => '. fild%XM %AM',
2341 attr_type => "ia32_x87_attr_t",
2346 state => "exc_pinned",
2347 rd_constructor => "NONE",
2349 emit => '. fist%XM %AM',
2351 attr_type => "ia32_x87_attr_t",
2356 state => "exc_pinned",
2357 rd_constructor => "NONE",
2359 emit => '. fistp%XM %AM',
2361 attr_type => "ia32_x87_attr_t",
2365 # SSE3 firsttp instruction
2367 state => "exc_pinned",
2368 rd_constructor => "NONE",
2370 emit => '. fisttp%XM %AM',
2372 attr_type => "ia32_x87_attr_t",
2379 op_flags => "R|c|K",
2381 reg_req => { out => [ "vfp" ] },
2383 attr_type => "ia32_x87_attr_t",
2388 op_flags => "R|c|K",
2390 reg_req => { out => [ "vfp" ] },
2392 attr_type => "ia32_x87_attr_t",
2397 op_flags => "R|c|K",
2399 reg_req => { out => [ "vfp" ] },
2401 attr_type => "ia32_x87_attr_t",
2406 op_flags => "R|c|K",
2408 reg_req => { out => [ "vfp" ] },
2410 attr_type => "ia32_x87_attr_t",
2415 op_flags => "R|c|K",
2417 reg_req => { out => [ "vfp" ] },
2419 attr_type => "ia32_x87_attr_t",
2424 op_flags => "R|c|K",
2426 reg_req => { out => [ "vfp" ] },
2427 emit => '. fldll2t',
2428 attr_type => "ia32_x87_attr_t",
2433 op_flags => "R|c|K",
2435 reg_req => { out => [ "vfp" ] },
2437 attr_type => "ia32_x87_attr_t",
2442 # Note that it is NEVER allowed to do CSE on these nodes
2443 # Moreover, note the virtual register requierements!
2448 cmp_attr => "return 1;",
2449 emit => '. fxch %X0',
2450 attr_type => "ia32_x87_attr_t",
2458 cmp_attr => "return 1;",
2459 emit => '. fld %X0',
2460 attr_type => "ia32_x87_attr_t",
2466 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2467 cmp_attr => "return 1;",
2468 emit => '. fld %X0',
2469 attr_type => "ia32_x87_attr_t",
2476 cmp_attr => "return 1;",
2477 emit => '. fstp %X0',
2478 attr_type => "ia32_x87_attr_t",
2486 cmp_attr => "return 1;",
2487 emit => '. ffreep %X0',
2488 attr_type => "ia32_x87_attr_t",
2496 cmp_attr => "return 1;",
2498 attr_type => "ia32_x87_attr_t",
2506 cmp_attr => "return 1;",
2508 attr_type => "ia32_x87_attr_t",
2517 emit => ". fucom %X1\n".
2519 attr_type => "ia32_x87_attr_t",
2525 emit => ". fucomp %X1\n".
2527 attr_type => "ia32_x87_attr_t",
2533 emit => ". fucompp\n".
2535 attr_type => "ia32_x87_attr_t",
2541 emit => '. fucomi %X1',
2542 attr_type => "ia32_x87_attr_t",
2548 emit => '. fucompi %X1',
2549 attr_type => "ia32_x87_attr_t",
2557 attr_type => "ia32_x87_attr_t",
2562 # -------------------------------------------------------------------------------- #
2563 # ____ ____ _____ _ _ #
2564 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2565 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2566 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2567 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2569 # -------------------------------------------------------------------------------- #
2572 # Spilling and reloading of SSE registers, hardcoded, not generated #
2576 state => "exc_pinned",
2577 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2578 emit => '. movdqu %D0, %AM',
2579 outs => [ "res", "M" ],
2586 state => "exc_pinned",
2587 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2588 ins => [ "base", "index", "mem", "val" ],
2589 emit => '. movdqu %binop',
2597 # Include the generated SIMD node specification written by the SIMD optimization
2598 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2599 unless ($return = do $my_script_name) {
2600 warn "couldn't parse $my_script_name: $@" if $@;
2601 warn "couldn't do $my_script_name: $!" unless defined $return;
2602 warn "couldn't run $my_script_name" unless $return;
2605 # Transform some attributes
2606 foreach my $op (keys(%nodes)) {
2607 my $node = $nodes{$op};
2608 my $op_attr_init = $node->{op_attr_init};
2610 if(defined($op_attr_init)) {
2611 $op_attr_init .= "\n\t";
2616 if(!defined($node->{latency})) {
2618 $node->{latency} = 0;
2620 die("Latency missing for op $op");
2623 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2625 $node->{op_attr_init} = $op_attr_init;