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_Source, ia32_am_unary);";
257 } elsif($am eq "source,binary") {
258 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
259 } elsif($am eq "source,ternary") {
260 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
261 } elsif($am eq "none") {
264 die("Invalid address mode '$am' specified on op $name");
267 if($node->{state} ne "exc_pinned"
268 and $node->{state} ne "pinned") {
269 die("AM nodes must have pinned or AM pinned state ($name)");
275 $custom_init_attr_func = \&ia32_custom_init_attr;
279 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
280 "\tinit_ia32_x87_attributes(res);".
281 "\tinit_ia32_asm_attributes(res);",
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
284 ia32_condcode_attr_t =>
285 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_condcode_attributes(res, pnc);",
288 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
289 "\tinit_ia32_copyb_attributes(res, size);",
290 ia32_immediate_attr_t =>
291 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_x87_attributes(res);",
299 ia32_asm_attr_t => "ia32_compare_asm_attr",
300 ia32_attr_t => "ia32_compare_nodes_attr",
301 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
302 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
303 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
304 ia32_x87_attr_t => "ia32_compare_x87_attr",
310 $mode_xmm = "mode_E";
311 $mode_gp = "mode_Iu";
312 $mode_flags = "mode_Iu";
313 $mode_fpcw = "mode_fpcw";
314 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
315 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
316 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
317 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
325 reg_req => { out => [ "gp_NOREG" ] },
326 attr => "ir_entity *symconst, int symconst_sign, long offset",
327 attr_type => "ia32_immediate_attr_t",
328 hash_func => "ia32_hash_Immediate",
336 out_arity => "variable",
337 attr_type => "ia32_asm_attr_t",
338 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
339 init_attr => "attr->asm_text = asm_text;\n".
340 "\tattr->register_map = register_map;\n",
345 # "allocates" a free register
349 reg_req => { out => [ "gp" ] },
354 cmp_attr => "return 1;",
357 #-----------------------------------------------------------------#
360 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
361 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
362 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
363 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
366 #-----------------------------------------------------------------#
368 # commutative operations
372 state => "exc_pinned",
373 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
374 out => [ "in_r4 in_r5", "flags", "none" ] },
375 ins => [ "base", "index", "mem", "left", "right" ],
376 outs => [ "res", "flags", "M" ],
377 emit => '. add%M %binop',
378 am => "source,binary",
382 modified_flags => $status_flags
387 state => "exc_pinned",
388 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
389 ins => [ "base", "index", "mem", "val" ],
390 emit => ". add%M %SI3, %AM",
394 modified_flags => $status_flags
399 state => "exc_pinned",
400 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
401 ins => [ "base", "index", "mem", "val" ],
402 emit => ". add%M %SB3, %AM",
406 modified_flags => $status_flags
410 state => "exc_pinned",
411 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
412 out => [ "in_r4 in_r5", "flags", "none" ] },
413 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
414 outs => [ "res", "flags", "M" ],
415 emit => '. adc%M %binop',
416 am => "source,binary",
420 modified_flags => $status_flags
425 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
426 ins => [ "left", "right" ],
430 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
431 ins => [ "left", "right", "eflags" ],
435 # we should not rematrialize this node. It produces 2 results and has
436 # very strict constraints
437 state => "exc_pinned",
438 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
439 out => [ "eax", "edx", "none" ] },
440 ins => [ "base", "index", "mem", "left", "right" ],
441 emit => '. mul%M %unop4',
442 outs => [ "res_low", "res_high", "M" ],
443 am => "source,binary",
446 modified_flags => $status_flags
450 # we should not rematrialize this node. It produces 2 results and has
451 # very strict constraints
453 cmp_attr => "return 1;",
454 outs => [ "EAX", "EDX", "M" ],
460 state => "exc_pinned",
461 # TODO: adjust out requirements for the 3 operand form
462 # (no need for should_be_same then)
463 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
464 out => [ "in_r4 in_r5", "flags", "none" ] },
465 ins => [ "base", "index", "mem", "left", "right" ],
466 outs => [ "res", "flags", "M" ],
467 am => "source,binary",
471 modified_flags => $status_flags
476 state => "exc_pinned",
477 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
478 out => [ "eax", "edx", "none" ] },
479 ins => [ "base", "index", "mem", "left", "right" ],
480 emit => '. imul%M %unop4',
481 outs => [ "res_low", "res_high", "M" ],
482 am => "source,binary",
485 modified_flags => $status_flags
490 cmp_attr => "return 1;",
491 outs => [ "res_low", "res_high", "M" ],
497 state => "exc_pinned",
498 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
499 out => [ "in_r4 in_r5", "flags", "none" ] },
500 ins => [ "base", "index", "mem", "left", "right" ],
501 outs => [ "res", "flags", "M" ],
502 op_modes => "commutative | am | immediate | mode_neutral",
503 am => "source,binary",
504 emit => '. and%M %binop',
508 modified_flags => $status_flags
513 state => "exc_pinned",
514 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
515 ins => [ "base", "index", "mem", "val" ],
516 emit => '. and%M %SI3, %AM',
520 modified_flags => $status_flags
525 state => "exc_pinned",
526 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
527 ins => [ "base", "index", "mem", "val" ],
528 emit => '. and%M %SB3, %AM',
532 modified_flags => $status_flags
537 state => "exc_pinned",
538 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
539 out => [ "in_r4 in_r5", "flags", "none" ] },
540 ins => [ "base", "index", "mem", "left", "right" ],
541 outs => [ "res", "flags", "M" ],
542 am => "source,binary",
543 emit => '. or%M %binop',
547 modified_flags => $status_flags
552 state => "exc_pinned",
553 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
554 ins => [ "base", "index", "mem", "val" ],
555 emit => '. or%M %SI3, %AM',
559 modified_flags => $status_flags
564 state => "exc_pinned",
565 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
566 ins => [ "base", "index", "mem", "val" ],
567 emit => '. or%M %SB3, %AM',
571 modified_flags => $status_flags
576 state => "exc_pinned",
577 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
578 out => [ "in_r4 in_r5", "flags", "none" ] },
579 ins => [ "base", "index", "mem", "left", "right" ],
580 outs => [ "res", "flags", "M" ],
581 am => "source,binary",
582 emit => '. xor%M %binop',
586 modified_flags => $status_flags
591 state => "exc_pinned",
592 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
593 ins => [ "base", "index", "mem", "val" ],
594 emit => '. xor%M %SI3, %AM',
598 modified_flags => $status_flags
603 state => "exc_pinned",
604 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
605 ins => [ "base", "index", "mem", "val" ],
606 emit => '. xor%M %SB3, %AM',
610 modified_flags => $status_flags
613 # not commutative operations
617 state => "exc_pinned",
618 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
619 out => [ "in_r4", "flags", "none" ] },
620 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
621 outs => [ "res", "flags", "M" ],
622 am => "source,binary",
623 emit => '. sub%M %binop',
627 modified_flags => $status_flags
632 state => "exc_pinned",
633 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
634 ins => [ "base", "index", "mem", "subtrahend" ],
635 emit => '. sub%M %SI3, %AM',
639 modified_flags => $status_flags
644 state => "exc_pinned",
645 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
646 ins => [ "base", "index", "mem", "subtrahend" ],
647 emit => '. sub%M %SB3, %AM',
651 modified_flags => $status_flags
655 state => "exc_pinned",
656 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
657 out => [ "in_r4 !in_r5", "flags", "none" ] },
658 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
659 outs => [ "res", "flags", "M" ],
660 am => "source,binary",
661 emit => '. sbb%M %binop',
665 modified_flags => $status_flags
669 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
670 ins => [ "minuend", "subtrahend" ],
674 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
675 ins => [ "minuend", "subtrahend", "eflags" ],
680 state => "exc_pinned",
681 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
682 out => [ "eax", "flags", "none", "edx", "none" ] },
683 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
684 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
685 am => "source,ternary",
686 emit => ". idiv%M %unop3",
689 modified_flags => $status_flags
694 state => "exc_pinned",
695 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
696 out => [ "eax", "flags", "none", "edx", "none" ] },
697 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
698 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
699 am => "source,ternary",
700 emit => ". div%M %unop3",
703 modified_flags => $status_flags
708 reg_req => { in => [ "gp", "ecx" ],
709 out => [ "in_r1 !in_r2", "flags" ] },
710 ins => [ "val", "count" ],
711 outs => [ "res", "flags" ],
712 emit => '. shl %SB1, %S0',
716 modified_flags => $status_flags
721 state => "exc_pinned",
722 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
723 ins => [ "base", "index", "mem", "count" ],
724 emit => '. shl%M %SB3, %AM',
728 modified_flags => $status_flags
732 cmp_attr => "return 1;",
733 ins => [ "val", "count", "dep" ],
739 reg_req => { in => [ "gp", "gp", "ecx" ],
740 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
741 ins => [ "val_high", "val_low", "count" ],
742 outs => [ "res", "flags" ],
743 emit => ". shld%M %SB2, %S1, %D0",
747 modified_flags => $status_flags
751 cmp_attr => "return 1;",
752 ins => [ "val_high", "val_low", "count" ],
758 reg_req => { in => [ "gp", "ecx" ],
759 out => [ "in_r1 !in_r2", "flags" ] },
760 ins => [ "val", "count" ],
761 outs => [ "res", "flags" ],
762 emit => '. shr %SB1, %S0',
766 modified_flags => $status_flags
771 state => "exc_pinned",
772 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
773 ins => [ "base", "index", "mem", "count" ],
774 emit => '. shr%M %SB3, %AM',
778 modified_flags => $status_flags
782 cmp_attr => "return 1;",
783 ins => [ "val", "count", "dep" ],
789 reg_req => { in => [ "gp", "gp", "ecx" ],
790 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
791 ins => [ "val_high", "val_low", "count" ],
792 outs => [ "res", "flags" ],
793 emit => ". shrd%M %SB2, %S1, %D0",
797 modified_flags => $status_flags
801 cmp_attr => "return 1;",
803 ins => [ "val_high", "val_low", "count" ],
808 reg_req => { in => [ "gp", "ecx" ],
809 out => [ "in_r1 !in_r2", "flags" ] },
810 ins => [ "val", "count" ],
811 outs => [ "res", "flags" ],
812 emit => '. sar %SB1, %S0',
816 modified_flags => $status_flags
821 state => "exc_pinned",
822 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
823 ins => [ "base", "index", "mem", "count" ],
824 emit => '. sar%M %SB3, %AM',
828 modified_flags => $status_flags
832 cmp_attr => "return 1;",
833 ins => [ "val", "count", "dep" ],
839 reg_req => { in => [ "gp", "ecx" ],
840 out => [ "in_r1 !in_r2", "flags" ] },
841 ins => [ "val", "count" ],
842 outs => [ "res", "flags" ],
843 emit => '. ror %SB1, %S0',
847 modified_flags => $status_flags
852 state => "exc_pinned",
853 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
854 ins => [ "base", "index", "mem", "count" ],
855 emit => '. ror%M %SB3, %AM',
859 modified_flags => $status_flags
864 reg_req => { in => [ "gp", "ecx" ],
865 out => [ "in_r1 !in_r2", "flags" ] },
866 ins => [ "val", "count" ],
867 outs => [ "res", "flags" ],
868 emit => '. rol %SB1, %S0',
872 modified_flags => $status_flags
877 state => "exc_pinned",
878 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
879 ins => [ "base", "index", "mem", "count" ],
880 emit => '. rol%M %SB3, %AM',
884 modified_flags => $status_flags
891 reg_req => { in => [ "gp" ],
892 out => [ "in_r1", "flags" ] },
895 outs => [ "res", "flags" ],
899 modified_flags => $status_flags
904 state => "exc_pinned",
905 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
906 ins => [ "base", "index", "mem" ],
907 emit => '. neg%M %AM',
911 modified_flags => $status_flags
916 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
917 outs => [ "low_res", "high_res" ],
920 modified_flags => $status_flags
926 reg_req => { in => [ "gp" ],
927 out => [ "in_r1", "flags" ] },
929 outs => [ "res", "flags" ],
934 modified_flags => $status_flags_wo_cf
939 state => "exc_pinned",
940 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
941 ins => [ "base", "index", "mem" ],
942 emit => '. inc%M %AM',
946 modified_flags => $status_flags_wo_cf
951 reg_req => { in => [ "gp" ],
952 out => [ "in_r1", "flags" ] },
954 outs => [ "res", "flags" ],
959 modified_flags => $status_flags_wo_cf
964 state => "exc_pinned",
965 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
966 ins => [ "base", "index", "mem" ],
967 emit => '. dec%M %AM',
971 modified_flags => $status_flags_wo_cf
976 reg_req => { in => [ "gp" ],
977 out => [ "in_r1", "flags" ] },
979 outs => [ "res", "flags" ],
989 state => "exc_pinned",
990 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
991 ins => [ "base", "index", "mem" ],
992 emit => '. not%M %AM',
1000 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1004 mode => $mode_flags,
1005 modified_flags => $status_flags
1009 reg_req => { out => [ "flags" ] },
1013 mode => $mode_flags,
1014 modified_flags => $status_flags
1021 state => "exc_pinned",
1022 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1023 out => [ "flags", "none", "none" ] },
1024 ins => [ "base", "index", "mem", "left", "right" ],
1025 outs => [ "eflags", "unused", "M" ],
1026 am => "source,binary",
1027 emit => '. cmp%M %binop',
1028 attr => "int ins_permuted, int cmp_unsigned",
1029 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1030 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1033 mode => $mode_flags,
1034 modified_flags => $status_flags
1039 state => "exc_pinned",
1040 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1041 ins => [ "base", "index", "mem", "left", "right" ],
1042 outs => [ "eflags" ],
1043 am => "source,binary",
1044 emit => '. cmpb %binop',
1045 attr => "int ins_permuted, int cmp_unsigned",
1046 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1047 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1050 mode => $mode_flags,
1051 modified_flags => $status_flags
1056 state => "exc_pinned",
1057 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1058 ins => [ "base", "index", "mem", "left", "right" ],
1059 outs => [ "eflags" ],
1060 am => "source,binary",
1061 emit => '. test%M %binop',
1062 attr => "int ins_permuted, int cmp_unsigned",
1063 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1064 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1067 mode => $mode_flags,
1068 modified_flags => $status_flags
1073 state => "exc_pinned",
1074 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1075 ins => [ "base", "index", "mem", "left", "right" ],
1076 outs => [ "eflags" ],
1077 am => "source,binary",
1078 emit => '. testb %binop',
1079 attr => "int ins_permuted, int cmp_unsigned",
1080 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1081 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1084 mode => $mode_flags,
1085 modified_flags => $status_flags
1090 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1091 ins => [ "eflags" ],
1092 attr_type => "ia32_condcode_attr_t",
1093 attr => "pn_Cmp pnc, int ins_permuted",
1094 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1095 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1096 emit => '. set%CMP0 %DB0',
1104 state => "exc_pinned",
1105 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1106 ins => [ "base", "index", "mem","eflags" ],
1107 attr_type => "ia32_condcode_attr_t",
1108 attr => "pn_Cmp pnc, int ins_permuted",
1109 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1110 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1111 emit => '. set%CMP3 %AM',
1119 # (note: leave the false,true order intact to make it compatible with other
1121 state => "exc_pinned",
1122 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1123 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1124 am => "source,binary",
1125 attr_type => "ia32_condcode_attr_t",
1126 attr => "int ins_permuted, pn_Cmp pnc",
1127 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1135 op_flags => "L|X|Y",
1136 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1137 ins => [ "eflags" ],
1138 outs => [ "false", "true" ],
1139 attr_type => "ia32_condcode_attr_t",
1140 attr => "pn_Cmp pnc",
1142 units => [ "BRANCH" ],
1147 op_flags => "L|X|Y",
1148 reg_req => { in => [ "gp" ], out => [ "none" ] },
1150 attr_type => "ia32_condcode_attr_t",
1153 units => [ "BRANCH" ],
1154 modified_flags => $status_flags,
1160 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1161 ins => [ "base", "index", "mem", "target" ],
1162 am => "source,unary",
1163 emit => '. jmp *%unop3',
1165 units => [ "BRANCH" ],
1172 reg_req => { out => [ "gp" ] },
1174 attr => "ir_entity *symconst, int symconst_sign, long offset",
1175 attr_type => "ia32_immediate_attr_t",
1182 reg_req => { out => [ "gp" ] },
1186 modified_flags => $status_flags,
1193 reg_req => { out => [ "gp_UKNWN" ] },
1204 reg_req => { out => [ "vfp_UKNWN" ] },
1209 attr_type => "ia32_x87_attr_t",
1216 reg_req => { out => [ "xmm_UKNWN" ] },
1225 op_flags => "c|NB|NI",
1227 reg_req => { out => [ "gp_NOREG" ] },
1236 op_flags => "c|NB|NI",
1238 reg_req => { out => [ "vfp_NOREG" ] },
1243 attr_type => "ia32_x87_attr_t",
1248 op_flags => "c|NB|NI",
1250 reg_req => { out => [ "xmm_NOREG" ] },
1261 reg_req => { out => [ "fp_cw" ] },
1265 modified_flags => $fpcw_flags
1271 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1272 ins => [ "base", "index", "mem" ],
1274 emit => ". fldcw %AM",
1277 modified_flags => $fpcw_flags
1283 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1284 ins => [ "base", "index", "mem", "fpcw" ],
1286 emit => ". fnstcw %AM",
1294 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1302 # we should not rematrialize this node. It has very strict constraints.
1303 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1304 ins => [ "val", "clobbered" ],
1313 # Note that we add additional latency values depending on address mode, so a
1314 # lateny of 0 for load is correct
1318 state => "exc_pinned",
1319 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1320 ins => [ "base", "index", "mem" ],
1321 outs => [ "res", "M", "X_exc" ],
1323 emit => ". mov%SE%ME%.l %AM, %D0",
1329 state => "exc_pinned",
1330 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1331 ins => [ "base", "index", "mem", "val" ],
1332 outs => [ "M", "X_exc" ],
1333 emit => '. mov%M %SI3, %AM',
1341 state => "exc_pinned",
1342 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1343 ins => [ "base", "index", "mem", "val" ],
1344 outs => [ "M", "X_exc" ],
1345 emit => '. mov%M %SB3, %AM',
1353 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1354 ins => [ "base", "index" ],
1355 emit => '. leal %AM, %D0',
1359 # lea doesn't modify the flags, but setting this seems advantageous since it
1360 # increases chances that the Lea is transformed back to an Add
1361 modified_flags => 1,
1365 state => "exc_pinned",
1366 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1367 ins => [ "base", "index", "mem", "val", "stack" ],
1368 emit => '. push%M %unop3',
1369 outs => [ "stack:I|S", "M" ],
1370 am => "source,unary",
1376 state => "exc_pinned",
1377 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1378 ins => [ "mem", "stack" ],
1379 outs => [ "res", "M", "unused", "stack:I|S" ],
1380 emit => '. pop%M %D0',
1381 latency => 3, # Pop is more expensive than Push on Athlon
1386 state => "exc_pinned",
1387 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1388 ins => [ "base", "index", "mem", "stack" ],
1389 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1390 emit => '. pop%M %AM',
1391 latency => 3, # Pop is more expensive than Push on Athlon
1396 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1398 outs => [ "frame:I", "stack:I|S", "M" ],
1404 reg_req => { in => [ "ebp" ], out => [ "ebp", "esp" ] },
1406 outs => [ "frame:I", "stack:I|S" ],
1414 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1415 ins => [ "base", "index", "mem", "stack", "size" ],
1416 am => "source,binary",
1417 emit => '. addl %binop',
1419 outs => [ "stack:I|S", "M" ],
1421 modified_flags => $status_flags
1427 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1428 ins => [ "base", "index", "mem", "stack", "size" ],
1429 am => "source,binary",
1430 emit => ". subl %binop\n".
1431 ". movl %%esp, %D1",
1433 outs => [ "stack:I|S", "addr", "M" ],
1435 modified_flags => $status_flags
1448 reg_req => { out => [ "gp" ] },
1455 state => "exc_pinned",
1456 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1457 ins => [ "left", "right" ],
1458 emit => '. bt%M %S1, %S0',
1461 mode => $mode_flags,
1462 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1465 #-----------------------------------------------------------------------------#
1466 # _____ _____ ______ __ _ _ _ #
1467 # / ____/ ____| ____| / _| | | | | | #
1468 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1469 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1470 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1471 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1472 #-----------------------------------------------------------------------------#
1477 reg_req => { out => [ "xmm" ] },
1478 emit => '. xorp%XSD %D0, %D0',
1486 reg_req => { out => [ "xmm" ] },
1487 emit => '. pxor %D0, %D0',
1493 # produces all 1 bits
1496 reg_req => { out => [ "xmm" ] },
1497 emit => '. pcmpeqb %D0, %D0',
1503 # integer shift left, dword
1506 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1507 emit => '. pslld %SI1, %D0',
1513 # integer shift left, qword
1516 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1517 emit => '. psllq %SI1, %D0',
1523 # integer shift right, dword
1526 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1527 emit => '. psrld %SI1, %D0',
1533 # mov from integer to SSE register
1536 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1537 emit => '. movd %S0, %D0',
1543 # commutative operations
1547 state => "exc_pinned",
1548 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1549 ins => [ "base", "index", "mem", "left", "right" ],
1550 am => "source,binary",
1551 emit => '. add%XXM %binop',
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 => '. mul%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 => '. max%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 => '. min%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 => '. andp%XSD %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 => '. orp%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 => '. xorp%XSD %binop',
1629 # not commutative operations
1633 state => "exc_pinned",
1634 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1635 ins => [ "base", "index", "mem", "left", "right" ],
1636 am => "source,binary",
1637 emit => '. andnp%XSD %binop',
1645 state => "exc_pinned",
1646 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1647 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1648 am => "source,binary",
1649 emit => '. sub%XXM %binop',
1657 state => "exc_pinned",
1658 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1659 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1660 am => "source,binary",
1661 outs => [ "res", "M" ],
1662 emit => '. div%XXM %binop',
1671 state => "exc_pinned",
1672 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1673 ins => [ "base", "index", "mem", "left", "right" ],
1674 outs => [ "flags" ],
1675 am => "source,binary",
1676 attr => "int ins_permuted",
1677 init_attr => "attr->data.ins_permuted = ins_permuted;",
1678 emit => ' .ucomi%XXM %binop',
1681 mode => $mode_flags,
1682 modified_flags => 1,
1689 state => "exc_pinned",
1690 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1691 ins => [ "base", "index", "mem" ],
1692 outs => [ "res", "M", "X_exc" ],
1693 emit => '. mov%XXM %AM, %D0',
1694 attr => "ir_mode *load_mode",
1695 init_attr => "attr->ls_mode = load_mode;",
1702 state => "exc_pinned",
1703 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1704 ins => [ "base", "index", "mem", "val" ],
1705 outs => [ "M", "X_exc" ],
1706 emit => '. mov%XXM %S3, %AM',
1714 state => "exc_pinned",
1715 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1716 ins => [ "base", "index", "mem", "val" ],
1717 emit => '. mov%XXM %S3, %AM',
1725 state => "exc_pinned",
1726 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1727 ins => [ "base", "index", "mem", "val" ],
1728 am => "source,unary",
1729 emit => '. cvtsi2ss %unop3, %D0',
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 => '. cvtsi2sd %unop3, %D0',
1750 cmp_attr => "return 1;",
1751 ins => [ "val_high", "val_low" ],
1756 cmp_attr => "return 1;",
1758 outs => [ "res_high", "res_low" ],
1766 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1767 outs => [ "DST", "SRC", "CNT", "M" ],
1768 attr_type => "ia32_copyb_attr_t",
1769 attr => "unsigned size",
1772 # we don't care about this flag, so no need to mark this node
1773 # modified_flags => [ "DF" ]
1779 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1780 outs => [ "DST", "SRC", "M" ],
1781 attr_type => "ia32_copyb_attr_t",
1782 attr => "unsigned size",
1785 # we don't care about this flag, so no need to mark this node
1786 # modified_flags => [ "DF" ]
1792 state => "exc_pinned",
1793 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1794 ins => [ "base", "index", "mem", "val" ],
1795 am => "source,unary",
1798 attr => "ir_mode *smaller_mode",
1799 init_attr => "attr->ls_mode = smaller_mode;",
1804 state => "exc_pinned",
1805 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], 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", "gp" ], out => [ "xmm", "none" ] },
1818 ins => [ "base", "index", "mem", "val" ],
1819 am => "source,unary",
1826 state => "exc_pinned",
1827 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1828 ins => [ "base", "index", "mem", "val" ],
1829 am => "source,unary",
1836 state => "exc_pinned",
1837 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1838 ins => [ "base", "index", "mem", "val" ],
1839 am => "source,unary",
1845 #----------------------------------------------------------#
1847 # (_) | | | | / _| | | | #
1848 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1849 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1850 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1851 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1853 # _ __ ___ __| | ___ ___ #
1854 # | '_ \ / _ \ / _` |/ _ \/ __| #
1855 # | | | | (_) | (_| | __/\__ \ #
1856 # |_| |_|\___/ \__,_|\___||___/ #
1857 #----------------------------------------------------------#
1859 # rematerialisation disabled for all float nodes for now, because the fpcw
1860 # handler runs before spilling and we might end up with wrong fpcw then
1864 state => "exc_pinned",
1865 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1866 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1867 am => "source,binary",
1871 attr_type => "ia32_x87_attr_t",
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", "minuend", "subtrahend", "fpcw" ],
1891 am => "source,binary",
1895 attr_type => "ia32_x87_attr_t",
1899 state => "exc_pinned",
1900 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1901 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1902 am => "source,binary",
1903 outs => [ "res", "M" ],
1906 attr_type => "ia32_x87_attr_t",
1910 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1911 ins => [ "left", "right", "fpcw" ],
1915 attr_type => "ia32_x87_attr_t",
1920 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1925 attr_type => "ia32_x87_attr_t",
1930 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1935 attr_type => "ia32_x87_attr_t",
1938 # virtual Load and Store
1943 state => "exc_pinned",
1944 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1945 ins => [ "base", "index", "mem" ],
1946 outs => [ "res", "M", "X_exc" ],
1947 attr => "ir_mode *load_mode",
1948 init_attr => "attr->attr.ls_mode = load_mode;",
1951 attr_type => "ia32_x87_attr_t",
1957 state => "exc_pinned",
1958 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1959 ins => [ "base", "index", "mem", "val" ],
1960 outs => [ "M", "X_exc" ],
1961 attr => "ir_mode *store_mode",
1962 init_attr => "attr->attr.ls_mode = store_mode;",
1966 attr_type => "ia32_x87_attr_t",
1972 state => "exc_pinned",
1973 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1974 outs => [ "res", "M" ],
1975 ins => [ "base", "index", "mem" ],
1978 attr_type => "ia32_x87_attr_t",
1982 state => "exc_pinned",
1983 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1984 ins => [ "base", "index", "mem", "val", "fpcw" ],
1988 attr_type => "ia32_x87_attr_t",
1991 # SSE3 fisttp instruction
1993 state => "exc_pinned",
1994 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
1995 ins => [ "base", "index", "mem", "val" ],
1996 outs => [ "res", "M" ],
1999 attr_type => "ia32_x87_attr_t",
2007 reg_req => { out => [ "vfp" ] },
2011 attr_type => "ia32_x87_attr_t",
2016 reg_req => { out => [ "vfp" ] },
2020 attr_type => "ia32_x87_attr_t",
2025 reg_req => { out => [ "vfp" ] },
2029 attr_type => "ia32_x87_attr_t",
2034 reg_req => { out => [ "vfp" ] },
2038 attr_type => "ia32_x87_attr_t",
2043 reg_req => { out => [ "vfp" ] },
2047 attr_type => "ia32_x87_attr_t",
2052 reg_req => { out => [ "vfp" ] },
2056 attr_type => "ia32_x87_attr_t",
2061 reg_req => { out => [ "vfp" ] },
2065 attr_type => "ia32_x87_attr_t",
2071 # we can't allow to rematerialize this node so we don't have
2072 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2074 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2075 ins => [ "left", "right" ],
2076 outs => [ "flags" ],
2077 attr => "int ins_permuted",
2078 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2081 attr_type => "ia32_x87_attr_t",
2087 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2088 ins => [ "left", "right" ],
2089 outs => [ "flags" ],
2090 attr => "int ins_permuted",
2091 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2094 attr_type => "ia32_x87_attr_t",
2100 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2102 outs => [ "flags" ],
2103 attr => "int ins_permuted",
2104 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2107 attr_type => "ia32_x87_attr_t",
2113 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2115 outs => [ "flags" ],
2119 mode => $mode_flags,
2122 #------------------------------------------------------------------------#
2123 # ___ _____ __ _ _ _ #
2124 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2125 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2126 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2127 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2128 #------------------------------------------------------------------------#
2130 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2131 # are swapped, we work this around in the emitter...
2134 state => "exc_pinned",
2135 rd_constructor => "NONE",
2137 emit => '. fadd%XM %x87_binop',
2139 attr_type => "ia32_x87_attr_t",
2143 state => "exc_pinned",
2144 rd_constructor => "NONE",
2146 emit => '. faddp%XM %x87_binop',
2148 attr_type => "ia32_x87_attr_t",
2152 state => "exc_pinned",
2153 rd_constructor => "NONE",
2155 emit => '. fmul%XM %x87_binop',
2157 attr_type => "ia32_x87_attr_t",
2161 state => "exc_pinned",
2162 rd_constructor => "NONE",
2164 emit => '. fmulp%XM %x87_binop',,
2166 attr_type => "ia32_x87_attr_t",
2170 state => "exc_pinned",
2171 rd_constructor => "NONE",
2173 emit => '. fsub%XM %x87_binop',
2175 attr_type => "ia32_x87_attr_t",
2179 state => "exc_pinned",
2180 rd_constructor => "NONE",
2182 # see note about gas bugs
2183 emit => '. fsubrp%XM %x87_binop',
2185 attr_type => "ia32_x87_attr_t",
2189 state => "exc_pinned",
2190 rd_constructor => "NONE",
2193 emit => '. fsubr%XM %x87_binop',
2195 attr_type => "ia32_x87_attr_t",
2199 state => "exc_pinned",
2200 rd_constructor => "NONE",
2203 # see note about gas bugs
2204 emit => '. fsubp%XM %x87_binop',
2206 attr_type => "ia32_x87_attr_t",
2210 rd_constructor => "NONE",
2214 attr_type => "ia32_x87_attr_t",
2217 # this node is just here, to keep the simulator running
2218 # we can omit this when a fprem simulation function exists
2220 rd_constructor => "NONE",
2222 emit => '. fprem1\n'.
2225 attr_type => "ia32_x87_attr_t",
2229 state => "exc_pinned",
2230 rd_constructor => "NONE",
2232 emit => '. fdiv%XM %x87_binop',
2234 attr_type => "ia32_x87_attr_t",
2238 state => "exc_pinned",
2239 rd_constructor => "NONE",
2241 # see note about gas bugs
2242 emit => '. fdivrp%XM %x87_binop',
2244 attr_type => "ia32_x87_attr_t",
2248 state => "exc_pinned",
2249 rd_constructor => "NONE",
2251 emit => '. fdivr%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 => '. fdivp%XM %x87_binop',
2263 attr_type => "ia32_x87_attr_t",
2267 rd_constructor => "NONE",
2271 attr_type => "ia32_x87_attr_t",
2276 rd_constructor => "NONE",
2280 attr_type => "ia32_x87_attr_t",
2283 # x87 Load and Store
2286 rd_constructor => "NONE",
2287 op_flags => "R|L|F",
2288 state => "exc_pinned",
2290 emit => '. fld%XM %AM',
2291 attr_type => "ia32_x87_attr_t",
2296 rd_constructor => "NONE",
2297 op_flags => "R|L|F",
2298 state => "exc_pinned",
2300 emit => '. fst%XM %AM',
2302 attr_type => "ia32_x87_attr_t",
2307 rd_constructor => "NONE",
2308 op_flags => "R|L|F",
2309 state => "exc_pinned",
2311 emit => '. fstp%XM %AM',
2313 attr_type => "ia32_x87_attr_t",
2320 state => "exc_pinned",
2321 rd_constructor => "NONE",
2323 emit => '. fild%M %AM',
2324 attr_type => "ia32_x87_attr_t",
2329 state => "exc_pinned",
2330 rd_constructor => "NONE",
2332 emit => '. fist%M %AM',
2334 attr_type => "ia32_x87_attr_t",
2339 state => "exc_pinned",
2340 rd_constructor => "NONE",
2342 emit => '. fistp%M %AM',
2344 attr_type => "ia32_x87_attr_t",
2348 # SSE3 firsttp instruction
2350 state => "exc_pinned",
2351 rd_constructor => "NONE",
2353 emit => '. fisttp%M %AM',
2355 attr_type => "ia32_x87_attr_t",
2362 op_flags => "R|c|K",
2364 reg_req => { out => [ "vfp" ] },
2366 attr_type => "ia32_x87_attr_t",
2371 op_flags => "R|c|K",
2373 reg_req => { out => [ "vfp" ] },
2375 attr_type => "ia32_x87_attr_t",
2380 op_flags => "R|c|K",
2382 reg_req => { out => [ "vfp" ] },
2384 attr_type => "ia32_x87_attr_t",
2389 op_flags => "R|c|K",
2391 reg_req => { out => [ "vfp" ] },
2393 attr_type => "ia32_x87_attr_t",
2398 op_flags => "R|c|K",
2400 reg_req => { out => [ "vfp" ] },
2402 attr_type => "ia32_x87_attr_t",
2407 op_flags => "R|c|K",
2409 reg_req => { out => [ "vfp" ] },
2410 emit => '. fldll2t',
2411 attr_type => "ia32_x87_attr_t",
2416 op_flags => "R|c|K",
2418 reg_req => { out => [ "vfp" ] },
2420 attr_type => "ia32_x87_attr_t",
2425 # Note that it is NEVER allowed to do CSE on these nodes
2426 # Moreover, note the virtual register requierements!
2431 cmp_attr => "return 1;",
2432 emit => '. fxch %X0',
2433 attr_type => "ia32_x87_attr_t",
2441 cmp_attr => "return 1;",
2442 emit => '. fld %X0',
2443 attr_type => "ia32_x87_attr_t",
2449 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2450 cmp_attr => "return 1;",
2451 emit => '. fld %X0',
2452 attr_type => "ia32_x87_attr_t",
2459 cmp_attr => "return 1;",
2460 emit => '. fstp %X0',
2461 attr_type => "ia32_x87_attr_t",
2469 cmp_attr => "return 1;",
2470 emit => '. ffreep %X0',
2471 attr_type => "ia32_x87_attr_t",
2479 cmp_attr => "return 1;",
2481 attr_type => "ia32_x87_attr_t",
2489 cmp_attr => "return 1;",
2491 attr_type => "ia32_x87_attr_t",
2500 emit => ". fucom %X1\n".
2502 attr_type => "ia32_x87_attr_t",
2508 emit => ". fucomp %X1\n".
2510 attr_type => "ia32_x87_attr_t",
2516 emit => ". fucompp\n".
2518 attr_type => "ia32_x87_attr_t",
2524 emit => '. fucomi %X1',
2525 attr_type => "ia32_x87_attr_t",
2531 emit => '. fucompi %X1',
2532 attr_type => "ia32_x87_attr_t",
2540 attr_type => "ia32_x87_attr_t",
2545 # -------------------------------------------------------------------------------- #
2546 # ____ ____ _____ _ _ #
2547 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2548 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2549 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2550 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2552 # -------------------------------------------------------------------------------- #
2555 # Spilling and reloading of SSE registers, hardcoded, not generated #
2559 state => "exc_pinned",
2560 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2561 emit => '. movdqu %D0, %AM',
2562 outs => [ "res", "M" ],
2569 state => "exc_pinned",
2570 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2571 ins => [ "base", "index", "mem", "val" ],
2572 emit => '. movdqu %binop',
2580 # Include the generated SIMD node specification written by the SIMD optimization
2581 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2582 unless ($return = do $my_script_name) {
2583 warn "couldn't parse $my_script_name: $@" if $@;
2584 warn "couldn't do $my_script_name: $!" unless defined $return;
2585 warn "couldn't run $my_script_name" unless $return;
2588 # Transform some attributes
2589 foreach my $op (keys(%nodes)) {
2590 my $node = $nodes{$op};
2591 my $op_attr_init = $node->{op_attr_init};
2593 if(defined($op_attr_init)) {
2594 $op_attr_init .= "\n\t";
2599 if(!defined($node->{latency})) {
2601 $node->{latency} = 0;
2603 die("Latency missing for op $op");
2606 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2608 $node->{op_attr_init} = $op_attr_init;