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 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r2 !in_r3" ] },
723 ins => [ "left_high", "left_low", "right" ],
724 emit => ". shld%M %SB2, %S1, %D0",
728 modified_flags => $status_flags
732 cmp_attr => "return 1;",
733 ins => [ "high", "low", "count" ],
739 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
740 ins => [ "val", "count" ],
741 emit => '. shr %SB1, %S0',
745 modified_flags => $status_flags
750 state => "exc_pinned",
751 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
752 ins => [ "base", "index", "mem", "count" ],
753 emit => '. shr%M %SB3, %AM',
757 modified_flags => $status_flags
761 cmp_attr => "return 1;",
762 ins => [ "left", "right", "dep" ],
763 # value, cnt, dependency
769 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r2 !in_r3" ] },
770 ins => [ "left_high", "left_low", "right" ],
771 emit => ". shrd%M %SB2, %S1, %D0",
775 modified_flags => $status_flags
779 cmp_attr => "return 1;",
781 ins => [ "high", "low", "count" ],
786 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
787 ins => [ "val", "count" ],
788 emit => '. sar %SB1, %S0',
792 modified_flags => $status_flags
797 state => "exc_pinned",
798 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
799 ins => [ "base", "index", "mem", "count" ],
800 emit => '. sar%M %SB3, %AM',
804 modified_flags => $status_flags
808 cmp_attr => "return 1;",
809 ins => [ "left", "right", "dep" ],
810 # value, cnt, dependency
816 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
817 ins => [ "val", "count" ],
818 emit => '. ror %SB1, %S0',
822 modified_flags => $status_flags
827 state => "exc_pinned",
828 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
829 ins => [ "base", "index", "mem", "count" ],
830 emit => '. ror%M %SB3, %AM',
834 modified_flags => $status_flags
839 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
840 ins => [ "val", "count" ],
841 emit => '. rol %SB1, %S0',
845 modified_flags => $status_flags
850 state => "exc_pinned",
851 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
852 ins => [ "base", "index", "mem", "count" ],
853 emit => '. rol%M %SB3, %AM',
857 modified_flags => $status_flags
864 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
870 modified_flags => $status_flags
875 state => "exc_pinned",
876 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
877 ins => [ "base", "index", "mem" ],
878 emit => '. neg%M %AM',
882 modified_flags => $status_flags
887 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
888 outs => [ "low_res", "high_res" ],
891 modified_flags => $status_flags
897 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
902 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
907 state => "exc_pinned",
908 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
909 ins => [ "base", "index", "mem" ],
910 emit => '. inc%M %AM',
914 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
919 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
924 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
929 state => "exc_pinned",
930 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
931 ins => [ "base", "index", "mem" ],
932 emit => '. dec%M %AM',
936 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
941 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
951 state => "exc_pinned",
952 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
953 ins => [ "base", "index", "mem" ],
954 emit => '. not%M %AM',
964 state => "exc_pinned",
965 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
966 ins => [ "base", "index", "mem", "left", "right" ],
967 outs => [ "eflags" ],
968 am => "source,binary",
969 emit => '. cmp%M %binop',
970 attr => "int ins_permuted, int cmp_unsigned",
971 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
972 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
976 modified_flags => $status_flags
981 state => "exc_pinned",
982 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
983 ins => [ "base", "index", "mem", "left", "right" ],
984 outs => [ "eflags" ],
985 am => "source,binary",
986 emit => '. cmpb %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", "gp", "gp" ] , out => [ "flags" ] },
1000 ins => [ "base", "index", "mem", "left", "right" ],
1001 outs => [ "eflags" ],
1002 am => "source,binary",
1003 emit => '. test%M %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", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1017 ins => [ "base", "index", "mem", "left", "right" ],
1018 outs => [ "eflags" ],
1019 am => "source,binary",
1020 emit => '. testb %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 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1033 ins => [ "eflags" ],
1034 attr_type => "ia32_condcode_attr_t",
1035 attr => "pn_Cmp pnc, int ins_permuted",
1036 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1037 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1038 emit => '. set%CMP0 %DB0',
1046 state => "exc_pinned",
1047 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1048 ins => [ "base", "index", "mem","eflags" ],
1049 attr_type => "ia32_condcode_attr_t",
1050 attr => "pn_Cmp pnc, int ins_permuted",
1051 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1052 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1053 emit => '. set%CMP3 %AM',
1061 # (note: leave the false,true order intact to make it compatible with other
1063 state => "exc_pinned",
1064 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1065 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1066 am => "source,binary",
1067 attr_type => "ia32_condcode_attr_t",
1068 attr => "int ins_permuted, pn_Cmp pnc",
1069 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1077 op_flags => "L|X|Y",
1078 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1079 ins => [ "eflags" ],
1080 outs => [ "false", "true" ],
1081 attr_type => "ia32_condcode_attr_t",
1082 attr => "pn_Cmp pnc",
1084 units => [ "BRANCH" ],
1089 op_flags => "L|X|Y",
1090 reg_req => { in => [ "gp" ], out => [ "none" ] },
1092 attr_type => "ia32_condcode_attr_t",
1093 attr => "pn_Cmp pnc",
1095 units => [ "BRANCH" ],
1096 modified_flags => $status_flags,
1102 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1103 ins => [ "base", "index", "mem", "target" ],
1104 am => "source,unary",
1105 emit => '. jmp *%unop3',
1107 units => [ "BRANCH" ],
1114 reg_req => { out => [ "gp" ] },
1116 attr => "ir_entity *symconst, int symconst_sign, long offset",
1117 attr_type => "ia32_immediate_attr_t",
1126 reg_req => { out => [ "gp_UKNWN" ] },
1137 reg_req => { out => [ "vfp_UKNWN" ] },
1142 attr_type => "ia32_x87_attr_t",
1149 reg_req => { out => [ "xmm_UKNWN" ] },
1160 reg_req => { out => [ "gp_NOREG" ] },
1171 reg_req => { out => [ "vfp_NOREG" ] },
1176 attr_type => "ia32_x87_attr_t",
1183 reg_req => { out => [ "xmm_NOREG" ] },
1194 reg_req => { out => [ "fp_cw" ] },
1198 modified_flags => $fpcw_flags
1204 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1205 ins => [ "base", "index", "mem" ],
1207 emit => ". fldcw %AM",
1210 modified_flags => $fpcw_flags
1216 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1217 ins => [ "base", "index", "mem", "fpcw" ],
1219 emit => ". fnstcw %AM",
1227 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1235 # we should not rematrialize this node. It has very strict constraints.
1236 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1237 ins => [ "val", "globbered" ],
1246 # Note that we add additional latency values depending on address mode, so a
1247 # lateny of 0 for load is correct
1251 state => "exc_pinned",
1252 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1253 ins => [ "base", "index", "mem" ],
1254 outs => [ "res", "M" ],
1256 emit => ". mov%SE%ME%.l %AM, %D0",
1262 cmp_attr => "return 1;",
1263 outs => [ "res", "M" ],
1269 cmp_attr => "return 1;",
1270 state => "exc_pinned",
1277 state => "exc_pinned",
1278 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1279 ins => [ "base", "index", "mem", "val" ],
1280 emit => '. mov%M %SI3, %AM',
1288 state => "exc_pinned",
1289 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1290 ins => [ "base", "index", "mem", "val" ],
1291 emit => '. mov%M %SB3, %AM',
1299 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1300 ins => [ "base", "index" ],
1301 emit => '. leal %AM, %D0',
1305 # lea doesn't modify the flags, but setting this seems advantageous since it
1306 # increases chances that the Lea is transformed back to an Add
1307 modified_flags => 1,
1311 state => "exc_pinned",
1312 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp", "none" ] },
1313 ins => [ "base", "index", "mem", "val", "stack" ],
1314 emit => '. push%M %unop4',
1315 outs => [ "stack:I|S", "M" ],
1316 am => "source,binary",
1322 state => "exc_pinned",
1323 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1324 emit => '. pop%M %DAM0',
1325 outs => [ "res", "M", "unused", "stack:I|S" ],
1326 ins => [ "base", "index", "mem", "stack" ],
1328 latency => 3, # Pop is more expensive than Push on Athlon
1333 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1335 outs => [ "frame:I", "stack:I|S", "M" ],
1341 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1343 outs => [ "frame:I", "stack:I|S" ],
1351 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1352 ins => [ "base", "index", "mem", "stack", "size" ],
1353 am => "source,binary",
1354 emit => '. addl %binop',
1356 outs => [ "stack:S", "M" ],
1358 modified_flags => $status_flags
1364 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1365 ins => [ "base", "index", "mem", "stack", "size" ],
1366 am => "source,binary",
1367 emit => ". subl %binop\n".
1368 ". movl %%esp, %D1",
1370 outs => [ "stack:I|S", "addr", "M" ],
1372 modified_flags => $status_flags
1377 reg_req => { out => [ "gp" ] },
1383 #-----------------------------------------------------------------------------#
1384 # _____ _____ ______ __ _ _ _ #
1385 # / ____/ ____| ____| / _| | | | | | #
1386 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1387 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1388 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1389 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1390 #-----------------------------------------------------------------------------#
1394 reg_req => { out => [ "xmm" ] },
1395 emit => '. xorp%XSD %D0, %D0',
1401 # commutative operations
1405 state => "exc_pinned",
1406 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1407 ins => [ "base", "index", "mem", "left", "right" ],
1408 am => "source,binary",
1409 emit => '. add%XXM %binop',
1417 state => "exc_pinned",
1418 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1419 ins => [ "base", "index", "mem", "left", "right" ],
1420 am => "source,binary",
1421 emit => '. mul%XXM %binop',
1429 state => "exc_pinned",
1430 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1431 ins => [ "base", "index", "mem", "left", "right" ],
1432 am => "source,binary",
1433 emit => '. max%XXM %binop',
1441 state => "exc_pinned",
1442 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1443 ins => [ "base", "index", "mem", "left", "right" ],
1444 am => "source,binary",
1445 emit => '. min%XXM %binop',
1453 state => "exc_pinned",
1454 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1455 ins => [ "base", "index", "mem", "left", "right" ],
1456 am => "source,binary",
1457 emit => '. andp%XSD %binop',
1465 state => "exc_pinned",
1466 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1467 ins => [ "base", "index", "mem", "left", "right" ],
1468 am => "source,binary",
1469 emit => '. orp%XSD %binop',
1477 state => "exc_pinned",
1478 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1479 ins => [ "base", "index", "mem", "left", "right" ],
1480 am => "source,binary",
1481 emit => '. xorp%XSD %binop',
1487 # not commutative operations
1491 state => "exc_pinned",
1492 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1493 ins => [ "base", "index", "mem", "left", "right" ],
1494 am => "source,binary",
1495 emit => '. andnp%XSD %binop',
1503 state => "exc_pinned",
1504 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1505 ins => [ "base", "index", "mem", "left", "right" ],
1506 am => "source,binary",
1507 emit => '. sub%XXM %binop',
1515 state => "exc_pinned",
1516 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1517 ins => [ "base", "index", "mem", "left", "right" ],
1518 am => "source,binary",
1519 outs => [ "res", "M" ],
1520 emit => '. div%XXM %binop',
1529 state => "exc_pinned",
1530 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1531 ins => [ "base", "index", "mem", "left", "right" ],
1532 outs => [ "flags" ],
1533 am => "source,binary",
1534 attr => "int ins_permuted",
1535 init_attr => "attr->data.ins_permuted = ins_permuted;",
1536 emit => ' .ucomi%XXM %binop',
1539 mode => $mode_flags,
1540 modified_flags => 1,
1547 state => "exc_pinned",
1548 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1549 ins => [ "base", "index", "mem" ],
1550 emit => '. mov%XXM %AM, %D0',
1551 attr => "ir_mode *load_mode",
1552 init_attr => "attr->ls_mode = load_mode;",
1553 outs => [ "res", "M" ],
1560 state => "exc_pinned",
1561 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1562 ins => [ "base", "index", "mem", "val" ],
1563 emit => '. mov%XXM %S3, %AM',
1571 state => "exc_pinned",
1572 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1573 ins => [ "base", "index", "mem", "val" ],
1574 emit => '. mov%XXM %S3, %AM',
1582 state => "exc_pinned",
1583 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1584 ins => [ "base", "index", "mem", "val" ],
1585 am => "source,unary",
1586 emit => '. cvtsi2ss %unop3, %D0',
1594 state => "exc_pinned",
1595 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1596 ins => [ "base", "index", "mem", "val" ],
1597 am => "source,unary",
1598 emit => '. cvtsi2sd %unop3, %D0',
1607 cmp_attr => "return 1;",
1613 cmp_attr => "return 1;",
1622 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1623 outs => [ "DST", "SRC", "CNT", "M" ],
1624 attr_type => "ia32_copyb_attr_t",
1625 attr => "unsigned size",
1628 # we don't care about this flag, so no need to mark this node
1629 # modified_flags => [ "DF" ]
1635 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1636 outs => [ "DST", "SRC", "M" ],
1637 attr_type => "ia32_copyb_attr_t",
1638 attr => "unsigned size",
1641 # we don't care about this flag, so no need to mark this node
1642 # modified_flags => [ "DF" ]
1648 state => "exc_pinned",
1649 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1650 ins => [ "base", "index", "mem", "val" ],
1651 am => "source,unary",
1654 attr => "ir_mode *smaller_mode",
1655 init_attr => "attr->ls_mode = smaller_mode;",
1660 state => "exc_pinned",
1661 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1662 ins => [ "base", "index", "mem", "val" ],
1663 am => "source,unary",
1666 attr => "ir_mode *smaller_mode",
1667 init_attr => "attr->ls_mode = smaller_mode;",
1672 state => "exc_pinned",
1673 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1674 ins => [ "base", "index", "mem", "val" ],
1675 am => "source,unary",
1682 state => "exc_pinned",
1683 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1684 ins => [ "base", "index", "mem", "val" ],
1685 am => "source,unary",
1692 state => "exc_pinned",
1693 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1694 ins => [ "base", "index", "mem", "val" ],
1695 am => "source,unary",
1701 #----------------------------------------------------------#
1703 # (_) | | | | / _| | | | #
1704 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1705 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1706 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1707 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1709 # _ __ ___ __| | ___ ___ #
1710 # | '_ \ / _ \ / _` |/ _ \/ __| #
1711 # | | | | (_) | (_| | __/\__ \ #
1712 # |_| |_|\___/ \__,_|\___||___/ #
1713 #----------------------------------------------------------#
1715 # rematerialisation disabled for all float nodes for now, because the fpcw
1716 # handler runs before spilling and we might end up with wrong fpcw then
1720 state => "exc_pinned",
1721 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1722 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1723 am => "source,binary",
1727 attr_type => "ia32_x87_attr_t",
1732 state => "exc_pinned",
1733 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1734 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1735 am => "source,binary",
1739 attr_type => "ia32_x87_attr_t",
1744 state => "exc_pinned",
1745 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1746 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1747 am => "source,binary",
1751 attr_type => "ia32_x87_attr_t",
1755 state => "exc_pinned",
1756 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1757 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1758 am => "source,binary",
1759 outs => [ "res", "M" ],
1762 attr_type => "ia32_x87_attr_t",
1766 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1767 ins => [ "left", "right", "fpcw" ],
1771 attr_type => "ia32_x87_attr_t",
1776 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1781 attr_type => "ia32_x87_attr_t",
1786 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1791 attr_type => "ia32_x87_attr_t",
1794 # virtual Load and Store
1799 state => "exc_pinned",
1800 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1801 ins => [ "base", "index", "mem" ],
1802 outs => [ "res", "M" ],
1803 attr => "ir_mode *load_mode",
1804 init_attr => "attr->attr.ls_mode = load_mode;",
1807 attr_type => "ia32_x87_attr_t",
1813 state => "exc_pinned",
1814 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1815 ins => [ "base", "index", "mem", "val" ],
1816 attr => "ir_mode *store_mode",
1817 init_attr => "attr->attr.ls_mode = store_mode;",
1821 attr_type => "ia32_x87_attr_t",
1827 state => "exc_pinned",
1828 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1829 outs => [ "res", "M" ],
1830 ins => [ "base", "index", "mem" ],
1833 attr_type => "ia32_x87_attr_t",
1837 cmp_attr => "return 1;",
1838 outs => [ "res", "M" ],
1843 state => "exc_pinned",
1844 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1845 ins => [ "base", "index", "mem", "val", "fpcw" ],
1849 attr_type => "ia32_x87_attr_t",
1853 cmp_attr => "return 1;",
1854 state => "exc_pinned",
1864 reg_req => { out => [ "vfp" ] },
1868 attr_type => "ia32_x87_attr_t",
1873 reg_req => { out => [ "vfp" ] },
1877 attr_type => "ia32_x87_attr_t",
1882 reg_req => { out => [ "vfp" ] },
1886 attr_type => "ia32_x87_attr_t",
1891 reg_req => { out => [ "vfp" ] },
1895 attr_type => "ia32_x87_attr_t",
1900 reg_req => { out => [ "vfp" ] },
1904 attr_type => "ia32_x87_attr_t",
1909 reg_req => { out => [ "vfp" ] },
1913 attr_type => "ia32_x87_attr_t",
1918 reg_req => { out => [ "vfp" ] },
1922 attr_type => "ia32_x87_attr_t",
1928 # we can't allow to rematerialize this node so we don't have
1929 # accidently produce Phi(Fucom, Fucom(ins_permuted))
1931 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1932 ins => [ "left", "right" ],
1933 outs => [ "flags" ],
1934 attr => "int ins_permuted",
1935 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1938 attr_type => "ia32_x87_attr_t",
1944 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
1945 ins => [ "left", "right" ],
1946 outs => [ "flags" ],
1947 attr => "int ins_permuted",
1948 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1951 attr_type => "ia32_x87_attr_t",
1957 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
1959 outs => [ "flags" ],
1960 attr => "int ins_permuted",
1961 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1964 attr_type => "ia32_x87_attr_t",
1970 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
1972 outs => [ "flags" ],
1976 mode => $mode_flags,
1979 #------------------------------------------------------------------------#
1980 # ___ _____ __ _ _ _ #
1981 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1982 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1983 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1984 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1985 #------------------------------------------------------------------------#
1987 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1988 # are swapped, we work this around in the emitter...
1991 state => "exc_pinned",
1992 rd_constructor => "NONE",
1994 emit => '. fadd%XM %x87_binop',
1996 attr_type => "ia32_x87_attr_t",
2000 state => "exc_pinned",
2001 rd_constructor => "NONE",
2003 emit => '. faddp%XM %x87_binop',
2005 attr_type => "ia32_x87_attr_t",
2009 state => "exc_pinned",
2010 rd_constructor => "NONE",
2012 emit => '. fmul%XM %x87_binop',
2014 attr_type => "ia32_x87_attr_t",
2018 state => "exc_pinned",
2019 rd_constructor => "NONE",
2021 emit => '. fmulp%XM %x87_binop',,
2023 attr_type => "ia32_x87_attr_t",
2027 state => "exc_pinned",
2028 rd_constructor => "NONE",
2030 emit => '. fsub%XM %x87_binop',
2032 attr_type => "ia32_x87_attr_t",
2036 state => "exc_pinned",
2037 rd_constructor => "NONE",
2039 # see note about gas bugs
2040 emit => '. fsubrp%XM %x87_binop',
2042 attr_type => "ia32_x87_attr_t",
2046 state => "exc_pinned",
2047 rd_constructor => "NONE",
2050 emit => '. fsubr%XM %x87_binop',
2052 attr_type => "ia32_x87_attr_t",
2056 state => "exc_pinned",
2057 rd_constructor => "NONE",
2060 # see note about gas bugs
2061 emit => '. fsubp%XM %x87_binop',
2063 attr_type => "ia32_x87_attr_t",
2067 rd_constructor => "NONE",
2071 attr_type => "ia32_x87_attr_t",
2074 # this node is just here, to keep the simulator running
2075 # we can omit this when a fprem simulation function exists
2077 rd_constructor => "NONE",
2079 emit => '. fprem1\n'.
2082 attr_type => "ia32_x87_attr_t",
2086 state => "exc_pinned",
2087 rd_constructor => "NONE",
2089 emit => '. fdiv%XM %x87_binop',
2091 attr_type => "ia32_x87_attr_t",
2095 state => "exc_pinned",
2096 rd_constructor => "NONE",
2098 # see note about gas bugs
2099 emit => '. fdivrp%XM %x87_binop',
2101 attr_type => "ia32_x87_attr_t",
2105 state => "exc_pinned",
2106 rd_constructor => "NONE",
2108 emit => '. fdivr%XM %x87_binop',
2110 attr_type => "ia32_x87_attr_t",
2114 state => "exc_pinned",
2115 rd_constructor => "NONE",
2117 # see note about gas bugs
2118 emit => '. fdivp%XM %x87_binop',
2120 attr_type => "ia32_x87_attr_t",
2124 rd_constructor => "NONE",
2128 attr_type => "ia32_x87_attr_t",
2133 rd_constructor => "NONE",
2137 attr_type => "ia32_x87_attr_t",
2140 # x87 Load and Store
2143 rd_constructor => "NONE",
2144 op_flags => "R|L|F",
2145 state => "exc_pinned",
2147 emit => '. fld%XM %AM',
2148 attr_type => "ia32_x87_attr_t",
2153 rd_constructor => "NONE",
2154 op_flags => "R|L|F",
2155 state => "exc_pinned",
2157 emit => '. fst%XM %AM',
2159 attr_type => "ia32_x87_attr_t",
2164 rd_constructor => "NONE",
2165 op_flags => "R|L|F",
2166 state => "exc_pinned",
2168 emit => '. fstp%XM %AM',
2170 attr_type => "ia32_x87_attr_t",
2177 state => "exc_pinned",
2178 rd_constructor => "NONE",
2180 emit => '. fild%M %AM',
2181 attr_type => "ia32_x87_attr_t",
2186 state => "exc_pinned",
2187 rd_constructor => "NONE",
2189 emit => '. fist%M %AM',
2191 attr_type => "ia32_x87_attr_t",
2196 state => "exc_pinned",
2197 rd_constructor => "NONE",
2199 emit => '. fistp%M %AM',
2201 attr_type => "ia32_x87_attr_t",
2208 op_flags => "R|c|K",
2210 reg_req => { out => [ "vfp" ] },
2212 attr_type => "ia32_x87_attr_t",
2217 op_flags => "R|c|K",
2219 reg_req => { out => [ "vfp" ] },
2221 attr_type => "ia32_x87_attr_t",
2226 op_flags => "R|c|K",
2228 reg_req => { out => [ "vfp" ] },
2230 attr_type => "ia32_x87_attr_t",
2235 op_flags => "R|c|K",
2237 reg_req => { out => [ "vfp" ] },
2239 attr_type => "ia32_x87_attr_t",
2244 op_flags => "R|c|K",
2246 reg_req => { out => [ "vfp" ] },
2248 attr_type => "ia32_x87_attr_t",
2253 op_flags => "R|c|K",
2255 reg_req => { out => [ "vfp" ] },
2256 emit => '. fldll2t',
2257 attr_type => "ia32_x87_attr_t",
2262 op_flags => "R|c|K",
2264 reg_req => { out => [ "vfp" ] },
2266 attr_type => "ia32_x87_attr_t",
2271 # Note that it is NEVER allowed to do CSE on these nodes
2272 # Moreover, note the virtual register requierements!
2277 cmp_attr => "return 1;",
2278 emit => '. fxch %X0',
2279 attr_type => "ia32_x87_attr_t",
2287 cmp_attr => "return 1;",
2288 emit => '. fld %X0',
2289 attr_type => "ia32_x87_attr_t",
2295 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2296 cmp_attr => "return 1;",
2297 emit => '. fld %X0',
2298 attr_type => "ia32_x87_attr_t",
2305 cmp_attr => "return 1;",
2306 emit => '. fstp %X0',
2307 attr_type => "ia32_x87_attr_t",
2315 cmp_attr => "return 1;",
2316 emit => '. ffreep %X0',
2317 attr_type => "ia32_x87_attr_t",
2325 cmp_attr => "return 1;",
2327 attr_type => "ia32_x87_attr_t",
2335 cmp_attr => "return 1;",
2337 attr_type => "ia32_x87_attr_t",
2346 emit => ". fucom %X1\n".
2348 attr_type => "ia32_x87_attr_t",
2354 emit => ". fucomp %X1\n".
2356 attr_type => "ia32_x87_attr_t",
2362 emit => ". fucompp\n".
2364 attr_type => "ia32_x87_attr_t",
2370 emit => '. fucomi %X1',
2371 attr_type => "ia32_x87_attr_t",
2377 emit => '. fucompi %X1',
2378 attr_type => "ia32_x87_attr_t",
2386 attr_type => "ia32_x87_attr_t",
2391 # -------------------------------------------------------------------------------- #
2392 # ____ ____ _____ _ _ #
2393 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2394 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2395 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2396 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2398 # -------------------------------------------------------------------------------- #
2401 # Spilling and reloading of SSE registers, hardcoded, not generated #
2405 state => "exc_pinned",
2406 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2407 emit => '. movdqu %D0, %AM',
2408 outs => [ "res", "M" ],
2415 state => "exc_pinned",
2416 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2417 ins => [ "base", "index", "mem", "val" ],
2418 emit => '. movdqu %binop',
2426 # Include the generated SIMD node specification written by the SIMD optimization
2427 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2428 unless ($return = do $my_script_name) {
2429 warn "couldn't parse $my_script_name: $@" if $@;
2430 warn "couldn't do $my_script_name: $!" unless defined $return;
2431 warn "couldn't run $my_script_name" unless $return;
2434 # Transform some attributes
2435 foreach my $op (keys(%nodes)) {
2436 my $node = $nodes{$op};
2437 my $op_attr_init = $node->{op_attr_init};
2439 if(defined($op_attr_init)) {
2440 $op_attr_init .= "\n\t";
2445 if(!defined($node->{latency})) {
2447 $node->{latency} = 0;
2449 die("Latency missing for op $op");
2452 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2454 $node->{op_attr_init} = $op_attr_init;