3 # This is the specification for the ia32 assembler Firm-operations
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
13 # The node description is done as a perl hash initializer with the
14 # following structure:
19 # op_flags => "N|L|C|X|I|F|Y|H|c|K",
20 # irn_flags => "R|N|I|S"
21 # arity => "0|1|2|3 ... |variable|dynamic|any",
22 # state => "floats|pinned|mem_pinned|exc_pinned",
24 # { type => "type 1", name => "name 1" },
25 # { type => "type 2", name => "name 2" },
28 # comment => "any comment for constructor",
29 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 # cmp_attr => "c source code for comparing node attributes",
31 # emit => "emit code with templates",
32 # attr => "attitional attribute arguments for constructor"
33 # init_attr => "emit attribute initialization template"
34 # rd_constructor => "c source code which constructs an ir_node"
35 # attr_type => "name of the attribute struct",
38 # ... # (all nodes you need to describe)
40 # ); # close the %nodes initializer
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
46 # C irop_flag_commutative
47 # X irop_flag_cfopcode
48 # I irop_flag_ip_cfopcode
51 # H irop_flag_highlevel
52 # c irop_flag_constlike
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
59 # I ignore for register allocation
60 # S modifies stack pointer
62 # state: state of the operation, OPTIONAL (default is "floats")
64 # arity: arity of the operation, MUST NOT BE OMITTED
66 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
67 # are always the first 3 arguments and are always autmatically
69 # If this key is missing the following arguments will be created:
70 # for i = 1 .. arity: ir_node *op_i
73 # outs: if a node defines more than one output, the names of the projections
74 # nodes having outs having automatically the mode mode_T
75 # One can also annotate some flags for each out, additional to irn_flags.
76 # They are separated from name with a colon ':', and concatenated by pipe '|'
77 # Only I and S are available at the moment (same meaning as in irn_flags).
78 # example: [ "frame:I", "stack:I|S", "M" ]
80 # comment: OPTIONAL comment for the node constructor
82 # rd_constructor: for every operation there will be a
83 # new_rd_<arch>_<op-name> function with the arguments from above
84 # which creates the ir_node corresponding to the defined operation
85 # you can either put the complete source code of this function here
87 # This key is OPTIONAL. If omitted, the following constructor will
89 # if (!op_<arch>_<op-name>) assert(0);
93 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
96 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
100 # 0 - no special type
101 # 1 - caller save (register must be saved by the caller of a function)
102 # 2 - callee save (register must be saved by the called function)
103 # 4 - ignore (do not assign this register)
104 # 8 - emitter can choose an arbitrary register of this class
105 # 16 - the register is a virtual one
106 # 32 - register represents a state
107 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
110 { name => "edx", type => 1 },
111 { name => "ecx", type => 1 },
112 { name => "eax", type => 1 },
113 { name => "ebx", type => 2 },
114 { name => "esi", type => 2 },
115 { name => "edi", type => 2 },
116 { name => "ebp", type => 2 },
117 { name => "esp", type => 4 },
118 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
119 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
120 { mode => "mode_Iu" }
123 { name => "mm0", type => 4 },
124 { name => "mm1", type => 4 },
125 { name => "mm2", type => 4 },
126 { name => "mm3", type => 4 },
127 { name => "mm4", type => 4 },
128 { name => "mm5", type => 4 },
129 { name => "mm6", type => 4 },
130 { name => "mm7", type => 4 },
131 { mode => "mode_E", flags => "manual_ra" }
134 { name => "xmm0", type => 1 },
135 { name => "xmm1", type => 1 },
136 { name => "xmm2", type => 1 },
137 { name => "xmm3", type => 1 },
138 { name => "xmm4", type => 1 },
139 { name => "xmm5", type => 1 },
140 { name => "xmm6", type => 1 },
141 { name => "xmm7", type => 1 },
142 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
143 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
147 { name => "vf0", type => 1 | 16 },
148 { name => "vf1", type => 1 | 16 },
149 { name => "vf2", type => 1 | 16 },
150 { name => "vf3", type => 1 | 16 },
151 { name => "vf4", type => 1 | 16 },
152 { name => "vf5", type => 1 | 16 },
153 { name => "vf6", type => 1 | 16 },
154 { name => "vf7", type => 1 | 16 },
155 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
156 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
160 { name => "st0", realname => "st", type => 4 },
161 { name => "st1", realname => "st(1)", type => 4 },
162 { name => "st2", realname => "st(2)", type => 4 },
163 { name => "st3", realname => "st(3)", type => 4 },
164 { name => "st4", realname => "st(4)", type => 4 },
165 { name => "st5", realname => "st(5)", type => 4 },
166 { name => "st6", realname => "st(6)", type => 4 },
167 { name => "st7", realname => "st(7)", type => 4 },
168 { mode => "mode_E", flags => "manual_ra" }
170 fp_cw => [ # the floating point control word
171 { name => "fpcw", type => 4|32 },
172 { mode => "mode_fpcw", flags => "manual_ra|state" }
175 { name => "eflags", type => 0 },
176 { mode => "mode_Iu", flags => "manual_ra" }
181 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
182 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
183 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
184 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
189 bundels_per_cycle => 1
193 S0 => "${arch}_emit_source_register(node, 0);",
194 S1 => "${arch}_emit_source_register(node, 1);",
195 S2 => "${arch}_emit_source_register(node, 2);",
196 S3 => "${arch}_emit_source_register(node, 3);",
197 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
198 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
199 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
200 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
201 D0 => "${arch}_emit_dest_register(node, 0);",
202 D1 => "${arch}_emit_dest_register(node, 1);",
203 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
204 X0 => "${arch}_emit_x87_register(node, 0);",
205 X1 => "${arch}_emit_x87_register(node, 1);",
206 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
207 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
208 ia32_emit_mode_suffix(node);",
209 M => "${arch}_emit_mode_suffix(node);",
210 XM => "${arch}_emit_x87_mode_suffix(node);",
211 XXM => "${arch}_emit_xmm_mode_suffix(node);",
212 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
213 AM => "${arch}_emit_am(node);",
214 unop3 => "${arch}_emit_unop(node, 3);",
215 unop4 => "${arch}_emit_unop(node, 4);",
216 unop5 => "${arch}_emit_unop(node, 5);",
217 DAM0 => "${arch}_emit_am_or_dest_register(node, 0);",
218 binop => "${arch}_emit_binop(node);",
219 x87_binop => "${arch}_emit_x87_binop(node);",
220 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
221 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
224 #--------------------------------------------------#
227 # _ __ _____ __ _ _ __ ___ _ __ ___ #
228 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
229 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
230 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
233 #--------------------------------------------------#
235 $default_op_attr_type = "ia32_op_attr_t";
236 $default_attr_type = "ia32_attr_t";
237 $default_copy_attr = "ia32_copy_attr";
239 sub ia32_custom_init_attr {
244 if(defined($node->{modified_flags})) {
245 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
247 if(defined($node->{am})) {
248 my $am = $node->{am};
249 if($am eq "full,binary") {
250 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
251 } elsif($am eq "full,unary") {
252 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
253 } elsif($am eq "source,unary") {
254 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_unary);";
255 } elsif($am eq "source,binary") {
256 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
257 } elsif($am eq "dest,unary") {
258 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
259 } elsif($am eq "dest,binary") {
260 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
261 } elsif($am eq "dest,ternary") {
262 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
263 } elsif($am eq "source,ternary") {
264 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
265 } elsif($am eq "none") {
268 die("Invalid address mode '$am' specified on op $name");
271 if($node->{state} ne "exc_pinned"
272 and $node->{state} ne "pinned") {
273 die("AM nodes must have pinned or AM pinned state ($name)");
279 $custom_init_attr_func = \&ia32_custom_init_attr;
282 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
284 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
285 "\tinit_ia32_x87_attributes(res);",
287 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
288 "\tinit_ia32_x87_attributes(res);".
289 "\tinit_ia32_asm_attributes(res);",
290 ia32_immediate_attr_t =>
291 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_copyb_attributes(res, size);",
296 ia32_condcode_attr_t =>
297 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
298 "\tinit_ia32_condcode_attributes(res, pnc);",
302 ia32_attr_t => "ia32_compare_nodes_attr",
303 ia32_x87_attr_t => "ia32_compare_x87_attr",
304 ia32_asm_attr_t => "ia32_compare_asm_attr",
305 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
306 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
307 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
313 $mode_xmm = "mode_E";
314 $mode_gp = "mode_Iu";
315 $mode_flags = "mode_Iu";
316 $mode_fpcw = "mode_fpcw";
317 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
318 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
319 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
327 reg_req => { out => [ "gp_NOREG" ] },
328 attr => "ir_entity *symconst, int symconst_sign, long offset",
329 attr_type => "ia32_immediate_attr_t",
337 out_arity => "variable",
338 attr_type => "ia32_asm_attr_t",
339 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
340 init_attr => "attr->asm_text = asm_text;\n".
341 "\tattr->register_map = register_map;\n",
349 reg_req => { out => [ "gp" ] },
354 cmp_attr => "return 1;",
357 #-----------------------------------------------------------------#
360 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
361 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
362 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
363 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
366 #-----------------------------------------------------------------#
368 # commutative operations
372 state => "exc_pinned",
373 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
374 out => [ "in_r4 in_r5", "flags", "none" ] },
375 ins => [ "base", "index", "mem", "left", "right" ],
376 outs => [ "res", "flags", "M" ],
377 emit => '. add%M %binop',
382 modified_flags => $status_flags
387 state => "exc_pinned",
388 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
389 ins => [ "base", "index", "mem", "val" ],
390 emit => ". add%M %SI3, %AM",
394 modified_flags => $status_flags
399 state => "exc_pinned",
400 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
401 ins => [ "base", "index", "mem", "val" ],
402 emit => ". add%M %SB3, %AM",
406 modified_flags => $status_flags
410 state => "exc_pinned",
411 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
412 out => [ "in_r4 in_r5", "flags", "none" ] },
413 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
414 outs => [ "res", "flags", "M" ],
415 emit => '. adc%M %binop',
420 modified_flags => $status_flags
425 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
426 ins => [ "left", "right" ],
430 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
431 ins => [ "left", "right", "eflags" ],
435 # we should not rematrialize this node. It produces 2 results and has
436 # very strict constrains
437 state => "exc_pinned",
438 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
439 out => [ "eax", "edx", "none" ] },
440 ins => [ "base", "index", "mem", "val_high", "val_low" ],
441 emit => '. mul%M %unop4',
442 outs => [ "res_low", "res_high", "M" ],
443 am => "source,binary",
446 modified_flags => $status_flags
450 # we should not rematrialize this node. It produces 2 results and has
451 # very strict constrains
453 cmp_attr => "return 1;",
454 outs => [ "EAX", "EDX", "M" ],
460 state => "exc_pinned",
461 # TODO: adjust out requirements for the 3 operand form
462 # (no need for should_be_same then)
463 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
464 out => [ "in_r4 in_r5", "flags", "none" ] },
465 ins => [ "base", "index", "mem", "left", "right" ],
466 outs => [ "res", "flags", "M" ],
467 am => "source,binary",
471 modified_flags => $status_flags
476 state => "exc_pinned",
477 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
478 out => [ "eax", "edx", "none" ] },
479 ins => [ "base", "index", "mem", "val_high", "val_low" ],
480 emit => '. imul%M %unop4',
481 outs => [ "res_low", "res_high", "M" ],
482 am => "source,binary",
485 modified_flags => $status_flags
490 cmp_attr => "return 1;",
491 outs => [ "res_low", "res_high", "M" ],
497 state => "exc_pinned",
498 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
499 out => [ "in_r4 in_r5", "flags", "none" ] },
500 ins => [ "base", "index", "mem", "left", "right" ],
501 outs => [ "res", "flags", "M" ],
502 op_modes => "commutative | am | immediate | mode_neutral",
504 emit => '. and%M %binop',
508 modified_flags => $status_flags
513 state => "exc_pinned",
514 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
515 ins => [ "base", "index", "mem", "val" ],
516 emit => '. and%M %SI3, %AM',
520 modified_flags => $status_flags
525 state => "exc_pinned",
526 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
527 ins => [ "base", "index", "mem", "val" ],
528 emit => '. and%M %SB3, %AM',
532 modified_flags => $status_flags
537 state => "exc_pinned",
538 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
539 out => [ "in_r4 in_r5", "flags", "none" ] },
540 ins => [ "base", "index", "mem", "left", "right" ],
541 outs => [ "res", "flags", "M" ],
543 emit => '. or%M %binop',
547 modified_flags => $status_flags
552 state => "exc_pinned",
553 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
554 ins => [ "base", "index", "mem", "val" ],
555 emit => '. or%M %SI3, %AM',
559 modified_flags => $status_flags
564 state => "exc_pinned",
565 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
566 ins => [ "base", "index", "mem", "val" ],
567 emit => '. or%M %SB3, %AM',
571 modified_flags => $status_flags
576 state => "exc_pinned",
577 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
578 out => [ "in_r4 in_r5", "flags", "none" ] },
579 ins => [ "base", "index", "mem", "left", "right" ],
580 outs => [ "res", "flags", "M" ],
582 emit => '. xor%M %binop',
586 modified_flags => $status_flags
591 state => "exc_pinned",
592 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
593 ins => [ "base", "index", "mem", "val" ],
594 emit => '. xor%M %SI3, %AM',
598 modified_flags => $status_flags
603 state => "exc_pinned",
604 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
605 ins => [ "base", "index", "mem", "val" ],
606 emit => '. xor%M %SB3, %AM',
610 modified_flags => $status_flags
613 # not commutative operations
617 state => "exc_pinned",
618 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
619 out => [ "in_r4", "flags", "none" ] },
620 ins => [ "base", "index", "mem", "left", "right" ],
621 outs => [ "res", "flags", "M" ],
623 emit => '. sub%M %binop',
627 modified_flags => $status_flags
632 state => "exc_pinned",
633 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
634 ins => [ "base", "index", "mem", "val" ],
635 emit => '. sub%M %SI3, %AM',
639 modified_flags => $status_flags
644 state => "exc_pinned",
645 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
646 ins => [ "base", "index", "mem", "val" ],
647 emit => '. sub%M %SB3, %AM',
651 modified_flags => $status_flags
655 state => "exc_pinned",
656 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
657 out => [ "in_r4 !in_r5", "flags", "none" ] },
658 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
659 outs => [ "res", "flags", "M" ],
661 emit => '. sbb%M %binop',
665 modified_flags => $status_flags
669 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
670 ins => [ "left", "right" ],
674 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
675 ins => [ "left", "right", "eflags" ],
680 state => "exc_pinned",
681 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ],
682 out => [ "eax", "flags", "none", "edx" ] },
683 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
684 outs => [ "div_res", "flags", "M", "mod_res" ],
685 am => "source,ternary",
686 emit => ". idiv%M %unop5",
689 modified_flags => $status_flags
694 state => "exc_pinned",
695 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ],
696 out => [ "eax", "flags", "none", "edx" ] },
697 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
698 outs => [ "div_res", "flags", "M", "mod_res" ],
699 am => "source,ternary",
700 emit => ". div%M %unop5",
703 modified_flags => $status_flags
708 reg_req => { in => [ "gp", "ecx" ],
709 out => [ "in_r1 !in_r2", "flags" ] },
710 ins => [ "val", "count" ],
711 outs => [ "res", "flags" ],
712 emit => '. shl %SB1, %S0',
716 modified_flags => $status_flags
721 state => "exc_pinned",
722 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
723 ins => [ "base", "index", "mem", "count" ],
724 emit => '. shl%M %SB3, %AM',
728 modified_flags => $status_flags
732 cmp_attr => "return 1;",
733 ins => [ "val", "count", "dep" ],
739 reg_req => { in => [ "gp", "gp", "ecx" ],
740 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
741 ins => [ "val_high", "val_low", "count" ],
742 outs => [ "res", "flags" ],
743 emit => ". shld%M %SB2, %S1, %D0",
747 modified_flags => $status_flags
751 cmp_attr => "return 1;",
752 ins => [ "val_high", "val_low", "count" ],
758 reg_req => { in => [ "gp", "ecx" ],
759 out => [ "in_r1 !in_r2", "flags" ] },
760 ins => [ "val", "count" ],
761 outs => [ "res", "flags" ],
762 emit => '. shr %SB1, %S0',
766 modified_flags => $status_flags
771 state => "exc_pinned",
772 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
773 ins => [ "base", "index", "mem", "count" ],
774 emit => '. shr%M %SB3, %AM',
778 modified_flags => $status_flags
782 cmp_attr => "return 1;",
783 ins => [ "val", "count", "dep" ],
789 reg_req => { in => [ "gp", "gp", "ecx" ],
790 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
791 ins => [ "val_high", "val_low", "count" ],
792 outs => [ "res", "flags" ],
793 emit => ". shrd%M %SB2, %S1, %D0",
797 modified_flags => $status_flags
801 cmp_attr => "return 1;",
803 ins => [ "val_high", "val_low", "count" ],
808 reg_req => { in => [ "gp", "ecx" ],
809 out => [ "in_r1 !in_r2", "flags" ] },
810 ins => [ "val", "count" ],
811 outs => [ "res", "flags" ],
812 emit => '. sar %SB1, %S0',
816 modified_flags => $status_flags
821 state => "exc_pinned",
822 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
823 ins => [ "base", "index", "mem", "count" ],
824 emit => '. sar%M %SB3, %AM',
828 modified_flags => $status_flags
832 cmp_attr => "return 1;",
833 ins => [ "val", "count", "dep" ],
839 reg_req => { in => [ "gp", "ecx" ],
840 out => [ "in_r1 !in_r2", "flags" ] },
841 ins => [ "val", "count" ],
842 outs => [ "res", "flags" ],
843 emit => '. ror %SB1, %S0',
847 modified_flags => $status_flags
852 state => "exc_pinned",
853 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
854 ins => [ "base", "index", "mem", "count" ],
855 emit => '. ror%M %SB3, %AM',
859 modified_flags => $status_flags
864 reg_req => { in => [ "gp", "ecx" ],
865 out => [ "in_r1 !in_r2", "flags" ] },
866 ins => [ "val", "count" ],
867 outs => [ "res", "flags" ],
868 emit => '. rol %SB1, %S0',
872 modified_flags => $status_flags
877 state => "exc_pinned",
878 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
879 ins => [ "base", "index", "mem", "count" ],
880 emit => '. rol%M %SB3, %AM',
884 modified_flags => $status_flags
891 reg_req => { in => [ "gp" ],
892 out => [ "in_r1", "flags" ] },
895 outs => [ "res", "flags" ],
899 modified_flags => $status_flags
904 state => "exc_pinned",
905 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
906 ins => [ "base", "index", "mem" ],
907 emit => '. neg%M %AM',
911 modified_flags => $status_flags
916 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
917 outs => [ "low_res", "high_res" ],
920 modified_flags => $status_flags
926 reg_req => { in => [ "gp" ],
927 out => [ "in_r1", "flags" ] },
928 outs => [ "res", "flags" ],
933 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
938 state => "exc_pinned",
939 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
940 ins => [ "base", "index", "mem" ],
941 emit => '. inc%M %AM',
945 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
950 reg_req => { in => [ "gp" ],
951 out => [ "in_r1", "flags" ] },
952 outs => [ "res", "flags" ],
957 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
962 state => "exc_pinned",
963 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
964 ins => [ "base", "index", "mem" ],
965 emit => '. dec%M %AM',
969 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
974 reg_req => { in => [ "gp" ],
975 out => [ "in_r1", "flags" ] },
977 outs => [ "res", "flags" ],
987 state => "exc_pinned",
988 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
989 ins => [ "base", "index", "mem" ],
990 emit => '. not%M %AM',
998 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1002 mode => $mode_flags,
1003 modified_flags => $status_flags
1007 reg_req => { out => [ "flags" ] },
1011 mode => $mode_flags,
1012 modified_flags => $status_flags
1019 state => "exc_pinned",
1020 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1021 ins => [ "base", "index", "mem", "left", "right" ],
1022 outs => [ "eflags" ],
1023 am => "source,binary",
1024 emit => '. cmp%M %binop',
1025 attr => "int ins_permuted, int cmp_unsigned",
1026 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1027 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1030 mode => $mode_flags,
1031 modified_flags => $status_flags
1036 state => "exc_pinned",
1037 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1038 ins => [ "base", "index", "mem", "left", "right" ],
1039 outs => [ "eflags" ],
1040 am => "source,binary",
1041 emit => '. cmpb %binop',
1042 attr => "int ins_permuted, int cmp_unsigned",
1043 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1044 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1047 mode => $mode_flags,
1048 modified_flags => $status_flags
1053 state => "exc_pinned",
1054 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1055 ins => [ "base", "index", "mem", "left", "right" ],
1056 outs => [ "eflags" ],
1057 am => "source,binary",
1058 emit => '. test%M %binop',
1059 attr => "int ins_permuted, int cmp_unsigned",
1060 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1061 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1064 mode => $mode_flags,
1065 modified_flags => $status_flags
1070 state => "exc_pinned",
1071 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1072 ins => [ "base", "index", "mem", "left", "right" ],
1073 outs => [ "eflags" ],
1074 am => "source,binary",
1075 emit => '. testb %binop',
1076 attr => "int ins_permuted, int cmp_unsigned",
1077 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1078 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1081 mode => $mode_flags,
1082 modified_flags => $status_flags
1087 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1088 ins => [ "eflags" ],
1089 attr_type => "ia32_condcode_attr_t",
1090 attr => "pn_Cmp pnc, int ins_permuted",
1091 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1092 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1093 emit => '. set%CMP0 %DB0',
1101 state => "exc_pinned",
1102 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1103 ins => [ "base", "index", "mem","eflags" ],
1104 attr_type => "ia32_condcode_attr_t",
1105 attr => "pn_Cmp pnc, int ins_permuted",
1106 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1107 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1108 emit => '. set%CMP3 %AM',
1116 # (note: leave the false,true order intact to make it compatible with other
1118 state => "exc_pinned",
1119 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1120 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1121 am => "source,binary",
1122 attr_type => "ia32_condcode_attr_t",
1123 attr => "int ins_permuted, pn_Cmp pnc",
1124 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1132 op_flags => "L|X|Y",
1133 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1134 ins => [ "eflags" ],
1135 outs => [ "false", "true" ],
1136 attr_type => "ia32_condcode_attr_t",
1137 attr => "pn_Cmp pnc",
1139 units => [ "BRANCH" ],
1144 op_flags => "L|X|Y",
1145 reg_req => { in => [ "gp" ], out => [ "none" ] },
1147 attr_type => "ia32_condcode_attr_t",
1148 attr => "pn_Cmp pnc",
1150 units => [ "BRANCH" ],
1151 modified_flags => $status_flags,
1157 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1158 ins => [ "base", "index", "mem", "target" ],
1159 am => "source,unary",
1160 emit => '. jmp *%unop3',
1162 units => [ "BRANCH" ],
1169 reg_req => { out => [ "gp" ] },
1171 attr => "ir_entity *symconst, int symconst_sign, long offset",
1172 attr_type => "ia32_immediate_attr_t",
1181 reg_req => { out => [ "gp_UKNWN" ] },
1192 reg_req => { out => [ "vfp_UKNWN" ] },
1197 attr_type => "ia32_x87_attr_t",
1204 reg_req => { out => [ "xmm_UKNWN" ] },
1215 reg_req => { out => [ "gp_NOREG" ] },
1226 reg_req => { out => [ "vfp_NOREG" ] },
1231 attr_type => "ia32_x87_attr_t",
1238 reg_req => { out => [ "xmm_NOREG" ] },
1249 reg_req => { out => [ "fp_cw" ] },
1253 modified_flags => $fpcw_flags
1259 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1260 ins => [ "base", "index", "mem" ],
1262 emit => ". fldcw %AM",
1265 modified_flags => $fpcw_flags
1271 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1272 ins => [ "base", "index", "mem", "fpcw" ],
1274 emit => ". fnstcw %AM",
1282 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1290 # we should not rematrialize this node. It has very strict constraints.
1291 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1292 ins => [ "val", "globbered" ],
1301 # Note that we add additional latency values depending on address mode, so a
1302 # lateny of 0 for load is correct
1306 state => "exc_pinned",
1307 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1308 ins => [ "base", "index", "mem" ],
1309 outs => [ "res", "M" ],
1311 emit => ". mov%SE%ME%.l %AM, %D0",
1317 cmp_attr => "return 1;",
1318 outs => [ "res", "M" ],
1324 cmp_attr => "return 1;",
1325 state => "exc_pinned",
1332 state => "exc_pinned",
1333 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1334 ins => [ "base", "index", "mem", "val" ],
1335 emit => '. mov%M %SI3, %AM',
1343 state => "exc_pinned",
1344 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1345 ins => [ "base", "index", "mem", "val" ],
1346 emit => '. mov%M %SB3, %AM',
1354 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1355 ins => [ "base", "index" ],
1356 emit => '. leal %AM, %D0',
1360 # lea doesn't modify the flags, but setting this seems advantageous since it
1361 # increases chances that the Lea is transformed back to an Add
1362 modified_flags => 1,
1366 state => "exc_pinned",
1367 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp", "none" ] },
1368 ins => [ "base", "index", "mem", "val", "stack" ],
1369 emit => '. push%M %unop4',
1370 outs => [ "stack:I|S", "M" ],
1371 am => "source,binary",
1377 state => "exc_pinned",
1378 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1379 emit => '. pop%M %DAM0',
1380 outs => [ "res", "M", "unused", "stack:I|S" ],
1381 ins => [ "base", "index", "mem", "stack" ],
1383 latency => 3, # Pop is more expensive than Push on Athlon
1388 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1390 outs => [ "frame:I", "stack:I|S", "M" ],
1396 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1398 outs => [ "frame:I", "stack:I|S" ],
1406 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1407 ins => [ "base", "index", "mem", "stack", "size" ],
1408 am => "source,binary",
1409 emit => '. addl %binop',
1411 outs => [ "stack:S", "M" ],
1413 modified_flags => $status_flags
1419 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1420 ins => [ "base", "index", "mem", "stack", "size" ],
1421 am => "source,binary",
1422 emit => ". subl %binop\n".
1423 ". movl %%esp, %D1",
1425 outs => [ "stack:I|S", "addr", "M" ],
1427 modified_flags => $status_flags
1432 reg_req => { out => [ "gp" ] },
1438 #-----------------------------------------------------------------------------#
1439 # _____ _____ ______ __ _ _ _ #
1440 # / ____/ ____| ____| / _| | | | | | #
1441 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1442 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1443 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1444 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1445 #-----------------------------------------------------------------------------#
1449 reg_req => { out => [ "xmm" ] },
1450 emit => '. xorp%XSD %D0, %D0',
1456 # commutative operations
1460 state => "exc_pinned",
1461 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1462 ins => [ "base", "index", "mem", "left", "right" ],
1463 am => "source,binary",
1464 emit => '. add%XXM %binop',
1472 state => "exc_pinned",
1473 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1474 ins => [ "base", "index", "mem", "left", "right" ],
1475 am => "source,binary",
1476 emit => '. mul%XXM %binop',
1484 state => "exc_pinned",
1485 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1486 ins => [ "base", "index", "mem", "left", "right" ],
1487 am => "source,binary",
1488 emit => '. max%XXM %binop',
1496 state => "exc_pinned",
1497 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1498 ins => [ "base", "index", "mem", "left", "right" ],
1499 am => "source,binary",
1500 emit => '. min%XXM %binop',
1508 state => "exc_pinned",
1509 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1510 ins => [ "base", "index", "mem", "left", "right" ],
1511 am => "source,binary",
1512 emit => '. andp%XSD %binop',
1520 state => "exc_pinned",
1521 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1522 ins => [ "base", "index", "mem", "left", "right" ],
1523 am => "source,binary",
1524 emit => '. orp%XSD %binop',
1532 state => "exc_pinned",
1533 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1534 ins => [ "base", "index", "mem", "left", "right" ],
1535 am => "source,binary",
1536 emit => '. xorp%XSD %binop',
1542 # not commutative operations
1546 state => "exc_pinned",
1547 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1548 ins => [ "base", "index", "mem", "left", "right" ],
1549 am => "source,binary",
1550 emit => '. andnp%XSD %binop',
1558 state => "exc_pinned",
1559 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1560 ins => [ "base", "index", "mem", "left", "right" ],
1561 am => "source,binary",
1562 emit => '. sub%XXM %binop',
1570 state => "exc_pinned",
1571 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1572 ins => [ "base", "index", "mem", "left", "right" ],
1573 am => "source,binary",
1574 outs => [ "res", "M" ],
1575 emit => '. div%XXM %binop',
1584 state => "exc_pinned",
1585 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1586 ins => [ "base", "index", "mem", "left", "right" ],
1587 outs => [ "flags" ],
1588 am => "source,binary",
1589 attr => "int ins_permuted",
1590 init_attr => "attr->data.ins_permuted = ins_permuted;",
1591 emit => ' .ucomi%XXM %binop',
1594 mode => $mode_flags,
1595 modified_flags => 1,
1602 state => "exc_pinned",
1603 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1604 ins => [ "base", "index", "mem" ],
1605 emit => '. mov%XXM %AM, %D0',
1606 attr => "ir_mode *load_mode",
1607 init_attr => "attr->ls_mode = load_mode;",
1608 outs => [ "res", "M" ],
1615 state => "exc_pinned",
1616 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1617 ins => [ "base", "index", "mem", "val" ],
1618 emit => '. mov%XXM %S3, %AM',
1626 state => "exc_pinned",
1627 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1628 ins => [ "base", "index", "mem", "val" ],
1629 emit => '. mov%XXM %S3, %AM',
1637 state => "exc_pinned",
1638 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1639 ins => [ "base", "index", "mem", "val" ],
1640 am => "source,unary",
1641 emit => '. cvtsi2ss %unop3, %D0',
1649 state => "exc_pinned",
1650 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1651 ins => [ "base", "index", "mem", "val" ],
1652 am => "source,unary",
1653 emit => '. cvtsi2sd %unop3, %D0',
1662 cmp_attr => "return 1;",
1663 ins => [ "val_high", "val_low" ],
1668 cmp_attr => "return 1;",
1670 outs => [ "res_high", "res_low" ],
1678 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1679 outs => [ "DST", "SRC", "CNT", "M" ],
1680 attr_type => "ia32_copyb_attr_t",
1681 attr => "unsigned size",
1684 # we don't care about this flag, so no need to mark this node
1685 # modified_flags => [ "DF" ]
1691 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1692 outs => [ "DST", "SRC", "M" ],
1693 attr_type => "ia32_copyb_attr_t",
1694 attr => "unsigned size",
1697 # we don't care about this flag, so no need to mark this node
1698 # modified_flags => [ "DF" ]
1704 state => "exc_pinned",
1705 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1706 ins => [ "base", "index", "mem", "val" ],
1707 am => "source,unary",
1710 attr => "ir_mode *smaller_mode",
1711 init_attr => "attr->ls_mode = smaller_mode;",
1716 state => "exc_pinned",
1717 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1718 ins => [ "base", "index", "mem", "val" ],
1719 am => "source,unary",
1722 attr => "ir_mode *smaller_mode",
1723 init_attr => "attr->ls_mode = smaller_mode;",
1728 state => "exc_pinned",
1729 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1730 ins => [ "base", "index", "mem", "val" ],
1731 am => "source,unary",
1738 state => "exc_pinned",
1739 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1740 ins => [ "base", "index", "mem", "val" ],
1741 am => "source,unary",
1748 state => "exc_pinned",
1749 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1750 ins => [ "base", "index", "mem", "val" ],
1751 am => "source,unary",
1757 #----------------------------------------------------------#
1759 # (_) | | | | / _| | | | #
1760 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1761 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1762 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1763 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1765 # _ __ ___ __| | ___ ___ #
1766 # | '_ \ / _ \ / _` |/ _ \/ __| #
1767 # | | | | (_) | (_| | __/\__ \ #
1768 # |_| |_|\___/ \__,_|\___||___/ #
1769 #----------------------------------------------------------#
1771 # rematerialisation disabled for all float nodes for now, because the fpcw
1772 # handler runs before spilling and we might end up with wrong fpcw then
1776 state => "exc_pinned",
1777 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1778 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1779 am => "source,binary",
1783 attr_type => "ia32_x87_attr_t",
1788 state => "exc_pinned",
1789 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1790 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1791 am => "source,binary",
1795 attr_type => "ia32_x87_attr_t",
1800 state => "exc_pinned",
1801 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1802 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1803 am => "source,binary",
1807 attr_type => "ia32_x87_attr_t",
1811 state => "exc_pinned",
1812 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1813 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1814 am => "source,binary",
1815 outs => [ "res", "M" ],
1818 attr_type => "ia32_x87_attr_t",
1822 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1823 ins => [ "left", "right", "fpcw" ],
1827 attr_type => "ia32_x87_attr_t",
1832 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1837 attr_type => "ia32_x87_attr_t",
1842 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1847 attr_type => "ia32_x87_attr_t",
1850 # virtual Load and Store
1855 state => "exc_pinned",
1856 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1857 ins => [ "base", "index", "mem" ],
1858 outs => [ "res", "M" ],
1859 attr => "ir_mode *load_mode",
1860 init_attr => "attr->attr.ls_mode = load_mode;",
1863 attr_type => "ia32_x87_attr_t",
1869 state => "exc_pinned",
1870 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1871 ins => [ "base", "index", "mem", "val" ],
1872 attr => "ir_mode *store_mode",
1873 init_attr => "attr->attr.ls_mode = store_mode;",
1877 attr_type => "ia32_x87_attr_t",
1883 state => "exc_pinned",
1884 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1885 outs => [ "res", "M" ],
1886 ins => [ "base", "index", "mem" ],
1889 attr_type => "ia32_x87_attr_t",
1893 cmp_attr => "return 1;",
1894 outs => [ "res", "M" ],
1899 state => "exc_pinned",
1900 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1901 ins => [ "base", "index", "mem", "val", "fpcw" ],
1905 attr_type => "ia32_x87_attr_t",
1909 cmp_attr => "return 1;",
1910 state => "exc_pinned",
1920 reg_req => { out => [ "vfp" ] },
1924 attr_type => "ia32_x87_attr_t",
1929 reg_req => { out => [ "vfp" ] },
1933 attr_type => "ia32_x87_attr_t",
1938 reg_req => { out => [ "vfp" ] },
1942 attr_type => "ia32_x87_attr_t",
1947 reg_req => { out => [ "vfp" ] },
1951 attr_type => "ia32_x87_attr_t",
1956 reg_req => { out => [ "vfp" ] },
1960 attr_type => "ia32_x87_attr_t",
1965 reg_req => { out => [ "vfp" ] },
1969 attr_type => "ia32_x87_attr_t",
1974 reg_req => { out => [ "vfp" ] },
1978 attr_type => "ia32_x87_attr_t",
1984 # we can't allow to rematerialize this node so we don't have
1985 # accidently produce Phi(Fucom, Fucom(ins_permuted))
1987 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1988 ins => [ "left", "right" ],
1989 outs => [ "flags" ],
1990 attr => "int ins_permuted",
1991 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1994 attr_type => "ia32_x87_attr_t",
2000 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2001 ins => [ "left", "right" ],
2002 outs => [ "flags" ],
2003 attr => "int ins_permuted",
2004 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2007 attr_type => "ia32_x87_attr_t",
2013 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2015 outs => [ "flags" ],
2016 attr => "int ins_permuted",
2017 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2020 attr_type => "ia32_x87_attr_t",
2026 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2028 outs => [ "flags" ],
2032 mode => $mode_flags,
2035 #------------------------------------------------------------------------#
2036 # ___ _____ __ _ _ _ #
2037 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2038 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2039 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2040 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2041 #------------------------------------------------------------------------#
2043 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2044 # are swapped, we work this around in the emitter...
2047 state => "exc_pinned",
2048 rd_constructor => "NONE",
2050 emit => '. fadd%XM %x87_binop',
2052 attr_type => "ia32_x87_attr_t",
2056 state => "exc_pinned",
2057 rd_constructor => "NONE",
2059 emit => '. faddp%XM %x87_binop',
2061 attr_type => "ia32_x87_attr_t",
2065 state => "exc_pinned",
2066 rd_constructor => "NONE",
2068 emit => '. fmul%XM %x87_binop',
2070 attr_type => "ia32_x87_attr_t",
2074 state => "exc_pinned",
2075 rd_constructor => "NONE",
2077 emit => '. fmulp%XM %x87_binop',,
2079 attr_type => "ia32_x87_attr_t",
2083 state => "exc_pinned",
2084 rd_constructor => "NONE",
2086 emit => '. fsub%XM %x87_binop',
2088 attr_type => "ia32_x87_attr_t",
2092 state => "exc_pinned",
2093 rd_constructor => "NONE",
2095 # see note about gas bugs
2096 emit => '. fsubrp%XM %x87_binop',
2098 attr_type => "ia32_x87_attr_t",
2102 state => "exc_pinned",
2103 rd_constructor => "NONE",
2106 emit => '. fsubr%XM %x87_binop',
2108 attr_type => "ia32_x87_attr_t",
2112 state => "exc_pinned",
2113 rd_constructor => "NONE",
2116 # see note about gas bugs
2117 emit => '. fsubp%XM %x87_binop',
2119 attr_type => "ia32_x87_attr_t",
2123 rd_constructor => "NONE",
2127 attr_type => "ia32_x87_attr_t",
2130 # this node is just here, to keep the simulator running
2131 # we can omit this when a fprem simulation function exists
2133 rd_constructor => "NONE",
2135 emit => '. fprem1\n'.
2138 attr_type => "ia32_x87_attr_t",
2142 state => "exc_pinned",
2143 rd_constructor => "NONE",
2145 emit => '. fdiv%XM %x87_binop',
2147 attr_type => "ia32_x87_attr_t",
2151 state => "exc_pinned",
2152 rd_constructor => "NONE",
2154 # see note about gas bugs
2155 emit => '. fdivrp%XM %x87_binop',
2157 attr_type => "ia32_x87_attr_t",
2161 state => "exc_pinned",
2162 rd_constructor => "NONE",
2164 emit => '. fdivr%XM %x87_binop',
2166 attr_type => "ia32_x87_attr_t",
2170 state => "exc_pinned",
2171 rd_constructor => "NONE",
2173 # see note about gas bugs
2174 emit => '. fdivp%XM %x87_binop',
2176 attr_type => "ia32_x87_attr_t",
2180 rd_constructor => "NONE",
2184 attr_type => "ia32_x87_attr_t",
2189 rd_constructor => "NONE",
2193 attr_type => "ia32_x87_attr_t",
2196 # x87 Load and Store
2199 rd_constructor => "NONE",
2200 op_flags => "R|L|F",
2201 state => "exc_pinned",
2203 emit => '. fld%XM %AM',
2204 attr_type => "ia32_x87_attr_t",
2209 rd_constructor => "NONE",
2210 op_flags => "R|L|F",
2211 state => "exc_pinned",
2213 emit => '. fst%XM %AM',
2215 attr_type => "ia32_x87_attr_t",
2220 rd_constructor => "NONE",
2221 op_flags => "R|L|F",
2222 state => "exc_pinned",
2224 emit => '. fstp%XM %AM',
2226 attr_type => "ia32_x87_attr_t",
2233 state => "exc_pinned",
2234 rd_constructor => "NONE",
2236 emit => '. fild%M %AM',
2237 attr_type => "ia32_x87_attr_t",
2242 state => "exc_pinned",
2243 rd_constructor => "NONE",
2245 emit => '. fist%M %AM',
2247 attr_type => "ia32_x87_attr_t",
2252 state => "exc_pinned",
2253 rd_constructor => "NONE",
2255 emit => '. fistp%M %AM',
2257 attr_type => "ia32_x87_attr_t",
2264 op_flags => "R|c|K",
2266 reg_req => { out => [ "vfp" ] },
2268 attr_type => "ia32_x87_attr_t",
2273 op_flags => "R|c|K",
2275 reg_req => { out => [ "vfp" ] },
2277 attr_type => "ia32_x87_attr_t",
2282 op_flags => "R|c|K",
2284 reg_req => { out => [ "vfp" ] },
2286 attr_type => "ia32_x87_attr_t",
2291 op_flags => "R|c|K",
2293 reg_req => { out => [ "vfp" ] },
2295 attr_type => "ia32_x87_attr_t",
2300 op_flags => "R|c|K",
2302 reg_req => { out => [ "vfp" ] },
2304 attr_type => "ia32_x87_attr_t",
2309 op_flags => "R|c|K",
2311 reg_req => { out => [ "vfp" ] },
2312 emit => '. fldll2t',
2313 attr_type => "ia32_x87_attr_t",
2318 op_flags => "R|c|K",
2320 reg_req => { out => [ "vfp" ] },
2322 attr_type => "ia32_x87_attr_t",
2327 # Note that it is NEVER allowed to do CSE on these nodes
2328 # Moreover, note the virtual register requierements!
2333 cmp_attr => "return 1;",
2334 emit => '. fxch %X0',
2335 attr_type => "ia32_x87_attr_t",
2343 cmp_attr => "return 1;",
2344 emit => '. fld %X0',
2345 attr_type => "ia32_x87_attr_t",
2351 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2352 cmp_attr => "return 1;",
2353 emit => '. fld %X0',
2354 attr_type => "ia32_x87_attr_t",
2361 cmp_attr => "return 1;",
2362 emit => '. fstp %X0',
2363 attr_type => "ia32_x87_attr_t",
2371 cmp_attr => "return 1;",
2372 emit => '. ffreep %X0',
2373 attr_type => "ia32_x87_attr_t",
2381 cmp_attr => "return 1;",
2383 attr_type => "ia32_x87_attr_t",
2391 cmp_attr => "return 1;",
2393 attr_type => "ia32_x87_attr_t",
2402 emit => ". fucom %X1\n".
2404 attr_type => "ia32_x87_attr_t",
2410 emit => ". fucomp %X1\n".
2412 attr_type => "ia32_x87_attr_t",
2418 emit => ". fucompp\n".
2420 attr_type => "ia32_x87_attr_t",
2426 emit => '. fucomi %X1',
2427 attr_type => "ia32_x87_attr_t",
2433 emit => '. fucompi %X1',
2434 attr_type => "ia32_x87_attr_t",
2442 attr_type => "ia32_x87_attr_t",
2447 # -------------------------------------------------------------------------------- #
2448 # ____ ____ _____ _ _ #
2449 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2450 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2451 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2452 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2454 # -------------------------------------------------------------------------------- #
2457 # Spilling and reloading of SSE registers, hardcoded, not generated #
2461 state => "exc_pinned",
2462 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2463 emit => '. movdqu %D0, %AM',
2464 outs => [ "res", "M" ],
2471 state => "exc_pinned",
2472 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2473 ins => [ "base", "index", "mem", "val" ],
2474 emit => '. movdqu %binop',
2482 # Include the generated SIMD node specification written by the SIMD optimization
2483 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2484 unless ($return = do $my_script_name) {
2485 warn "couldn't parse $my_script_name: $@" if $@;
2486 warn "couldn't do $my_script_name: $!" unless defined $return;
2487 warn "couldn't run $my_script_name" unless $return;
2490 # Transform some attributes
2491 foreach my $op (keys(%nodes)) {
2492 my $node = $nodes{$op};
2493 my $op_attr_init = $node->{op_attr_init};
2495 if(defined($op_attr_init)) {
2496 $op_attr_init .= "\n\t";
2501 if(!defined($node->{latency})) {
2503 $node->{latency} = 0;
2505 die("Latency missing for op $op");
2508 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2510 $node->{op_attr_init} = $op_attr_init;