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
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
59 # I ignore for register allocation
60 # S modifies stack pointer
62 # state: state of the operation, OPTIONAL (default is "floats")
64 # arity: arity of the operation, MUST NOT BE OMITTED
66 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
67 # are always the first 3 arguments and are always autmatically
69 # If this key is missing the following arguments will be created:
70 # for i = 1 .. arity: ir_node *op_i
73 # outs: if a node defines more than one output, the names of the projections
74 # nodes having outs having automatically the mode mode_T
75 # One can also annotate some flags for each out, additional to irn_flags.
76 # They are separated from name with a colon ':', and concatenated by pipe '|'
77 # Only I and S are available at the moment (same meaning as in irn_flags).
78 # example: [ "frame:I", "stack:I|S", "M" ]
80 # comment: OPTIONAL comment for the node constructor
82 # rd_constructor: for every operation there will be a
83 # new_rd_<arch>_<op-name> function with the arguments from above
84 # which creates the ir_node corresponding to the defined operation
85 # you can either put the complete source code of this function here
87 # This key is OPTIONAL. If omitted, the following constructor will
89 # if (!op_<arch>_<op-name>) assert(0);
93 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
96 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
100 # 0 - no special type
101 # 1 - caller save (register must be saved by the caller of a function)
102 # 2 - callee save (register must be saved by the called function)
103 # 4 - ignore (do not assign this register)
104 # 8 - emitter can choose an arbitrary register of this class
105 # 16 - the register is a virtual one
106 # 32 - register represents a state
107 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
110 { name => "edx", type => 1 },
111 { name => "ecx", type => 1 },
112 { name => "eax", type => 1 },
113 { name => "ebx", type => 2 },
114 { name => "esi", type => 2 },
115 { name => "edi", type => 2 },
116 { name => "ebp", type => 2 },
117 { name => "esp", type => 4 },
118 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
119 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
120 { mode => "mode_Iu" }
123 { name => "mm0", type => 4 },
124 { name => "mm1", type => 4 },
125 { name => "mm2", type => 4 },
126 { name => "mm3", type => 4 },
127 { name => "mm4", type => 4 },
128 { name => "mm5", type => 4 },
129 { name => "mm6", type => 4 },
130 { name => "mm7", type => 4 },
131 { mode => "mode_E", flags => "manual_ra" }
134 { name => "xmm0", type => 1 },
135 { name => "xmm1", type => 1 },
136 { name => "xmm2", type => 1 },
137 { name => "xmm3", type => 1 },
138 { name => "xmm4", type => 1 },
139 { name => "xmm5", type => 1 },
140 { name => "xmm6", type => 1 },
141 { name => "xmm7", type => 1 },
142 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
143 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
147 { name => "vf0", type => 1 | 16 },
148 { name => "vf1", type => 1 | 16 },
149 { name => "vf2", type => 1 | 16 },
150 { name => "vf3", type => 1 | 16 },
151 { name => "vf4", type => 1 | 16 },
152 { name => "vf5", type => 1 | 16 },
153 { name => "vf6", type => 1 | 16 },
154 { name => "vf7", type => 1 | 16 },
155 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
156 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
160 { name => "st0", realname => "st", type => 4 },
161 { name => "st1", realname => "st(1)", type => 4 },
162 { name => "st2", realname => "st(2)", type => 4 },
163 { name => "st3", realname => "st(3)", type => 4 },
164 { name => "st4", realname => "st(4)", type => 4 },
165 { name => "st5", realname => "st(5)", type => 4 },
166 { name => "st6", realname => "st(6)", type => 4 },
167 { name => "st7", realname => "st(7)", type => 4 },
168 { mode => "mode_E", flags => "manual_ra" }
170 fp_cw => [ # the floating point control word
171 { name => "fpcw", type => 4|32 },
172 { mode => "mode_fpcw", flags => "manual_ra|state" }
175 { name => "eflags", type => 0 },
176 { mode => "mode_Iu", flags => "manual_ra" }
181 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
182 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
183 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
184 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
189 bundels_per_cycle => 1
193 S0 => "${arch}_emit_source_register(node, 0);",
194 S1 => "${arch}_emit_source_register(node, 1);",
195 S2 => "${arch}_emit_source_register(node, 2);",
196 S3 => "${arch}_emit_source_register(node, 3);",
197 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
198 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
199 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
200 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
201 D0 => "${arch}_emit_dest_register(node, 0);",
202 D1 => "${arch}_emit_dest_register(node, 1);",
203 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
204 X0 => "${arch}_emit_x87_register(node, 0);",
205 X1 => "${arch}_emit_x87_register(node, 1);",
206 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
207 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
208 ia32_emit_mode_suffix(node);",
209 M => "${arch}_emit_mode_suffix(node);",
210 XM => "${arch}_emit_x87_mode_suffix(node);",
211 XXM => "${arch}_emit_xmm_mode_suffix(node);",
212 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
213 AM => "${arch}_emit_am(node);",
214 unop3 => "${arch}_emit_unop(node, 3);",
215 unop4 => "${arch}_emit_unop(node, 4);",
216 unop5 => "${arch}_emit_unop(node, 5);",
217 DAM0 => "${arch}_emit_am_or_dest_register(node, 0);",
218 binop => "${arch}_emit_binop(node);",
219 x87_binop => "${arch}_emit_x87_binop(node);",
220 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
221 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
224 #--------------------------------------------------#
227 # _ __ _____ __ _ _ __ ___ _ __ ___ #
228 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
229 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
230 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
233 #--------------------------------------------------#
235 $default_op_attr_type = "ia32_op_attr_t";
236 $default_attr_type = "ia32_attr_t";
237 $default_copy_attr = "ia32_copy_attr";
239 sub ia32_custom_init_attr {
244 if(defined($node->{modified_flags})) {
245 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
247 if(defined($node->{am})) {
248 my $am = $node->{am};
249 if($am eq "full,binary") {
250 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
251 } elsif($am eq "full,unary") {
252 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
253 } elsif($am eq "source,unary") {
254 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_unary);";
255 } elsif($am eq "source,binary") {
256 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
257 } elsif($am eq "dest,unary") {
258 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
259 } elsif($am eq "dest,binary") {
260 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
261 } elsif($am eq "dest,ternary") {
262 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
263 } elsif($am eq "source,ternary") {
264 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
265 } elsif($am eq "none") {
268 die("Invalid address mode '$am' specified on op $name");
271 if($node->{state} ne "exc_pinned"
272 and $node->{state} ne "pinned") {
273 die("AM nodes must have pinned or AM pinned state ($name)");
279 $custom_init_attr_func = \&ia32_custom_init_attr;
282 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
284 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
285 "\tinit_ia32_x87_attributes(res);",
287 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
288 "\tinit_ia32_x87_attributes(res);".
289 "\tinit_ia32_asm_attributes(res);",
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_copyb_attributes(res, size);",
296 ia32_condcode_attr_t =>
297 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
298 "\tinit_ia32_condcode_attributes(res, pnc);",
302 ia32_attr_t => "ia32_compare_nodes_attr",
303 ia32_x87_attr_t => "ia32_compare_x87_attr",
304 ia32_asm_attr_t => "ia32_compare_asm_attr",
305 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
306 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
307 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
313 $mode_xmm = "mode_E";
314 $mode_gp = "mode_Iu";
315 $mode_flags = "mode_Iu";
316 $mode_fpcw = "mode_fpcw";
317 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
318 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
319 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
327 reg_req => { out => [ "gp_NOREG" ] },
328 attr => "ir_entity *symconst, int symconst_sign, long offset",
329 attr_type => "ia32_immediate_attr_t",
337 out_arity => "variable",
338 attr_type => "ia32_asm_attr_t",
339 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
340 init_attr => "attr->asm_text = asm_text;\n".
341 "\tattr->register_map = register_map;\n",
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" ], out => [ "in_r4 in_r5", "none", "flags" ] },
374 ins => [ "base", "index", "mem", "left", "right" ],
375 emit => '. add%M %binop',
380 modified_flags => $status_flags
385 state => "exc_pinned",
386 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
387 ins => [ "base", "index", "mem", "val" ],
388 emit => ". add%M %SI3, %AM",
392 modified_flags => $status_flags
397 state => "exc_pinned",
398 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
399 ins => [ "base", "index", "mem", "val" ],
400 emit => ". add%M %SB3, %AM",
404 modified_flags => $status_flags
408 state => "exc_pinned",
409 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 in_r5" ] },
410 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
411 emit => '. adc%M %binop',
416 modified_flags => $status_flags
421 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
422 ins => [ "left", "right" ],
426 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
427 ins => [ "left", "right", "eflags" ],
431 # we should not rematrialize this node. It produces 2 results and has
432 # very strict constrains
433 state => "exc_pinned",
434 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
435 ins => [ "base", "index", "mem", "val_high", "val_low" ],
436 emit => '. mul%M %unop4',
437 outs => [ "EAX", "EDX", "M" ],
438 am => "source,binary",
441 modified_flags => $status_flags
445 # we should not rematrialize this node. It produces 2 results and has
446 # very strict constrains
448 cmp_attr => "return 1;",
449 outs => [ "EAX", "EDX", "M" ],
455 state => "exc_pinned",
456 # TODO: adjust out requirements for the 3 operand form
457 # (no need for should_be_same then)
458 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
459 out => [ "in_r4 in_r5", "none", "flags" ] },
460 ins => [ "base", "index", "mem", "left", "right" ],
461 outs => [ "res", "M", "flags" ],
462 am => "source,binary",
466 modified_flags => $status_flags
471 state => "exc_pinned",
472 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
473 ins => [ "base", "index", "mem", "val_high", "val_low" ],
474 emit => '. imul%M %unop4',
475 outs => [ "EAX", "EDX", "M" ],
476 am => "source,binary",
479 modified_flags => $status_flags
483 # we should not rematrialize this node. It produces 2 results and has
484 # very strict constrains
486 cmp_attr => "return 1;",
487 outs => [ "EAX", "EDX", "M" ],
493 state => "exc_pinned",
494 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
495 ins => [ "base", "index", "mem", "left", "right" ],
496 op_modes => "commutative | am | immediate | mode_neutral",
498 emit => '. and%M %binop',
502 modified_flags => $status_flags
507 state => "exc_pinned",
508 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
509 ins => [ "base", "index", "mem", "val" ],
510 emit => '. and%M %SI3, %AM',
514 modified_flags => $status_flags
519 state => "exc_pinned",
520 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
521 ins => [ "base", "index", "mem", "val" ],
522 emit => '. and%M %SB3, %AM',
526 modified_flags => $status_flags
531 state => "exc_pinned",
532 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
533 ins => [ "base", "index", "mem", "left", "right" ],
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" ], out => [ "in_r4 in_r5" ] },
570 ins => [ "base", "index", "mem", "left", "right" ],
572 emit => '. xor%M %binop',
576 modified_flags => $status_flags
581 state => "exc_pinned",
582 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
583 ins => [ "base", "index", "mem", "val" ],
584 emit => '. xor%M %SI3, %AM',
588 modified_flags => $status_flags
593 state => "exc_pinned",
594 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
595 ins => [ "base", "index", "mem", "val" ],
596 emit => '. xor%M %SB3, %AM',
600 modified_flags => $status_flags
603 # not commutative operations
607 state => "exc_pinned",
608 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4", "none", "flags" ] },
609 ins => [ "base", "index", "mem", "left", "right" ],
611 emit => '. sub%M %binop',
615 modified_flags => $status_flags
620 state => "exc_pinned",
621 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
622 ins => [ "base", "index", "mem", "val" ],
623 emit => '. sub%M %SI3, %AM',
627 modified_flags => $status_flags
632 state => "exc_pinned",
633 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
634 ins => [ "base", "index", "mem", "val" ],
635 emit => '. sub%M %SB3, %AM',
639 modified_flags => $status_flags
643 state => "exc_pinned",
644 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 !in_r5" ] },
645 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
647 emit => '. sbb%M %binop',
651 modified_flags => $status_flags
655 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
656 ins => [ "left", "right" ],
660 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
661 ins => [ "left", "right", "eflags" ],
666 state => "exc_pinned",
667 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "none", "none", "edx" ] },
668 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
669 outs => [ "div_res", "M", "unused", "mod_res" ],
670 am => "source,ternary",
671 emit => ". idiv%M %unop5",
674 modified_flags => $status_flags
679 state => "exc_pinned",
680 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "none", "none", "edx" ] },
681 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
682 outs => [ "div_res", "M", "unused", "mod_res" ],
683 am => "source,ternary",
684 emit => ". div%M %unop5",
687 modified_flags => $status_flags
692 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
693 ins => [ "left", "right" ],
694 emit => '. shl %SB1, %S0',
698 modified_flags => $status_flags
703 state => "exc_pinned",
704 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
705 ins => [ "base", "index", "mem", "count" ],
706 emit => '. shl%M %SB3, %AM',
710 modified_flags => $status_flags
714 cmp_attr => "return 1;",
715 ins => [ "left", "right", "dep" ],
716 # value, cnt, dependency
722 # see ShrD about the strange out constraint
723 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
724 ins => [ "left_high", "left_low", "right" ],
725 emit => ". shld%M %SB2, %S1, %S0\n".
730 modified_flags => $status_flags
734 cmp_attr => "return 1;",
735 ins => [ "high", "low", "count" ],
741 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
742 ins => [ "val", "count" ],
743 emit => '. shr %SB1, %S0',
747 modified_flags => $status_flags
752 state => "exc_pinned",
753 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
754 ins => [ "base", "index", "mem", "count" ],
755 emit => '. shr%M %SB3, %AM',
759 modified_flags => $status_flags
763 cmp_attr => "return 1;",
764 ins => [ "left", "right", "dep" ],
765 # value, cnt, dependency
770 # What's going on with the out constraint here? We would like to write
771 # "in_r2" and be done. However in firm we only support should_be_same
772 # constraints at the moment. Which means they could be non-fullfilled in
773 # some cases. Now when all values happen to live through the node, out
774 # is ecx and in_r2 not ecx, then we're screwed. Because in this case we
775 # need a 4th Register.
777 # The best solution for this is extending the register allocator to support
778 # must_be_same constraints which create a copy when the in_r2 value
779 # lives through (this ensures that we have the 4th register in the cases
780 # when we need it and can always fix the situation).
782 # For now I'm doing this ultra ugly !in hack which allocates 4 registers
783 # and creates an extra mov
785 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
786 ins => [ "left_high", "left_low", "right" ],
787 emit => ". shrd%M %SB2, %S1, %S0\n".
792 modified_flags => $status_flags
796 cmp_attr => "return 1;",
798 ins => [ "high", "low", "count" ],
803 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
804 ins => [ "val", "count" ],
805 emit => '. sar %SB1, %S0',
809 modified_flags => $status_flags
814 state => "exc_pinned",
815 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
816 ins => [ "base", "index", "mem", "count" ],
817 emit => '. sar%M %SB3, %AM',
821 modified_flags => $status_flags
825 cmp_attr => "return 1;",
826 ins => [ "left", "right", "dep" ],
827 # value, cnt, dependency
833 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
834 ins => [ "val", "count" ],
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" ], out => [ "in_r1 !in_r2" ] },
857 ins => [ "val", "count" ],
858 emit => '. rol %SB1, %S0',
862 modified_flags => $status_flags
867 state => "exc_pinned",
868 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
869 ins => [ "base", "index", "mem", "count" ],
870 emit => '. rol%M %SB3, %AM',
874 modified_flags => $status_flags
881 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
887 modified_flags => $status_flags
892 state => "exc_pinned",
893 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
894 ins => [ "base", "index", "mem" ],
895 emit => '. neg%M %AM',
899 modified_flags => $status_flags
904 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
905 outs => [ "low_res", "high_res" ],
908 modified_flags => $status_flags
914 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
919 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
924 state => "exc_pinned",
925 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
926 ins => [ "base", "index", "mem" ],
927 emit => '. inc%M %AM',
931 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
936 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
941 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
946 state => "exc_pinned",
947 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
948 ins => [ "base", "index", "mem" ],
949 emit => '. dec%M %AM',
953 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
958 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
968 state => "exc_pinned",
969 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
970 ins => [ "base", "index", "mem" ],
971 emit => '. not%M %AM',
981 state => "exc_pinned",
982 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
983 ins => [ "base", "index", "mem", "left", "right" ],
984 outs => [ "eflags" ],
985 am => "source,binary",
986 emit => '. cmp%M %binop',
987 attr => "int ins_permuted, int cmp_unsigned",
988 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
989 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
993 modified_flags => $status_flags
998 state => "exc_pinned",
999 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1000 ins => [ "base", "index", "mem", "left", "right" ],
1001 outs => [ "eflags" ],
1002 am => "source,binary",
1003 emit => '. cmpb %binop',
1004 attr => "int ins_permuted, int cmp_unsigned",
1005 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1006 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1009 mode => $mode_flags,
1010 modified_flags => $status_flags
1015 state => "exc_pinned",
1016 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1017 ins => [ "base", "index", "mem", "left", "right" ],
1018 outs => [ "eflags" ],
1019 am => "source,binary",
1020 emit => '. test%M %binop',
1021 attr => "int ins_permuted, int cmp_unsigned",
1022 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1023 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1026 mode => $mode_flags,
1027 modified_flags => $status_flags
1032 state => "exc_pinned",
1033 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1034 ins => [ "base", "index", "mem", "left", "right" ],
1035 outs => [ "eflags" ],
1036 am => "source,binary",
1037 emit => '. testb %binop',
1038 attr => "int ins_permuted, int cmp_unsigned",
1039 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1040 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1043 mode => $mode_flags,
1044 modified_flags => $status_flags
1049 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1050 ins => [ "eflags" ],
1051 attr_type => "ia32_condcode_attr_t",
1052 attr => "pn_Cmp pnc, int ins_permuted",
1053 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1054 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1055 emit => '. set%CMP0 %DB0',
1063 state => "exc_pinned",
1064 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1065 ins => [ "base", "index", "mem","eflags" ],
1066 attr_type => "ia32_condcode_attr_t",
1067 attr => "pn_Cmp pnc, int ins_permuted",
1068 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1069 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1070 emit => '. set%CMP3 %AM',
1078 # (note: leave the false,true order intact to make it compatible with other
1080 state => "exc_pinned",
1081 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1082 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1083 am => "source,binary",
1084 attr_type => "ia32_condcode_attr_t",
1085 attr => "int ins_permuted, pn_Cmp pnc",
1086 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1094 op_flags => "L|X|Y",
1095 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1096 ins => [ "eflags" ],
1097 outs => [ "false", "true" ],
1098 attr_type => "ia32_condcode_attr_t",
1099 attr => "pn_Cmp pnc",
1101 units => [ "BRANCH" ],
1106 op_flags => "L|X|Y",
1107 reg_req => { in => [ "gp" ], out => [ "none" ] },
1109 attr_type => "ia32_condcode_attr_t",
1110 attr => "pn_Cmp pnc",
1112 units => [ "BRANCH" ],
1113 modified_flags => $status_flags,
1119 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1120 ins => [ "base", "index", "mem", "target" ],
1121 am => "source,unary",
1122 emit => '. jmp *%unop3',
1124 units => [ "BRANCH" ],
1131 reg_req => { out => [ "gp" ] },
1133 attr => "ir_entity *symconst, int symconst_sign, long offset",
1134 attr_type => "ia32_immediate_attr_t",
1143 reg_req => { out => [ "gp_UKNWN" ] },
1154 reg_req => { out => [ "vfp_UKNWN" ] },
1159 attr_type => "ia32_x87_attr_t",
1166 reg_req => { out => [ "xmm_UKNWN" ] },
1177 reg_req => { out => [ "gp_NOREG" ] },
1188 reg_req => { out => [ "vfp_NOREG" ] },
1193 attr_type => "ia32_x87_attr_t",
1200 reg_req => { out => [ "xmm_NOREG" ] },
1211 reg_req => { out => [ "fp_cw" ] },
1215 modified_flags => $fpcw_flags
1221 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1222 ins => [ "base", "index", "mem" ],
1224 emit => ". fldcw %AM",
1227 modified_flags => $fpcw_flags
1233 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1234 ins => [ "base", "index", "mem", "fpcw" ],
1236 emit => ". fnstcw %AM",
1244 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1252 # we should not rematrialize this node. It has very strict constraints.
1253 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1254 ins => [ "val", "globbered" ],
1263 # Note that we add additional latency values depending on address mode, so a
1264 # lateny of 0 for load is correct
1268 state => "exc_pinned",
1269 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1270 ins => [ "base", "index", "mem" ],
1271 outs => [ "res", "M" ],
1273 emit => ". mov%SE%ME%.l %AM, %D0",
1279 cmp_attr => "return 1;",
1280 outs => [ "res", "M" ],
1286 cmp_attr => "return 1;",
1287 state => "exc_pinned",
1294 state => "exc_pinned",
1295 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1296 ins => [ "base", "index", "mem", "val" ],
1297 emit => '. mov%M %SI3, %AM',
1305 state => "exc_pinned",
1306 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1307 ins => [ "base", "index", "mem", "val" ],
1308 emit => '. mov%M %SB3, %AM',
1316 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1317 ins => [ "base", "index" ],
1318 emit => '. leal %AM, %D0',
1322 # lea doesn't modify the flags, but setting this seems advantageous since it
1323 # increases chances that the Lea is transformed back to an Add
1324 modified_flags => 1,
1328 state => "exc_pinned",
1329 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp", "none" ] },
1330 ins => [ "base", "index", "mem", "val", "stack" ],
1331 emit => '. push%M %unop4',
1332 outs => [ "stack:I|S", "M" ],
1333 am => "source,binary",
1339 state => "exc_pinned",
1340 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1341 emit => '. pop%M %DAM0',
1342 outs => [ "res", "M", "unused", "stack:I|S" ],
1343 ins => [ "base", "index", "mem", "stack" ],
1345 latency => 3, # Pop is more expensive than Push on Athlon
1350 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1352 outs => [ "frame:I", "stack:I|S", "M" ],
1358 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1360 outs => [ "frame:I", "stack:I|S" ],
1368 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1369 ins => [ "base", "index", "mem", "stack", "size" ],
1370 am => "source,binary",
1371 emit => '. addl %binop',
1373 outs => [ "stack:S", "M" ],
1375 modified_flags => $status_flags
1381 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1382 ins => [ "base", "index", "mem", "stack", "size" ],
1383 am => "source,binary",
1384 emit => ". subl %binop\n".
1385 ". movl %%esp, %D1",
1387 outs => [ "stack:I|S", "addr", "M" ],
1389 modified_flags => $status_flags
1394 reg_req => { out => [ "gp" ] },
1400 #-----------------------------------------------------------------------------#
1401 # _____ _____ ______ __ _ _ _ #
1402 # / ____/ ____| ____| / _| | | | | | #
1403 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1404 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1405 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1406 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1407 #-----------------------------------------------------------------------------#
1411 reg_req => { out => [ "xmm" ] },
1412 emit => '. xorp%XSD %D0, %D0',
1418 # commutative operations
1422 state => "exc_pinned",
1423 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1424 ins => [ "base", "index", "mem", "left", "right" ],
1425 am => "source,binary",
1426 emit => '. add%XXM %binop',
1434 state => "exc_pinned",
1435 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1436 ins => [ "base", "index", "mem", "left", "right" ],
1437 am => "source,binary",
1438 emit => '. mul%XXM %binop',
1446 state => "exc_pinned",
1447 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1448 ins => [ "base", "index", "mem", "left", "right" ],
1449 am => "source,binary",
1450 emit => '. max%XXM %binop',
1458 state => "exc_pinned",
1459 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1460 ins => [ "base", "index", "mem", "left", "right" ],
1461 am => "source,binary",
1462 emit => '. min%XXM %binop',
1470 state => "exc_pinned",
1471 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1472 ins => [ "base", "index", "mem", "left", "right" ],
1473 am => "source,binary",
1474 emit => '. andp%XSD %binop',
1482 state => "exc_pinned",
1483 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1484 ins => [ "base", "index", "mem", "left", "right" ],
1485 am => "source,binary",
1486 emit => '. orp%XSD %binop',
1494 state => "exc_pinned",
1495 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1496 ins => [ "base", "index", "mem", "left", "right" ],
1497 am => "source,binary",
1498 emit => '. xorp%XSD %binop',
1504 # not commutative operations
1508 state => "exc_pinned",
1509 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1510 ins => [ "base", "index", "mem", "left", "right" ],
1511 am => "source,binary",
1512 emit => '. andnp%XSD %binop',
1520 state => "exc_pinned",
1521 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1522 ins => [ "base", "index", "mem", "left", "right" ],
1523 am => "source,binary",
1524 emit => '. sub%XXM %binop',
1532 state => "exc_pinned",
1533 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1534 ins => [ "base", "index", "mem", "left", "right" ],
1535 am => "source,binary",
1536 outs => [ "res", "M" ],
1537 emit => '. div%XXM %binop',
1546 state => "exc_pinned",
1547 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1548 ins => [ "base", "index", "mem", "left", "right" ],
1549 outs => [ "flags" ],
1550 am => "source,binary",
1551 attr => "int ins_permuted",
1552 init_attr => "attr->data.ins_permuted = ins_permuted;",
1553 emit => ' .ucomi%XXM %binop',
1556 mode => $mode_flags,
1557 modified_flags => 1,
1564 state => "exc_pinned",
1565 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1566 ins => [ "base", "index", "mem" ],
1567 emit => '. mov%XXM %AM, %D0',
1568 attr => "ir_mode *load_mode",
1569 init_attr => "attr->ls_mode = load_mode;",
1570 outs => [ "res", "M" ],
1577 state => "exc_pinned",
1578 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1579 ins => [ "base", "index", "mem", "val" ],
1580 emit => '. mov%XXM %S3, %AM',
1588 state => "exc_pinned",
1589 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1590 ins => [ "base", "index", "mem", "val" ],
1591 emit => '. mov%XXM %S3, %AM',
1599 state => "exc_pinned",
1600 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1601 ins => [ "base", "index", "mem", "val" ],
1602 am => "source,unary",
1603 emit => '. cvtsi2ss %unop3, %D0',
1611 state => "exc_pinned",
1612 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1613 ins => [ "base", "index", "mem", "val" ],
1614 am => "source,unary",
1615 emit => '. cvtsi2sd %unop3, %D0',
1624 cmp_attr => "return 1;",
1630 cmp_attr => "return 1;",
1639 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1640 outs => [ "DST", "SRC", "CNT", "M" ],
1641 attr_type => "ia32_copyb_attr_t",
1642 attr => "unsigned size",
1645 # we don't care about this flag, so no need to mark this node
1646 # modified_flags => [ "DF" ]
1652 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1653 outs => [ "DST", "SRC", "M" ],
1654 attr_type => "ia32_copyb_attr_t",
1655 attr => "unsigned size",
1658 # we don't care about this flag, so no need to mark this node
1659 # modified_flags => [ "DF" ]
1665 state => "exc_pinned",
1666 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1667 ins => [ "base", "index", "mem", "val" ],
1668 am => "source,unary",
1671 attr => "ir_mode *smaller_mode",
1672 init_attr => "attr->ls_mode = smaller_mode;",
1677 state => "exc_pinned",
1678 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1679 ins => [ "base", "index", "mem", "val" ],
1680 am => "source,unary",
1683 attr => "ir_mode *smaller_mode",
1684 init_attr => "attr->ls_mode = smaller_mode;",
1689 state => "exc_pinned",
1690 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1691 ins => [ "base", "index", "mem", "val" ],
1692 am => "source,unary",
1699 state => "exc_pinned",
1700 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1701 ins => [ "base", "index", "mem", "val" ],
1702 am => "source,unary",
1709 state => "exc_pinned",
1710 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1711 ins => [ "base", "index", "mem", "val" ],
1712 am => "source,unary",
1718 #----------------------------------------------------------#
1720 # (_) | | | | / _| | | | #
1721 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1722 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1723 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1724 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1726 # _ __ ___ __| | ___ ___ #
1727 # | '_ \ / _ \ / _` |/ _ \/ __| #
1728 # | | | | (_) | (_| | __/\__ \ #
1729 # |_| |_|\___/ \__,_|\___||___/ #
1730 #----------------------------------------------------------#
1732 # rematerialisation disabled for all float nodes for now, because the fpcw
1733 # handler runs before spilling and we might end up with wrong fpcw then
1737 state => "exc_pinned",
1738 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1739 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1740 am => "source,binary",
1744 attr_type => "ia32_x87_attr_t",
1749 state => "exc_pinned",
1750 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1751 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1752 am => "source,binary",
1756 attr_type => "ia32_x87_attr_t",
1761 state => "exc_pinned",
1762 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1763 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1764 am => "source,binary",
1768 attr_type => "ia32_x87_attr_t",
1772 state => "exc_pinned",
1773 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1774 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1775 am => "source,binary",
1776 outs => [ "res", "M" ],
1779 attr_type => "ia32_x87_attr_t",
1783 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1784 ins => [ "left", "right", "fpcw" ],
1788 attr_type => "ia32_x87_attr_t",
1793 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1798 attr_type => "ia32_x87_attr_t",
1803 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1808 attr_type => "ia32_x87_attr_t",
1811 # virtual Load and Store
1816 state => "exc_pinned",
1817 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1818 ins => [ "base", "index", "mem" ],
1819 outs => [ "res", "M" ],
1820 attr => "ir_mode *load_mode",
1821 init_attr => "attr->attr.ls_mode = load_mode;",
1824 attr_type => "ia32_x87_attr_t",
1830 state => "exc_pinned",
1831 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1832 ins => [ "base", "index", "mem", "val" ],
1833 attr => "ir_mode *store_mode",
1834 init_attr => "attr->attr.ls_mode = store_mode;",
1838 attr_type => "ia32_x87_attr_t",
1844 state => "exc_pinned",
1845 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1846 outs => [ "res", "M" ],
1847 ins => [ "base", "index", "mem" ],
1850 attr_type => "ia32_x87_attr_t",
1854 cmp_attr => "return 1;",
1855 outs => [ "res", "M" ],
1860 state => "exc_pinned",
1861 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1862 ins => [ "base", "index", "mem", "val", "fpcw" ],
1866 attr_type => "ia32_x87_attr_t",
1870 cmp_attr => "return 1;",
1871 state => "exc_pinned",
1881 reg_req => { out => [ "vfp" ] },
1885 attr_type => "ia32_x87_attr_t",
1890 reg_req => { out => [ "vfp" ] },
1894 attr_type => "ia32_x87_attr_t",
1899 reg_req => { out => [ "vfp" ] },
1903 attr_type => "ia32_x87_attr_t",
1908 reg_req => { out => [ "vfp" ] },
1912 attr_type => "ia32_x87_attr_t",
1917 reg_req => { out => [ "vfp" ] },
1921 attr_type => "ia32_x87_attr_t",
1926 reg_req => { out => [ "vfp" ] },
1930 attr_type => "ia32_x87_attr_t",
1935 reg_req => { out => [ "vfp" ] },
1939 attr_type => "ia32_x87_attr_t",
1945 # we can't allow to rematerialize this node so we don't have
1946 # accidently produce Phi(Fucom, Fucom(ins_permuted))
1948 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1949 ins => [ "left", "right" ],
1950 outs => [ "flags" ],
1951 attr => "int ins_permuted",
1952 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1955 attr_type => "ia32_x87_attr_t",
1961 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
1962 ins => [ "left", "right" ],
1963 outs => [ "flags" ],
1964 attr => "int ins_permuted",
1965 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1968 attr_type => "ia32_x87_attr_t",
1974 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
1976 outs => [ "flags" ],
1977 attr => "int ins_permuted",
1978 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1981 attr_type => "ia32_x87_attr_t",
1987 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
1989 outs => [ "flags" ],
1993 mode => $mode_flags,
1996 #------------------------------------------------------------------------#
1997 # ___ _____ __ _ _ _ #
1998 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1999 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2000 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2001 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2002 #------------------------------------------------------------------------#
2004 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2005 # are swapped, we work this around in the emitter...
2008 state => "exc_pinned",
2009 rd_constructor => "NONE",
2011 emit => '. fadd%XM %x87_binop',
2013 attr_type => "ia32_x87_attr_t",
2017 state => "exc_pinned",
2018 rd_constructor => "NONE",
2020 emit => '. faddp%XM %x87_binop',
2022 attr_type => "ia32_x87_attr_t",
2026 state => "exc_pinned",
2027 rd_constructor => "NONE",
2029 emit => '. fmul%XM %x87_binop',
2031 attr_type => "ia32_x87_attr_t",
2035 state => "exc_pinned",
2036 rd_constructor => "NONE",
2038 emit => '. fmulp%XM %x87_binop',,
2040 attr_type => "ia32_x87_attr_t",
2044 state => "exc_pinned",
2045 rd_constructor => "NONE",
2047 emit => '. fsub%XM %x87_binop',
2049 attr_type => "ia32_x87_attr_t",
2053 state => "exc_pinned",
2054 rd_constructor => "NONE",
2056 # see note about gas bugs
2057 emit => '. fsubrp%XM %x87_binop',
2059 attr_type => "ia32_x87_attr_t",
2063 state => "exc_pinned",
2064 rd_constructor => "NONE",
2067 emit => '. fsubr%XM %x87_binop',
2069 attr_type => "ia32_x87_attr_t",
2073 state => "exc_pinned",
2074 rd_constructor => "NONE",
2077 # see note about gas bugs
2078 emit => '. fsubp%XM %x87_binop',
2080 attr_type => "ia32_x87_attr_t",
2084 rd_constructor => "NONE",
2088 attr_type => "ia32_x87_attr_t",
2091 # this node is just here, to keep the simulator running
2092 # we can omit this when a fprem simulation function exists
2094 rd_constructor => "NONE",
2096 emit => '. fprem1\n'.
2099 attr_type => "ia32_x87_attr_t",
2103 state => "exc_pinned",
2104 rd_constructor => "NONE",
2106 emit => '. fdiv%XM %x87_binop',
2108 attr_type => "ia32_x87_attr_t",
2112 state => "exc_pinned",
2113 rd_constructor => "NONE",
2115 # see note about gas bugs
2116 emit => '. fdivrp%XM %x87_binop',
2118 attr_type => "ia32_x87_attr_t",
2122 state => "exc_pinned",
2123 rd_constructor => "NONE",
2125 emit => '. fdivr%XM %x87_binop',
2127 attr_type => "ia32_x87_attr_t",
2131 state => "exc_pinned",
2132 rd_constructor => "NONE",
2134 # see note about gas bugs
2135 emit => '. fdivp%XM %x87_binop',
2137 attr_type => "ia32_x87_attr_t",
2141 rd_constructor => "NONE",
2145 attr_type => "ia32_x87_attr_t",
2150 rd_constructor => "NONE",
2154 attr_type => "ia32_x87_attr_t",
2157 # x87 Load and Store
2160 rd_constructor => "NONE",
2161 op_flags => "R|L|F",
2162 state => "exc_pinned",
2164 emit => '. fld%XM %AM',
2165 attr_type => "ia32_x87_attr_t",
2170 rd_constructor => "NONE",
2171 op_flags => "R|L|F",
2172 state => "exc_pinned",
2174 emit => '. fst%XM %AM',
2176 attr_type => "ia32_x87_attr_t",
2181 rd_constructor => "NONE",
2182 op_flags => "R|L|F",
2183 state => "exc_pinned",
2185 emit => '. fstp%XM %AM',
2187 attr_type => "ia32_x87_attr_t",
2194 state => "exc_pinned",
2195 rd_constructor => "NONE",
2197 emit => '. fild%M %AM',
2198 attr_type => "ia32_x87_attr_t",
2203 state => "exc_pinned",
2204 rd_constructor => "NONE",
2206 emit => '. fist%M %AM',
2208 attr_type => "ia32_x87_attr_t",
2213 state => "exc_pinned",
2214 rd_constructor => "NONE",
2216 emit => '. fistp%M %AM',
2218 attr_type => "ia32_x87_attr_t",
2225 op_flags => "R|c|K",
2227 reg_req => { out => [ "vfp" ] },
2229 attr_type => "ia32_x87_attr_t",
2234 op_flags => "R|c|K",
2236 reg_req => { out => [ "vfp" ] },
2238 attr_type => "ia32_x87_attr_t",
2243 op_flags => "R|c|K",
2245 reg_req => { out => [ "vfp" ] },
2247 attr_type => "ia32_x87_attr_t",
2252 op_flags => "R|c|K",
2254 reg_req => { out => [ "vfp" ] },
2256 attr_type => "ia32_x87_attr_t",
2261 op_flags => "R|c|K",
2263 reg_req => { out => [ "vfp" ] },
2265 attr_type => "ia32_x87_attr_t",
2270 op_flags => "R|c|K",
2272 reg_req => { out => [ "vfp" ] },
2273 emit => '. fldll2t',
2274 attr_type => "ia32_x87_attr_t",
2279 op_flags => "R|c|K",
2281 reg_req => { out => [ "vfp" ] },
2283 attr_type => "ia32_x87_attr_t",
2288 # Note that it is NEVER allowed to do CSE on these nodes
2289 # Moreover, note the virtual register requierements!
2294 cmp_attr => "return 1;",
2295 emit => '. fxch %X0',
2296 attr_type => "ia32_x87_attr_t",
2304 cmp_attr => "return 1;",
2305 emit => '. fld %X0',
2306 attr_type => "ia32_x87_attr_t",
2312 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2313 cmp_attr => "return 1;",
2314 emit => '. fld %X0',
2315 attr_type => "ia32_x87_attr_t",
2322 cmp_attr => "return 1;",
2323 emit => '. fstp %X0',
2324 attr_type => "ia32_x87_attr_t",
2332 cmp_attr => "return 1;",
2333 emit => '. ffreep %X0',
2334 attr_type => "ia32_x87_attr_t",
2342 cmp_attr => "return 1;",
2344 attr_type => "ia32_x87_attr_t",
2352 cmp_attr => "return 1;",
2354 attr_type => "ia32_x87_attr_t",
2363 emit => ". fucom %X1\n".
2365 attr_type => "ia32_x87_attr_t",
2371 emit => ". fucomp %X1\n".
2373 attr_type => "ia32_x87_attr_t",
2379 emit => ". fucompp\n".
2381 attr_type => "ia32_x87_attr_t",
2387 emit => '. fucomi %X1',
2388 attr_type => "ia32_x87_attr_t",
2394 emit => '. fucompi %X1',
2395 attr_type => "ia32_x87_attr_t",
2403 attr_type => "ia32_x87_attr_t",
2408 # -------------------------------------------------------------------------------- #
2409 # ____ ____ _____ _ _ #
2410 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2411 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2412 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2413 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2415 # -------------------------------------------------------------------------------- #
2418 # Spilling and reloading of SSE registers, hardcoded, not generated #
2422 state => "exc_pinned",
2423 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2424 emit => '. movdqu %D0, %AM',
2425 outs => [ "res", "M" ],
2432 state => "exc_pinned",
2433 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2434 ins => [ "base", "index", "mem", "val" ],
2435 emit => '. movdqu %binop',
2443 # Include the generated SIMD node specification written by the SIMD optimization
2444 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2445 unless ($return = do $my_script_name) {
2446 warn "couldn't parse $my_script_name: $@" if $@;
2447 warn "couldn't do $my_script_name: $!" unless defined $return;
2448 warn "couldn't run $my_script_name" unless $return;
2451 # Transform some attributes
2452 foreach my $op (keys(%nodes)) {
2453 my $node = $nodes{$op};
2454 my $op_attr_init = $node->{op_attr_init};
2456 if(defined($op_attr_init)) {
2457 $op_attr_init .= "\n\t";
2462 if(!defined($node->{latency})) {
2464 $node->{latency} = 0;
2466 die("Latency missing for op $op");
2469 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2471 $node->{op_attr_init} = $op_attr_init;