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 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
201 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
202 D0 => "${arch}_emit_dest_register(node, 0);",
203 D1 => "${arch}_emit_dest_register(node, 1);",
204 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
205 X0 => "${arch}_emit_x87_register(node, 0);",
206 X1 => "${arch}_emit_x87_register(node, 1);",
207 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
208 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
209 ia32_emit_mode_suffix(node);",
210 M => "${arch}_emit_mode_suffix(node);",
211 XM => "${arch}_emit_x87_mode_suffix(node);",
212 XXM => "${arch}_emit_xmm_mode_suffix(node);",
213 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
214 AM => "${arch}_emit_am(node);",
215 unop3 => "${arch}_emit_unop(node, 3);",
216 unop4 => "${arch}_emit_unop(node, 4);",
217 binop => "${arch}_emit_binop(node);",
218 x87_binop => "${arch}_emit_x87_binop(node);",
219 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
220 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
223 #--------------------------------------------------#
226 # _ __ _____ __ _ _ __ ___ _ __ ___ #
227 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
228 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
229 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
232 #--------------------------------------------------#
234 $default_op_attr_type = "ia32_op_attr_t";
235 $default_attr_type = "ia32_attr_t";
236 $default_copy_attr = "ia32_copy_attr";
238 sub ia32_custom_init_attr {
243 if(defined($node->{modified_flags})) {
244 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
246 if(defined($node->{am})) {
247 my $am = $node->{am};
248 if($am eq "source,unary") {
249 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_unary);";
250 } elsif($am eq "source,binary") {
251 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
252 } elsif($am eq "source,ternary") {
253 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
254 } elsif($am eq "none") {
257 die("Invalid address mode '$am' specified on op $name");
260 if($node->{state} ne "exc_pinned"
261 and $node->{state} ne "pinned") {
262 die("AM nodes must have pinned or AM pinned state ($name)");
268 $custom_init_attr_func = \&ia32_custom_init_attr;
271 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
273 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
274 "\tinit_ia32_x87_attributes(res);",
276 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
277 "\tinit_ia32_x87_attributes(res);".
278 "\tinit_ia32_asm_attributes(res);",
279 ia32_immediate_attr_t =>
280 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
281 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
284 "\tinit_ia32_copyb_attributes(res, size);",
285 ia32_condcode_attr_t =>
286 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
287 "\tinit_ia32_condcode_attributes(res, pnc);",
291 ia32_attr_t => "ia32_compare_nodes_attr",
292 ia32_x87_attr_t => "ia32_compare_x87_attr",
293 ia32_asm_attr_t => "ia32_compare_asm_attr",
294 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
295 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
296 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
302 $mode_xmm = "mode_E";
303 $mode_gp = "mode_Iu";
304 $mode_flags = "mode_Iu";
305 $mode_fpcw = "mode_fpcw";
306 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
307 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
308 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
316 reg_req => { out => [ "gp_NOREG" ] },
317 attr => "ir_entity *symconst, int symconst_sign, long offset",
318 attr_type => "ia32_immediate_attr_t",
326 out_arity => "variable",
327 attr_type => "ia32_asm_attr_t",
328 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
329 init_attr => "attr->asm_text = asm_text;\n".
330 "\tattr->register_map = register_map;\n",
335 # "allocates" a free register
339 reg_req => { out => [ "gp" ] },
344 cmp_attr => "return 1;",
347 #-----------------------------------------------------------------#
350 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
351 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
352 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
353 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
356 #-----------------------------------------------------------------#
358 # commutative operations
362 state => "exc_pinned",
363 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
364 out => [ "in_r4 in_r5", "flags", "none" ] },
365 ins => [ "base", "index", "mem", "left", "right" ],
366 outs => [ "res", "flags", "M" ],
367 emit => '. add%M %binop',
368 am => "source,binary",
372 modified_flags => $status_flags
377 state => "exc_pinned",
378 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
379 ins => [ "base", "index", "mem", "val" ],
380 emit => ". add%M %SI3, %AM",
384 modified_flags => $status_flags
389 state => "exc_pinned",
390 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
391 ins => [ "base", "index", "mem", "val" ],
392 emit => ". add%M %SB3, %AM",
396 modified_flags => $status_flags
400 state => "exc_pinned",
401 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
402 out => [ "in_r4 in_r5", "flags", "none" ] },
403 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
404 outs => [ "res", "flags", "M" ],
405 emit => '. adc%M %binop',
406 am => "source,binary",
410 modified_flags => $status_flags
415 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
416 ins => [ "left", "right" ],
420 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
421 ins => [ "left", "right", "eflags" ],
425 # we should not rematrialize this node. It produces 2 results and has
426 # very strict constrains
427 state => "exc_pinned",
428 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
429 out => [ "eax", "edx", "none" ] },
430 ins => [ "base", "index", "mem", "val_high", "val_low" ],
431 emit => '. mul%M %unop4',
432 outs => [ "res_low", "res_high", "M" ],
433 am => "source,binary",
436 modified_flags => $status_flags
440 # we should not rematrialize this node. It produces 2 results and has
441 # very strict constrains
443 cmp_attr => "return 1;",
444 outs => [ "EAX", "EDX", "M" ],
450 state => "exc_pinned",
451 # TODO: adjust out requirements for the 3 operand form
452 # (no need for should_be_same then)
453 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
454 out => [ "in_r4 in_r5", "flags", "none" ] },
455 ins => [ "base", "index", "mem", "left", "right" ],
456 outs => [ "res", "flags", "M" ],
457 am => "source,binary",
461 modified_flags => $status_flags
466 state => "exc_pinned",
467 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
468 out => [ "eax", "edx", "none" ] },
469 ins => [ "base", "index", "mem", "val_high", "val_low" ],
470 emit => '. imul%M %unop4',
471 outs => [ "res_low", "res_high", "M" ],
472 am => "source,binary",
475 modified_flags => $status_flags
480 cmp_attr => "return 1;",
481 outs => [ "res_low", "res_high", "M" ],
487 state => "exc_pinned",
488 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
489 out => [ "in_r4 in_r5", "flags", "none" ] },
490 ins => [ "base", "index", "mem", "left", "right" ],
491 outs => [ "res", "flags", "M" ],
492 op_modes => "commutative | am | immediate | mode_neutral",
493 am => "source,binary",
494 emit => '. and%M %binop',
498 modified_flags => $status_flags
503 state => "exc_pinned",
504 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
505 ins => [ "base", "index", "mem", "val" ],
506 emit => '. and%M %SI3, %AM',
510 modified_flags => $status_flags
515 state => "exc_pinned",
516 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
517 ins => [ "base", "index", "mem", "val" ],
518 emit => '. and%M %SB3, %AM',
522 modified_flags => $status_flags
527 state => "exc_pinned",
528 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
529 out => [ "in_r4 in_r5", "flags", "none" ] },
530 ins => [ "base", "index", "mem", "left", "right" ],
531 outs => [ "res", "flags", "M" ],
532 am => "source,binary",
533 emit => '. or%M %binop',
537 modified_flags => $status_flags
542 state => "exc_pinned",
543 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
544 ins => [ "base", "index", "mem", "val" ],
545 emit => '. or%M %SI3, %AM',
549 modified_flags => $status_flags
554 state => "exc_pinned",
555 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
556 ins => [ "base", "index", "mem", "val" ],
557 emit => '. or%M %SB3, %AM',
561 modified_flags => $status_flags
566 state => "exc_pinned",
567 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
568 out => [ "in_r4 in_r5", "flags", "none" ] },
569 ins => [ "base", "index", "mem", "left", "right" ],
570 outs => [ "res", "flags", "M" ],
571 am => "source,binary",
572 emit => '. xor%M %binop',
576 modified_flags => $status_flags
581 state => "exc_pinned",
582 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
583 ins => [ "base", "index", "mem", "val" ],
584 emit => '. xor%M %SI3, %AM',
588 modified_flags => $status_flags
593 state => "exc_pinned",
594 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
595 ins => [ "base", "index", "mem", "val" ],
596 emit => '. xor%M %SB3, %AM',
600 modified_flags => $status_flags
603 # not commutative operations
607 state => "exc_pinned",
608 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
609 out => [ "in_r4", "flags", "none" ] },
610 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
611 outs => [ "res", "flags", "M" ],
612 am => "source,binary",
613 emit => '. sub%M %binop',
617 modified_flags => $status_flags
622 state => "exc_pinned",
623 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
624 ins => [ "base", "index", "mem", "subtrahend" ],
625 emit => '. sub%M %SI3, %AM',
629 modified_flags => $status_flags
634 state => "exc_pinned",
635 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
636 ins => [ "base", "index", "mem", "subtrahend" ],
637 emit => '. sub%M %SB3, %AM',
641 modified_flags => $status_flags
645 state => "exc_pinned",
646 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
647 out => [ "in_r4 !in_r5", "flags", "none" ] },
648 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
649 outs => [ "res", "flags", "M" ],
650 am => "source,binary",
651 emit => '. sbb%M %binop',
655 modified_flags => $status_flags
659 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
660 ins => [ "minuend", "subtrahend" ],
664 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
665 ins => [ "minuend", "subtrahend", "eflags" ],
670 state => "exc_pinned",
671 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
672 out => [ "eax", "flags", "none", "edx", "none" ] },
673 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
674 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
675 am => "source,ternary",
676 emit => ". idiv%M %unop3",
679 modified_flags => $status_flags
684 state => "exc_pinned",
685 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
686 out => [ "eax", "flags", "none", "edx", "none" ] },
687 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
688 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
689 am => "source,ternary",
690 emit => ". div%M %unop3",
693 modified_flags => $status_flags
698 reg_req => { in => [ "gp", "ecx" ],
699 out => [ "in_r1 !in_r2", "flags" ] },
700 ins => [ "val", "count" ],
701 outs => [ "res", "flags" ],
702 emit => '. shl %SB1, %S0',
706 modified_flags => $status_flags
711 state => "exc_pinned",
712 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
713 ins => [ "base", "index", "mem", "count" ],
714 emit => '. shl%M %SB3, %AM',
718 modified_flags => $status_flags
722 cmp_attr => "return 1;",
723 ins => [ "val", "count", "dep" ],
729 reg_req => { in => [ "gp", "gp", "ecx" ],
730 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
731 ins => [ "val_high", "val_low", "count" ],
732 outs => [ "res", "flags" ],
733 emit => ". shld%M %SB2, %S1, %D0",
737 modified_flags => $status_flags
741 cmp_attr => "return 1;",
742 ins => [ "val_high", "val_low", "count" ],
748 reg_req => { in => [ "gp", "ecx" ],
749 out => [ "in_r1 !in_r2", "flags" ] },
750 ins => [ "val", "count" ],
751 outs => [ "res", "flags" ],
752 emit => '. shr %SB1, %S0',
756 modified_flags => $status_flags
761 state => "exc_pinned",
762 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
763 ins => [ "base", "index", "mem", "count" ],
764 emit => '. shr%M %SB3, %AM',
768 modified_flags => $status_flags
772 cmp_attr => "return 1;",
773 ins => [ "val", "count", "dep" ],
779 reg_req => { in => [ "gp", "gp", "ecx" ],
780 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
781 ins => [ "val_high", "val_low", "count" ],
782 outs => [ "res", "flags" ],
783 emit => ". shrd%M %SB2, %S1, %D0",
787 modified_flags => $status_flags
791 cmp_attr => "return 1;",
793 ins => [ "val_high", "val_low", "count" ],
798 reg_req => { in => [ "gp", "ecx" ],
799 out => [ "in_r1 !in_r2", "flags" ] },
800 ins => [ "val", "count" ],
801 outs => [ "res", "flags" ],
802 emit => '. sar %SB1, %S0',
806 modified_flags => $status_flags
811 state => "exc_pinned",
812 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
813 ins => [ "base", "index", "mem", "count" ],
814 emit => '. sar%M %SB3, %AM',
818 modified_flags => $status_flags
822 cmp_attr => "return 1;",
823 ins => [ "val", "count", "dep" ],
829 reg_req => { in => [ "gp", "ecx" ],
830 out => [ "in_r1 !in_r2", "flags" ] },
831 ins => [ "val", "count" ],
832 outs => [ "res", "flags" ],
833 emit => '. ror %SB1, %S0',
837 modified_flags => $status_flags
842 state => "exc_pinned",
843 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
844 ins => [ "base", "index", "mem", "count" ],
845 emit => '. ror%M %SB3, %AM',
849 modified_flags => $status_flags
854 reg_req => { in => [ "gp", "ecx" ],
855 out => [ "in_r1 !in_r2", "flags" ] },
856 ins => [ "val", "count" ],
857 outs => [ "res", "flags" ],
858 emit => '. rol %SB1, %S0',
862 modified_flags => $status_flags
867 state => "exc_pinned",
868 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
869 ins => [ "base", "index", "mem", "count" ],
870 emit => '. rol%M %SB3, %AM',
874 modified_flags => $status_flags
881 reg_req => { in => [ "gp" ],
882 out => [ "in_r1", "flags" ] },
885 outs => [ "res", "flags" ],
889 modified_flags => $status_flags
894 state => "exc_pinned",
895 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
896 ins => [ "base", "index", "mem" ],
897 emit => '. neg%M %AM',
901 modified_flags => $status_flags
906 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
907 outs => [ "low_res", "high_res" ],
910 modified_flags => $status_flags
916 reg_req => { in => [ "gp" ],
917 out => [ "in_r1", "flags" ] },
919 outs => [ "res", "flags" ],
924 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
929 state => "exc_pinned",
930 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
931 ins => [ "base", "index", "mem" ],
932 emit => '. inc%M %AM',
936 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
941 reg_req => { in => [ "gp" ],
942 out => [ "in_r1", "flags" ] },
944 outs => [ "res", "flags" ],
949 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
954 state => "exc_pinned",
955 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
956 ins => [ "base", "index", "mem" ],
957 emit => '. dec%M %AM',
961 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
966 reg_req => { in => [ "gp" ],
967 out => [ "in_r1", "flags" ] },
969 outs => [ "res", "flags" ],
979 state => "exc_pinned",
980 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
981 ins => [ "base", "index", "mem" ],
982 emit => '. not%M %AM',
990 reg_req => { in => [ "flags" ], out => [ "flags" ] },
995 modified_flags => $status_flags
999 reg_req => { out => [ "flags" ] },
1003 mode => $mode_flags,
1004 modified_flags => $status_flags
1011 state => "exc_pinned",
1012 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1013 ins => [ "base", "index", "mem", "left", "right" ],
1014 outs => [ "eflags" ],
1015 am => "source,binary",
1016 emit => '. cmp%M %binop',
1017 attr => "int ins_permuted, int cmp_unsigned",
1018 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1019 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1022 mode => $mode_flags,
1023 modified_flags => $status_flags
1028 state => "exc_pinned",
1029 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1030 ins => [ "base", "index", "mem", "left", "right" ],
1031 outs => [ "eflags" ],
1032 am => "source,binary",
1033 emit => '. cmpb %binop',
1034 attr => "int ins_permuted, int cmp_unsigned",
1035 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1036 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1039 mode => $mode_flags,
1040 modified_flags => $status_flags
1045 state => "exc_pinned",
1046 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1047 ins => [ "base", "index", "mem", "left", "right" ],
1048 outs => [ "eflags" ],
1049 am => "source,binary",
1050 emit => '. test%M %binop',
1051 attr => "int ins_permuted, int cmp_unsigned",
1052 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1053 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1056 mode => $mode_flags,
1057 modified_flags => $status_flags
1062 state => "exc_pinned",
1063 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1064 ins => [ "base", "index", "mem", "left", "right" ],
1065 outs => [ "eflags" ],
1066 am => "source,binary",
1067 emit => '. testb %binop',
1068 attr => "int ins_permuted, int cmp_unsigned",
1069 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1070 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1073 mode => $mode_flags,
1074 modified_flags => $status_flags
1079 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1080 ins => [ "eflags" ],
1081 attr_type => "ia32_condcode_attr_t",
1082 attr => "pn_Cmp pnc, int ins_permuted",
1083 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1084 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1085 emit => '. set%CMP0 %DB0',
1093 state => "exc_pinned",
1094 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1095 ins => [ "base", "index", "mem","eflags" ],
1096 attr_type => "ia32_condcode_attr_t",
1097 attr => "pn_Cmp pnc, int ins_permuted",
1098 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1099 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1100 emit => '. set%CMP3 %AM',
1108 # (note: leave the false,true order intact to make it compatible with other
1110 state => "exc_pinned",
1111 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1112 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1113 am => "source,binary",
1114 attr_type => "ia32_condcode_attr_t",
1115 attr => "int ins_permuted, pn_Cmp pnc",
1116 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1124 op_flags => "L|X|Y",
1125 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1126 ins => [ "eflags" ],
1127 outs => [ "false", "true" ],
1128 attr_type => "ia32_condcode_attr_t",
1129 attr => "pn_Cmp pnc",
1131 units => [ "BRANCH" ],
1136 op_flags => "L|X|Y",
1137 reg_req => { in => [ "gp" ], out => [ "none" ] },
1139 attr_type => "ia32_condcode_attr_t",
1140 attr => "pn_Cmp pnc",
1142 units => [ "BRANCH" ],
1143 modified_flags => $status_flags,
1149 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1150 ins => [ "base", "index", "mem", "target" ],
1151 am => "source,unary",
1152 emit => '. jmp *%unop3',
1154 units => [ "BRANCH" ],
1161 reg_req => { out => [ "gp" ] },
1163 attr => "ir_entity *symconst, int symconst_sign, long offset",
1164 attr_type => "ia32_immediate_attr_t",
1171 reg_req => { out => [ "gp" ] },
1175 modified_flags => $status_flags,
1182 reg_req => { out => [ "gp_UKNWN" ] },
1193 reg_req => { out => [ "vfp_UKNWN" ] },
1198 attr_type => "ia32_x87_attr_t",
1205 reg_req => { out => [ "xmm_UKNWN" ] },
1216 reg_req => { out => [ "gp_NOREG" ] },
1227 reg_req => { out => [ "vfp_NOREG" ] },
1232 attr_type => "ia32_x87_attr_t",
1239 reg_req => { out => [ "xmm_NOREG" ] },
1250 reg_req => { out => [ "fp_cw" ] },
1254 modified_flags => $fpcw_flags
1260 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1261 ins => [ "base", "index", "mem" ],
1263 emit => ". fldcw %AM",
1266 modified_flags => $fpcw_flags
1272 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1273 ins => [ "base", "index", "mem", "fpcw" ],
1275 emit => ". fnstcw %AM",
1283 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1291 # we should not rematrialize this node. It has very strict constraints.
1292 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1293 ins => [ "val", "clobbered" ],
1302 # Note that we add additional latency values depending on address mode, so a
1303 # lateny of 0 for load is correct
1307 state => "exc_pinned",
1308 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1309 ins => [ "base", "index", "mem" ],
1310 outs => [ "res", "M", "X_exc" ],
1312 emit => ". mov%SE%ME%.l %AM, %D0",
1318 cmp_attr => "return 1;",
1319 outs => [ "res", "M" ],
1325 cmp_attr => "return 1;",
1326 state => "exc_pinned",
1333 state => "exc_pinned",
1334 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1335 ins => [ "base", "index", "mem", "val" ],
1336 outs => [ "M", "X_exc" ],
1337 emit => '. mov%M %SI3, %AM',
1345 state => "exc_pinned",
1346 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1347 ins => [ "base", "index", "mem", "val" ],
1348 outs => [ "M", "X_exc" ],
1349 emit => '. mov%M %SB3, %AM',
1357 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1358 ins => [ "base", "index" ],
1359 emit => '. leal %AM, %D0',
1363 # lea doesn't modify the flags, but setting this seems advantageous since it
1364 # increases chances that the Lea is transformed back to an Add
1365 modified_flags => 1,
1369 state => "exc_pinned",
1370 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1371 ins => [ "base", "index", "mem", "val", "stack" ],
1372 emit => '. push%M %unop3',
1373 outs => [ "stack:I|S", "M" ],
1374 am => "source,binary",
1380 state => "exc_pinned",
1381 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1382 ins => [ "mem", "stack" ],
1383 outs => [ "res", "M", "unused", "stack:I|S" ],
1384 emit => '. pop%M %D0',
1385 latency => 3, # Pop is more expensive than Push on Athlon
1390 state => "exc_pinned",
1391 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1392 ins => [ "base", "index", "mem", "stack" ],
1393 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1394 emit => '. pop%M %AM',
1395 latency => 3, # Pop is more expensive than Push on Athlon
1400 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1402 outs => [ "frame:I", "stack:I|S", "M" ],
1408 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1410 outs => [ "frame:I", "stack:I|S" ],
1418 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1419 ins => [ "base", "index", "mem", "stack", "size" ],
1420 am => "source,binary",
1421 emit => '. addl %binop',
1423 outs => [ "stack:I|S", "M" ],
1425 modified_flags => $status_flags
1431 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1432 ins => [ "base", "index", "mem", "stack", "size" ],
1433 am => "source,binary",
1434 emit => ". subl %binop\n".
1435 ". movl %%esp, %D1",
1437 outs => [ "stack:I|S", "addr", "M" ],
1439 modified_flags => $status_flags
1452 reg_req => { out => [ "gp" ] },
1459 state => "exc_pinned",
1460 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1461 ins => [ "left", "right" ],
1462 emit => '. bt%M %S1, %S0',
1465 mode => $mode_flags,
1466 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1469 #-----------------------------------------------------------------------------#
1470 # _____ _____ ______ __ _ _ _ #
1471 # / ____/ ____| ____| / _| | | | | | #
1472 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1473 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1474 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1475 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1476 #-----------------------------------------------------------------------------#
1481 reg_req => { out => [ "xmm" ] },
1482 emit => '. xorp%XSD %D0, %D0',
1490 reg_req => { out => [ "xmm" ] },
1491 emit => '. pxor %D0, %D0',
1497 # produces all 1 bits
1500 reg_req => { out => [ "xmm" ] },
1501 emit => '. pcmpeqb %D0, %D0',
1507 # integer shift left, dword
1510 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1511 emit => '. pslld %SI1, %D0',
1517 # integer shift left, qword
1520 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1521 emit => '. psllq %SI1, %D0',
1527 # integer shift right, dword
1530 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1531 emit => '. psrld %SI1, %D0',
1537 # mov from integer to SSE register
1540 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1541 emit => '. movd %S0, %D0',
1547 # commutative operations
1551 state => "exc_pinned",
1552 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1553 ins => [ "base", "index", "mem", "left", "right" ],
1554 am => "source,binary",
1555 emit => '. add%XXM %binop',
1563 state => "exc_pinned",
1564 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1565 ins => [ "base", "index", "mem", "left", "right" ],
1566 am => "source,binary",
1567 emit => '. mul%XXM %binop',
1575 state => "exc_pinned",
1576 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1577 ins => [ "base", "index", "mem", "left", "right" ],
1578 am => "source,binary",
1579 emit => '. max%XXM %binop',
1587 state => "exc_pinned",
1588 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1589 ins => [ "base", "index", "mem", "left", "right" ],
1590 am => "source,binary",
1591 emit => '. min%XXM %binop',
1599 state => "exc_pinned",
1600 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1601 ins => [ "base", "index", "mem", "left", "right" ],
1602 am => "source,binary",
1603 emit => '. andp%XSD %binop',
1611 state => "exc_pinned",
1612 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1613 ins => [ "base", "index", "mem", "left", "right" ],
1614 am => "source,binary",
1615 emit => '. orp%XSD %binop',
1623 state => "exc_pinned",
1624 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1625 ins => [ "base", "index", "mem", "left", "right" ],
1626 am => "source,binary",
1627 emit => '. xorp%XSD %binop',
1633 # not commutative operations
1637 state => "exc_pinned",
1638 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1639 ins => [ "base", "index", "mem", "left", "right" ],
1640 am => "source,binary",
1641 emit => '. andnp%XSD %binop',
1649 state => "exc_pinned",
1650 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1651 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1652 am => "source,binary",
1653 emit => '. sub%XXM %binop',
1661 state => "exc_pinned",
1662 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1663 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1664 am => "source,binary",
1665 outs => [ "res", "M" ],
1666 emit => '. div%XXM %binop',
1675 state => "exc_pinned",
1676 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1677 ins => [ "base", "index", "mem", "left", "right" ],
1678 outs => [ "flags" ],
1679 am => "source,binary",
1680 attr => "int ins_permuted",
1681 init_attr => "attr->data.ins_permuted = ins_permuted;",
1682 emit => ' .ucomi%XXM %binop',
1685 mode => $mode_flags,
1686 modified_flags => 1,
1693 state => "exc_pinned",
1694 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1695 ins => [ "base", "index", "mem" ],
1696 outs => [ "res", "M", "X_exc" ],
1697 emit => '. mov%XXM %AM, %D0',
1698 attr => "ir_mode *load_mode",
1699 init_attr => "attr->ls_mode = load_mode;",
1706 state => "exc_pinned",
1707 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1708 ins => [ "base", "index", "mem", "val" ],
1709 outs => [ "M", "X_exc" ],
1710 emit => '. mov%XXM %S3, %AM',
1718 state => "exc_pinned",
1719 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1720 ins => [ "base", "index", "mem", "val" ],
1721 emit => '. mov%XXM %S3, %AM',
1729 state => "exc_pinned",
1730 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1731 ins => [ "base", "index", "mem", "val" ],
1732 am => "source,unary",
1733 emit => '. cvtsi2ss %unop3, %D0',
1741 state => "exc_pinned",
1742 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1743 ins => [ "base", "index", "mem", "val" ],
1744 am => "source,unary",
1745 emit => '. cvtsi2sd %unop3, %D0',
1754 cmp_attr => "return 1;",
1755 ins => [ "val_high", "val_low" ],
1760 cmp_attr => "return 1;",
1762 outs => [ "res_high", "res_low" ],
1770 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1771 outs => [ "DST", "SRC", "CNT", "M" ],
1772 attr_type => "ia32_copyb_attr_t",
1773 attr => "unsigned size",
1776 # we don't care about this flag, so no need to mark this node
1777 # modified_flags => [ "DF" ]
1783 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1784 outs => [ "DST", "SRC", "M" ],
1785 attr_type => "ia32_copyb_attr_t",
1786 attr => "unsigned size",
1789 # we don't care about this flag, so no need to mark this node
1790 # modified_flags => [ "DF" ]
1796 state => "exc_pinned",
1797 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1798 ins => [ "base", "index", "mem", "val" ],
1799 am => "source,unary",
1802 attr => "ir_mode *smaller_mode",
1803 init_attr => "attr->ls_mode = smaller_mode;",
1808 state => "exc_pinned",
1809 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1810 ins => [ "base", "index", "mem", "val" ],
1811 am => "source,unary",
1814 attr => "ir_mode *smaller_mode",
1815 init_attr => "attr->ls_mode = smaller_mode;",
1820 state => "exc_pinned",
1821 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1822 ins => [ "base", "index", "mem", "val" ],
1823 am => "source,unary",
1830 state => "exc_pinned",
1831 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1832 ins => [ "base", "index", "mem", "val" ],
1833 am => "source,unary",
1840 state => "exc_pinned",
1841 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1842 ins => [ "base", "index", "mem", "val" ],
1843 am => "source,unary",
1849 #----------------------------------------------------------#
1851 # (_) | | | | / _| | | | #
1852 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1853 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1854 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1855 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1857 # _ __ ___ __| | ___ ___ #
1858 # | '_ \ / _ \ / _` |/ _ \/ __| #
1859 # | | | | (_) | (_| | __/\__ \ #
1860 # |_| |_|\___/ \__,_|\___||___/ #
1861 #----------------------------------------------------------#
1863 # rematerialisation disabled for all float nodes for now, because the fpcw
1864 # handler runs before spilling and we might end up with wrong fpcw then
1868 state => "exc_pinned",
1869 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1870 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1871 am => "source,binary",
1875 attr_type => "ia32_x87_attr_t",
1880 state => "exc_pinned",
1881 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1882 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1883 am => "source,binary",
1887 attr_type => "ia32_x87_attr_t",
1892 state => "exc_pinned",
1893 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1894 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1895 am => "source,binary",
1899 attr_type => "ia32_x87_attr_t",
1903 state => "exc_pinned",
1904 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1905 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1906 am => "source,binary",
1907 outs => [ "res", "M" ],
1910 attr_type => "ia32_x87_attr_t",
1914 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1915 ins => [ "left", "right", "fpcw" ],
1919 attr_type => "ia32_x87_attr_t",
1924 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1929 attr_type => "ia32_x87_attr_t",
1934 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1939 attr_type => "ia32_x87_attr_t",
1942 # virtual Load and Store
1947 state => "exc_pinned",
1948 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1949 ins => [ "base", "index", "mem" ],
1950 outs => [ "res", "M", "X_exc" ],
1951 attr => "ir_mode *load_mode",
1952 init_attr => "attr->attr.ls_mode = load_mode;",
1955 attr_type => "ia32_x87_attr_t",
1961 state => "exc_pinned",
1962 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1963 ins => [ "base", "index", "mem", "val" ],
1964 outs => [ "M", "X_exc" ],
1965 attr => "ir_mode *store_mode",
1966 init_attr => "attr->attr.ls_mode = store_mode;",
1970 attr_type => "ia32_x87_attr_t",
1976 state => "exc_pinned",
1977 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1978 outs => [ "res", "M" ],
1979 ins => [ "base", "index", "mem" ],
1982 attr_type => "ia32_x87_attr_t",
1986 cmp_attr => "return 1;",
1987 outs => [ "res", "M" ],
1992 state => "exc_pinned",
1993 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1994 ins => [ "base", "index", "mem", "val", "fpcw" ],
1998 attr_type => "ia32_x87_attr_t",
2001 # SSE3 fisttp instruction
2003 state => "exc_pinned",
2004 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2005 ins => [ "base", "index", "mem", "val" ],
2006 outs => [ "res", "M" ],
2009 attr_type => "ia32_x87_attr_t",
2013 cmp_attr => "return 1;",
2014 state => "exc_pinned",
2024 reg_req => { out => [ "vfp" ] },
2028 attr_type => "ia32_x87_attr_t",
2033 reg_req => { out => [ "vfp" ] },
2037 attr_type => "ia32_x87_attr_t",
2042 reg_req => { out => [ "vfp" ] },
2046 attr_type => "ia32_x87_attr_t",
2051 reg_req => { out => [ "vfp" ] },
2055 attr_type => "ia32_x87_attr_t",
2060 reg_req => { out => [ "vfp" ] },
2064 attr_type => "ia32_x87_attr_t",
2069 reg_req => { out => [ "vfp" ] },
2073 attr_type => "ia32_x87_attr_t",
2078 reg_req => { out => [ "vfp" ] },
2082 attr_type => "ia32_x87_attr_t",
2088 # we can't allow to rematerialize this node so we don't have
2089 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2091 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2092 ins => [ "left", "right" ],
2093 outs => [ "flags" ],
2094 attr => "int ins_permuted",
2095 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2098 attr_type => "ia32_x87_attr_t",
2104 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2105 ins => [ "left", "right" ],
2106 outs => [ "flags" ],
2107 attr => "int ins_permuted",
2108 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2111 attr_type => "ia32_x87_attr_t",
2117 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2119 outs => [ "flags" ],
2120 attr => "int ins_permuted",
2121 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2124 attr_type => "ia32_x87_attr_t",
2130 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2132 outs => [ "flags" ],
2136 mode => $mode_flags,
2139 #------------------------------------------------------------------------#
2140 # ___ _____ __ _ _ _ #
2141 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2142 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2143 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2144 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2145 #------------------------------------------------------------------------#
2147 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2148 # are swapped, we work this around in the emitter...
2151 state => "exc_pinned",
2152 rd_constructor => "NONE",
2154 emit => '. fadd%XM %x87_binop',
2156 attr_type => "ia32_x87_attr_t",
2160 state => "exc_pinned",
2161 rd_constructor => "NONE",
2163 emit => '. faddp%XM %x87_binop',
2165 attr_type => "ia32_x87_attr_t",
2169 state => "exc_pinned",
2170 rd_constructor => "NONE",
2172 emit => '. fmul%XM %x87_binop',
2174 attr_type => "ia32_x87_attr_t",
2178 state => "exc_pinned",
2179 rd_constructor => "NONE",
2181 emit => '. fmulp%XM %x87_binop',,
2183 attr_type => "ia32_x87_attr_t",
2187 state => "exc_pinned",
2188 rd_constructor => "NONE",
2190 emit => '. fsub%XM %x87_binop',
2192 attr_type => "ia32_x87_attr_t",
2196 state => "exc_pinned",
2197 rd_constructor => "NONE",
2199 # see note about gas bugs
2200 emit => '. fsubrp%XM %x87_binop',
2202 attr_type => "ia32_x87_attr_t",
2206 state => "exc_pinned",
2207 rd_constructor => "NONE",
2210 emit => '. fsubr%XM %x87_binop',
2212 attr_type => "ia32_x87_attr_t",
2216 state => "exc_pinned",
2217 rd_constructor => "NONE",
2220 # see note about gas bugs
2221 emit => '. fsubp%XM %x87_binop',
2223 attr_type => "ia32_x87_attr_t",
2227 rd_constructor => "NONE",
2231 attr_type => "ia32_x87_attr_t",
2234 # this node is just here, to keep the simulator running
2235 # we can omit this when a fprem simulation function exists
2237 rd_constructor => "NONE",
2239 emit => '. fprem1\n'.
2242 attr_type => "ia32_x87_attr_t",
2246 state => "exc_pinned",
2247 rd_constructor => "NONE",
2249 emit => '. fdiv%XM %x87_binop',
2251 attr_type => "ia32_x87_attr_t",
2255 state => "exc_pinned",
2256 rd_constructor => "NONE",
2258 # see note about gas bugs
2259 emit => '. fdivrp%XM %x87_binop',
2261 attr_type => "ia32_x87_attr_t",
2265 state => "exc_pinned",
2266 rd_constructor => "NONE",
2268 emit => '. fdivr%XM %x87_binop',
2270 attr_type => "ia32_x87_attr_t",
2274 state => "exc_pinned",
2275 rd_constructor => "NONE",
2277 # see note about gas bugs
2278 emit => '. fdivp%XM %x87_binop',
2280 attr_type => "ia32_x87_attr_t",
2284 rd_constructor => "NONE",
2288 attr_type => "ia32_x87_attr_t",
2293 rd_constructor => "NONE",
2297 attr_type => "ia32_x87_attr_t",
2300 # x87 Load and Store
2303 rd_constructor => "NONE",
2304 op_flags => "R|L|F",
2305 state => "exc_pinned",
2307 emit => '. fld%XM %AM',
2308 attr_type => "ia32_x87_attr_t",
2313 rd_constructor => "NONE",
2314 op_flags => "R|L|F",
2315 state => "exc_pinned",
2317 emit => '. fst%XM %AM',
2319 attr_type => "ia32_x87_attr_t",
2324 rd_constructor => "NONE",
2325 op_flags => "R|L|F",
2326 state => "exc_pinned",
2328 emit => '. fstp%XM %AM',
2330 attr_type => "ia32_x87_attr_t",
2337 state => "exc_pinned",
2338 rd_constructor => "NONE",
2340 emit => '. fild%M %AM',
2341 attr_type => "ia32_x87_attr_t",
2346 state => "exc_pinned",
2347 rd_constructor => "NONE",
2349 emit => '. fist%M %AM',
2351 attr_type => "ia32_x87_attr_t",
2356 state => "exc_pinned",
2357 rd_constructor => "NONE",
2359 emit => '. fistp%M %AM',
2361 attr_type => "ia32_x87_attr_t",
2365 # SSE3 firsttp instruction
2367 state => "exc_pinned",
2368 rd_constructor => "NONE",
2370 emit => '. fisttp%M %AM',
2372 attr_type => "ia32_x87_attr_t",
2379 op_flags => "R|c|K",
2381 reg_req => { out => [ "vfp" ] },
2383 attr_type => "ia32_x87_attr_t",
2388 op_flags => "R|c|K",
2390 reg_req => { out => [ "vfp" ] },
2392 attr_type => "ia32_x87_attr_t",
2397 op_flags => "R|c|K",
2399 reg_req => { out => [ "vfp" ] },
2401 attr_type => "ia32_x87_attr_t",
2406 op_flags => "R|c|K",
2408 reg_req => { out => [ "vfp" ] },
2410 attr_type => "ia32_x87_attr_t",
2415 op_flags => "R|c|K",
2417 reg_req => { out => [ "vfp" ] },
2419 attr_type => "ia32_x87_attr_t",
2424 op_flags => "R|c|K",
2426 reg_req => { out => [ "vfp" ] },
2427 emit => '. fldll2t',
2428 attr_type => "ia32_x87_attr_t",
2433 op_flags => "R|c|K",
2435 reg_req => { out => [ "vfp" ] },
2437 attr_type => "ia32_x87_attr_t",
2442 # Note that it is NEVER allowed to do CSE on these nodes
2443 # Moreover, note the virtual register requierements!
2448 cmp_attr => "return 1;",
2449 emit => '. fxch %X0',
2450 attr_type => "ia32_x87_attr_t",
2458 cmp_attr => "return 1;",
2459 emit => '. fld %X0',
2460 attr_type => "ia32_x87_attr_t",
2466 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2467 cmp_attr => "return 1;",
2468 emit => '. fld %X0',
2469 attr_type => "ia32_x87_attr_t",
2476 cmp_attr => "return 1;",
2477 emit => '. fstp %X0',
2478 attr_type => "ia32_x87_attr_t",
2486 cmp_attr => "return 1;",
2487 emit => '. ffreep %X0',
2488 attr_type => "ia32_x87_attr_t",
2496 cmp_attr => "return 1;",
2498 attr_type => "ia32_x87_attr_t",
2506 cmp_attr => "return 1;",
2508 attr_type => "ia32_x87_attr_t",
2517 emit => ". fucom %X1\n".
2519 attr_type => "ia32_x87_attr_t",
2525 emit => ". fucomp %X1\n".
2527 attr_type => "ia32_x87_attr_t",
2533 emit => ". fucompp\n".
2535 attr_type => "ia32_x87_attr_t",
2541 emit => '. fucomi %X1',
2542 attr_type => "ia32_x87_attr_t",
2548 emit => '. fucompi %X1',
2549 attr_type => "ia32_x87_attr_t",
2557 attr_type => "ia32_x87_attr_t",
2562 # -------------------------------------------------------------------------------- #
2563 # ____ ____ _____ _ _ #
2564 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2565 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2566 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2567 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2569 # -------------------------------------------------------------------------------- #
2572 # Spilling and reloading of SSE registers, hardcoded, not generated #
2576 state => "exc_pinned",
2577 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2578 emit => '. movdqu %D0, %AM',
2579 outs => [ "res", "M" ],
2586 state => "exc_pinned",
2587 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2588 ins => [ "base", "index", "mem", "val" ],
2589 emit => '. movdqu %binop',
2597 # Include the generated SIMD node specification written by the SIMD optimization
2598 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2599 unless ($return = do $my_script_name) {
2600 warn "couldn't parse $my_script_name: $@" if $@;
2601 warn "couldn't do $my_script_name: $!" unless defined $return;
2602 warn "couldn't run $my_script_name" unless $return;
2605 # Transform some attributes
2606 foreach my $op (keys(%nodes)) {
2607 my $node = $nodes{$op};
2608 my $op_attr_init = $node->{op_attr_init};
2610 if(defined($op_attr_init)) {
2611 $op_attr_init .= "\n\t";
2616 if(!defined($node->{latency})) {
2618 $node->{latency} = 0;
2620 die("Latency missing for op $op");
2623 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2625 $node->{op_attr_init} = $op_attr_init;