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 # emit => "emit code with templates",
32 # attr => "attitional attribute arguments for constructor"
33 # init_attr => "emit attribute initialization template"
34 # rd_constructor => "c source code which constructs an ir_node"
35 # attr_type => "name of the attribute struct",
38 # ... # (all nodes you need to describe)
40 # ); # close the %nodes initializer
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
46 # C irop_flag_commutative
47 # X irop_flag_cfopcode
48 # I irop_flag_ip_cfopcode
51 # H irop_flag_highlevel
52 # c irop_flag_constlike
54 # NB irop_flag_dump_noblock
55 # NI irop_flag_dump_noinput
57 # irn_flags: special node flags, OPTIONAL (default is 0)
58 # following irn_flags are supported:
61 # I ignore for register allocation
62 # S modifies stack pointer
64 # state: state of the operation, OPTIONAL (default is "floats")
66 # arity: arity of the operation, MUST NOT BE OMITTED
68 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
69 # are always the first 3 arguments and are always autmatically
71 # If this key is missing the following arguments will be created:
72 # for i = 1 .. arity: ir_node *op_i
75 # outs: if a node defines more than one output, the names of the projections
76 # nodes having outs having automatically the mode mode_T
77 # One can also annotate some flags for each out, additional to irn_flags.
78 # They are separated from name with a colon ':', and concatenated by pipe '|'
79 # Only I and S are available at the moment (same meaning as in irn_flags).
80 # example: [ "frame:I", "stack:I|S", "M" ]
82 # comment: OPTIONAL comment for the node constructor
84 # rd_constructor: for every operation there will be a
85 # new_rd_<arch>_<op-name> function with the arguments from above
86 # which creates the ir_node corresponding to the defined operation
87 # you can either put the complete source code of this function here
89 # This key is OPTIONAL. If omitted, the following constructor will
91 # if (!op_<arch>_<op-name>) assert(0);
95 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
98 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
102 # 0 - no special type
103 # 1 - caller save (register must be saved by the caller of a function)
104 # 2 - callee save (register must be saved by the called function)
105 # 4 - ignore (do not assign this register)
106 # 8 - emitter can choose an arbitrary register of this class
107 # 16 - the register is a virtual one
108 # 32 - register represents a state
109 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
112 { name => "edx", type => 1 },
113 { name => "ecx", type => 1 },
114 { name => "eax", type => 1 },
115 { name => "ebx", type => 2 },
116 { name => "esi", type => 2 },
117 { name => "edi", type => 2 },
118 { name => "ebp", type => 2 },
119 { name => "esp", type => 4 },
120 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
121 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
122 { mode => "mode_Iu" }
125 { name => "mm0", type => 4 },
126 { name => "mm1", type => 4 },
127 { name => "mm2", type => 4 },
128 { name => "mm3", type => 4 },
129 { name => "mm4", type => 4 },
130 { name => "mm5", type => 4 },
131 { name => "mm6", type => 4 },
132 { name => "mm7", type => 4 },
133 { mode => "mode_E", flags => "manual_ra" }
136 { name => "xmm0", type => 1 },
137 { name => "xmm1", type => 1 },
138 { name => "xmm2", type => 1 },
139 { name => "xmm3", type => 1 },
140 { name => "xmm4", type => 1 },
141 { name => "xmm5", type => 1 },
142 { name => "xmm6", type => 1 },
143 { name => "xmm7", type => 1 },
144 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
145 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
149 { name => "vf0", type => 1 | 16 },
150 { name => "vf1", type => 1 | 16 },
151 { name => "vf2", type => 1 | 16 },
152 { name => "vf3", type => 1 | 16 },
153 { name => "vf4", type => 1 | 16 },
154 { name => "vf5", type => 1 | 16 },
155 { name => "vf6", type => 1 | 16 },
156 { name => "vf7", type => 1 | 16 },
157 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
158 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
162 { name => "st0", realname => "st", type => 4 },
163 { name => "st1", realname => "st(1)", type => 4 },
164 { name => "st2", realname => "st(2)", type => 4 },
165 { name => "st3", realname => "st(3)", type => 4 },
166 { name => "st4", realname => "st(4)", type => 4 },
167 { name => "st5", realname => "st(5)", type => 4 },
168 { name => "st6", realname => "st(6)", type => 4 },
169 { name => "st7", realname => "st(7)", type => 4 },
170 { mode => "mode_E", flags => "manual_ra" }
172 fp_cw => [ # the floating point control word
173 { name => "fpcw", type => 4|32 },
174 { mode => "mode_fpcw", flags => "manual_ra|state" }
177 { name => "eflags", type => 0 },
178 { mode => "mode_Iu", flags => "manual_ra" }
183 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
184 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
185 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
186 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
191 bundels_per_cycle => 1
195 S0 => "${arch}_emit_source_register(node, 0);",
196 S1 => "${arch}_emit_source_register(node, 1);",
197 S2 => "${arch}_emit_source_register(node, 2);",
198 S3 => "${arch}_emit_source_register(node, 3);",
199 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
200 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
201 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
202 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
203 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
204 D0 => "${arch}_emit_dest_register(node, 0);",
205 D1 => "${arch}_emit_dest_register(node, 1);",
206 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
207 X0 => "${arch}_emit_x87_register(node, 0);",
208 X1 => "${arch}_emit_x87_register(node, 1);",
209 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
210 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
211 ia32_emit_mode_suffix(node);",
212 M => "${arch}_emit_mode_suffix(node);",
213 XM => "${arch}_emit_x87_mode_suffix(node);",
214 XXM => "${arch}_emit_xmm_mode_suffix(node);",
215 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
216 AM => "${arch}_emit_am(node);",
217 unop3 => "${arch}_emit_unop(node, 3);",
218 unop4 => "${arch}_emit_unop(node, 4);",
219 binop => "${arch}_emit_binop(node);",
220 x87_binop => "${arch}_emit_x87_binop(node);",
221 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
222 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
225 #--------------------------------------------------#
228 # _ __ _____ __ _ _ __ ___ _ __ ___ #
229 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
230 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
231 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
234 #--------------------------------------------------#
236 $default_op_attr_type = "ia32_op_attr_t";
237 $default_attr_type = "ia32_attr_t";
238 $default_copy_attr = "ia32_copy_attr";
240 sub ia32_custom_init_attr {
245 if(defined($node->{modified_flags})) {
246 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
248 if(defined($node->{am})) {
249 my $am = $node->{am};
250 if($am eq "source,unary") {
251 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_unary);";
252 } elsif($am eq "source,binary") {
253 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
254 } elsif($am eq "source,ternary") {
255 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
256 } elsif($am eq "none") {
259 die("Invalid address mode '$am' specified on op $name");
262 if($node->{state} ne "exc_pinned"
263 and $node->{state} ne "pinned") {
264 die("AM nodes must have pinned or AM pinned state ($name)");
270 $custom_init_attr_func = \&ia32_custom_init_attr;
273 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
275 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
276 "\tinit_ia32_x87_attributes(res);",
278 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
279 "\tinit_ia32_x87_attributes(res);".
280 "\tinit_ia32_asm_attributes(res);",
281 ia32_immediate_attr_t =>
282 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
283 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
285 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_copyb_attributes(res, size);",
287 ia32_condcode_attr_t =>
288 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
289 "\tinit_ia32_condcode_attributes(res, pnc);",
293 ia32_attr_t => "ia32_compare_nodes_attr",
294 ia32_x87_attr_t => "ia32_compare_x87_attr",
295 ia32_asm_attr_t => "ia32_compare_asm_attr",
296 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
297 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
298 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
304 $mode_xmm = "mode_E";
305 $mode_gp = "mode_Iu";
306 $mode_flags = "mode_Iu";
307 $mode_fpcw = "mode_fpcw";
308 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
309 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
310 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
318 reg_req => { out => [ "gp_NOREG" ] },
319 attr => "ir_entity *symconst, int symconst_sign, long offset",
320 attr_type => "ia32_immediate_attr_t",
328 out_arity => "variable",
329 attr_type => "ia32_asm_attr_t",
330 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
331 init_attr => "attr->asm_text = asm_text;\n".
332 "\tattr->register_map = register_map;\n",
337 # "allocates" a free register
341 reg_req => { out => [ "gp" ] },
346 cmp_attr => "return 1;",
349 #-----------------------------------------------------------------#
352 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
353 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
354 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
355 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
358 #-----------------------------------------------------------------#
360 # commutative operations
364 state => "exc_pinned",
365 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
366 out => [ "in_r4 in_r5", "flags", "none" ] },
367 ins => [ "base", "index", "mem", "left", "right" ],
368 outs => [ "res", "flags", "M" ],
369 emit => '. add%M %binop',
370 am => "source,binary",
374 modified_flags => $status_flags
379 state => "exc_pinned",
380 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
381 ins => [ "base", "index", "mem", "val" ],
382 emit => ". add%M %SI3, %AM",
386 modified_flags => $status_flags
391 state => "exc_pinned",
392 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
393 ins => [ "base", "index", "mem", "val" ],
394 emit => ". add%M %SB3, %AM",
398 modified_flags => $status_flags
402 state => "exc_pinned",
403 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
404 out => [ "in_r4 in_r5", "flags", "none" ] },
405 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
406 outs => [ "res", "flags", "M" ],
407 emit => '. adc%M %binop',
408 am => "source,binary",
412 modified_flags => $status_flags
417 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
418 ins => [ "left", "right" ],
422 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
423 ins => [ "left", "right", "eflags" ],
427 # we should not rematrialize this node. It produces 2 results and has
428 # very strict constrains
429 state => "exc_pinned",
430 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
431 out => [ "eax", "edx", "none" ] },
432 ins => [ "base", "index", "mem", "val_high", "val_low" ],
433 emit => '. mul%M %unop4',
434 outs => [ "res_low", "res_high", "M" ],
435 am => "source,binary",
438 modified_flags => $status_flags
442 # we should not rematrialize this node. It produces 2 results and has
443 # very strict constrains
445 cmp_attr => "return 1;",
446 outs => [ "EAX", "EDX", "M" ],
452 state => "exc_pinned",
453 # TODO: adjust out requirements for the 3 operand form
454 # (no need for should_be_same then)
455 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
456 out => [ "in_r4 in_r5", "flags", "none" ] },
457 ins => [ "base", "index", "mem", "left", "right" ],
458 outs => [ "res", "flags", "M" ],
459 am => "source,binary",
463 modified_flags => $status_flags
468 state => "exc_pinned",
469 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
470 out => [ "eax", "edx", "none" ] },
471 ins => [ "base", "index", "mem", "val_high", "val_low" ],
472 emit => '. imul%M %unop4',
473 outs => [ "res_low", "res_high", "M" ],
474 am => "source,binary",
477 modified_flags => $status_flags
482 cmp_attr => "return 1;",
483 outs => [ "res_low", "res_high", "M" ],
489 state => "exc_pinned",
490 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
491 out => [ "in_r4 in_r5", "flags", "none" ] },
492 ins => [ "base", "index", "mem", "left", "right" ],
493 outs => [ "res", "flags", "M" ],
494 op_modes => "commutative | am | immediate | mode_neutral",
495 am => "source,binary",
496 emit => '. and%M %binop',
500 modified_flags => $status_flags
505 state => "exc_pinned",
506 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
507 ins => [ "base", "index", "mem", "val" ],
508 emit => '. and%M %SI3, %AM',
512 modified_flags => $status_flags
517 state => "exc_pinned",
518 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
519 ins => [ "base", "index", "mem", "val" ],
520 emit => '. and%M %SB3, %AM',
524 modified_flags => $status_flags
529 state => "exc_pinned",
530 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
531 out => [ "in_r4 in_r5", "flags", "none" ] },
532 ins => [ "base", "index", "mem", "left", "right" ],
533 outs => [ "res", "flags", "M" ],
534 am => "source,binary",
535 emit => '. or%M %binop',
539 modified_flags => $status_flags
544 state => "exc_pinned",
545 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
546 ins => [ "base", "index", "mem", "val" ],
547 emit => '. or%M %SI3, %AM',
551 modified_flags => $status_flags
556 state => "exc_pinned",
557 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
558 ins => [ "base", "index", "mem", "val" ],
559 emit => '. or%M %SB3, %AM',
563 modified_flags => $status_flags
568 state => "exc_pinned",
569 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
570 out => [ "in_r4 in_r5", "flags", "none" ] },
571 ins => [ "base", "index", "mem", "left", "right" ],
572 outs => [ "res", "flags", "M" ],
573 am => "source,binary",
574 emit => '. xor%M %binop',
578 modified_flags => $status_flags
583 state => "exc_pinned",
584 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
585 ins => [ "base", "index", "mem", "val" ],
586 emit => '. xor%M %SI3, %AM',
590 modified_flags => $status_flags
595 state => "exc_pinned",
596 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
597 ins => [ "base", "index", "mem", "val" ],
598 emit => '. xor%M %SB3, %AM',
602 modified_flags => $status_flags
605 # not commutative operations
609 state => "exc_pinned",
610 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
611 out => [ "in_r4", "flags", "none" ] },
612 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
613 outs => [ "res", "flags", "M" ],
614 am => "source,binary",
615 emit => '. sub%M %binop',
619 modified_flags => $status_flags
624 state => "exc_pinned",
625 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
626 ins => [ "base", "index", "mem", "subtrahend" ],
627 emit => '. sub%M %SI3, %AM',
631 modified_flags => $status_flags
636 state => "exc_pinned",
637 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
638 ins => [ "base", "index", "mem", "subtrahend" ],
639 emit => '. sub%M %SB3, %AM',
643 modified_flags => $status_flags
647 state => "exc_pinned",
648 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
649 out => [ "in_r4 !in_r5", "flags", "none" ] },
650 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
651 outs => [ "res", "flags", "M" ],
652 am => "source,binary",
653 emit => '. sbb%M %binop',
657 modified_flags => $status_flags
661 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
662 ins => [ "minuend", "subtrahend" ],
666 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
667 ins => [ "minuend", "subtrahend", "eflags" ],
672 state => "exc_pinned",
673 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
674 out => [ "eax", "flags", "none", "edx", "none" ] },
675 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
676 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
677 am => "source,ternary",
678 emit => ". idiv%M %unop3",
681 modified_flags => $status_flags
686 state => "exc_pinned",
687 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
688 out => [ "eax", "flags", "none", "edx", "none" ] },
689 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
690 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
691 am => "source,ternary",
692 emit => ". div%M %unop3",
695 modified_flags => $status_flags
700 reg_req => { in => [ "gp", "ecx" ],
701 out => [ "in_r1 !in_r2", "flags" ] },
702 ins => [ "val", "count" ],
703 outs => [ "res", "flags" ],
704 emit => '. shl %SB1, %S0',
708 modified_flags => $status_flags
713 state => "exc_pinned",
714 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
715 ins => [ "base", "index", "mem", "count" ],
716 emit => '. shl%M %SB3, %AM',
720 modified_flags => $status_flags
724 cmp_attr => "return 1;",
725 ins => [ "val", "count", "dep" ],
731 reg_req => { in => [ "gp", "gp", "ecx" ],
732 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
733 ins => [ "val_high", "val_low", "count" ],
734 outs => [ "res", "flags" ],
735 emit => ". shld%M %SB2, %S1, %D0",
739 modified_flags => $status_flags
743 cmp_attr => "return 1;",
744 ins => [ "val_high", "val_low", "count" ],
750 reg_req => { in => [ "gp", "ecx" ],
751 out => [ "in_r1 !in_r2", "flags" ] },
752 ins => [ "val", "count" ],
753 outs => [ "res", "flags" ],
754 emit => '. shr %SB1, %S0',
758 modified_flags => $status_flags
763 state => "exc_pinned",
764 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
765 ins => [ "base", "index", "mem", "count" ],
766 emit => '. shr%M %SB3, %AM',
770 modified_flags => $status_flags
774 cmp_attr => "return 1;",
775 ins => [ "val", "count", "dep" ],
781 reg_req => { in => [ "gp", "gp", "ecx" ],
782 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
783 ins => [ "val_high", "val_low", "count" ],
784 outs => [ "res", "flags" ],
785 emit => ". shrd%M %SB2, %S1, %D0",
789 modified_flags => $status_flags
793 cmp_attr => "return 1;",
795 ins => [ "val_high", "val_low", "count" ],
800 reg_req => { in => [ "gp", "ecx" ],
801 out => [ "in_r1 !in_r2", "flags" ] },
802 ins => [ "val", "count" ],
803 outs => [ "res", "flags" ],
804 emit => '. sar %SB1, %S0',
808 modified_flags => $status_flags
813 state => "exc_pinned",
814 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
815 ins => [ "base", "index", "mem", "count" ],
816 emit => '. sar%M %SB3, %AM',
820 modified_flags => $status_flags
824 cmp_attr => "return 1;",
825 ins => [ "val", "count", "dep" ],
831 reg_req => { in => [ "gp", "ecx" ],
832 out => [ "in_r1 !in_r2", "flags" ] },
833 ins => [ "val", "count" ],
834 outs => [ "res", "flags" ],
835 emit => '. ror %SB1, %S0',
839 modified_flags => $status_flags
844 state => "exc_pinned",
845 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
846 ins => [ "base", "index", "mem", "count" ],
847 emit => '. ror%M %SB3, %AM',
851 modified_flags => $status_flags
856 reg_req => { in => [ "gp", "ecx" ],
857 out => [ "in_r1 !in_r2", "flags" ] },
858 ins => [ "val", "count" ],
859 outs => [ "res", "flags" ],
860 emit => '. rol %SB1, %S0',
864 modified_flags => $status_flags
869 state => "exc_pinned",
870 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
871 ins => [ "base", "index", "mem", "count" ],
872 emit => '. rol%M %SB3, %AM',
876 modified_flags => $status_flags
883 reg_req => { in => [ "gp" ],
884 out => [ "in_r1", "flags" ] },
887 outs => [ "res", "flags" ],
891 modified_flags => $status_flags
896 state => "exc_pinned",
897 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
898 ins => [ "base", "index", "mem" ],
899 emit => '. neg%M %AM',
903 modified_flags => $status_flags
908 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
909 outs => [ "low_res", "high_res" ],
912 modified_flags => $status_flags
918 reg_req => { in => [ "gp" ],
919 out => [ "in_r1", "flags" ] },
921 outs => [ "res", "flags" ],
926 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
931 state => "exc_pinned",
932 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
933 ins => [ "base", "index", "mem" ],
934 emit => '. inc%M %AM',
938 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
943 reg_req => { in => [ "gp" ],
944 out => [ "in_r1", "flags" ] },
946 outs => [ "res", "flags" ],
951 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
956 state => "exc_pinned",
957 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
958 ins => [ "base", "index", "mem" ],
959 emit => '. dec%M %AM',
963 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
968 reg_req => { in => [ "gp" ],
969 out => [ "in_r1", "flags" ] },
971 outs => [ "res", "flags" ],
981 state => "exc_pinned",
982 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
983 ins => [ "base", "index", "mem" ],
984 emit => '. not%M %AM',
992 reg_req => { in => [ "flags" ], out => [ "flags" ] },
997 modified_flags => $status_flags
1001 reg_req => { out => [ "flags" ] },
1005 mode => $mode_flags,
1006 modified_flags => $status_flags
1013 state => "exc_pinned",
1014 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1015 out => [ "flags", "none", "none" ] },
1016 ins => [ "base", "index", "mem", "left", "right" ],
1017 outs => [ "eflags", "unused", "M" ],
1018 am => "source,binary",
1019 emit => '. cmp%M %binop',
1020 attr => "int ins_permuted, int cmp_unsigned",
1021 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1022 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1025 mode => $mode_flags,
1026 modified_flags => $status_flags
1031 state => "exc_pinned",
1032 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1033 ins => [ "base", "index", "mem", "left", "right" ],
1034 outs => [ "eflags" ],
1035 am => "source,binary",
1036 emit => '. cmpb %binop',
1037 attr => "int ins_permuted, int cmp_unsigned",
1038 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1039 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1042 mode => $mode_flags,
1043 modified_flags => $status_flags
1048 state => "exc_pinned",
1049 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1050 ins => [ "base", "index", "mem", "left", "right" ],
1051 outs => [ "eflags" ],
1052 am => "source,binary",
1053 emit => '. test%M %binop',
1054 attr => "int ins_permuted, int cmp_unsigned",
1055 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1056 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1059 mode => $mode_flags,
1060 modified_flags => $status_flags
1065 state => "exc_pinned",
1066 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1067 ins => [ "base", "index", "mem", "left", "right" ],
1068 outs => [ "eflags" ],
1069 am => "source,binary",
1070 emit => '. testb %binop',
1071 attr => "int ins_permuted, int cmp_unsigned",
1072 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1073 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1076 mode => $mode_flags,
1077 modified_flags => $status_flags
1082 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1083 ins => [ "eflags" ],
1084 attr_type => "ia32_condcode_attr_t",
1085 attr => "pn_Cmp pnc, int ins_permuted",
1086 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1087 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1088 emit => '. set%CMP0 %DB0',
1096 state => "exc_pinned",
1097 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1098 ins => [ "base", "index", "mem","eflags" ],
1099 attr_type => "ia32_condcode_attr_t",
1100 attr => "pn_Cmp pnc, int ins_permuted",
1101 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1102 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1103 emit => '. set%CMP3 %AM',
1111 # (note: leave the false,true order intact to make it compatible with other
1113 state => "exc_pinned",
1114 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1115 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1116 am => "source,binary",
1117 attr_type => "ia32_condcode_attr_t",
1118 attr => "int ins_permuted, pn_Cmp pnc",
1119 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1127 op_flags => "L|X|Y",
1128 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1129 ins => [ "eflags" ],
1130 outs => [ "false", "true" ],
1131 attr_type => "ia32_condcode_attr_t",
1132 attr => "pn_Cmp pnc",
1134 units => [ "BRANCH" ],
1139 op_flags => "L|X|Y",
1140 reg_req => { in => [ "gp" ], out => [ "none" ] },
1142 attr_type => "ia32_condcode_attr_t",
1145 units => [ "BRANCH" ],
1146 modified_flags => $status_flags,
1152 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1153 ins => [ "base", "index", "mem", "target" ],
1154 am => "source,unary",
1155 emit => '. jmp *%unop3',
1157 units => [ "BRANCH" ],
1164 reg_req => { out => [ "gp" ] },
1166 attr => "ir_entity *symconst, int symconst_sign, long offset",
1167 attr_type => "ia32_immediate_attr_t",
1174 reg_req => { out => [ "gp" ] },
1178 modified_flags => $status_flags,
1185 reg_req => { out => [ "gp_UKNWN" ] },
1196 reg_req => { out => [ "vfp_UKNWN" ] },
1201 attr_type => "ia32_x87_attr_t",
1208 reg_req => { out => [ "xmm_UKNWN" ] },
1217 op_flags => "c|NB|NI",
1219 reg_req => { out => [ "gp_NOREG" ] },
1228 op_flags => "c|NB|NI",
1230 reg_req => { out => [ "vfp_NOREG" ] },
1235 attr_type => "ia32_x87_attr_t",
1240 op_flags => "c|NB|NI",
1242 reg_req => { out => [ "xmm_NOREG" ] },
1253 reg_req => { out => [ "fp_cw" ] },
1257 modified_flags => $fpcw_flags
1263 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1264 ins => [ "base", "index", "mem" ],
1266 emit => ". fldcw %AM",
1269 modified_flags => $fpcw_flags
1275 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1276 ins => [ "base", "index", "mem", "fpcw" ],
1278 emit => ". fnstcw %AM",
1286 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1294 # we should not rematrialize this node. It has very strict constraints.
1295 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1296 ins => [ "val", "clobbered" ],
1305 # Note that we add additional latency values depending on address mode, so a
1306 # lateny of 0 for load is correct
1310 state => "exc_pinned",
1311 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1312 ins => [ "base", "index", "mem" ],
1313 outs => [ "res", "M", "X_exc" ],
1315 emit => ". mov%SE%ME%.l %AM, %D0",
1321 cmp_attr => "return 1;",
1322 outs => [ "res", "M" ],
1328 cmp_attr => "return 1;",
1329 state => "exc_pinned",
1336 state => "exc_pinned",
1337 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1338 ins => [ "base", "index", "mem", "val" ],
1339 outs => [ "M", "X_exc" ],
1340 emit => '. mov%M %SI3, %AM',
1348 state => "exc_pinned",
1349 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1350 ins => [ "base", "index", "mem", "val" ],
1351 outs => [ "M", "X_exc" ],
1352 emit => '. mov%M %SB3, %AM',
1360 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1361 ins => [ "base", "index" ],
1362 emit => '. leal %AM, %D0',
1366 # lea doesn't modify the flags, but setting this seems advantageous since it
1367 # increases chances that the Lea is transformed back to an Add
1368 modified_flags => 1,
1372 state => "exc_pinned",
1373 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1374 ins => [ "base", "index", "mem", "val", "stack" ],
1375 emit => '. push%M %unop3',
1376 outs => [ "stack:I|S", "M" ],
1377 am => "source,binary",
1383 state => "exc_pinned",
1384 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1385 ins => [ "mem", "stack" ],
1386 outs => [ "res", "M", "unused", "stack:I|S" ],
1387 emit => '. pop%M %D0',
1388 latency => 3, # Pop is more expensive than Push on Athlon
1393 state => "exc_pinned",
1394 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1395 ins => [ "base", "index", "mem", "stack" ],
1396 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1397 emit => '. pop%M %AM',
1398 latency => 3, # Pop is more expensive than Push on Athlon
1403 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1405 outs => [ "frame:I", "stack:I|S", "M" ],
1411 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1413 outs => [ "frame:I", "stack:I|S" ],
1421 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1422 ins => [ "base", "index", "mem", "stack", "size" ],
1423 am => "source,binary",
1424 emit => '. addl %binop',
1426 outs => [ "stack:I|S", "M" ],
1428 modified_flags => $status_flags
1434 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1435 ins => [ "base", "index", "mem", "stack", "size" ],
1436 am => "source,binary",
1437 emit => ". subl %binop\n".
1438 ". movl %%esp, %D1",
1440 outs => [ "stack:I|S", "addr", "M" ],
1442 modified_flags => $status_flags
1455 reg_req => { out => [ "gp" ] },
1462 state => "exc_pinned",
1463 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1464 ins => [ "left", "right" ],
1465 emit => '. bt%M %S1, %S0',
1468 mode => $mode_flags,
1469 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1472 #-----------------------------------------------------------------------------#
1473 # _____ _____ ______ __ _ _ _ #
1474 # / ____/ ____| ____| / _| | | | | | #
1475 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1476 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1477 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1478 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1479 #-----------------------------------------------------------------------------#
1484 reg_req => { out => [ "xmm" ] },
1485 emit => '. xorp%XSD %D0, %D0',
1493 reg_req => { out => [ "xmm" ] },
1494 emit => '. pxor %D0, %D0',
1500 # produces all 1 bits
1503 reg_req => { out => [ "xmm" ] },
1504 emit => '. pcmpeqb %D0, %D0',
1510 # integer shift left, dword
1513 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1514 emit => '. pslld %SI1, %D0',
1520 # integer shift left, qword
1523 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1524 emit => '. psllq %SI1, %D0',
1530 # integer shift right, dword
1533 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1534 emit => '. psrld %SI1, %D0',
1540 # mov from integer to SSE register
1543 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1544 emit => '. movd %S0, %D0',
1550 # commutative operations
1554 state => "exc_pinned",
1555 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1556 ins => [ "base", "index", "mem", "left", "right" ],
1557 am => "source,binary",
1558 emit => '. add%XXM %binop',
1566 state => "exc_pinned",
1567 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1568 ins => [ "base", "index", "mem", "left", "right" ],
1569 am => "source,binary",
1570 emit => '. mul%XXM %binop',
1578 state => "exc_pinned",
1579 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1580 ins => [ "base", "index", "mem", "left", "right" ],
1581 am => "source,binary",
1582 emit => '. max%XXM %binop',
1590 state => "exc_pinned",
1591 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1592 ins => [ "base", "index", "mem", "left", "right" ],
1593 am => "source,binary",
1594 emit => '. min%XXM %binop',
1602 state => "exc_pinned",
1603 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1604 ins => [ "base", "index", "mem", "left", "right" ],
1605 am => "source,binary",
1606 emit => '. andp%XSD %binop',
1614 state => "exc_pinned",
1615 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1616 ins => [ "base", "index", "mem", "left", "right" ],
1617 am => "source,binary",
1618 emit => '. orp%XSD %binop',
1626 state => "exc_pinned",
1627 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1628 ins => [ "base", "index", "mem", "left", "right" ],
1629 am => "source,binary",
1630 emit => '. xorp%XSD %binop',
1636 # not commutative operations
1640 state => "exc_pinned",
1641 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1642 ins => [ "base", "index", "mem", "left", "right" ],
1643 am => "source,binary",
1644 emit => '. andnp%XSD %binop',
1652 state => "exc_pinned",
1653 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1654 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1655 am => "source,binary",
1656 emit => '. sub%XXM %binop',
1664 state => "exc_pinned",
1665 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1666 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1667 am => "source,binary",
1668 outs => [ "res", "M" ],
1669 emit => '. div%XXM %binop',
1678 state => "exc_pinned",
1679 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1680 ins => [ "base", "index", "mem", "left", "right" ],
1681 outs => [ "flags" ],
1682 am => "source,binary",
1683 attr => "int ins_permuted",
1684 init_attr => "attr->data.ins_permuted = ins_permuted;",
1685 emit => ' .ucomi%XXM %binop',
1688 mode => $mode_flags,
1689 modified_flags => 1,
1696 state => "exc_pinned",
1697 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1698 ins => [ "base", "index", "mem" ],
1699 outs => [ "res", "M", "X_exc" ],
1700 emit => '. mov%XXM %AM, %D0',
1701 attr => "ir_mode *load_mode",
1702 init_attr => "attr->ls_mode = load_mode;",
1709 state => "exc_pinned",
1710 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1711 ins => [ "base", "index", "mem", "val" ],
1712 outs => [ "M", "X_exc" ],
1713 emit => '. mov%XXM %S3, %AM',
1721 state => "exc_pinned",
1722 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1723 ins => [ "base", "index", "mem", "val" ],
1724 emit => '. mov%XXM %S3, %AM',
1732 state => "exc_pinned",
1733 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1734 ins => [ "base", "index", "mem", "val" ],
1735 am => "source,unary",
1736 emit => '. cvtsi2ss %unop3, %D0',
1744 state => "exc_pinned",
1745 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1746 ins => [ "base", "index", "mem", "val" ],
1747 am => "source,unary",
1748 emit => '. cvtsi2sd %unop3, %D0',
1757 cmp_attr => "return 1;",
1758 ins => [ "val_high", "val_low" ],
1763 cmp_attr => "return 1;",
1765 outs => [ "res_high", "res_low" ],
1773 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1774 outs => [ "DST", "SRC", "CNT", "M" ],
1775 attr_type => "ia32_copyb_attr_t",
1776 attr => "unsigned size",
1779 # we don't care about this flag, so no need to mark this node
1780 # modified_flags => [ "DF" ]
1786 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1787 outs => [ "DST", "SRC", "M" ],
1788 attr_type => "ia32_copyb_attr_t",
1789 attr => "unsigned size",
1792 # we don't care about this flag, so no need to mark this node
1793 # modified_flags => [ "DF" ]
1799 state => "exc_pinned",
1800 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1801 ins => [ "base", "index", "mem", "val" ],
1802 am => "source,unary",
1805 attr => "ir_mode *smaller_mode",
1806 init_attr => "attr->ls_mode = smaller_mode;",
1811 state => "exc_pinned",
1812 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1813 ins => [ "base", "index", "mem", "val" ],
1814 am => "source,unary",
1817 attr => "ir_mode *smaller_mode",
1818 init_attr => "attr->ls_mode = smaller_mode;",
1823 state => "exc_pinned",
1824 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1825 ins => [ "base", "index", "mem", "val" ],
1826 am => "source,unary",
1833 state => "exc_pinned",
1834 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1835 ins => [ "base", "index", "mem", "val" ],
1836 am => "source,unary",
1843 state => "exc_pinned",
1844 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1845 ins => [ "base", "index", "mem", "val" ],
1846 am => "source,unary",
1852 #----------------------------------------------------------#
1854 # (_) | | | | / _| | | | #
1855 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1856 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1857 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1858 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1860 # _ __ ___ __| | ___ ___ #
1861 # | '_ \ / _ \ / _` |/ _ \/ __| #
1862 # | | | | (_) | (_| | __/\__ \ #
1863 # |_| |_|\___/ \__,_|\___||___/ #
1864 #----------------------------------------------------------#
1866 # rematerialisation disabled for all float nodes for now, because the fpcw
1867 # handler runs before spilling and we might end up with wrong fpcw then
1871 state => "exc_pinned",
1872 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1873 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1874 am => "source,binary",
1878 attr_type => "ia32_x87_attr_t",
1883 state => "exc_pinned",
1884 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1885 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1886 am => "source,binary",
1890 attr_type => "ia32_x87_attr_t",
1895 state => "exc_pinned",
1896 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1897 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1898 am => "source,binary",
1902 attr_type => "ia32_x87_attr_t",
1906 state => "exc_pinned",
1907 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1908 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1909 am => "source,binary",
1910 outs => [ "res", "M" ],
1913 attr_type => "ia32_x87_attr_t",
1917 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1918 ins => [ "left", "right", "fpcw" ],
1922 attr_type => "ia32_x87_attr_t",
1927 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1932 attr_type => "ia32_x87_attr_t",
1937 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1942 attr_type => "ia32_x87_attr_t",
1945 # virtual Load and Store
1950 state => "exc_pinned",
1951 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1952 ins => [ "base", "index", "mem" ],
1953 outs => [ "res", "M", "X_exc" ],
1954 attr => "ir_mode *load_mode",
1955 init_attr => "attr->attr.ls_mode = load_mode;",
1958 attr_type => "ia32_x87_attr_t",
1964 state => "exc_pinned",
1965 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1966 ins => [ "base", "index", "mem", "val" ],
1967 outs => [ "M", "X_exc" ],
1968 attr => "ir_mode *store_mode",
1969 init_attr => "attr->attr.ls_mode = store_mode;",
1973 attr_type => "ia32_x87_attr_t",
1979 state => "exc_pinned",
1980 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1981 outs => [ "res", "M" ],
1982 ins => [ "base", "index", "mem" ],
1985 attr_type => "ia32_x87_attr_t",
1989 cmp_attr => "return 1;",
1990 outs => [ "res", "M" ],
1995 state => "exc_pinned",
1996 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1997 ins => [ "base", "index", "mem", "val", "fpcw" ],
2001 attr_type => "ia32_x87_attr_t",
2004 # SSE3 fisttp instruction
2006 state => "exc_pinned",
2007 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2008 ins => [ "base", "index", "mem", "val" ],
2009 outs => [ "res", "M" ],
2012 attr_type => "ia32_x87_attr_t",
2016 cmp_attr => "return 1;",
2017 state => "exc_pinned",
2027 reg_req => { out => [ "vfp" ] },
2031 attr_type => "ia32_x87_attr_t",
2036 reg_req => { out => [ "vfp" ] },
2040 attr_type => "ia32_x87_attr_t",
2045 reg_req => { out => [ "vfp" ] },
2049 attr_type => "ia32_x87_attr_t",
2054 reg_req => { out => [ "vfp" ] },
2058 attr_type => "ia32_x87_attr_t",
2063 reg_req => { out => [ "vfp" ] },
2067 attr_type => "ia32_x87_attr_t",
2072 reg_req => { out => [ "vfp" ] },
2076 attr_type => "ia32_x87_attr_t",
2081 reg_req => { out => [ "vfp" ] },
2085 attr_type => "ia32_x87_attr_t",
2091 # we can't allow to rematerialize this node so we don't have
2092 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2094 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2095 ins => [ "left", "right" ],
2096 outs => [ "flags" ],
2097 attr => "int ins_permuted",
2098 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2101 attr_type => "ia32_x87_attr_t",
2107 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2108 ins => [ "left", "right" ],
2109 outs => [ "flags" ],
2110 attr => "int ins_permuted",
2111 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2114 attr_type => "ia32_x87_attr_t",
2120 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2122 outs => [ "flags" ],
2123 attr => "int ins_permuted",
2124 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2127 attr_type => "ia32_x87_attr_t",
2133 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2135 outs => [ "flags" ],
2139 mode => $mode_flags,
2142 #------------------------------------------------------------------------#
2143 # ___ _____ __ _ _ _ #
2144 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2145 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2146 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2147 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2148 #------------------------------------------------------------------------#
2150 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2151 # are swapped, we work this around in the emitter...
2154 state => "exc_pinned",
2155 rd_constructor => "NONE",
2157 emit => '. fadd%XM %x87_binop',
2159 attr_type => "ia32_x87_attr_t",
2163 state => "exc_pinned",
2164 rd_constructor => "NONE",
2166 emit => '. faddp%XM %x87_binop',
2168 attr_type => "ia32_x87_attr_t",
2172 state => "exc_pinned",
2173 rd_constructor => "NONE",
2175 emit => '. fmul%XM %x87_binop',
2177 attr_type => "ia32_x87_attr_t",
2181 state => "exc_pinned",
2182 rd_constructor => "NONE",
2184 emit => '. fmulp%XM %x87_binop',,
2186 attr_type => "ia32_x87_attr_t",
2190 state => "exc_pinned",
2191 rd_constructor => "NONE",
2193 emit => '. fsub%XM %x87_binop',
2195 attr_type => "ia32_x87_attr_t",
2199 state => "exc_pinned",
2200 rd_constructor => "NONE",
2202 # see note about gas bugs
2203 emit => '. fsubrp%XM %x87_binop',
2205 attr_type => "ia32_x87_attr_t",
2209 state => "exc_pinned",
2210 rd_constructor => "NONE",
2213 emit => '. fsubr%XM %x87_binop',
2215 attr_type => "ia32_x87_attr_t",
2219 state => "exc_pinned",
2220 rd_constructor => "NONE",
2223 # see note about gas bugs
2224 emit => '. fsubp%XM %x87_binop',
2226 attr_type => "ia32_x87_attr_t",
2230 rd_constructor => "NONE",
2234 attr_type => "ia32_x87_attr_t",
2237 # this node is just here, to keep the simulator running
2238 # we can omit this when a fprem simulation function exists
2240 rd_constructor => "NONE",
2242 emit => '. fprem1\n'.
2245 attr_type => "ia32_x87_attr_t",
2249 state => "exc_pinned",
2250 rd_constructor => "NONE",
2252 emit => '. fdiv%XM %x87_binop',
2254 attr_type => "ia32_x87_attr_t",
2258 state => "exc_pinned",
2259 rd_constructor => "NONE",
2261 # see note about gas bugs
2262 emit => '. fdivrp%XM %x87_binop',
2264 attr_type => "ia32_x87_attr_t",
2268 state => "exc_pinned",
2269 rd_constructor => "NONE",
2271 emit => '. fdivr%XM %x87_binop',
2273 attr_type => "ia32_x87_attr_t",
2277 state => "exc_pinned",
2278 rd_constructor => "NONE",
2280 # see note about gas bugs
2281 emit => '. fdivp%XM %x87_binop',
2283 attr_type => "ia32_x87_attr_t",
2287 rd_constructor => "NONE",
2291 attr_type => "ia32_x87_attr_t",
2296 rd_constructor => "NONE",
2300 attr_type => "ia32_x87_attr_t",
2303 # x87 Load and Store
2306 rd_constructor => "NONE",
2307 op_flags => "R|L|F",
2308 state => "exc_pinned",
2310 emit => '. fld%XM %AM',
2311 attr_type => "ia32_x87_attr_t",
2316 rd_constructor => "NONE",
2317 op_flags => "R|L|F",
2318 state => "exc_pinned",
2320 emit => '. fst%XM %AM',
2322 attr_type => "ia32_x87_attr_t",
2327 rd_constructor => "NONE",
2328 op_flags => "R|L|F",
2329 state => "exc_pinned",
2331 emit => '. fstp%XM %AM',
2333 attr_type => "ia32_x87_attr_t",
2340 state => "exc_pinned",
2341 rd_constructor => "NONE",
2343 emit => '. fild%M %AM',
2344 attr_type => "ia32_x87_attr_t",
2349 state => "exc_pinned",
2350 rd_constructor => "NONE",
2352 emit => '. fist%M %AM',
2354 attr_type => "ia32_x87_attr_t",
2359 state => "exc_pinned",
2360 rd_constructor => "NONE",
2362 emit => '. fistp%M %AM',
2364 attr_type => "ia32_x87_attr_t",
2368 # SSE3 firsttp instruction
2370 state => "exc_pinned",
2371 rd_constructor => "NONE",
2373 emit => '. fisttp%M %AM',
2375 attr_type => "ia32_x87_attr_t",
2382 op_flags => "R|c|K",
2384 reg_req => { out => [ "vfp" ] },
2386 attr_type => "ia32_x87_attr_t",
2391 op_flags => "R|c|K",
2393 reg_req => { out => [ "vfp" ] },
2395 attr_type => "ia32_x87_attr_t",
2400 op_flags => "R|c|K",
2402 reg_req => { out => [ "vfp" ] },
2404 attr_type => "ia32_x87_attr_t",
2409 op_flags => "R|c|K",
2411 reg_req => { out => [ "vfp" ] },
2413 attr_type => "ia32_x87_attr_t",
2418 op_flags => "R|c|K",
2420 reg_req => { out => [ "vfp" ] },
2422 attr_type => "ia32_x87_attr_t",
2427 op_flags => "R|c|K",
2429 reg_req => { out => [ "vfp" ] },
2430 emit => '. fldll2t',
2431 attr_type => "ia32_x87_attr_t",
2436 op_flags => "R|c|K",
2438 reg_req => { out => [ "vfp" ] },
2440 attr_type => "ia32_x87_attr_t",
2445 # Note that it is NEVER allowed to do CSE on these nodes
2446 # Moreover, note the virtual register requierements!
2451 cmp_attr => "return 1;",
2452 emit => '. fxch %X0',
2453 attr_type => "ia32_x87_attr_t",
2461 cmp_attr => "return 1;",
2462 emit => '. fld %X0',
2463 attr_type => "ia32_x87_attr_t",
2469 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2470 cmp_attr => "return 1;",
2471 emit => '. fld %X0',
2472 attr_type => "ia32_x87_attr_t",
2479 cmp_attr => "return 1;",
2480 emit => '. fstp %X0',
2481 attr_type => "ia32_x87_attr_t",
2489 cmp_attr => "return 1;",
2490 emit => '. ffreep %X0',
2491 attr_type => "ia32_x87_attr_t",
2499 cmp_attr => "return 1;",
2501 attr_type => "ia32_x87_attr_t",
2509 cmp_attr => "return 1;",
2511 attr_type => "ia32_x87_attr_t",
2520 emit => ". fucom %X1\n".
2522 attr_type => "ia32_x87_attr_t",
2528 emit => ". fucomp %X1\n".
2530 attr_type => "ia32_x87_attr_t",
2536 emit => ". fucompp\n".
2538 attr_type => "ia32_x87_attr_t",
2544 emit => '. fucomi %X1',
2545 attr_type => "ia32_x87_attr_t",
2551 emit => '. fucompi %X1',
2552 attr_type => "ia32_x87_attr_t",
2560 attr_type => "ia32_x87_attr_t",
2565 # -------------------------------------------------------------------------------- #
2566 # ____ ____ _____ _ _ #
2567 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2568 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2569 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2570 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2572 # -------------------------------------------------------------------------------- #
2575 # Spilling and reloading of SSE registers, hardcoded, not generated #
2579 state => "exc_pinned",
2580 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2581 emit => '. movdqu %D0, %AM',
2582 outs => [ "res", "M" ],
2589 state => "exc_pinned",
2590 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2591 ins => [ "base", "index", "mem", "val" ],
2592 emit => '. movdqu %binop',
2600 # Include the generated SIMD node specification written by the SIMD optimization
2601 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2602 unless ($return = do $my_script_name) {
2603 warn "couldn't parse $my_script_name: $@" if $@;
2604 warn "couldn't do $my_script_name: $!" unless defined $return;
2605 warn "couldn't run $my_script_name" unless $return;
2608 # Transform some attributes
2609 foreach my $op (keys(%nodes)) {
2610 my $node = $nodes{$op};
2611 my $op_attr_init = $node->{op_attr_init};
2613 if(defined($op_attr_init)) {
2614 $op_attr_init .= "\n\t";
2619 if(!defined($node->{latency})) {
2621 $node->{latency} = 0;
2623 die("Latency missing for op $op");
2626 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2628 $node->{op_attr_init} = $op_attr_init;