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",
338 reg_req => { out => [ "gp" ] },
343 cmp_attr => "return 1;",
346 #-----------------------------------------------------------------#
349 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
350 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
351 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
352 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
355 #-----------------------------------------------------------------#
357 # commutative operations
361 state => "exc_pinned",
362 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
363 out => [ "in_r4 in_r5", "flags", "none" ] },
364 ins => [ "base", "index", "mem", "left", "right" ],
365 outs => [ "res", "flags", "M" ],
366 emit => '. add%M %binop',
367 am => "source,binary",
371 modified_flags => $status_flags
376 state => "exc_pinned",
377 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
378 ins => [ "base", "index", "mem", "val" ],
379 emit => ". add%M %SI3, %AM",
383 modified_flags => $status_flags
388 state => "exc_pinned",
389 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
390 ins => [ "base", "index", "mem", "val" ],
391 emit => ". add%M %SB3, %AM",
395 modified_flags => $status_flags
399 state => "exc_pinned",
400 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
401 out => [ "in_r4 in_r5", "flags", "none" ] },
402 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
403 outs => [ "res", "flags", "M" ],
404 emit => '. adc%M %binop',
405 am => "source,binary",
409 modified_flags => $status_flags
414 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
415 ins => [ "left", "right" ],
419 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
420 ins => [ "left", "right", "eflags" ],
424 # we should not rematrialize this node. It produces 2 results and has
425 # very strict constrains
426 state => "exc_pinned",
427 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
428 out => [ "eax", "edx", "none" ] },
429 ins => [ "base", "index", "mem", "val_high", "val_low" ],
430 emit => '. mul%M %unop4',
431 outs => [ "res_low", "res_high", "M" ],
432 am => "source,binary",
435 modified_flags => $status_flags
439 # we should not rematrialize this node. It produces 2 results and has
440 # very strict constrains
442 cmp_attr => "return 1;",
443 outs => [ "EAX", "EDX", "M" ],
449 state => "exc_pinned",
450 # TODO: adjust out requirements for the 3 operand form
451 # (no need for should_be_same then)
452 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
453 out => [ "in_r4 in_r5", "flags", "none" ] },
454 ins => [ "base", "index", "mem", "left", "right" ],
455 outs => [ "res", "flags", "M" ],
456 am => "source,binary",
460 modified_flags => $status_flags
465 state => "exc_pinned",
466 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
467 out => [ "eax", "edx", "none" ] },
468 ins => [ "base", "index", "mem", "val_high", "val_low" ],
469 emit => '. imul%M %unop4',
470 outs => [ "res_low", "res_high", "M" ],
471 am => "source,binary",
474 modified_flags => $status_flags
479 cmp_attr => "return 1;",
480 outs => [ "res_low", "res_high", "M" ],
486 state => "exc_pinned",
487 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
488 out => [ "in_r4 in_r5", "flags", "none" ] },
489 ins => [ "base", "index", "mem", "left", "right" ],
490 outs => [ "res", "flags", "M" ],
491 op_modes => "commutative | am | immediate | mode_neutral",
492 am => "source,binary",
493 emit => '. and%M %binop',
497 modified_flags => $status_flags
502 state => "exc_pinned",
503 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
504 ins => [ "base", "index", "mem", "val" ],
505 emit => '. and%M %SI3, %AM',
509 modified_flags => $status_flags
514 state => "exc_pinned",
515 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
516 ins => [ "base", "index", "mem", "val" ],
517 emit => '. and%M %SB3, %AM',
521 modified_flags => $status_flags
526 state => "exc_pinned",
527 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
528 out => [ "in_r4 in_r5", "flags", "none" ] },
529 ins => [ "base", "index", "mem", "left", "right" ],
530 outs => [ "res", "flags", "M" ],
531 am => "source,binary",
532 emit => '. or%M %binop',
536 modified_flags => $status_flags
541 state => "exc_pinned",
542 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
543 ins => [ "base", "index", "mem", "val" ],
544 emit => '. or%M %SI3, %AM',
548 modified_flags => $status_flags
553 state => "exc_pinned",
554 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
555 ins => [ "base", "index", "mem", "val" ],
556 emit => '. or%M %SB3, %AM',
560 modified_flags => $status_flags
565 state => "exc_pinned",
566 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
567 out => [ "in_r4 in_r5", "flags", "none" ] },
568 ins => [ "base", "index", "mem", "left", "right" ],
569 outs => [ "res", "flags", "M" ],
570 am => "source,binary",
571 emit => '. xor%M %binop',
575 modified_flags => $status_flags
580 state => "exc_pinned",
581 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
582 ins => [ "base", "index", "mem", "val" ],
583 emit => '. xor%M %SI3, %AM',
587 modified_flags => $status_flags
592 state => "exc_pinned",
593 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
594 ins => [ "base", "index", "mem", "val" ],
595 emit => '. xor%M %SB3, %AM',
599 modified_flags => $status_flags
602 # not commutative operations
606 state => "exc_pinned",
607 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
608 out => [ "in_r4", "flags", "none" ] },
609 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
610 outs => [ "res", "flags", "M" ],
611 am => "source,binary",
612 emit => '. sub%M %binop',
616 modified_flags => $status_flags
621 state => "exc_pinned",
622 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
623 ins => [ "base", "index", "mem", "subtrahend" ],
624 emit => '. sub%M %SI3, %AM',
628 modified_flags => $status_flags
633 state => "exc_pinned",
634 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
635 ins => [ "base", "index", "mem", "subtrahend" ],
636 emit => '. sub%M %SB3, %AM',
640 modified_flags => $status_flags
644 state => "exc_pinned",
645 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
646 out => [ "in_r4 !in_r5", "flags", "none" ] },
647 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
648 outs => [ "res", "flags", "M" ],
649 am => "source,binary",
650 emit => '. sbb%M %binop',
654 modified_flags => $status_flags
658 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
659 ins => [ "minuend", "subtrahend" ],
663 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
664 ins => [ "minuend", "subtrahend", "eflags" ],
669 state => "exc_pinned",
670 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
671 out => [ "eax", "flags", "none", "edx", "none" ] },
672 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
673 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
674 am => "source,ternary",
675 emit => ". idiv%M %unop3",
678 modified_flags => $status_flags
683 state => "exc_pinned",
684 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
685 out => [ "eax", "flags", "none", "edx", "none" ] },
686 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
687 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
688 am => "source,ternary",
689 emit => ". div%M %unop3",
692 modified_flags => $status_flags
697 reg_req => { in => [ "gp", "ecx" ],
698 out => [ "in_r1 !in_r2", "flags" ] },
699 ins => [ "val", "count" ],
700 outs => [ "res", "flags" ],
701 emit => '. shl %SB1, %S0',
705 modified_flags => $status_flags
710 state => "exc_pinned",
711 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
712 ins => [ "base", "index", "mem", "count" ],
713 emit => '. shl%M %SB3, %AM',
717 modified_flags => $status_flags
721 cmp_attr => "return 1;",
722 ins => [ "val", "count", "dep" ],
728 reg_req => { in => [ "gp", "gp", "ecx" ],
729 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
730 ins => [ "val_high", "val_low", "count" ],
731 outs => [ "res", "flags" ],
732 emit => ". shld%M %SB2, %S1, %D0",
736 modified_flags => $status_flags
740 cmp_attr => "return 1;",
741 ins => [ "val_high", "val_low", "count" ],
747 reg_req => { in => [ "gp", "ecx" ],
748 out => [ "in_r1 !in_r2", "flags" ] },
749 ins => [ "val", "count" ],
750 outs => [ "res", "flags" ],
751 emit => '. shr %SB1, %S0',
755 modified_flags => $status_flags
760 state => "exc_pinned",
761 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
762 ins => [ "base", "index", "mem", "count" ],
763 emit => '. shr%M %SB3, %AM',
767 modified_flags => $status_flags
771 cmp_attr => "return 1;",
772 ins => [ "val", "count", "dep" ],
778 reg_req => { in => [ "gp", "gp", "ecx" ],
779 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
780 ins => [ "val_high", "val_low", "count" ],
781 outs => [ "res", "flags" ],
782 emit => ". shrd%M %SB2, %S1, %D0",
786 modified_flags => $status_flags
790 cmp_attr => "return 1;",
792 ins => [ "val_high", "val_low", "count" ],
797 reg_req => { in => [ "gp", "ecx" ],
798 out => [ "in_r1 !in_r2", "flags" ] },
799 ins => [ "val", "count" ],
800 outs => [ "res", "flags" ],
801 emit => '. sar %SB1, %S0',
805 modified_flags => $status_flags
810 state => "exc_pinned",
811 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
812 ins => [ "base", "index", "mem", "count" ],
813 emit => '. sar%M %SB3, %AM',
817 modified_flags => $status_flags
821 cmp_attr => "return 1;",
822 ins => [ "val", "count", "dep" ],
828 reg_req => { in => [ "gp", "ecx" ],
829 out => [ "in_r1 !in_r2", "flags" ] },
830 ins => [ "val", "count" ],
831 outs => [ "res", "flags" ],
832 emit => '. ror %SB1, %S0',
836 modified_flags => $status_flags
841 state => "exc_pinned",
842 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
843 ins => [ "base", "index", "mem", "count" ],
844 emit => '. ror%M %SB3, %AM',
848 modified_flags => $status_flags
853 reg_req => { in => [ "gp", "ecx" ],
854 out => [ "in_r1 !in_r2", "flags" ] },
855 ins => [ "val", "count" ],
856 outs => [ "res", "flags" ],
857 emit => '. rol %SB1, %S0',
861 modified_flags => $status_flags
866 state => "exc_pinned",
867 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
868 ins => [ "base", "index", "mem", "count" ],
869 emit => '. rol%M %SB3, %AM',
873 modified_flags => $status_flags
880 reg_req => { in => [ "gp" ],
881 out => [ "in_r1", "flags" ] },
884 outs => [ "res", "flags" ],
888 modified_flags => $status_flags
893 state => "exc_pinned",
894 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
895 ins => [ "base", "index", "mem" ],
896 emit => '. neg%M %AM',
900 modified_flags => $status_flags
905 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
906 outs => [ "low_res", "high_res" ],
909 modified_flags => $status_flags
915 reg_req => { in => [ "gp" ],
916 out => [ "in_r1", "flags" ] },
918 outs => [ "res", "flags" ],
923 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
928 state => "exc_pinned",
929 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
930 ins => [ "base", "index", "mem" ],
931 emit => '. inc%M %AM',
935 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
940 reg_req => { in => [ "gp" ],
941 out => [ "in_r1", "flags" ] },
943 outs => [ "res", "flags" ],
948 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
953 state => "exc_pinned",
954 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
955 ins => [ "base", "index", "mem" ],
956 emit => '. dec%M %AM',
960 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
965 reg_req => { in => [ "gp" ],
966 out => [ "in_r1", "flags" ] },
968 outs => [ "res", "flags" ],
978 state => "exc_pinned",
979 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
980 ins => [ "base", "index", "mem" ],
981 emit => '. not%M %AM',
989 reg_req => { in => [ "flags" ], out => [ "flags" ] },
994 modified_flags => $status_flags
998 reg_req => { out => [ "flags" ] },
1002 mode => $mode_flags,
1003 modified_flags => $status_flags
1010 state => "exc_pinned",
1011 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1012 ins => [ "base", "index", "mem", "left", "right" ],
1013 outs => [ "eflags" ],
1014 am => "source,binary",
1015 emit => '. cmp%M %binop',
1016 attr => "int ins_permuted, int cmp_unsigned",
1017 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1018 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1021 mode => $mode_flags,
1022 modified_flags => $status_flags
1027 state => "exc_pinned",
1028 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1029 ins => [ "base", "index", "mem", "left", "right" ],
1030 outs => [ "eflags" ],
1031 am => "source,binary",
1032 emit => '. cmpb %binop',
1033 attr => "int ins_permuted, int cmp_unsigned",
1034 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1035 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1038 mode => $mode_flags,
1039 modified_flags => $status_flags
1044 state => "exc_pinned",
1045 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1046 ins => [ "base", "index", "mem", "left", "right" ],
1047 outs => [ "eflags" ],
1048 am => "source,binary",
1049 emit => '. test%M %binop',
1050 attr => "int ins_permuted, int cmp_unsigned",
1051 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1052 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1055 mode => $mode_flags,
1056 modified_flags => $status_flags
1061 state => "exc_pinned",
1062 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1063 ins => [ "base", "index", "mem", "left", "right" ],
1064 outs => [ "eflags" ],
1065 am => "source,binary",
1066 emit => '. testb %binop',
1067 attr => "int ins_permuted, int cmp_unsigned",
1068 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1069 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1072 mode => $mode_flags,
1073 modified_flags => $status_flags
1078 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1079 ins => [ "eflags" ],
1080 attr_type => "ia32_condcode_attr_t",
1081 attr => "pn_Cmp pnc, int ins_permuted",
1082 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1083 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1084 emit => '. set%CMP0 %DB0',
1092 state => "exc_pinned",
1093 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1094 ins => [ "base", "index", "mem","eflags" ],
1095 attr_type => "ia32_condcode_attr_t",
1096 attr => "pn_Cmp pnc, int ins_permuted",
1097 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1098 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1099 emit => '. set%CMP3 %AM',
1107 # (note: leave the false,true order intact to make it compatible with other
1109 state => "exc_pinned",
1110 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1111 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1112 am => "source,binary",
1113 attr_type => "ia32_condcode_attr_t",
1114 attr => "int ins_permuted, pn_Cmp pnc",
1115 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1123 op_flags => "L|X|Y",
1124 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1125 ins => [ "eflags" ],
1126 outs => [ "false", "true" ],
1127 attr_type => "ia32_condcode_attr_t",
1128 attr => "pn_Cmp pnc",
1130 units => [ "BRANCH" ],
1135 op_flags => "L|X|Y",
1136 reg_req => { in => [ "gp" ], out => [ "none" ] },
1138 attr_type => "ia32_condcode_attr_t",
1139 attr => "pn_Cmp pnc",
1141 units => [ "BRANCH" ],
1142 modified_flags => $status_flags,
1148 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1149 ins => [ "base", "index", "mem", "target" ],
1150 am => "source,unary",
1151 emit => '. jmp *%unop3',
1153 units => [ "BRANCH" ],
1160 reg_req => { out => [ "gp" ] },
1162 attr => "ir_entity *symconst, int symconst_sign, long offset",
1163 attr_type => "ia32_immediate_attr_t",
1170 reg_req => { out => [ "gp" ] },
1174 modified_flags => $status_flags,
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", "clobbered" ],
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", "none" ] },
1308 ins => [ "base", "index", "mem" ],
1309 outs => [ "res", "M", "X_exc" ],
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", "none" ] },
1334 ins => [ "base", "index", "mem", "val" ],
1335 outs => [ "M", "X_exc" ],
1336 emit => '. mov%M %SI3, %AM',
1344 state => "exc_pinned",
1345 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1346 ins => [ "base", "index", "mem", "val" ],
1347 outs => [ "M", "X_exc" ],
1348 emit => '. mov%M %SB3, %AM',
1356 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1357 ins => [ "base", "index" ],
1358 emit => '. leal %AM, %D0',
1362 # lea doesn't modify the flags, but setting this seems advantageous since it
1363 # increases chances that the Lea is transformed back to an Add
1364 modified_flags => 1,
1368 state => "exc_pinned",
1369 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1370 ins => [ "base", "index", "mem", "val", "stack" ],
1371 emit => '. push%M %unop3',
1372 outs => [ "stack:I|S", "M" ],
1373 am => "source,binary",
1379 state => "exc_pinned",
1380 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1381 ins => [ "mem", "stack" ],
1382 outs => [ "res", "M", "unused", "stack:I|S" ],
1383 emit => '. pop%M %D0',
1384 latency => 3, # Pop is more expensive than Push on Athlon
1389 state => "exc_pinned",
1390 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1391 ins => [ "base", "index", "mem", "stack" ],
1392 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1393 emit => '. pop%M %AM',
1394 latency => 3, # Pop is more expensive than Push on Athlon
1399 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1401 outs => [ "frame:I", "stack:I|S", "M" ],
1407 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1409 outs => [ "frame:I", "stack:I|S" ],
1417 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1418 ins => [ "base", "index", "mem", "stack", "size" ],
1419 am => "source,binary",
1420 emit => '. addl %binop',
1422 outs => [ "stack:I|S", "M" ],
1424 modified_flags => $status_flags
1430 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1431 ins => [ "base", "index", "mem", "stack", "size" ],
1432 am => "source,binary",
1433 emit => ". subl %binop\n".
1434 ". movl %%esp, %D1",
1436 outs => [ "stack:I|S", "addr", "M" ],
1438 modified_flags => $status_flags
1451 reg_req => { out => [ "gp" ] },
1458 state => "exc_pinned",
1459 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1460 ins => [ "left", "right" ],
1461 emit => '. bt%M %S1, %S0',
1464 mode => $mode_flags,
1465 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1468 #-----------------------------------------------------------------------------#
1469 # _____ _____ ______ __ _ _ _ #
1470 # / ____/ ____| ____| / _| | | | | | #
1471 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1472 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1473 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1474 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1475 #-----------------------------------------------------------------------------#
1480 reg_req => { out => [ "xmm" ] },
1481 emit => '. xorp%XSD %D0, %D0',
1489 reg_req => { out => [ "xmm" ] },
1490 emit => '. pxor %D0, %D0',
1496 # produces all 1 bits
1499 reg_req => { out => [ "xmm" ] },
1500 emit => '. pcmpeqb %D0, %D0',
1506 # integer shift left, dword
1509 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1510 emit => '. pslld %SI1, %D0',
1516 # integer shift left, qword
1519 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1520 emit => '. psllq %SI1, %D0',
1526 # integer shift right, dword
1529 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1530 emit => '. psrld %SI1, %D0',
1536 # mov from integer to SSE register
1539 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1540 emit => '. movd %S0, %D0',
1546 # commutative operations
1550 state => "exc_pinned",
1551 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1552 ins => [ "base", "index", "mem", "left", "right" ],
1553 am => "source,binary",
1554 emit => '. add%XXM %binop',
1562 state => "exc_pinned",
1563 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1564 ins => [ "base", "index", "mem", "left", "right" ],
1565 am => "source,binary",
1566 emit => '. mul%XXM %binop',
1574 state => "exc_pinned",
1575 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1576 ins => [ "base", "index", "mem", "left", "right" ],
1577 am => "source,binary",
1578 emit => '. max%XXM %binop',
1586 state => "exc_pinned",
1587 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1588 ins => [ "base", "index", "mem", "left", "right" ],
1589 am => "source,binary",
1590 emit => '. min%XXM %binop',
1598 state => "exc_pinned",
1599 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1600 ins => [ "base", "index", "mem", "left", "right" ],
1601 am => "source,binary",
1602 emit => '. andp%XSD %binop',
1610 state => "exc_pinned",
1611 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1612 ins => [ "base", "index", "mem", "left", "right" ],
1613 am => "source,binary",
1614 emit => '. orp%XSD %binop',
1622 state => "exc_pinned",
1623 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1624 ins => [ "base", "index", "mem", "left", "right" ],
1625 am => "source,binary",
1626 emit => '. xorp%XSD %binop',
1632 # not commutative operations
1636 state => "exc_pinned",
1637 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1638 ins => [ "base", "index", "mem", "left", "right" ],
1639 am => "source,binary",
1640 emit => '. andnp%XSD %binop',
1648 state => "exc_pinned",
1649 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1650 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1651 am => "source,binary",
1652 emit => '. sub%XXM %binop',
1660 state => "exc_pinned",
1661 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1662 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1663 am => "source,binary",
1664 outs => [ "res", "M" ],
1665 emit => '. div%XXM %binop',
1674 state => "exc_pinned",
1675 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1676 ins => [ "base", "index", "mem", "left", "right" ],
1677 outs => [ "flags" ],
1678 am => "source,binary",
1679 attr => "int ins_permuted",
1680 init_attr => "attr->data.ins_permuted = ins_permuted;",
1681 emit => ' .ucomi%XXM %binop',
1684 mode => $mode_flags,
1685 modified_flags => 1,
1692 state => "exc_pinned",
1693 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1694 ins => [ "base", "index", "mem" ],
1695 outs => [ "res", "M", "X_exc" ],
1696 emit => '. mov%XXM %AM, %D0',
1697 attr => "ir_mode *load_mode",
1698 init_attr => "attr->ls_mode = load_mode;",
1705 state => "exc_pinned",
1706 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1707 ins => [ "base", "index", "mem", "val" ],
1708 outs => [ "M", "X_exc" ],
1709 emit => '. mov%XXM %S3, %AM',
1717 state => "exc_pinned",
1718 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1719 ins => [ "base", "index", "mem", "val" ],
1720 emit => '. mov%XXM %S3, %AM',
1728 state => "exc_pinned",
1729 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1730 ins => [ "base", "index", "mem", "val" ],
1731 am => "source,unary",
1732 emit => '. cvtsi2ss %unop3, %D0',
1740 state => "exc_pinned",
1741 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1742 ins => [ "base", "index", "mem", "val" ],
1743 am => "source,unary",
1744 emit => '. cvtsi2sd %unop3, %D0',
1753 cmp_attr => "return 1;",
1754 ins => [ "val_high", "val_low" ],
1759 cmp_attr => "return 1;",
1761 outs => [ "res_high", "res_low" ],
1769 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1770 outs => [ "DST", "SRC", "CNT", "M" ],
1771 attr_type => "ia32_copyb_attr_t",
1772 attr => "unsigned size",
1775 # we don't care about this flag, so no need to mark this node
1776 # modified_flags => [ "DF" ]
1782 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1783 outs => [ "DST", "SRC", "M" ],
1784 attr_type => "ia32_copyb_attr_t",
1785 attr => "unsigned size",
1788 # we don't care about this flag, so no need to mark this node
1789 # modified_flags => [ "DF" ]
1795 state => "exc_pinned",
1796 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1797 ins => [ "base", "index", "mem", "val" ],
1798 am => "source,unary",
1801 attr => "ir_mode *smaller_mode",
1802 init_attr => "attr->ls_mode = smaller_mode;",
1807 state => "exc_pinned",
1808 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1809 ins => [ "base", "index", "mem", "val" ],
1810 am => "source,unary",
1813 attr => "ir_mode *smaller_mode",
1814 init_attr => "attr->ls_mode = smaller_mode;",
1819 state => "exc_pinned",
1820 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1821 ins => [ "base", "index", "mem", "val" ],
1822 am => "source,unary",
1829 state => "exc_pinned",
1830 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1831 ins => [ "base", "index", "mem", "val" ],
1832 am => "source,unary",
1839 state => "exc_pinned",
1840 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1841 ins => [ "base", "index", "mem", "val" ],
1842 am => "source,unary",
1848 #----------------------------------------------------------#
1850 # (_) | | | | / _| | | | #
1851 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1852 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1853 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1854 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1856 # _ __ ___ __| | ___ ___ #
1857 # | '_ \ / _ \ / _` |/ _ \/ __| #
1858 # | | | | (_) | (_| | __/\__ \ #
1859 # |_| |_|\___/ \__,_|\___||___/ #
1860 #----------------------------------------------------------#
1862 # rematerialisation disabled for all float nodes for now, because the fpcw
1863 # handler runs before spilling and we might end up with wrong fpcw then
1867 state => "exc_pinned",
1868 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1869 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1870 am => "source,binary",
1874 attr_type => "ia32_x87_attr_t",
1879 state => "exc_pinned",
1880 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1881 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1882 am => "source,binary",
1886 attr_type => "ia32_x87_attr_t",
1891 state => "exc_pinned",
1892 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1893 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1894 am => "source,binary",
1898 attr_type => "ia32_x87_attr_t",
1902 state => "exc_pinned",
1903 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1904 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1905 am => "source,binary",
1906 outs => [ "res", "M" ],
1909 attr_type => "ia32_x87_attr_t",
1913 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1914 ins => [ "left", "right", "fpcw" ],
1918 attr_type => "ia32_x87_attr_t",
1923 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1928 attr_type => "ia32_x87_attr_t",
1933 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1938 attr_type => "ia32_x87_attr_t",
1941 # virtual Load and Store
1946 state => "exc_pinned",
1947 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1948 ins => [ "base", "index", "mem" ],
1949 outs => [ "res", "M", "X_exc" ],
1950 attr => "ir_mode *load_mode",
1951 init_attr => "attr->attr.ls_mode = load_mode;",
1954 attr_type => "ia32_x87_attr_t",
1960 state => "exc_pinned",
1961 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1962 ins => [ "base", "index", "mem", "val" ],
1963 outs => [ "M", "X_exc" ],
1964 attr => "ir_mode *store_mode",
1965 init_attr => "attr->attr.ls_mode = store_mode;",
1969 attr_type => "ia32_x87_attr_t",
1975 state => "exc_pinned",
1976 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1977 outs => [ "res", "M" ],
1978 ins => [ "base", "index", "mem" ],
1981 attr_type => "ia32_x87_attr_t",
1985 cmp_attr => "return 1;",
1986 outs => [ "res", "M" ],
1991 state => "exc_pinned",
1992 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1993 ins => [ "base", "index", "mem", "val", "fpcw" ],
1997 attr_type => "ia32_x87_attr_t",
2000 # SSE3 fisttp instruction
2002 state => "exc_pinned",
2003 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2004 ins => [ "base", "index", "mem", "val" ],
2005 outs => [ "res", "M" ],
2008 attr_type => "ia32_x87_attr_t",
2012 cmp_attr => "return 1;",
2013 state => "exc_pinned",
2023 reg_req => { out => [ "vfp" ] },
2027 attr_type => "ia32_x87_attr_t",
2032 reg_req => { out => [ "vfp" ] },
2036 attr_type => "ia32_x87_attr_t",
2041 reg_req => { out => [ "vfp" ] },
2045 attr_type => "ia32_x87_attr_t",
2050 reg_req => { out => [ "vfp" ] },
2054 attr_type => "ia32_x87_attr_t",
2059 reg_req => { out => [ "vfp" ] },
2063 attr_type => "ia32_x87_attr_t",
2068 reg_req => { out => [ "vfp" ] },
2072 attr_type => "ia32_x87_attr_t",
2077 reg_req => { out => [ "vfp" ] },
2081 attr_type => "ia32_x87_attr_t",
2087 # we can't allow to rematerialize this node so we don't have
2088 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2090 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2091 ins => [ "left", "right" ],
2092 outs => [ "flags" ],
2093 attr => "int ins_permuted",
2094 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2097 attr_type => "ia32_x87_attr_t",
2103 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2104 ins => [ "left", "right" ],
2105 outs => [ "flags" ],
2106 attr => "int ins_permuted",
2107 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2110 attr_type => "ia32_x87_attr_t",
2116 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2118 outs => [ "flags" ],
2119 attr => "int ins_permuted",
2120 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2123 attr_type => "ia32_x87_attr_t",
2129 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2131 outs => [ "flags" ],
2135 mode => $mode_flags,
2138 #------------------------------------------------------------------------#
2139 # ___ _____ __ _ _ _ #
2140 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2141 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2142 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2143 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2144 #------------------------------------------------------------------------#
2146 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2147 # are swapped, we work this around in the emitter...
2150 state => "exc_pinned",
2151 rd_constructor => "NONE",
2153 emit => '. fadd%XM %x87_binop',
2155 attr_type => "ia32_x87_attr_t",
2159 state => "exc_pinned",
2160 rd_constructor => "NONE",
2162 emit => '. faddp%XM %x87_binop',
2164 attr_type => "ia32_x87_attr_t",
2168 state => "exc_pinned",
2169 rd_constructor => "NONE",
2171 emit => '. fmul%XM %x87_binop',
2173 attr_type => "ia32_x87_attr_t",
2177 state => "exc_pinned",
2178 rd_constructor => "NONE",
2180 emit => '. fmulp%XM %x87_binop',,
2182 attr_type => "ia32_x87_attr_t",
2186 state => "exc_pinned",
2187 rd_constructor => "NONE",
2189 emit => '. fsub%XM %x87_binop',
2191 attr_type => "ia32_x87_attr_t",
2195 state => "exc_pinned",
2196 rd_constructor => "NONE",
2198 # see note about gas bugs
2199 emit => '. fsubrp%XM %x87_binop',
2201 attr_type => "ia32_x87_attr_t",
2205 state => "exc_pinned",
2206 rd_constructor => "NONE",
2209 emit => '. fsubr%XM %x87_binop',
2211 attr_type => "ia32_x87_attr_t",
2215 state => "exc_pinned",
2216 rd_constructor => "NONE",
2219 # see note about gas bugs
2220 emit => '. fsubp%XM %x87_binop',
2222 attr_type => "ia32_x87_attr_t",
2226 rd_constructor => "NONE",
2230 attr_type => "ia32_x87_attr_t",
2233 # this node is just here, to keep the simulator running
2234 # we can omit this when a fprem simulation function exists
2236 rd_constructor => "NONE",
2238 emit => '. fprem1\n'.
2241 attr_type => "ia32_x87_attr_t",
2245 state => "exc_pinned",
2246 rd_constructor => "NONE",
2248 emit => '. fdiv%XM %x87_binop',
2250 attr_type => "ia32_x87_attr_t",
2254 state => "exc_pinned",
2255 rd_constructor => "NONE",
2257 # see note about gas bugs
2258 emit => '. fdivrp%XM %x87_binop',
2260 attr_type => "ia32_x87_attr_t",
2264 state => "exc_pinned",
2265 rd_constructor => "NONE",
2267 emit => '. fdivr%XM %x87_binop',
2269 attr_type => "ia32_x87_attr_t",
2273 state => "exc_pinned",
2274 rd_constructor => "NONE",
2276 # see note about gas bugs
2277 emit => '. fdivp%XM %x87_binop',
2279 attr_type => "ia32_x87_attr_t",
2283 rd_constructor => "NONE",
2287 attr_type => "ia32_x87_attr_t",
2292 rd_constructor => "NONE",
2296 attr_type => "ia32_x87_attr_t",
2299 # x87 Load and Store
2302 rd_constructor => "NONE",
2303 op_flags => "R|L|F",
2304 state => "exc_pinned",
2306 emit => '. fld%XM %AM',
2307 attr_type => "ia32_x87_attr_t",
2312 rd_constructor => "NONE",
2313 op_flags => "R|L|F",
2314 state => "exc_pinned",
2316 emit => '. fst%XM %AM',
2318 attr_type => "ia32_x87_attr_t",
2323 rd_constructor => "NONE",
2324 op_flags => "R|L|F",
2325 state => "exc_pinned",
2327 emit => '. fstp%XM %AM',
2329 attr_type => "ia32_x87_attr_t",
2336 state => "exc_pinned",
2337 rd_constructor => "NONE",
2339 emit => '. fild%M %AM',
2340 attr_type => "ia32_x87_attr_t",
2345 state => "exc_pinned",
2346 rd_constructor => "NONE",
2348 emit => '. fist%M %AM',
2350 attr_type => "ia32_x87_attr_t",
2355 state => "exc_pinned",
2356 rd_constructor => "NONE",
2358 emit => '. fistp%M %AM',
2360 attr_type => "ia32_x87_attr_t",
2364 # SSE3 firsttp instruction
2366 state => "exc_pinned",
2367 rd_constructor => "NONE",
2369 emit => '. fisttp%M %AM',
2371 attr_type => "ia32_x87_attr_t",
2378 op_flags => "R|c|K",
2380 reg_req => { out => [ "vfp" ] },
2382 attr_type => "ia32_x87_attr_t",
2387 op_flags => "R|c|K",
2389 reg_req => { out => [ "vfp" ] },
2391 attr_type => "ia32_x87_attr_t",
2396 op_flags => "R|c|K",
2398 reg_req => { out => [ "vfp" ] },
2400 attr_type => "ia32_x87_attr_t",
2405 op_flags => "R|c|K",
2407 reg_req => { out => [ "vfp" ] },
2409 attr_type => "ia32_x87_attr_t",
2414 op_flags => "R|c|K",
2416 reg_req => { out => [ "vfp" ] },
2418 attr_type => "ia32_x87_attr_t",
2423 op_flags => "R|c|K",
2425 reg_req => { out => [ "vfp" ] },
2426 emit => '. fldll2t',
2427 attr_type => "ia32_x87_attr_t",
2432 op_flags => "R|c|K",
2434 reg_req => { out => [ "vfp" ] },
2436 attr_type => "ia32_x87_attr_t",
2441 # Note that it is NEVER allowed to do CSE on these nodes
2442 # Moreover, note the virtual register requierements!
2447 cmp_attr => "return 1;",
2448 emit => '. fxch %X0',
2449 attr_type => "ia32_x87_attr_t",
2457 cmp_attr => "return 1;",
2458 emit => '. fld %X0',
2459 attr_type => "ia32_x87_attr_t",
2465 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2466 cmp_attr => "return 1;",
2467 emit => '. fld %X0',
2468 attr_type => "ia32_x87_attr_t",
2475 cmp_attr => "return 1;",
2476 emit => '. fstp %X0',
2477 attr_type => "ia32_x87_attr_t",
2485 cmp_attr => "return 1;",
2486 emit => '. ffreep %X0',
2487 attr_type => "ia32_x87_attr_t",
2495 cmp_attr => "return 1;",
2497 attr_type => "ia32_x87_attr_t",
2505 cmp_attr => "return 1;",
2507 attr_type => "ia32_x87_attr_t",
2516 emit => ". fucom %X1\n".
2518 attr_type => "ia32_x87_attr_t",
2524 emit => ". fucomp %X1\n".
2526 attr_type => "ia32_x87_attr_t",
2532 emit => ". fucompp\n".
2534 attr_type => "ia32_x87_attr_t",
2540 emit => '. fucomi %X1',
2541 attr_type => "ia32_x87_attr_t",
2547 emit => '. fucompi %X1',
2548 attr_type => "ia32_x87_attr_t",
2556 attr_type => "ia32_x87_attr_t",
2561 # -------------------------------------------------------------------------------- #
2562 # ____ ____ _____ _ _ #
2563 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2564 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2565 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2566 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2568 # -------------------------------------------------------------------------------- #
2571 # Spilling and reloading of SSE registers, hardcoded, not generated #
2575 state => "exc_pinned",
2576 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2577 emit => '. movdqu %D0, %AM',
2578 outs => [ "res", "M" ],
2585 state => "exc_pinned",
2586 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2587 ins => [ "base", "index", "mem", "val" ],
2588 emit => '. movdqu %binop',
2596 # Include the generated SIMD node specification written by the SIMD optimization
2597 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2598 unless ($return = do $my_script_name) {
2599 warn "couldn't parse $my_script_name: $@" if $@;
2600 warn "couldn't do $my_script_name: $!" unless defined $return;
2601 warn "couldn't run $my_script_name" unless $return;
2604 # Transform some attributes
2605 foreach my $op (keys(%nodes)) {
2606 my $node = $nodes{$op};
2607 my $op_attr_init = $node->{op_attr_init};
2609 if(defined($op_attr_init)) {
2610 $op_attr_init .= "\n\t";
2615 if(!defined($node->{latency})) {
2617 $node->{latency} = 0;
2619 die("Latency missing for op $op");
2622 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2624 $node->{op_attr_init} = $op_attr_init;