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 S4 => "${arch}_emit_source_register(node, 4);",
201 S5 => "${arch}_emit_source_register(node, 5);",
202 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
203 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
204 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
205 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
206 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
207 SI2 => "${arch}_emit_source_register_or_immediate(node, 2);",
208 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
209 D0 => "${arch}_emit_dest_register(node, 0);",
210 D1 => "${arch}_emit_dest_register(node, 1);",
211 D2 => "${arch}_emit_dest_register(node, 2);",
212 D3 => "${arch}_emit_dest_register(node, 3);",
213 D4 => "${arch}_emit_dest_register(node, 4);",
214 D5 => "${arch}_emit_dest_register(node, 5);",
215 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
216 X0 => "${arch}_emit_x87_register(node, 0);",
217 X1 => "${arch}_emit_x87_register(node, 1);",
218 X2 => "${arch}_emit_x87_register(node, 2);",
219 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
220 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
221 ia32_emit_mode_suffix(node);",
222 M => "${arch}_emit_mode_suffix(node);",
223 XM => "${arch}_emit_x87_mode_suffix(node);",
224 XXM => "${arch}_emit_xmm_mode_suffix(node);",
225 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
226 AM => "${arch}_emit_am(node);",
227 unop0 => "${arch}_emit_unop(node, 0);",
228 unop1 => "${arch}_emit_unop(node, 1);",
229 unop2 => "${arch}_emit_unop(node, 2);",
230 unop3 => "${arch}_emit_unop(node, 3);",
231 unop4 => "${arch}_emit_unop(node, 4);",
232 unop5 => "${arch}_emit_unop(node, 5);",
233 DAM0 => "${arch}_emit_am_or_dest_register(node, 0);",
234 DAM1 => "${arch}_emit_am_or_dest_register(node, 1);",
235 binop => "${arch}_emit_binop(node, 1);",
236 binop_nores => "${arch}_emit_binop(node, 0);",
237 x87_binop => "${arch}_emit_x87_binop(node);",
238 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
241 #--------------------------------------------------#
244 # _ __ _____ __ _ _ __ ___ _ __ ___ #
245 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
246 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
247 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
250 #--------------------------------------------------#
252 $default_attr_type = "ia32_attr_t";
253 $default_copy_attr = "ia32_copy_attr";
255 sub ia32_custom_init_attr {
259 if(defined($node->{modified_flags})) {
260 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
262 if(defined($node->{am})) {
263 my $am = $node->{am};
264 if($am eq "full,binary") {
265 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
266 } elsif($am eq "full,unary") {
267 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
268 } elsif($am eq "source,binary") {
269 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
270 } elsif($am eq "dest,unary") {
271 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
272 } elsif($am eq "dest,binary") {
273 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
274 } elsif($am eq "dest,ternary") {
275 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
276 } elsif($am eq "source,ternary") {
277 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
278 } elsif($am eq "none") {
281 die("Invalid address mode '$am' specified on op $name");
286 $custom_init_attr_func = \&ia32_custom_init_attr;
289 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
291 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
292 "\tinit_ia32_x87_attributes(res);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
295 "\tinit_ia32_x87_attributes(res);".
296 "\tinit_ia32_asm_attributes(res);",
297 ia32_immediate_attr_t =>
298 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
299 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);"
303 ia32_attr_t => "ia32_compare_nodes_attr",
304 ia32_x87_attr_t => "ia32_compare_x87_attr",
305 ia32_asm_attr_t => "ia32_compare_asm_attr",
306 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
312 $mode_xmm = "mode_E";
313 $mode_gp = "mode_Iu";
314 $mode_flags = "mode_Iu";
315 $mode_fpcw = "mode_fpcw";
316 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
317 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
318 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
326 reg_req => { out => [ "gp_NOREG" ] },
327 attr => "ir_entity *symconst, int symconst_sign, long offset",
328 attr_type => "ia32_immediate_attr_t",
336 out_arity => "variable",
337 attr_type => "ia32_asm_attr_t",
344 reg_req => { out => [ "gp" ] },
349 cmp_attr => "return 1;",
352 #-----------------------------------------------------------------#
355 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
356 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
357 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
358 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
361 #-----------------------------------------------------------------#
363 # commutative operations
367 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5", "none", "flags" ] },
368 ins => [ "base", "index", "mem", "left", "right" ],
369 emit => '. add%M %binop',
373 modified_flags => $status_flags
378 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
379 ins => [ "base", "index", "mem", "val" ],
380 emit => ". add%M %SI3, %AM",
383 modified_flags => $status_flags
388 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
389 ins => [ "base", "index", "mem", "val" ],
390 emit => ". add%M %SB3, %AM",
393 modified_flags => $status_flags
397 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 in_r5" ] },
398 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
399 emit => '. adc%M %binop',
403 modified_flags => $status_flags
408 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
409 ins => [ "left", "right" ],
413 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
414 ins => [ "left", "right", "eflags" ],
418 # we should not rematrialize this node. It produces 2 results and has
419 # very strict constrains
420 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
421 ins => [ "base", "index", "mem", "val_high", "val_low" ],
422 emit => '. mul%M %unop4',
423 outs => [ "EAX", "EDX", "M" ],
424 am => "source,binary",
427 modified_flags => $status_flags
431 # we should not rematrialize this node. It produces 2 results and has
432 # very strict constrains
434 cmp_attr => "return 1;",
435 outs => [ "EAX", "EDX", "M" ],
441 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
442 ins => [ "base", "index", "mem", "left", "right" ],
443 emit => '. imul%M %binop',
444 am => "source,binary",
448 modified_flags => $status_flags
453 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
454 ins => [ "base", "index", "mem", "val_high", "val_low" ],
455 emit => '. imul%M %unop4',
456 outs => [ "EAX", "EDX", "M" ],
457 am => "source,binary",
460 modified_flags => $status_flags
464 # we should not rematrialize this node. It produces 2 results and has
465 # very strict constrains
467 cmp_attr => "return 1;",
468 outs => [ "EAX", "EDX", "M" ],
474 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
475 ins => [ "base", "index", "mem", "left", "right" ],
477 emit => '. and%M %binop',
480 modified_flags => $status_flags
485 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
486 ins => [ "base", "index", "mem", "val" ],
487 emit => '. and%M %SI3, %AM',
490 modified_flags => $status_flags
495 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
496 ins => [ "base", "index", "mem", "val" ],
497 emit => '. and%M %SB3, %AM',
500 modified_flags => $status_flags
505 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
506 ins => [ "base", "index", "mem", "left", "right" ],
508 emit => '. or%M %binop',
511 modified_flags => $status_flags
516 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
517 ins => [ "base", "index", "mem", "val" ],
518 emit => '. or%M %SI3, %AM',
521 modified_flags => $status_flags
526 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
527 ins => [ "base", "index", "mem", "val" ],
528 emit => '. or%M %SB3, %AM',
531 modified_flags => $status_flags
536 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
537 ins => [ "base", "index", "mem", "left", "right" ],
539 emit => '. xor%M %binop',
542 modified_flags => $status_flags
547 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
548 ins => [ "base", "index", "mem", "val" ],
549 emit => '. xor%M %SI3, %AM',
552 modified_flags => $status_flags
557 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
558 ins => [ "base", "index", "mem", "val" ],
559 emit => '. xor%M %SB3, %AM',
562 modified_flags => $status_flags
565 # not commutative operations
569 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4", "none", "flags" ] },
570 ins => [ "base", "index", "mem", "left", "right" ],
572 emit => '. sub%M %binop',
575 modified_flags => $status_flags
580 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
581 ins => [ "base", "index", "mem", "val" ],
582 emit => '. sub%M %SI3, %AM',
585 modified_flags => $status_flags
590 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
591 ins => [ "base", "index", "mem", "val" ],
592 emit => '. sub%M %SB3, %AM',
595 modified_flags => $status_flags
599 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 !in_r5" ] },
600 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
602 emit => '. sbb%M %binop',
605 modified_flags => $status_flags
609 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
610 ins => [ "left", "right" ],
614 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
615 ins => [ "left", "right", "eflags" ],
620 state => "exc_pinned",
621 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
622 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
623 outs => [ "div_res", "mod_res", "M" ],
624 attr => "ia32_op_flavour_t dm_flav",
625 am => "source,ternary",
626 init_attr => "attr->data.op_flav = dm_flav;",
627 emit => ". idiv%M %unop5",
630 modified_flags => $status_flags
635 state => "exc_pinned",
636 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
637 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
638 outs => [ "div_res", "mod_res", "M" ],
639 attr => "ia32_op_flavour_t dm_flav",
640 am => "source,ternary",
641 init_attr => "attr->data.op_flav = dm_flav;",
642 emit => ". div%M %unop5",
645 modified_flags => $status_flags
650 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
651 ins => [ "left", "right" ],
653 emit => '. shl %SB1, %S0',
656 modified_flags => $status_flags
661 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
662 ins => [ "base", "index", "mem", "count" ],
663 emit => '. shl%M %SB3, %AM',
666 modified_flags => $status_flags
670 cmp_attr => "return 1;",
671 # value, cnt, dependency
676 # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shl
678 # Out requirements is: different from all in
679 # This is because, out must be different from LowPart and ShiftCount.
680 # We could say "!ecx !in_r4" but it can occur, that all values live through
681 # this Shift and the only value dying is the ShiftCount. Then there would be a
682 # register missing, as result must not be ecx and all other registers are
683 # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
684 # (and probably never will). So we create artificial interferences of the result
685 # with all inputs, so the spiller can always assure a free register.
686 # reg_req => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
689 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
690 ins => [ "left_high", "left_low", "right" ],
691 am => "dest,ternary",
692 emit => '. shld%M %SB2, %S1, %S0',
696 modified_flags => $status_flags
700 cmp_attr => "return 1;",
706 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
707 ins => [ "val", "count" ],
709 emit => '. shr %SB1, %S0',
712 modified_flags => $status_flags
717 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
718 ins => [ "base", "index", "mem", "count" ],
719 emit => '. shr%M %SB3, %AM',
722 modified_flags => $status_flags
726 cmp_attr => "return 1;",
727 # value, cnt, dependency
732 # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shr
734 # Out requirements is: different from all in
735 # This is because, out must be different from LowPart and ShiftCount.
736 # We could say "!ecx !in_r4" but it can occur, that all values live through
737 # this Shift and the only value dying is the ShiftCount. Then there would be a
738 # register missing, as result must not be ecx and all other registers are
739 # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
740 # (and probably never will). So we create artificial interferences of the result
741 # with all inputs, so the spiller can always assure a free register.
742 # reg_req => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
745 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
746 ins => [ "left_high", "left_low", "right" ],
747 am => "dest,ternary",
748 emit => '. shrd%M %SB2, %S1, %S0',
752 modified_flags => $status_flags
756 cmp_attr => "return 1;",
762 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
763 ins => [ "val", "count" ],
765 emit => '. sar %SB1, %S0',
768 modified_flags => $status_flags
773 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
774 ins => [ "base", "index", "mem", "count" ],
775 emit => '. sar%M %SB3, %AM',
778 modified_flags => $status_flags
782 cmp_attr => "return 1;",
788 cmp_attr => "return 1;",
789 # value, cnt, dependency
795 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
796 ins => [ "val", "count" ],
798 emit => '. ror %SB1, %S0',
801 modified_flags => $status_flags
806 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
807 ins => [ "base", "index", "mem", "count" ],
808 emit => '. ror%M %SB3, %AM',
811 modified_flags => $status_flags
816 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
817 ins => [ "val", "count" ],
819 emit => '. rol %SB1, %S0',
822 modified_flags => $status_flags
827 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
828 ins => [ "base", "index", "mem", "count" ],
829 emit => '. rol%M %SB3, %AM',
832 modified_flags => $status_flags
839 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
845 modified_flags => $status_flags
850 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
851 ins => [ "base", "index", "mem" ],
852 emit => '. neg%M %AM',
855 modified_flags => $status_flags
860 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
861 outs => [ "low_res", "high_res" ],
863 modified_flags => $status_flags
868 cmp_attr => "return 1;",
874 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
879 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
884 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
885 ins => [ "base", "index", "mem" ],
886 emit => '. inc%M %AM',
889 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
894 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
899 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
904 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
905 ins => [ "base", "index", "mem" ],
906 emit => '. dec%M %AM',
909 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
914 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
924 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
925 ins => [ "base", "index", "mem" ],
926 emit => '. not%M %AM',
935 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
936 ins => [ "base", "index", "mem", "left", "right" ],
937 outs => [ "eflags" ],
938 am => "source,binary",
939 emit => '. cmp%M %binop_nores',
940 attr => "int flipped, int cmp_unsigned",
941 init_attr => "attr->data.cmp_flipped = flipped;\n".
942 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
946 modified_flags => $status_flags
951 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
952 ins => [ "base", "index", "mem", "left", "right" ],
953 outs => [ "eflags" ],
954 am => "source,binary",
955 emit => '. cmpb %binop_nores',
956 attr => "int flipped, int cmp_unsigned",
957 init_attr => "attr->data.cmp_flipped = flipped;\n".
958 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
962 modified_flags => $status_flags
967 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
968 ins => [ "base", "index", "mem", "left", "right" ],
969 outs => [ "eflags" ],
970 am => "source,binary",
971 emit => '. test%M %binop_nores',
972 attr => "int flipped, int cmp_unsigned",
973 init_attr => "attr->data.cmp_flipped = flipped;\n".
974 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
978 modified_flags => $status_flags
983 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
984 ins => [ "base", "index", "mem", "left", "right" ],
985 outs => [ "eflags" ],
986 am => "source,binary",
987 emit => '. testb %binop_nores',
988 attr => "int flipped, int cmp_unsigned",
989 init_attr => "attr->data.cmp_flipped = flipped;\n".
990 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
994 modified_flags => $status_flags
999 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1000 ins => [ "eflags" ],
1002 attr => "pn_Cmp pnc",
1003 init_attr => "attr->pn_code = pnc;\nset_ia32_ls_mode(res, mode_Bu);\n",
1004 emit => '. set%CMP0 %DB0',
1012 # (note: leave the false,true order intact to make it compatible with other
1014 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4" ] },
1015 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1016 am => "source,binary",
1017 attr => "pn_Cmp pn_code",
1018 init_attr => "attr->pn_code = pn_code;",
1026 op_flags => "L|X|Y",
1027 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1028 ins => [ "eflags" ],
1029 outs => [ "false", "true" ],
1030 attr => "pn_Cmp pnc",
1031 init_attr => "attr->pn_code = pnc;",
1033 units => [ "BRANCH" ],
1038 op_flags => "L|X|Y",
1039 reg_req => { in => [ "gp" ], out => [ "none" ] },
1041 units => [ "BRANCH" ],
1043 modified_flags => $status_flags
1049 reg_req => { in => [ "gp" ] },
1050 emit => '. jmp *%S0',
1051 units => [ "BRANCH" ],
1058 reg_req => { out => [ "gp" ] },
1060 attr => "ir_entity *symconst, int symconst_sign, long offset",
1061 attr_type => "ia32_immediate_attr_t",
1063 # depends on the const and is set in ia32_transform
1064 # modified_flags => $status_flags
1071 reg_req => { out => [ "gp_UKNWN" ] },
1081 reg_req => { out => [ "vfp_UKNWN" ] },
1085 attr_type => "ia32_x87_attr_t",
1092 reg_req => { out => [ "xmm_UKNWN" ] },
1102 reg_req => { out => [ "gp_NOREG" ] },
1112 reg_req => { out => [ "vfp_NOREG" ] },
1116 attr_type => "ia32_x87_attr_t",
1123 reg_req => { out => [ "xmm_NOREG" ] },
1133 reg_req => { out => [ "fp_cw" ] },
1137 modified_flags => $fpcw_flags
1143 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1144 ins => [ "base", "index", "mem" ],
1146 emit => ". fldcw %AM",
1149 modified_flags => $fpcw_flags
1155 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1156 ins => [ "base", "index", "mem", "fpcw" ],
1158 emit => ". fnstcw %AM",
1164 # we should not rematrialize this node. It has very strict constraints.
1165 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1166 ins => [ "val", "globbered" ],
1174 # Note that we add additional latency values depending on address mode, so a
1175 # lateny of 0 for load is correct
1179 state => "exc_pinned",
1180 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1181 ins => [ "base", "index", "mem" ],
1182 outs => [ "res", "M" ],
1184 emit => ". mov%SE%ME%.l %AM, %D0",
1190 cmp_attr => "return 1;",
1191 outs => [ "res", "M" ],
1197 cmp_attr => "return 1;",
1198 state => "exc_pinned",
1205 state => "exc_pinned",
1206 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1207 ins => [ "base", "index", "mem", "val" ],
1208 emit => '. mov%M %SI3, %AM',
1216 state => "exc_pinned",
1217 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1218 ins => [ "base", "index", "mem", "val" ],
1219 emit => '. mov%M %SB3, %AM',
1227 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1228 ins => [ "base", "index" ],
1229 emit => '. leal %AM, %D0',
1233 # well this isn't true for Lea, but we often transform Lea back to Add, Inc
1234 # or Dec, so we set the flag
1235 modified_flags => 1,
1239 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1240 ins => [ "base", "index", "mem", "val", "stack" ],
1241 emit => '. push%M %unop3',
1242 outs => [ "stack:I|S", "M" ],
1243 am => "source,binary",
1249 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "esp", "gp", "none" ] },
1250 emit => '. pop%M %DAM1',
1251 outs => [ "stack:I|S", "res", "M" ],
1252 ins => [ "base", "index", "mem", "stack" ],
1254 latency => 3, # Pop is more expensive than Push on Athlon
1259 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1261 outs => [ "frame:I", "stack:I|S", "M" ],
1267 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1269 outs => [ "frame:I", "stack:I|S" ],
1277 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1278 ins => [ "base", "index", "mem", "stack", "size" ],
1279 am => "source,binary",
1280 emit => '. addl %binop',
1281 outs => [ "stack:S", "M" ],
1283 modified_flags => $status_flags
1289 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1290 ins => [ "base", "index", "mem", "stack", "size" ],
1291 am => "source,binary",
1292 emit => ". subl %binop\n".
1293 ". movl %%esp, %D1",
1294 outs => [ "stack:I|S", "addr", "M" ],
1296 modified_flags => $status_flags
1301 reg_req => { out => [ "gp" ] },
1305 # the int instruction
1307 reg_req => { in => [ "gp" ], out => [ "none" ] },
1309 emit => '. int %SI0',
1311 cmp_attr => "return 1;",
1315 #-----------------------------------------------------------------------------#
1316 # _____ _____ ______ __ _ _ _ #
1317 # / ____/ ____| ____| / _| | | | | | #
1318 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1319 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1320 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1321 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1322 #-----------------------------------------------------------------------------#
1326 reg_req => { out => [ "xmm" ] },
1327 emit => '. xorp%XSD %D0, %D0',
1333 # commutative operations
1337 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1338 ins => [ "base", "index", "mem", "left", "right" ],
1339 emit => '. add%XXM %binop',
1347 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1348 ins => [ "base", "index", "mem", "left", "right" ],
1349 emit => '. mul%XXM %binop',
1357 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1358 ins => [ "base", "index", "mem", "left", "right" ],
1359 emit => '. max%XXM %binop',
1367 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1368 ins => [ "base", "index", "mem", "left", "right" ],
1369 emit => '. min%XXM %binop',
1377 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1378 ins => [ "base", "index", "mem", "left", "right" ],
1379 emit => '. andp%XSD %binop',
1387 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1388 ins => [ "base", "index", "mem", "left", "right" ],
1389 emit => '. orp%XSD %binop',
1396 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1397 ins => [ "base", "index", "mem", "left", "right" ],
1398 emit => '. xorp%XSD %binop',
1404 # not commutative operations
1408 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1409 ins => [ "base", "index", "mem", "left", "right" ],
1410 emit => '. andnp%XSD %binop',
1418 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1419 ins => [ "base", "index", "mem", "left", "right" ],
1420 emit => '. sub%XXM %binop',
1428 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1429 ins => [ "base", "index", "mem", "left", "right" ],
1430 outs => [ "res", "M" ],
1431 emit => '. div%XXM %binop',
1440 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1441 ins => [ "base", "index", "mem", "left", "right" ],
1442 outs => [ "flags" ],
1443 am => "source,binary",
1444 attr => "int flipped",
1445 init_attr => "attr->data.cmp_flipped = flipped;",
1446 emit => ' .ucomi%XXM %binop_nores',
1449 mode => $mode_flags,
1450 modified_flags => 1,
1457 state => "exc_pinned",
1458 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1459 ins => [ "base", "index", "mem" ],
1460 emit => '. mov%XXM %AM, %D0',
1461 attr => "ir_mode *load_mode",
1462 init_attr => "attr->ls_mode = load_mode;",
1463 outs => [ "res", "M" ],
1470 state => "exc_pinned",
1471 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1472 ins => [ "base", "index", "mem", "val" ],
1473 emit => '. mov%XXM %S3, %AM',
1481 state => "exc_pinned",
1482 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1483 ins => [ "base", "index", "mem", "val" ],
1484 emit => '. mov%XXM %S3, %AM',
1492 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1493 ins => [ "base", "index", "mem", "val" ],
1494 emit => '. cvtsi2ss %D0, %AM',
1502 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1503 ins => [ "base", "index", "mem", "val" ],
1504 emit => '. cvtsi2sd %unop3',
1513 cmp_attr => "return 1;",
1519 cmp_attr => "return 1;",
1528 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1529 outs => [ "DST", "SRC", "CNT", "M" ],
1531 # we don't care about this flag, so no need to mark this node
1532 # modified_flags => [ "DF" ]
1538 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1539 outs => [ "DST", "SRC", "M" ],
1541 # we don't care about this flag, so no need to mark this node
1542 # modified_flags => [ "DF" ]
1548 state => "exc_pinned",
1549 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1550 ins => [ "base", "index", "mem", "val" ],
1552 attr => "ir_mode *smaller_mode",
1553 init_attr => "attr->ls_mode = smaller_mode;",
1558 state => "exc_pinned",
1559 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1560 ins => [ "base", "index", "mem", "val" ],
1562 attr => "ir_mode *smaller_mode",
1563 init_attr => "attr->ls_mode = smaller_mode;",
1568 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1569 ins => [ "base", "index", "mem", "val" ],
1576 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1577 ins => [ "base", "index", "mem", "val" ],
1584 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1585 ins => [ "base", "index", "mem", "val" ],
1591 #----------------------------------------------------------#
1593 # (_) | | | | / _| | | | #
1594 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1595 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1596 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1597 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1599 # _ __ ___ __| | ___ ___ #
1600 # | '_ \ / _ \ / _` |/ _ \/ __| #
1601 # | | | | (_) | (_| | __/\__ \ #
1602 # |_| |_|\___/ \__,_|\___||___/ #
1603 #----------------------------------------------------------#
1607 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1608 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1612 attr_type => "ia32_x87_attr_t",
1617 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1618 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1622 attr_type => "ia32_x87_attr_t",
1627 cmp_attr => "return 1;",
1633 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1634 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1638 attr_type => "ia32_x87_attr_t",
1642 cmp_attr => "return 1;",
1647 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1648 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1649 outs => [ "res", "M" ],
1652 attr_type => "ia32_x87_attr_t",
1656 cmp_attr => "return 1;",
1657 outs => [ "res", "M" ],
1662 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1663 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1667 attr_type => "ia32_x87_attr_t",
1671 cmp_attr => "return 1;",
1677 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1682 attr_type => "ia32_x87_attr_t",
1687 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1692 attr_type => "ia32_x87_attr_t",
1695 # virtual Load and Store
1699 state => "exc_pinned",
1700 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1701 ins => [ "base", "index", "mem" ],
1702 outs => [ "res", "M" ],
1703 attr => "ir_mode *load_mode",
1704 init_attr => "attr->attr.ls_mode = load_mode;",
1707 attr_type => "ia32_x87_attr_t",
1712 state => "exc_pinned",
1713 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1714 ins => [ "base", "index", "mem", "val" ],
1715 attr => "ir_mode *store_mode",
1716 init_attr => "attr->attr.ls_mode = store_mode;",
1720 attr_type => "ia32_x87_attr_t",
1726 state => "exc_pinned",
1727 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1728 outs => [ "res", "M" ],
1729 ins => [ "base", "index", "mem" ],
1732 attr_type => "ia32_x87_attr_t",
1736 cmp_attr => "return 1;",
1737 outs => [ "res", "M" ],
1742 state => "exc_pinned",
1743 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1744 ins => [ "base", "index", "mem", "val", "fpcw" ],
1748 attr_type => "ia32_x87_attr_t",
1752 cmp_attr => "return 1;",
1753 state => "exc_pinned",
1763 reg_req => { out => [ "vfp" ] },
1767 attr_type => "ia32_x87_attr_t",
1772 reg_req => { out => [ "vfp" ] },
1776 attr_type => "ia32_x87_attr_t",
1781 reg_req => { out => [ "vfp" ] },
1785 attr_type => "ia32_x87_attr_t",
1790 reg_req => { out => [ "vfp" ] },
1794 attr_type => "ia32_x87_attr_t",
1799 reg_req => { out => [ "vfp" ] },
1803 attr_type => "ia32_x87_attr_t",
1808 reg_req => { out => [ "vfp" ] },
1812 attr_type => "ia32_x87_attr_t",
1817 reg_req => { out => [ "vfp" ] },
1821 attr_type => "ia32_x87_attr_t",
1827 # we can't allow to rematerialize this node so we don't have
1828 # accidently produce Phi(Fucom, Fucom(flipped))
1830 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1831 ins => [ "left", "right" ],
1832 outs => [ "flags" ],
1833 am => "source,binary",
1834 attr => "int flipped",
1835 init_attr => "attr->attr.data.cmp_flipped = flipped;",
1838 attr_type => "ia32_x87_attr_t",
1844 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
1846 outs => [ "flags" ],
1849 mode => $mode_flags,
1852 #------------------------------------------------------------------------#
1853 # ___ _____ __ _ _ _ #
1854 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1855 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1856 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1857 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1858 #------------------------------------------------------------------------#
1860 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1861 # are swapped, we work this around in the emitter...
1865 rd_constructor => "NONE",
1867 emit => '. fadd%XM %x87_binop',
1868 attr_type => "ia32_x87_attr_t",
1873 rd_constructor => "NONE",
1875 emit => '. faddp%XM %x87_binop',
1876 attr_type => "ia32_x87_attr_t",
1881 rd_constructor => "NONE",
1883 emit => '. fmul%XM %x87_binop',
1884 attr_type => "ia32_x87_attr_t",
1889 rd_constructor => "NONE",
1891 emit => '. fmulp%XM %x87_binop',,
1892 attr_type => "ia32_x87_attr_t",
1897 rd_constructor => "NONE",
1899 emit => '. fsub%XM %x87_binop',
1900 attr_type => "ia32_x87_attr_t",
1905 rd_constructor => "NONE",
1907 # see note about gas bugs
1908 emit => '. fsubrp%XM %x87_binop',
1909 attr_type => "ia32_x87_attr_t",
1914 rd_constructor => "NONE",
1917 emit => '. fsubr%XM %x87_binop',
1918 attr_type => "ia32_x87_attr_t",
1923 rd_constructor => "NONE",
1926 # see note about gas bugs
1927 emit => '. fsubp%XM %x87_binop',
1928 attr_type => "ia32_x87_attr_t",
1933 rd_constructor => "NONE",
1936 attr_type => "ia32_x87_attr_t",
1939 # this node is just here, to keep the simulator running
1940 # we can omit this when a fprem simulation function exists
1943 rd_constructor => "NONE",
1946 attr_type => "ia32_x87_attr_t",
1951 rd_constructor => "NONE",
1953 emit => '. fdiv%XM %x87_binop',
1954 attr_type => "ia32_x87_attr_t",
1959 rd_constructor => "NONE",
1961 # see note about gas bugs
1962 emit => '. fdivrp%XM %x87_binop',
1963 attr_type => "ia32_x87_attr_t",
1968 rd_constructor => "NONE",
1970 emit => '. fdivr%XM %x87_binop',
1971 attr_type => "ia32_x87_attr_t",
1976 rd_constructor => "NONE",
1978 # see note about gas bugs
1979 emit => '. fdivp%XM %x87_binop',
1980 attr_type => "ia32_x87_attr_t",
1985 rd_constructor => "NONE",
1988 attr_type => "ia32_x87_attr_t",
1993 rd_constructor => "NONE",
1996 attr_type => "ia32_x87_attr_t",
1999 # x87 Load and Store
2002 rd_constructor => "NONE",
2003 op_flags => "R|L|F",
2004 state => "exc_pinned",
2006 emit => '. fld%XM %AM',
2007 attr_type => "ia32_x87_attr_t",
2011 rd_constructor => "NONE",
2012 op_flags => "R|L|F",
2013 state => "exc_pinned",
2015 emit => '. fst%XM %AM',
2017 attr_type => "ia32_x87_attr_t",
2021 rd_constructor => "NONE",
2022 op_flags => "R|L|F",
2023 state => "exc_pinned",
2025 emit => '. fstp%XM %AM',
2027 attr_type => "ia32_x87_attr_t",
2034 rd_constructor => "NONE",
2036 emit => '. fild%M %AM',
2037 attr_type => "ia32_x87_attr_t",
2042 state => "exc_pinned",
2043 rd_constructor => "NONE",
2045 emit => '. fist%M %AM',
2047 attr_type => "ia32_x87_attr_t",
2052 state => "exc_pinned",
2053 rd_constructor => "NONE",
2055 emit => '. fistp%M %AM',
2057 attr_type => "ia32_x87_attr_t",
2063 op_flags => "R|c|K",
2067 attr_type => "ia32_x87_attr_t",
2071 op_flags => "R|c|K",
2075 attr_type => "ia32_x87_attr_t",
2079 op_flags => "R|c|K",
2083 attr_type => "ia32_x87_attr_t",
2087 op_flags => "R|c|K",
2091 attr_type => "ia32_x87_attr_t",
2095 op_flags => "R|c|K",
2099 attr_type => "ia32_x87_attr_t",
2103 op_flags => "R|c|K",
2106 emit => '. fldll2t',
2107 attr_type => "ia32_x87_attr_t",
2111 op_flags => "R|c|K",
2115 attr_type => "ia32_x87_attr_t",
2119 # Note that it is NEVER allowed to do CSE on these nodes
2120 # Moreover, note the virtual register requierements!
2125 cmp_attr => "return 1;",
2126 emit => '. fxch %X0',
2127 attr_type => "ia32_x87_attr_t",
2133 cmp_attr => "return 1;",
2134 emit => '. fld %X0',
2135 attr_type => "ia32_x87_attr_t",
2140 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2141 cmp_attr => "return 1;",
2142 emit => '. fld %X0',
2143 attr_type => "ia32_x87_attr_t",
2149 cmp_attr => "return 1;",
2150 emit => '. fstp %X0',
2151 attr_type => "ia32_x87_attr_t",
2157 cmp_attr => "return 1;",
2158 emit => '. ffreep %X0',
2159 attr_type => "ia32_x87_attr_t",
2165 cmp_attr => "return 1;",
2167 attr_type => "ia32_x87_attr_t",
2173 cmp_attr => "return 1;",
2175 attr_type => "ia32_x87_attr_t",
2183 emit => ". fucom %X1\n".
2185 attr_type => "ia32_x87_attr_t",
2191 emit => ". fucomp %X1\n".
2193 attr_type => "ia32_x87_attr_t",
2199 emit => ". fucompp\n".
2201 attr_type => "ia32_x87_attr_t",
2205 # -------------------------------------------------------------------------------- #
2206 # ____ ____ _____ _ _ #
2207 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2208 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2209 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2210 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2212 # -------------------------------------------------------------------------------- #
2215 # Spilling and reloading of SSE registers, hardcoded, not generated #
2219 state => "exc_pinned",
2220 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2221 emit => '. movdqu %D0, %AM',
2222 outs => [ "res", "M" ],
2228 state => "exc_pinned",
2229 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2230 ins => [ "base", "index", "mem", "val" ],
2231 emit => '. movdqu %binop',
2238 # Include the generated SIMD node specification written by the SIMD optimization
2239 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2240 unless ($return = do $my_script_name) {
2241 warn "couldn't parse $my_script_name: $@" if $@;
2242 warn "couldn't do $my_script_name: $!" unless defined $return;
2243 warn "couldn't run $my_script_name" unless $return;