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 => "eax", type => 1 },
114 { name => "edx", type => 1 },
115 { name => "ebx", type => 2 },
116 { name => "ecx", type => 1 },
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(env, node, 0);",
197 S1 => "${arch}_emit_source_register(env, node, 1);",
198 S2 => "${arch}_emit_source_register(env, node, 2);",
199 S3 => "${arch}_emit_source_register(env, node, 3);",
200 S4 => "${arch}_emit_source_register(env, node, 4);",
201 S5 => "${arch}_emit_source_register(env, node, 5);",
202 SB1 => "${arch}_emit_8bit_source_register(env, node, 1);",
203 SB2 => "${arch}_emit_8bit_source_register(env, node, 2);",
204 SB3 => "${arch}_emit_8bit_source_register(env, node, 3);",
205 SW0 => "${arch}_emit_16bit_source_register(env, node, 0);",
206 SI0 => "${arch}_emit_source_register_or_immediate(env, node, 0);",
207 SI1 => "${arch}_emit_source_register_or_immediate(env, node, 1);",
208 SI2 => "${arch}_emit_source_register_or_immediate(env, node, 2);",
209 SI3 => "${arch}_emit_source_register_or_immediate(env, node, 3);",
210 D0 => "${arch}_emit_dest_register(env, node, 0);",
211 D1 => "${arch}_emit_dest_register(env, node, 1);",
212 D2 => "${arch}_emit_dest_register(env, node, 2);",
213 D3 => "${arch}_emit_dest_register(env, node, 3);",
214 D4 => "${arch}_emit_dest_register(env, node, 4);",
215 D5 => "${arch}_emit_dest_register(env, node, 5);",
216 DB0 => "${arch}_emit_8bit_dest_register(env, node, 0);",
217 X0 => "${arch}_emit_x87_name(env, node, 0);",
218 X1 => "${arch}_emit_x87_name(env, node, 1);",
219 X2 => "${arch}_emit_x87_name(env, node, 2);",
220 SE => "${arch}_emit_extend_suffix(env, get_ia32_ls_mode(node));",
221 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
222 ia32_emit_mode_suffix(env, node);",
223 M => "${arch}_emit_mode_suffix(env, node);",
224 XM => "${arch}_emit_x87_mode_suffix(env, node);",
225 XXM => "${arch}_emit_xmm_mode_suffix(env, node);",
226 XSD => "${arch}_emit_xmm_mode_suffix_s(env, node);",
227 AM => "${arch}_emit_am(env, node);",
228 unop0 => "${arch}_emit_unop(env, node, 0);",
229 unop1 => "${arch}_emit_unop(env, node, 1);",
230 unop2 => "${arch}_emit_unop(env, node, 2);",
231 unop3 => "${arch}_emit_unop(env, node, 3);",
232 unop4 => "${arch}_emit_unop(env, node, 4);",
233 unop5 => "${arch}_emit_unop(env, node, 5);",
234 DAM0 => "${arch}_emit_am_or_dest_register(env, node, 0);",
235 DAM1 => "${arch}_emit_am_or_dest_register(env, node, 1);",
236 binop => "${arch}_emit_binop(env, node, 1);",
237 binop_nores => "${arch}_emit_binop(env, node, 0);",
238 x87_binop => "${arch}_emit_x87_binop(env, node);",
239 CMP0 => "${arch}_emit_cmp_suffix_node(env, node, 0);",
242 #--------------------------------------------------#
245 # _ __ _____ __ _ _ __ ___ _ __ ___ #
246 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
247 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
248 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
251 #--------------------------------------------------#
253 $default_attr_type = "ia32_attr_t";
254 $default_copy_attr = "ia32_copy_attr";
256 sub ia32_custom_init_attr {
260 if(defined($node->{modified_flags})) {
261 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
263 if(defined($node->{am})) {
264 my $am = $node->{am};
265 if($am eq "full,binary") {
266 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
267 } elsif($am eq "full,unary") {
268 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
269 } elsif($am eq "source,binary") {
270 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
271 } elsif($am eq "dest,unary") {
272 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
273 } elsif($am eq "dest,binary") {
274 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
275 } elsif($am eq "dest,ternary") {
276 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
277 } elsif($am eq "source,ternary") {
278 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
279 } elsif($am eq "none") {
282 die("Invalid address mode '$am' specified on op $name");
287 $custom_init_attr_func = \&ia32_custom_init_attr;
290 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
292 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
293 "\tinit_ia32_x87_attributes(res);",
295 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
296 "\tinit_ia32_x87_attributes(res);".
297 "\tinit_ia32_asm_attributes(res);",
298 ia32_immediate_attr_t =>
299 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
300 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);"
304 ia32_attr_t => "ia32_compare_nodes_attr",
305 ia32_x87_attr_t => "ia32_compare_x87_attr",
306 ia32_asm_attr_t => "ia32_compare_asm_attr",
307 ia32_immediate_attr_t => "ia32_compare_immediate_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",
345 reg_req => { out => [ "gp" ] },
350 cmp_attr => "return 1;",
353 #-----------------------------------------------------------------#
356 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
357 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
358 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
359 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
362 #-----------------------------------------------------------------#
364 # commutative operations
368 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4", "none", "flags" ] },
369 ins => [ "base", "index", "mem", "left", "right" ],
370 emit => '. add%M %binop',
374 modified_flags => $status_flags
379 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
380 ins => [ "base", "index", "mem", "val" ],
381 emit => ". add%M %SI3, %AM",
384 modified_flags => $status_flags
389 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
390 ins => [ "base", "index", "mem", "val" ],
391 emit => ". add%M %SB3, %AM",
394 modified_flags => $status_flags
398 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4" ] },
399 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
400 emit => '. adc%M %binop',
404 modified_flags => $status_flags
409 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
410 ins => [ "left", "right" ],
414 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
415 ins => [ "left", "right", "eflags" ],
421 reg_req => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
428 outs => [ "low_res", "high_res" ],
430 modified_flags => $status_flags
434 # we should not rematrialize this node. It produces 2 results and has
435 # very strict constrains
436 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
437 ins => [ "base", "index", "mem", "val_high", "val_low" ],
438 emit => '. mul%M %unop4',
439 outs => [ "EAX", "EDX", "M" ],
440 am => "source,binary",
443 modified_flags => $status_flags
447 # we should not rematrialize this node. It produces 2 results and has
448 # very strict constrains
450 cmp_attr => "return 1;",
451 outs => [ "EAX", "EDX", "M" ],
457 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4" ] },
458 ins => [ "base", "index", "mem", "left", "right" ],
459 emit => '. imul%M %binop',
460 am => "source,binary",
464 modified_flags => $status_flags
469 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
470 ins => [ "base", "index", "mem", "val_high", "val_low" ],
471 emit => '. imul%M %unop4',
472 outs => [ "EAX", "EDX", "M" ],
473 am => "source,binary",
476 modified_flags => $status_flags
480 # we should not rematrialize this node. It produces 2 results and has
481 # very strict constrains
483 cmp_attr => "return 1;",
484 outs => [ "EAX", "EDX", "M" ],
490 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4" ] },
491 ins => [ "base", "index", "mem", "left", "right" ],
493 emit => '. and%M %binop',
496 modified_flags => $status_flags
501 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
502 ins => [ "base", "index", "mem", "val" ],
503 emit => '. and%M %SI3, %AM',
506 modified_flags => $status_flags
511 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
512 ins => [ "base", "index", "mem", "val" ],
513 emit => '. and%M %SB3, %AM',
516 modified_flags => $status_flags
521 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4" ] },
522 ins => [ "base", "index", "mem", "left", "right" ],
524 emit => '. or%M %binop',
527 modified_flags => $status_flags
532 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
533 ins => [ "base", "index", "mem", "val" ],
534 emit => '. or%M %SI3, %AM',
537 modified_flags => $status_flags
542 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
543 ins => [ "base", "index", "mem", "val" ],
544 emit => '. or%M %SB3, %AM',
547 modified_flags => $status_flags
552 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4" ] },
553 ins => [ "base", "index", "mem", "left", "right" ],
555 emit => '. xor%M %binop',
558 modified_flags => $status_flags
563 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
564 ins => [ "base", "index", "mem", "val" ],
565 emit => '. xor%M %SI3, %AM',
568 modified_flags => $status_flags
573 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
574 ins => [ "base", "index", "mem", "val" ],
575 emit => '. xor%M %SB3, %AM',
578 modified_flags => $status_flags
581 # not commutative operations
585 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4" ] },
586 ins => [ "base", "index", "mem", "left", "right" ],
588 emit => '. sub%M %binop',
591 modified_flags => $status_flags
596 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
597 ins => [ "base", "index", "mem", "val" ],
598 emit => '. sub%M %SI3, %AM',
601 modified_flags => $status_flags
606 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
607 ins => [ "base", "index", "mem", "val" ],
608 emit => '. sub%M %SB3, %AM',
611 modified_flags => $status_flags
615 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 !in_r5" ] },
616 ins => [ "base", "index", "mem", "left", "right" ],
618 emit => '. sbb%M %binop',
621 modified_flags => $status_flags
627 reg_req => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
634 outs => [ "low_res", "high_res" ],
636 modified_flags => $status_flags
641 state => "exc_pinned",
642 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
643 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
644 outs => [ "div_res", "mod_res", "M" ],
645 attr => "ia32_op_flavour_t dm_flav",
646 am => "source,ternary",
647 init_attr => "attr->data.op_flav = dm_flav;",
648 emit => ". idiv%M %unop5",
651 modified_flags => $status_flags
656 state => "exc_pinned",
657 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
658 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
659 outs => [ "div_res", "mod_res", "M" ],
660 attr => "ia32_op_flavour_t dm_flav",
661 am => "source,ternary",
662 init_attr => "attr->data.op_flav = dm_flav;",
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" ],
674 emit => '. shl %SB1, %S0',
677 modified_flags => $status_flags
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
697 # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shl
699 # Out requirements is: different from all in
700 # This is because, out must be different from LowPart and ShiftCount.
701 # We could say "!ecx !in_r4" but it can occur, that all values live through
702 # this Shift and the only value dying is the ShiftCount. Then there would be a
703 # register missing, as result must not be ecx and all other registers are
704 # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
705 # (and probably never will). So we create artificial interferences of the result
706 # with all inputs, so the spiller can always assure a free register.
707 # reg_req => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
710 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
711 ins => [ "left_high", "left_low", "right" ],
712 am => "dest,ternary",
713 emit => '. shld%M %SB2, %S1, %S0',
717 modified_flags => $status_flags
721 cmp_attr => "return 1;",
727 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
728 ins => [ "val", "count" ],
730 emit => '. shr %SB1, %S0',
733 modified_flags => $status_flags
738 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
739 ins => [ "base", "index", "mem", "count" ],
740 emit => '. shr%M %SB3, %AM',
743 modified_flags => $status_flags
747 cmp_attr => "return 1;",
748 # value, cnt, dependency
753 # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shr
755 # Out requirements is: different from all in
756 # This is because, out must be different from LowPart and ShiftCount.
757 # We could say "!ecx !in_r4" but it can occur, that all values live through
758 # this Shift and the only value dying is the ShiftCount. Then there would be a
759 # register missing, as result must not be ecx and all other registers are
760 # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
761 # (and probably never will). So we create artificial interferences of the result
762 # with all inputs, so the spiller can always assure a free register.
763 # reg_req => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
766 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
767 ins => [ "left_high", "left_low", "right" ],
768 am => "dest,ternary",
769 emit => '. shrd%M %SB2, %S1, %S0',
773 modified_flags => $status_flags
777 cmp_attr => "return 1;",
783 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
784 ins => [ "val", "count" ],
786 emit => '. sar %SB1, %S0',
789 modified_flags => $status_flags
794 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
795 ins => [ "base", "index", "mem", "count" ],
796 emit => '. sar%M %SB3, %AM',
799 modified_flags => $status_flags
803 cmp_attr => "return 1;",
809 cmp_attr => "return 1;",
810 # value, cnt, dependency
816 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
817 ins => [ "val", "count" ],
819 emit => '. ror %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 => '. ror%M %SB3, %AM',
832 modified_flags => $status_flags
837 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
838 ins => [ "val", "count" ],
840 emit => '. rol %SB1, %S0',
843 modified_flags => $status_flags
848 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
849 ins => [ "base", "index", "mem", "count" ],
850 emit => '. rol%M %SB3, %AM',
853 modified_flags => $status_flags
860 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
866 modified_flags => $status_flags
871 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
872 ins => [ "base", "index", "mem" ],
873 emit => '. neg%M %AM',
876 modified_flags => $status_flags
881 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
882 outs => [ "low_res", "high_res" ],
884 modified_flags => $status_flags
889 cmp_attr => "return 1;",
895 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
900 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
905 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
906 ins => [ "base", "index", "mem" ],
907 emit => '. inc%M %AM',
910 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
915 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
920 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
925 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
926 ins => [ "base", "index", "mem" ],
927 emit => '. dec%M %AM',
930 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
935 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
945 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
946 ins => [ "base", "index", "mem" ],
947 emit => '. not%M %AM',
956 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
957 ins => [ "base", "index", "mem", "left", "right" ],
958 outs => [ "eflags" ],
959 am => "source,binary",
960 emit => '. cmp%M %binop_nores',
961 attr => "int flipped, int cmp_unsigned",
962 init_attr => "attr->data.cmp_flipped = flipped;\n".
963 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
967 modified_flags => $status_flags
972 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
973 ins => [ "base", "index", "mem", "left", "right" ],
974 outs => [ "eflags" ],
975 am => "source,binary",
976 emit => '. cmpb %binop_nores',
977 attr => "int flipped, int cmp_unsigned",
978 init_attr => "attr->data.cmp_flipped = flipped;\n".
979 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
983 modified_flags => $status_flags
988 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
989 ins => [ "base", "index", "mem", "left", "right" ],
990 outs => [ "eflags" ],
991 am => "source,binary",
992 emit => '. test%M %binop_nores',
993 attr => "int flipped, int cmp_unsigned",
994 init_attr => "attr->data.cmp_flipped = flipped;\n".
995 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
999 modified_flags => $status_flags
1004 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1005 ins => [ "base", "index", "mem", "left", "right" ],
1006 outs => [ "eflags" ],
1007 am => "source,binary",
1008 emit => '. testb %binop_nores',
1009 attr => "int flipped, int cmp_unsigned",
1010 init_attr => "attr->data.cmp_flipped = flipped;\n".
1011 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1014 mode => $mode_flags,
1015 modified_flags => $status_flags
1020 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1021 ins => [ "eflags" ],
1023 attr => "pn_Cmp pnc",
1024 init_attr => "attr->pn_code = pnc;",
1025 emit => '. set%CMP0 %DB0',
1033 # (note: leave the false,true order intact to make it compatible with other
1035 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4" ] },
1036 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1037 am => "source,binary",
1038 attr => "pn_Cmp pn_code",
1039 init_attr => "attr->pn_code = pn_code;",
1047 op_flags => "L|X|Y",
1048 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1049 ins => [ "eflags" ],
1050 outs => [ "false", "true" ],
1051 attr => "pn_Cmp pnc",
1052 init_attr => "attr->pn_code = pnc;",
1054 units => [ "BRANCH" ],
1059 op_flags => "L|X|Y",
1060 reg_req => { in => [ "gp" ], out => [ "none" ] },
1062 units => [ "BRANCH" ],
1064 modified_flags => $status_flags
1070 reg_req => { in => [ "gp" ] },
1071 emit => '. jmp *%S0',
1072 units => [ "BRANCH" ],
1079 reg_req => { out => [ "gp" ] },
1081 attr => "ir_entity *symconst, int symconst_sign, long offset",
1082 attr_type => "ia32_immediate_attr_t",
1084 # depends on the const and is set in ia32_transform
1085 # modified_flags => $status_flags
1092 reg_req => { out => [ "gp_UKNWN" ] },
1102 reg_req => { out => [ "vfp_UKNWN" ] },
1106 attr_type => "ia32_x87_attr_t",
1113 reg_req => { out => [ "xmm_UKNWN" ] },
1123 reg_req => { out => [ "gp_NOREG" ] },
1133 reg_req => { out => [ "vfp_NOREG" ] },
1137 attr_type => "ia32_x87_attr_t",
1144 reg_req => { out => [ "xmm_NOREG" ] },
1154 reg_req => { out => [ "fp_cw" ] },
1158 modified_flags => $fpcw_flags
1164 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1165 ins => [ "base", "index", "mem" ],
1167 emit => ". fldcw %AM",
1170 modified_flags => $fpcw_flags
1176 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1177 ins => [ "base", "index", "mem", "fpcw" ],
1179 emit => ". fnstcw %AM",
1185 # we should not rematrialize this node. It produces 2 results and has
1186 # very strict constrains
1187 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1188 ins => [ "val", "globbered" ],
1196 # Note that we add additional latency values depending on address mode, so a
1197 # lateny of 0 for load is correct
1201 state => "exc_pinned",
1202 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1203 ins => [ "base", "index", "mem" ],
1204 outs => [ "res", "M" ],
1206 emit => ". mov%SE%ME%.l %AM, %D0",
1212 cmp_attr => "return 1;",
1213 outs => [ "res", "M" ],
1219 cmp_attr => "return 1;",
1220 state => "exc_pinned",
1227 state => "exc_pinned",
1228 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1229 ins => [ "base", "index", "mem", "val" ],
1230 emit => '. mov%M %SI3, %AM',
1238 state => "exc_pinned",
1239 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1240 ins => [ "base", "index", "mem", "val" ],
1241 emit => '. mov%M %SB3, %AM',
1249 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1250 ins => [ "base", "index" ],
1251 emit => '. leal %AM, %D0',
1255 # well this isn't true for Lea, but we often transform Lea back to Add, Inc
1256 # or Dec, so we set the flag
1257 modified_flags => 1,
1261 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1262 ins => [ "base", "index", "mem", "val", "stack" ],
1263 emit => '. push%M %unop3',
1264 outs => [ "stack:I|S", "M" ],
1265 am => "source,binary",
1271 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "esp", "gp", "none" ] },
1272 emit => '. pop%M %DAM1',
1273 outs => [ "stack:I|S", "res", "M" ],
1274 ins => [ "base", "index", "mem", "stack" ],
1276 latency => 3, # Pop is more expensive than Push on Athlon
1281 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1283 outs => [ "frame:I", "stack:I|S", "M" ],
1289 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1291 outs => [ "frame:I", "stack:I|S" ],
1299 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1300 ins => [ "base", "index", "mem", "stack", "size" ],
1301 am => "source,binary",
1302 emit => '. addl %binop',
1303 outs => [ "stack:S", "M" ],
1305 modified_flags => $status_flags
1311 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1312 ins => [ "base", "index", "mem", "stack", "size" ],
1313 am => "source,binary",
1314 emit => ". subl %binop\n".
1315 ". movl %%esp, %D1",
1316 outs => [ "stack:I|S", "addr", "M" ],
1318 modified_flags => $status_flags
1323 reg_req => { out => [ "gp" ] },
1327 # the int instruction
1329 reg_req => { in => [ "gp" ], out => [ "none" ] },
1331 emit => '. int %SI0',
1333 cmp_attr => "return 1;",
1337 #-----------------------------------------------------------------------------#
1338 # _____ _____ ______ __ _ _ _ #
1339 # / ____/ ____| ____| / _| | | | | | #
1340 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1341 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1342 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1343 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1344 #-----------------------------------------------------------------------------#
1348 reg_req => { out => [ "xmm" ] },
1349 emit => '. xorp%XSD %D1, %D1',
1355 # commutative operations
1359 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1360 ins => [ "base", "index", "mem", "left", "right" ],
1361 emit => '. add%XXM %binop',
1369 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1370 ins => [ "base", "index", "mem", "left", "right" ],
1371 emit => '. mul%XXM %binop',
1379 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1380 ins => [ "base", "index", "mem", "left", "right" ],
1381 emit => '. max%XXM %binop',
1389 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1390 ins => [ "base", "index", "mem", "left", "right" ],
1391 emit => '. min%XXM %binop',
1399 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1400 ins => [ "base", "index", "mem", "left", "right" ],
1401 emit => '. andp%XSD %binop',
1409 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1410 ins => [ "base", "index", "mem", "left", "right" ],
1411 emit => '. orp%XSD %binop',
1418 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1419 ins => [ "base", "index", "mem", "left", "right" ],
1420 emit => '. xorp%XSD %binop',
1426 # not commutative operations
1430 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1431 ins => [ "base", "index", "mem", "left", "right" ],
1432 emit => '. andnp%XSD %binop',
1440 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1441 ins => [ "base", "index", "mem", "left", "right" ],
1442 emit => '. sub%XXM %binop',
1450 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1451 ins => [ "base", "index", "mem", "left", "right" ],
1452 outs => [ "res", "M" ],
1453 emit => '. div%XXM %binop',
1462 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1463 ins => [ "base", "index", "mem", "left", "right" ],
1464 outs => [ "flags" ],
1465 am => "source,binary",
1466 attr => "int flipped",
1467 init_attr => "attr->data.cmp_flipped = flipped;",
1468 emit => ' .ucomi%XXM %binop_nores',
1471 mode => $mode_flags,
1472 modified_flags => 1,
1479 state => "exc_pinned",
1480 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1481 ins => [ "base", "index", "mem" ],
1482 emit => '. mov%XXM %AM, %D0',
1483 attr => "ir_mode *load_mode",
1484 init_attr => "attr->ls_mode = load_mode;",
1485 outs => [ "res", "M" ],
1492 state => "exc_pinned",
1493 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1494 ins => [ "base", "index", "mem", "val" ],
1495 emit => '. mov%XXM %S3, %AM',
1503 state => "exc_pinned",
1504 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1505 ins => [ "base", "index", "mem", "val" ],
1506 emit => '. mov%XXM %S3, %AM',
1514 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1515 ins => [ "base", "index", "mem", "val" ],
1516 emit => '. cvtsi2ss %D0, %AM',
1524 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1525 ins => [ "base", "index", "mem", "val" ],
1526 emit => '. cvtsi2sd %unop3',
1535 cmp_attr => "return 1;",
1541 cmp_attr => "return 1;",
1550 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1551 outs => [ "DST", "SRC", "CNT", "M" ],
1553 # we don't care about this flag, so no need to mark this node
1554 # modified_flags => [ "DF" ]
1560 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1561 outs => [ "DST", "SRC", "M" ],
1563 # we don't care about this flag, so no need to mark this node
1564 # modified_flags => [ "DF" ]
1570 state => "exc_pinned",
1571 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "in_r4", "none" ] },
1572 ins => [ "base", "index", "mem", "val" ],
1574 attr => "ir_mode *smaller_mode",
1575 init_attr => "attr->ls_mode = smaller_mode;",
1580 state => "exc_pinned",
1581 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "in_r4", "none" ] },
1582 ins => [ "base", "index", "mem", "val" ],
1584 attr => "ir_mode *smaller_mode",
1585 init_attr => "attr->ls_mode = smaller_mode;",
1590 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1591 ins => [ "base", "index", "mem", "val" ],
1598 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1599 ins => [ "base", "index", "mem", "val" ],
1606 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1607 ins => [ "base", "index", "mem", "val" ],
1613 #----------------------------------------------------------#
1615 # (_) | | | | / _| | | | #
1616 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1617 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1618 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1619 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1621 # _ __ ___ __| | ___ ___ #
1622 # | '_ \ / _ \ / _` |/ _ \/ __| #
1623 # | | | | (_) | (_| | __/\__ \ #
1624 # |_| |_|\___/ \__,_|\___||___/ #
1625 #----------------------------------------------------------#
1629 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1630 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1634 attr_type => "ia32_x87_attr_t",
1639 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1640 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1644 attr_type => "ia32_x87_attr_t",
1649 cmp_attr => "return 1;",
1655 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1656 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1660 attr_type => "ia32_x87_attr_t",
1664 cmp_attr => "return 1;",
1669 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1670 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1671 outs => [ "res", "M" ],
1674 attr_type => "ia32_x87_attr_t",
1678 cmp_attr => "return 1;",
1679 outs => [ "res", "M" ],
1684 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1685 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1689 attr_type => "ia32_x87_attr_t",
1693 cmp_attr => "return 1;",
1699 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1704 attr_type => "ia32_x87_attr_t",
1709 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1714 attr_type => "ia32_x87_attr_t",
1717 # virtual Load and Store
1721 state => "exc_pinned",
1722 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1723 ins => [ "base", "index", "mem" ],
1724 outs => [ "res", "M" ],
1725 attr => "ir_mode *load_mode",
1726 init_attr => "attr->attr.ls_mode = load_mode;",
1729 attr_type => "ia32_x87_attr_t",
1734 state => "exc_pinned",
1735 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1736 ins => [ "base", "index", "mem", "val" ],
1737 attr => "ir_mode *store_mode",
1738 init_attr => "attr->attr.ls_mode = store_mode;",
1742 attr_type => "ia32_x87_attr_t",
1748 state => "exc_pinned",
1749 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1750 outs => [ "res", "M" ],
1751 ins => [ "base", "index", "mem" ],
1754 attr_type => "ia32_x87_attr_t",
1758 cmp_attr => "return 1;",
1759 outs => [ "res", "M" ],
1764 state => "exc_pinned",
1765 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1766 ins => [ "base", "index", "mem", "val", "fpcw" ],
1770 attr_type => "ia32_x87_attr_t",
1774 cmp_attr => "return 1;",
1775 state => "exc_pinned",
1785 reg_req => { out => [ "vfp" ] },
1789 attr_type => "ia32_x87_attr_t",
1794 reg_req => { out => [ "vfp" ] },
1798 attr_type => "ia32_x87_attr_t",
1803 reg_req => { out => [ "vfp" ] },
1807 attr_type => "ia32_x87_attr_t",
1812 reg_req => { out => [ "vfp" ] },
1816 attr_type => "ia32_x87_attr_t",
1821 reg_req => { out => [ "vfp" ] },
1825 attr_type => "ia32_x87_attr_t",
1830 reg_req => { out => [ "vfp" ] },
1834 attr_type => "ia32_x87_attr_t",
1839 reg_req => { out => [ "vfp" ] },
1843 attr_type => "ia32_x87_attr_t",
1849 # we can't allow to rematerialize this node so we don't have
1850 # accidently produce Phi(Fucom, Fucom(flipped))
1852 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1853 ins => [ "left", "right" ],
1854 outs => [ "flags" ],
1855 am => "source,binary",
1856 attr => "int flipped",
1857 init_attr => "attr->attr.data.cmp_flipped = flipped;",
1860 attr_type => "ia32_x87_attr_t",
1866 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
1868 outs => [ "flags" ],
1871 mode => $mode_flags,
1874 #------------------------------------------------------------------------#
1875 # ___ _____ __ _ _ _ #
1876 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1877 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1878 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1879 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1880 #------------------------------------------------------------------------#
1882 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1883 # are swapped, we work this around in the emitter...
1887 rd_constructor => "NONE",
1889 emit => '. fadd%XM %x87_binop',
1890 attr_type => "ia32_x87_attr_t",
1895 rd_constructor => "NONE",
1897 emit => '. faddp%XM %x87_binop',
1898 attr_type => "ia32_x87_attr_t",
1903 rd_constructor => "NONE",
1905 emit => '. fmul%XM %x87_binop',
1906 attr_type => "ia32_x87_attr_t",
1911 rd_constructor => "NONE",
1913 emit => '. fmulp%XM %x87_binop',,
1914 attr_type => "ia32_x87_attr_t",
1919 rd_constructor => "NONE",
1921 emit => '. fsub%XM %x87_binop',
1922 attr_type => "ia32_x87_attr_t",
1927 rd_constructor => "NONE",
1929 # see note about gas bugs
1930 emit => '. fsubrp%XM %x87_binop',
1931 attr_type => "ia32_x87_attr_t",
1936 rd_constructor => "NONE",
1939 emit => '. fsubr%XM %x87_binop',
1940 attr_type => "ia32_x87_attr_t",
1945 rd_constructor => "NONE",
1948 # see note about gas bugs
1949 emit => '. fsubp%XM %x87_binop',
1950 attr_type => "ia32_x87_attr_t",
1955 rd_constructor => "NONE",
1958 attr_type => "ia32_x87_attr_t",
1961 # this node is just here, to keep the simulator running
1962 # we can omit this when a fprem simulation function exists
1965 rd_constructor => "NONE",
1968 attr_type => "ia32_x87_attr_t",
1973 rd_constructor => "NONE",
1975 emit => '. fdiv%XM %x87_binop',
1976 attr_type => "ia32_x87_attr_t",
1981 rd_constructor => "NONE",
1983 # see note about gas bugs
1984 emit => '. fdivrp%XM %x87_binop',
1985 attr_type => "ia32_x87_attr_t",
1990 rd_constructor => "NONE",
1992 emit => '. fdivr%XM %x87_binop',
1993 attr_type => "ia32_x87_attr_t",
1998 rd_constructor => "NONE",
2000 # see note about gas bugs
2001 emit => '. fdivp%XM %x87_binop',
2002 attr_type => "ia32_x87_attr_t",
2007 rd_constructor => "NONE",
2010 attr_type => "ia32_x87_attr_t",
2015 rd_constructor => "NONE",
2018 attr_type => "ia32_x87_attr_t",
2021 # x87 Load and Store
2024 rd_constructor => "NONE",
2025 op_flags => "R|L|F",
2026 state => "exc_pinned",
2028 emit => '. fld%XM %AM',
2029 attr_type => "ia32_x87_attr_t",
2033 rd_constructor => "NONE",
2034 op_flags => "R|L|F",
2035 state => "exc_pinned",
2037 emit => '. fst%XM %AM',
2039 attr_type => "ia32_x87_attr_t",
2043 rd_constructor => "NONE",
2044 op_flags => "R|L|F",
2045 state => "exc_pinned",
2047 emit => '. fstp%XM %AM',
2049 attr_type => "ia32_x87_attr_t",
2056 rd_constructor => "NONE",
2058 emit => '. fild%M %AM',
2059 attr_type => "ia32_x87_attr_t",
2064 state => "exc_pinned",
2065 rd_constructor => "NONE",
2067 emit => '. fist%M %AM',
2069 attr_type => "ia32_x87_attr_t",
2074 state => "exc_pinned",
2075 rd_constructor => "NONE",
2077 emit => '. fistp%M %AM',
2079 attr_type => "ia32_x87_attr_t",
2085 op_flags => "R|c|K",
2089 attr_type => "ia32_x87_attr_t",
2093 op_flags => "R|c|K",
2097 attr_type => "ia32_x87_attr_t",
2101 op_flags => "R|c|K",
2105 attr_type => "ia32_x87_attr_t",
2109 op_flags => "R|c|K",
2113 attr_type => "ia32_x87_attr_t",
2117 op_flags => "R|c|K",
2121 attr_type => "ia32_x87_attr_t",
2125 op_flags => "R|c|K",
2128 emit => '. fldll2t',
2129 attr_type => "ia32_x87_attr_t",
2133 op_flags => "R|c|K",
2137 attr_type => "ia32_x87_attr_t",
2141 # Note that it is NEVER allowed to do CSE on these nodes
2142 # Moreover, note the virtual register requierements!
2147 cmp_attr => "return 1;",
2148 emit => '. fxch %X0',
2149 attr_type => "ia32_x87_attr_t",
2155 cmp_attr => "return 1;",
2156 emit => '. fld %X0',
2157 attr_type => "ia32_x87_attr_t",
2162 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2163 cmp_attr => "return 1;",
2164 emit => '. fld %X0',
2165 attr_type => "ia32_x87_attr_t",
2171 cmp_attr => "return 1;",
2172 emit => '. fstp %X0',
2173 attr_type => "ia32_x87_attr_t",
2179 cmp_attr => "return 1;",
2180 emit => '. ffreep %X0',
2181 attr_type => "ia32_x87_attr_t",
2187 cmp_attr => "return 1;",
2189 attr_type => "ia32_x87_attr_t",
2195 cmp_attr => "return 1;",
2197 attr_type => "ia32_x87_attr_t",
2205 emit => ". fucom %X1\n".
2207 attr_type => "ia32_x87_attr_t",
2213 emit => ". fucomp %X1\n".
2215 attr_type => "ia32_x87_attr_t",
2221 emit => ". fucompp\n".
2223 attr_type => "ia32_x87_attr_t",
2227 # -------------------------------------------------------------------------------- #
2228 # ____ ____ _____ _ _ #
2229 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2230 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2231 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2232 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2234 # -------------------------------------------------------------------------------- #
2237 # Spilling and reloading of SSE registers, hardcoded, not generated #
2241 state => "exc_pinned",
2242 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2243 emit => '. movdqu %D0, %AM',
2244 outs => [ "res", "M" ],
2250 state => "exc_pinned",
2251 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2252 ins => [ "base", "index", "mem", "val" ],
2253 emit => '. movdqu %binop',
2260 # Include the generated SIMD node specification written by the SIMD optimization
2261 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2262 unless ($return = do $my_script_name) {
2263 warn "couldn't parse $my_script_name: $@" if $@;
2264 warn "couldn't do $my_script_name: $!" unless defined $return;
2265 warn "couldn't run $my_script_name" unless $return;