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 # latency => "latency of this operation (can be float)"
36 # attr_type => "name of the attribute struct",
39 # ... # (all nodes you need to describe)
41 # ); # close the %nodes initializer
43 # op_flags: flags for the operation, OPTIONAL (default is "N")
44 # the op_flags correspond to the firm irop_flags:
47 # C irop_flag_commutative
48 # X irop_flag_cfopcode
49 # I irop_flag_ip_cfopcode
52 # H irop_flag_highlevel
53 # c irop_flag_constlike
56 # irn_flags: special node flags, OPTIONAL (default is 0)
57 # following irn_flags are supported:
60 # I ignore for register allocation
61 # S modifies stack pointer
63 # state: state of the operation, OPTIONAL (default is "floats")
65 # arity: arity of the operation, MUST NOT BE OMITTED
67 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
68 # are always the first 3 arguments and are always autmatically
70 # If this key is missing the following arguments will be created:
71 # for i = 1 .. arity: ir_node *op_i
74 # outs: if a node defines more than one output, the names of the projections
75 # nodes having outs having automatically the mode mode_T
76 # One can also annotate some flags for each out, additional to irn_flags.
77 # They are separated from name with a colon ':', and concatenated by pipe '|'
78 # Only I and S are available at the moment (same meaning as in irn_flags).
79 # example: [ "frame:I", "stack:I|S", "M" ]
81 # comment: OPTIONAL comment for the node constructor
83 # rd_constructor: for every operation there will be a
84 # new_rd_<arch>_<op-name> function with the arguments from above
85 # which creates the ir_node corresponding to the defined operation
86 # you can either put the complete source code of this function here
88 # This key is OPTIONAL. If omitted, the following constructor will
90 # if (!op_<arch>_<op-name>) assert(0);
94 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
99 # latency: the latency of the operation, default is 1
103 # 0 - no special type
104 # 1 - caller save (register must be saved by the caller of a function)
105 # 2 - callee save (register must be saved by the called function)
106 # 4 - ignore (do not assign this register)
107 # 8 - emitter can choose an arbitrary register of this class
108 # 16 - the register is a virtual one
109 # 32 - register represents a state
110 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
113 { name => "edx", type => 1 },
114 { name => "ecx", type => 1 },
115 { name => "eax", type => 1 },
116 { name => "ebx", type => 2 },
117 { name => "esi", type => 2 },
118 { name => "edi", type => 2 },
119 { name => "ebp", type => 2 },
120 { name => "esp", type => 4 },
121 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
122 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
123 { mode => "mode_Iu" }
126 { name => "mm0", type => 4 },
127 { name => "mm1", type => 4 },
128 { name => "mm2", type => 4 },
129 { name => "mm3", type => 4 },
130 { name => "mm4", type => 4 },
131 { name => "mm5", type => 4 },
132 { name => "mm6", type => 4 },
133 { name => "mm7", type => 4 },
134 { mode => "mode_E", flags => "manual_ra" }
137 { name => "xmm0", type => 1 },
138 { name => "xmm1", type => 1 },
139 { name => "xmm2", type => 1 },
140 { name => "xmm3", type => 1 },
141 { name => "xmm4", type => 1 },
142 { name => "xmm5", type => 1 },
143 { name => "xmm6", type => 1 },
144 { name => "xmm7", type => 1 },
145 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
146 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
150 { name => "vf0", type => 1 | 16 },
151 { name => "vf1", type => 1 | 16 },
152 { name => "vf2", type => 1 | 16 },
153 { name => "vf3", type => 1 | 16 },
154 { name => "vf4", type => 1 | 16 },
155 { name => "vf5", type => 1 | 16 },
156 { name => "vf6", type => 1 | 16 },
157 { name => "vf7", type => 1 | 16 },
158 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
159 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
163 { name => "st0", realname => "st", type => 4 },
164 { name => "st1", realname => "st(1)", type => 4 },
165 { name => "st2", realname => "st(2)", type => 4 },
166 { name => "st3", realname => "st(3)", type => 4 },
167 { name => "st4", realname => "st(4)", type => 4 },
168 { name => "st5", realname => "st(5)", type => 4 },
169 { name => "st6", realname => "st(6)", type => 4 },
170 { name => "st7", realname => "st(7)", type => 4 },
171 { mode => "mode_E", flags => "manual_ra" }
173 fp_cw => [ # the floating point control word
174 { name => "fpcw", type => 4|32 },
175 { mode => "mode_fpcw", flags => "manual_ra|state" }
178 { name => "eflags", type => 0 },
179 { mode => "mode_Iu", flags => "manual_ra" }
184 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
185 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
186 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
187 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
192 bundels_per_cycle => 1
196 S0 => "${arch}_emit_source_register(node, 0);",
197 S1 => "${arch}_emit_source_register(node, 1);",
198 S2 => "${arch}_emit_source_register(node, 2);",
199 S3 => "${arch}_emit_source_register(node, 3);",
200 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
201 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
202 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
203 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
204 D0 => "${arch}_emit_dest_register(node, 0);",
205 D1 => "${arch}_emit_dest_register(node, 1);",
206 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
207 X0 => "${arch}_emit_x87_register(node, 0);",
208 X1 => "${arch}_emit_x87_register(node, 1);",
209 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
210 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
211 ia32_emit_mode_suffix(node);",
212 M => "${arch}_emit_mode_suffix(node);",
213 XM => "${arch}_emit_x87_mode_suffix(node);",
214 XXM => "${arch}_emit_xmm_mode_suffix(node);",
215 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
216 AM => "${arch}_emit_am(node);",
217 unop3 => "${arch}_emit_unop(node, 3);",
218 unop4 => "${arch}_emit_unop(node, 4);",
219 unop5 => "${arch}_emit_unop(node, 5);",
220 DAM1 => "${arch}_emit_am_or_dest_register(node, 1);",
221 binop => "${arch}_emit_binop(node);",
222 x87_binop => "${arch}_emit_x87_binop(node);",
223 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
226 #--------------------------------------------------#
229 # _ __ _____ __ _ _ __ ___ _ __ ___ #
230 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
231 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
232 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
235 #--------------------------------------------------#
237 $default_attr_type = "ia32_attr_t";
238 $default_copy_attr = "ia32_copy_attr";
240 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, latency);",
284 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
285 "\tinit_ia32_x87_attributes(res);",
287 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\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, latency);\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, latency);\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, latency);\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',
379 modified_flags => $status_flags
384 state => "exc_pinned",
385 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
386 ins => [ "base", "index", "mem", "val" ],
387 emit => ". add%M %SI3, %AM",
390 modified_flags => $status_flags
395 state => "exc_pinned",
396 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
397 ins => [ "base", "index", "mem", "val" ],
398 emit => ". add%M %SB3, %AM",
401 modified_flags => $status_flags
405 state => "exc_pinned",
406 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 in_r5" ] },
407 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
408 emit => '. adc%M %binop',
412 modified_flags => $status_flags
417 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
418 ins => [ "left", "right" ],
422 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
423 ins => [ "left", "right", "eflags" ],
427 # we should not rematrialize this node. It produces 2 results and has
428 # very strict constrains
429 state => "exc_pinned",
430 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
431 ins => [ "base", "index", "mem", "val_high", "val_low" ],
432 emit => '. mul%M %unop4',
433 outs => [ "EAX", "EDX", "M" ],
434 am => "source,binary",
437 modified_flags => $status_flags
441 # we should not rematrialize this node. It produces 2 results and has
442 # very strict constrains
444 cmp_attr => "return 1;",
445 outs => [ "EAX", "EDX", "M" ],
451 state => "exc_pinned",
452 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
453 ins => [ "base", "index", "mem", "left", "right" ],
454 emit => '. imul%M %binop',
455 am => "source,binary",
459 modified_flags => $status_flags
464 state => "exc_pinned",
465 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
466 ins => [ "base", "index", "mem", "val_high", "val_low" ],
467 emit => '. imul%M %unop4',
468 outs => [ "EAX", "EDX", "M" ],
469 am => "source,binary",
472 modified_flags => $status_flags
476 # we should not rematrialize this node. It produces 2 results and has
477 # very strict constrains
479 cmp_attr => "return 1;",
480 outs => [ "EAX", "EDX", "M" ],
486 state => "exc_pinned",
487 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
488 ins => [ "base", "index", "mem", "left", "right" ],
490 emit => '. and%M %binop',
493 modified_flags => $status_flags
498 state => "exc_pinned",
499 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
500 ins => [ "base", "index", "mem", "val" ],
501 emit => '. and%M %SI3, %AM',
504 modified_flags => $status_flags
509 state => "exc_pinned",
510 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
511 ins => [ "base", "index", "mem", "val" ],
512 emit => '. and%M %SB3, %AM',
515 modified_flags => $status_flags
520 state => "exc_pinned",
521 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
522 ins => [ "base", "index", "mem", "left", "right" ],
524 emit => '. or%M %binop',
527 modified_flags => $status_flags
532 state => "exc_pinned",
533 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
534 ins => [ "base", "index", "mem", "val" ],
535 emit => '. or%M %SI3, %AM',
538 modified_flags => $status_flags
543 state => "exc_pinned",
544 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
545 ins => [ "base", "index", "mem", "val" ],
546 emit => '. or%M %SB3, %AM',
549 modified_flags => $status_flags
554 state => "exc_pinned",
555 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
556 ins => [ "base", "index", "mem", "left", "right" ],
558 emit => '. xor%M %binop',
561 modified_flags => $status_flags
566 state => "exc_pinned",
567 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
568 ins => [ "base", "index", "mem", "val" ],
569 emit => '. xor%M %SI3, %AM',
572 modified_flags => $status_flags
577 state => "exc_pinned",
578 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
579 ins => [ "base", "index", "mem", "val" ],
580 emit => '. xor%M %SB3, %AM',
583 modified_flags => $status_flags
586 # not commutative operations
590 state => "exc_pinned",
591 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4", "none", "flags" ] },
592 ins => [ "base", "index", "mem", "left", "right" ],
594 emit => '. sub%M %binop',
597 modified_flags => $status_flags
602 state => "exc_pinned",
603 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
604 ins => [ "base", "index", "mem", "val" ],
605 emit => '. sub%M %SI3, %AM',
608 modified_flags => $status_flags
613 state => "exc_pinned",
614 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
615 ins => [ "base", "index", "mem", "val" ],
616 emit => '. sub%M %SB3, %AM',
619 modified_flags => $status_flags
623 state => "exc_pinned",
624 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 !in_r5" ] },
625 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
627 emit => '. sbb%M %binop',
630 modified_flags => $status_flags
634 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
635 ins => [ "left", "right" ],
639 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
640 ins => [ "left", "right", "eflags" ],
645 state => "exc_pinned",
646 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
647 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
648 outs => [ "div_res", "mod_res", "M" ],
649 am => "source,ternary",
650 emit => ". idiv%M %unop5",
653 modified_flags => $status_flags
658 state => "exc_pinned",
659 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
660 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
661 outs => [ "div_res", "mod_res", "M" ],
662 am => "source,ternary",
663 emit => ". div%M %unop5",
666 modified_flags => $status_flags
671 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
672 ins => [ "left", "right" ],
673 emit => '. shl %SB1, %S0',
676 modified_flags => $status_flags
681 state => "exc_pinned",
682 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
683 ins => [ "base", "index", "mem", "count" ],
684 emit => '. shl%M %SB3, %AM',
687 modified_flags => $status_flags
691 cmp_attr => "return 1;",
692 # value, cnt, dependency
698 # see ShrD about the strange out constraint
699 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
700 ins => [ "left_high", "left_low", "right" ],
701 emit => ". shld%M %SB2, %S1, %S0\n".
706 modified_flags => $status_flags
710 cmp_attr => "return 1;",
716 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
717 ins => [ "val", "count" ],
718 emit => '. shr %SB1, %S0',
721 modified_flags => $status_flags
726 state => "exc_pinned",
727 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
728 ins => [ "base", "index", "mem", "count" ],
729 emit => '. shr%M %SB3, %AM',
732 modified_flags => $status_flags
736 cmp_attr => "return 1;",
737 # value, cnt, dependency
742 # What's going on with the out constraint here? We would like to write
743 # "in_r2" and be done. However in firm we only support should_be_same
744 # constraints at the moment. Which means they could be non-fullfilled in
745 # some cases. Now when all values happen to live through the node, out
746 # is ecx and in_r2 not ecx, then we're screwed. Because in this case we
747 # need a 4th Register.
749 # The best solution for this is extending the register allocator to support
750 # must_be_same constraints which create a copy when the in_r2 value
751 # lives through (this ensures that we have the 4th register in the cases
752 # when we need it and can always fix the situation).
754 # For now I'm doing this ultra ugly !in hack which allocates 4 registers
755 # and creates an extra mov
757 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
758 ins => [ "left_high", "left_low", "right" ],
759 emit => ". shrd%M %SB2, %S1, %S0\n".
764 modified_flags => $status_flags
768 cmp_attr => "return 1;",
774 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
775 ins => [ "val", "count" ],
776 emit => '. sar %SB1, %S0',
779 modified_flags => $status_flags
784 state => "exc_pinned",
785 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
786 ins => [ "base", "index", "mem", "count" ],
787 emit => '. sar%M %SB3, %AM',
790 modified_flags => $status_flags
794 cmp_attr => "return 1;",
795 # value, cnt, dependency
801 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
802 ins => [ "val", "count" ],
803 emit => '. ror %SB1, %S0',
806 modified_flags => $status_flags
811 state => "exc_pinned",
812 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
813 ins => [ "base", "index", "mem", "count" ],
814 emit => '. ror%M %SB3, %AM',
817 modified_flags => $status_flags
822 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
823 ins => [ "val", "count" ],
824 emit => '. rol %SB1, %S0',
827 modified_flags => $status_flags
832 state => "exc_pinned",
833 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
834 ins => [ "base", "index", "mem", "count" ],
835 emit => '. rol%M %SB3, %AM',
838 modified_flags => $status_flags
845 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
850 modified_flags => $status_flags
855 state => "exc_pinned",
856 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
857 ins => [ "base", "index", "mem" ],
858 emit => '. neg%M %AM',
861 modified_flags => $status_flags
866 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
867 outs => [ "low_res", "high_res" ],
869 modified_flags => $status_flags
874 cmp_attr => "return 1;",
880 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
884 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
889 state => "exc_pinned",
890 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
891 ins => [ "base", "index", "mem" ],
892 emit => '. inc%M %AM',
895 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
900 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
904 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
909 state => "exc_pinned",
910 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
911 ins => [ "base", "index", "mem" ],
912 emit => '. dec%M %AM',
915 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
920 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
929 state => "exc_pinned",
930 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
931 ins => [ "base", "index", "mem" ],
932 emit => '. not%M %AM',
941 state => "exc_pinned",
942 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
943 ins => [ "base", "index", "mem", "left", "right" ],
944 outs => [ "eflags" ],
945 am => "source,binary",
946 emit => '. cmp%M %binop',
947 attr => "int ins_permuted, int cmp_unsigned",
948 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
949 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
953 modified_flags => $status_flags
958 state => "exc_pinned",
959 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
960 ins => [ "base", "index", "mem", "left", "right" ],
961 outs => [ "eflags" ],
962 am => "source,binary",
963 emit => '. cmpb %binop',
964 attr => "int ins_permuted, int cmp_unsigned",
965 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
966 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
970 modified_flags => $status_flags
975 state => "exc_pinned",
976 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
977 ins => [ "base", "index", "mem", "left", "right" ],
978 outs => [ "eflags" ],
979 am => "source,binary",
980 emit => '. test%M %binop',
981 attr => "int ins_permuted, int cmp_unsigned",
982 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
983 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
987 modified_flags => $status_flags
992 state => "exc_pinned",
993 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
994 ins => [ "base", "index", "mem", "left", "right" ],
995 outs => [ "eflags" ],
996 am => "source,binary",
997 emit => '. testb %binop',
998 attr => "int ins_permuted, int cmp_unsigned",
999 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1000 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1003 mode => $mode_flags,
1004 modified_flags => $status_flags
1009 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1010 ins => [ "eflags" ],
1011 attr_type => "ia32_condcode_attr_t",
1012 attr => "pn_Cmp pnc, int ins_permuted",
1013 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1014 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1015 emit => '. set%CMP0 %DB0',
1023 # (note: leave the false,true order intact to make it compatible with other
1025 state => "exc_pinned",
1026 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1027 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1028 am => "source,binary",
1029 attr_type => "ia32_condcode_attr_t",
1030 attr => "int ins_permuted, pn_Cmp pnc",
1031 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1039 op_flags => "L|X|Y",
1040 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1041 ins => [ "eflags" ],
1042 outs => [ "false", "true" ],
1043 attr_type => "ia32_condcode_attr_t",
1044 attr => "pn_Cmp pnc",
1046 units => [ "BRANCH" ],
1051 op_flags => "L|X|Y",
1052 reg_req => { in => [ "gp" ], out => [ "none" ] },
1054 attr_type => "ia32_condcode_attr_t",
1055 attr => "pn_Cmp pnc",
1057 units => [ "BRANCH" ],
1058 modified_flags => $status_flags,
1064 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1065 ins => [ "base", "index", "mem", "target" ],
1066 am => "source,unary",
1067 emit => '. jmp *%unop3',
1068 units => [ "BRANCH" ],
1075 reg_req => { out => [ "gp" ] },
1077 attr => "ir_entity *symconst, int symconst_sign, long offset",
1078 attr_type => "ia32_immediate_attr_t",
1080 # depends on the const and is set in ia32_transform
1081 # modified_flags => $status_flags
1088 reg_req => { out => [ "gp_UKNWN" ] },
1098 reg_req => { out => [ "vfp_UKNWN" ] },
1102 attr_type => "ia32_x87_attr_t",
1109 reg_req => { out => [ "xmm_UKNWN" ] },
1119 reg_req => { out => [ "gp_NOREG" ] },
1129 reg_req => { out => [ "vfp_NOREG" ] },
1133 attr_type => "ia32_x87_attr_t",
1140 reg_req => { out => [ "xmm_NOREG" ] },
1150 reg_req => { out => [ "fp_cw" ] },
1154 modified_flags => $fpcw_flags
1160 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1161 ins => [ "base", "index", "mem" ],
1163 emit => ". fldcw %AM",
1166 modified_flags => $fpcw_flags
1172 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1173 ins => [ "base", "index", "mem", "fpcw" ],
1175 emit => ". fnstcw %AM",
1181 # we should not rematrialize this node. It has very strict constraints.
1182 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1183 ins => [ "val", "globbered" ],
1191 # Note that we add additional latency values depending on address mode, so a
1192 # lateny of 0 for load is correct
1196 state => "exc_pinned",
1197 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1198 ins => [ "base", "index", "mem" ],
1199 outs => [ "res", "M" ],
1201 emit => ". mov%SE%ME%.l %AM, %D0",
1207 cmp_attr => "return 1;",
1208 outs => [ "res", "M" ],
1214 cmp_attr => "return 1;",
1215 state => "exc_pinned",
1222 state => "exc_pinned",
1223 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1224 ins => [ "base", "index", "mem", "val" ],
1225 emit => '. mov%M %SI3, %AM',
1233 state => "exc_pinned",
1234 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1235 ins => [ "base", "index", "mem", "val" ],
1236 emit => '. mov%M %SB3, %AM',
1244 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1245 ins => [ "base", "index" ],
1246 emit => '. leal %AM, %D0',
1250 # lea doesn't modify the flags, but setting this seems advantageous since it
1251 # increases chances that the Lea is transformed back to an Add
1252 modified_flags => 1,
1256 state => "exc_pinned",
1257 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp", "none" ] },
1258 ins => [ "base", "index", "mem", "val", "stack" ],
1259 emit => '. push%M %unop4',
1260 outs => [ "stack:I|S", "M" ],
1261 am => "source,binary",
1267 state => "exc_pinned",
1268 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "esp", "gp", "none" ] },
1269 emit => '. pop%M %DAM1',
1270 outs => [ "stack:I|S", "res", "M" ],
1271 ins => [ "base", "index", "mem", "stack" ],
1273 latency => 3, # Pop is more expensive than Push on Athlon
1278 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1280 outs => [ "frame:I", "stack:I|S", "M" ],
1286 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1288 outs => [ "frame:I", "stack:I|S" ],
1296 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1297 ins => [ "base", "index", "mem", "stack", "size" ],
1298 am => "source,binary",
1299 emit => '. addl %binop',
1300 outs => [ "stack:S", "M" ],
1302 modified_flags => $status_flags
1308 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1309 ins => [ "base", "index", "mem", "stack", "size" ],
1310 am => "source,binary",
1311 emit => ". subl %binop\n".
1312 ". movl %%esp, %D1",
1313 outs => [ "stack:I|S", "addr", "M" ],
1315 modified_flags => $status_flags
1320 reg_req => { out => [ "gp" ] },
1325 #-----------------------------------------------------------------------------#
1326 # _____ _____ ______ __ _ _ _ #
1327 # / ____/ ____| ____| / _| | | | | | #
1328 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1329 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1330 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1331 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1332 #-----------------------------------------------------------------------------#
1336 reg_req => { out => [ "xmm" ] },
1337 emit => '. xorp%XSD %D0, %D0',
1343 # commutative operations
1347 state => "exc_pinned",
1348 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1349 ins => [ "base", "index", "mem", "left", "right" ],
1350 am => "source,binary",
1351 emit => '. add%XXM %binop',
1359 state => "exc_pinned",
1360 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1361 ins => [ "base", "index", "mem", "left", "right" ],
1362 am => "source,binary",
1363 emit => '. mul%XXM %binop',
1371 state => "exc_pinned",
1372 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1373 ins => [ "base", "index", "mem", "left", "right" ],
1374 am => "source,binary",
1375 emit => '. max%XXM %binop',
1383 state => "exc_pinned",
1384 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1385 ins => [ "base", "index", "mem", "left", "right" ],
1386 am => "source,binary",
1387 emit => '. min%XXM %binop',
1395 state => "exc_pinned",
1396 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1397 ins => [ "base", "index", "mem", "left", "right" ],
1398 am => "source,binary",
1399 emit => '. andp%XSD %binop',
1407 state => "exc_pinned",
1408 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1409 ins => [ "base", "index", "mem", "left", "right" ],
1410 am => "source,binary",
1411 emit => '. orp%XSD %binop',
1418 state => "exc_pinned",
1419 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1420 ins => [ "base", "index", "mem", "left", "right" ],
1421 am => "source,binary",
1422 emit => '. xorp%XSD %binop',
1428 # not commutative operations
1432 state => "exc_pinned",
1433 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1434 ins => [ "base", "index", "mem", "left", "right" ],
1435 am => "source,binary",
1436 emit => '. andnp%XSD %binop',
1444 state => "exc_pinned",
1445 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1446 ins => [ "base", "index", "mem", "left", "right" ],
1447 am => "source,binary",
1448 emit => '. sub%XXM %binop',
1456 state => "exc_pinned",
1457 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1458 ins => [ "base", "index", "mem", "left", "right" ],
1459 am => "source,binary",
1460 outs => [ "res", "M" ],
1461 emit => '. div%XXM %binop',
1470 state => "exc_pinned",
1471 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1472 ins => [ "base", "index", "mem", "left", "right" ],
1473 outs => [ "flags" ],
1474 am => "source,binary",
1475 attr => "int ins_permuted",
1476 init_attr => "attr->data.ins_permuted = ins_permuted;",
1477 emit => ' .ucomi%XXM %binop',
1480 mode => $mode_flags,
1481 modified_flags => 1,
1488 state => "exc_pinned",
1489 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1490 ins => [ "base", "index", "mem" ],
1491 emit => '. mov%XXM %AM, %D0',
1492 attr => "ir_mode *load_mode",
1493 init_attr => "attr->ls_mode = load_mode;",
1494 outs => [ "res", "M" ],
1501 state => "exc_pinned",
1502 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1503 ins => [ "base", "index", "mem", "val" ],
1504 emit => '. mov%XXM %S3, %AM',
1512 state => "exc_pinned",
1513 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1514 ins => [ "base", "index", "mem", "val" ],
1515 emit => '. mov%XXM %S3, %AM',
1523 state => "exc_pinned",
1524 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1525 ins => [ "base", "index", "mem", "val" ],
1526 am => "source,unary",
1527 emit => '. cvtsi2ss %unop3, %D0',
1535 state => "exc_pinned",
1536 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1537 ins => [ "base", "index", "mem", "val" ],
1538 am => "source,unary",
1539 emit => '. cvtsi2sd %unop3, %D0',
1548 cmp_attr => "return 1;",
1554 cmp_attr => "return 1;",
1563 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1564 outs => [ "DST", "SRC", "CNT", "M" ],
1565 attr_type => "ia32_copyb_attr_t",
1566 attr => "unsigned size",
1568 # we don't care about this flag, so no need to mark this node
1569 # modified_flags => [ "DF" ]
1575 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1576 outs => [ "DST", "SRC", "M" ],
1577 attr_type => "ia32_copyb_attr_t",
1578 attr => "unsigned size",
1580 # we don't care about this flag, so no need to mark this node
1581 # modified_flags => [ "DF" ]
1587 state => "exc_pinned",
1588 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1589 ins => [ "base", "index", "mem", "val" ],
1590 am => "source,unary",
1592 attr => "ir_mode *smaller_mode",
1593 init_attr => "attr->ls_mode = smaller_mode;",
1598 state => "exc_pinned",
1599 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1600 ins => [ "base", "index", "mem", "val" ],
1601 am => "source,unary",
1603 attr => "ir_mode *smaller_mode",
1604 init_attr => "attr->ls_mode = smaller_mode;",
1609 state => "exc_pinned",
1610 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1611 ins => [ "base", "index", "mem", "val" ],
1612 am => "source,unary",
1619 state => "exc_pinned",
1620 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1621 ins => [ "base", "index", "mem", "val" ],
1622 am => "source,unary",
1629 state => "exc_pinned",
1630 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1631 ins => [ "base", "index", "mem", "val" ],
1632 am => "source,unary",
1638 #----------------------------------------------------------#
1640 # (_) | | | | / _| | | | #
1641 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1642 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1643 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1644 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1646 # _ __ ___ __| | ___ ___ #
1647 # | '_ \ / _ \ / _` |/ _ \/ __| #
1648 # | | | | (_) | (_| | __/\__ \ #
1649 # |_| |_|\___/ \__,_|\___||___/ #
1650 #----------------------------------------------------------#
1652 # rematerialisation disabled for all float nodes for now, because the fpcw
1653 # handler runs before spilling and we might end up with wrong fpcw then
1657 state => "exc_pinned",
1658 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1659 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1660 am => "source,binary",
1664 attr_type => "ia32_x87_attr_t",
1669 state => "exc_pinned",
1670 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1671 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1672 am => "source,binary",
1676 attr_type => "ia32_x87_attr_t",
1681 state => "exc_pinned",
1682 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1683 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1684 am => "source,binary",
1688 attr_type => "ia32_x87_attr_t",
1692 state => "exc_pinned",
1693 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1694 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1695 am => "source,binary",
1696 outs => [ "res", "M" ],
1699 attr_type => "ia32_x87_attr_t",
1703 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1704 ins => [ "left", "right", "fpcw" ],
1708 attr_type => "ia32_x87_attr_t",
1713 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1718 attr_type => "ia32_x87_attr_t",
1723 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1728 attr_type => "ia32_x87_attr_t",
1731 # virtual Load and Store
1736 state => "exc_pinned",
1737 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1738 ins => [ "base", "index", "mem" ],
1739 outs => [ "res", "M" ],
1740 attr => "ir_mode *load_mode",
1741 init_attr => "attr->attr.ls_mode = load_mode;",
1744 attr_type => "ia32_x87_attr_t",
1750 state => "exc_pinned",
1751 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1752 ins => [ "base", "index", "mem", "val" ],
1753 attr => "ir_mode *store_mode",
1754 init_attr => "attr->attr.ls_mode = store_mode;",
1758 attr_type => "ia32_x87_attr_t",
1764 state => "exc_pinned",
1765 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1766 outs => [ "res", "M" ],
1767 ins => [ "base", "index", "mem" ],
1770 attr_type => "ia32_x87_attr_t",
1774 cmp_attr => "return 1;",
1775 outs => [ "res", "M" ],
1780 state => "exc_pinned",
1781 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1782 ins => [ "base", "index", "mem", "val", "fpcw" ],
1786 attr_type => "ia32_x87_attr_t",
1790 cmp_attr => "return 1;",
1791 state => "exc_pinned",
1801 reg_req => { out => [ "vfp" ] },
1805 attr_type => "ia32_x87_attr_t",
1810 reg_req => { out => [ "vfp" ] },
1814 attr_type => "ia32_x87_attr_t",
1819 reg_req => { out => [ "vfp" ] },
1823 attr_type => "ia32_x87_attr_t",
1828 reg_req => { out => [ "vfp" ] },
1832 attr_type => "ia32_x87_attr_t",
1837 reg_req => { out => [ "vfp" ] },
1841 attr_type => "ia32_x87_attr_t",
1846 reg_req => { out => [ "vfp" ] },
1850 attr_type => "ia32_x87_attr_t",
1855 reg_req => { out => [ "vfp" ] },
1859 attr_type => "ia32_x87_attr_t",
1865 # we can't allow to rematerialize this node so we don't have
1866 # accidently produce Phi(Fucom, Fucom(ins_permuted))
1868 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1869 ins => [ "left", "right" ],
1870 outs => [ "flags" ],
1871 attr => "int ins_permuted",
1872 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1875 attr_type => "ia32_x87_attr_t",
1881 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
1882 ins => [ "left", "right" ],
1883 outs => [ "flags" ],
1884 attr => "int ins_permuted",
1885 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1888 attr_type => "ia32_x87_attr_t",
1894 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
1896 outs => [ "flags" ],
1897 attr => "int ins_permuted",
1898 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1901 attr_type => "ia32_x87_attr_t",
1907 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
1909 outs => [ "flags" ],
1912 mode => $mode_flags,
1915 #------------------------------------------------------------------------#
1916 # ___ _____ __ _ _ _ #
1917 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1918 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1919 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1920 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1921 #------------------------------------------------------------------------#
1923 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1924 # are swapped, we work this around in the emitter...
1927 state => "exc_pinned",
1928 rd_constructor => "NONE",
1930 emit => '. fadd%XM %x87_binop',
1931 attr_type => "ia32_x87_attr_t",
1935 state => "exc_pinned",
1936 rd_constructor => "NONE",
1938 emit => '. faddp%XM %x87_binop',
1939 attr_type => "ia32_x87_attr_t",
1943 state => "exc_pinned",
1944 rd_constructor => "NONE",
1946 emit => '. fmul%XM %x87_binop',
1947 attr_type => "ia32_x87_attr_t",
1951 state => "exc_pinned",
1952 rd_constructor => "NONE",
1954 emit => '. fmulp%XM %x87_binop',,
1955 attr_type => "ia32_x87_attr_t",
1959 state => "exc_pinned",
1960 rd_constructor => "NONE",
1962 emit => '. fsub%XM %x87_binop',
1963 attr_type => "ia32_x87_attr_t",
1967 state => "exc_pinned",
1968 rd_constructor => "NONE",
1970 # see note about gas bugs
1971 emit => '. fsubrp%XM %x87_binop',
1972 attr_type => "ia32_x87_attr_t",
1976 state => "exc_pinned",
1977 rd_constructor => "NONE",
1980 emit => '. fsubr%XM %x87_binop',
1981 attr_type => "ia32_x87_attr_t",
1985 state => "exc_pinned",
1986 rd_constructor => "NONE",
1989 # see note about gas bugs
1990 emit => '. fsubp%XM %x87_binop',
1991 attr_type => "ia32_x87_attr_t",
1995 rd_constructor => "NONE",
1998 attr_type => "ia32_x87_attr_t",
2001 # this node is just here, to keep the simulator running
2002 # we can omit this when a fprem simulation function exists
2004 rd_constructor => "NONE",
2007 attr_type => "ia32_x87_attr_t",
2011 state => "exc_pinned",
2012 rd_constructor => "NONE",
2014 emit => '. fdiv%XM %x87_binop',
2015 attr_type => "ia32_x87_attr_t",
2019 state => "exc_pinned",
2020 rd_constructor => "NONE",
2022 # see note about gas bugs
2023 emit => '. fdivrp%XM %x87_binop',
2024 attr_type => "ia32_x87_attr_t",
2028 state => "exc_pinned",
2029 rd_constructor => "NONE",
2031 emit => '. fdivr%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 => '. fdivp%XM %x87_binop',
2041 attr_type => "ia32_x87_attr_t",
2045 rd_constructor => "NONE",
2048 attr_type => "ia32_x87_attr_t",
2053 rd_constructor => "NONE",
2056 attr_type => "ia32_x87_attr_t",
2059 # x87 Load and Store
2062 rd_constructor => "NONE",
2063 op_flags => "R|L|F",
2064 state => "exc_pinned",
2066 emit => '. fld%XM %AM',
2067 attr_type => "ia32_x87_attr_t",
2071 rd_constructor => "NONE",
2072 op_flags => "R|L|F",
2073 state => "exc_pinned",
2075 emit => '. fst%XM %AM',
2077 attr_type => "ia32_x87_attr_t",
2081 rd_constructor => "NONE",
2082 op_flags => "R|L|F",
2083 state => "exc_pinned",
2085 emit => '. fstp%XM %AM',
2087 attr_type => "ia32_x87_attr_t",
2093 state => "exc_pinned",
2094 rd_constructor => "NONE",
2096 emit => '. fild%M %AM',
2097 attr_type => "ia32_x87_attr_t",
2101 state => "exc_pinned",
2102 rd_constructor => "NONE",
2104 emit => '. fist%M %AM',
2106 attr_type => "ia32_x87_attr_t",
2110 state => "exc_pinned",
2111 rd_constructor => "NONE",
2113 emit => '. fistp%M %AM',
2115 attr_type => "ia32_x87_attr_t",
2121 op_flags => "R|c|K",
2123 reg_req => { out => [ "vfp" ] },
2125 attr_type => "ia32_x87_attr_t",
2129 op_flags => "R|c|K",
2131 reg_req => { out => [ "vfp" ] },
2133 attr_type => "ia32_x87_attr_t",
2137 op_flags => "R|c|K",
2139 reg_req => { out => [ "vfp" ] },
2141 attr_type => "ia32_x87_attr_t",
2145 op_flags => "R|c|K",
2147 reg_req => { out => [ "vfp" ] },
2149 attr_type => "ia32_x87_attr_t",
2153 op_flags => "R|c|K",
2155 reg_req => { out => [ "vfp" ] },
2157 attr_type => "ia32_x87_attr_t",
2161 op_flags => "R|c|K",
2163 reg_req => { out => [ "vfp" ] },
2164 emit => '. fldll2t',
2165 attr_type => "ia32_x87_attr_t",
2169 op_flags => "R|c|K",
2171 reg_req => { out => [ "vfp" ] },
2173 attr_type => "ia32_x87_attr_t",
2177 # Note that it is NEVER allowed to do CSE on these nodes
2178 # Moreover, note the virtual register requierements!
2183 cmp_attr => "return 1;",
2184 emit => '. fxch %X0',
2185 attr_type => "ia32_x87_attr_t",
2192 cmp_attr => "return 1;",
2193 emit => '. fld %X0',
2194 attr_type => "ia32_x87_attr_t",
2199 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2200 cmp_attr => "return 1;",
2201 emit => '. fld %X0',
2202 attr_type => "ia32_x87_attr_t",
2208 cmp_attr => "return 1;",
2209 emit => '. fstp %X0',
2210 attr_type => "ia32_x87_attr_t",
2217 cmp_attr => "return 1;",
2218 emit => '. ffreep %X0',
2219 attr_type => "ia32_x87_attr_t",
2226 cmp_attr => "return 1;",
2228 attr_type => "ia32_x87_attr_t",
2235 cmp_attr => "return 1;",
2237 attr_type => "ia32_x87_attr_t",
2245 emit => ". fucom %X1\n".
2247 attr_type => "ia32_x87_attr_t",
2252 emit => ". fucomp %X1\n".
2254 attr_type => "ia32_x87_attr_t",
2259 emit => ". fucompp\n".
2261 attr_type => "ia32_x87_attr_t",
2266 emit => '. fucomi %X1',
2267 attr_type => "ia32_x87_attr_t",
2272 emit => '. fucompi %X1',
2273 attr_type => "ia32_x87_attr_t",
2280 attr_type => "ia32_x87_attr_t",
2284 # -------------------------------------------------------------------------------- #
2285 # ____ ____ _____ _ _ #
2286 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2287 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2288 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2289 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2291 # -------------------------------------------------------------------------------- #
2294 # Spilling and reloading of SSE registers, hardcoded, not generated #
2298 state => "exc_pinned",
2299 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2300 emit => '. movdqu %D0, %AM',
2301 outs => [ "res", "M" ],
2307 state => "exc_pinned",
2308 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2309 ins => [ "base", "index", "mem", "val" ],
2310 emit => '. movdqu %binop',
2317 # Include the generated SIMD node specification written by the SIMD optimization
2318 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2319 unless ($return = do $my_script_name) {
2320 warn "couldn't parse $my_script_name: $@" if $@;
2321 warn "couldn't do $my_script_name: $!" unless defined $return;
2322 warn "couldn't run $my_script_name" unless $return;