3 # This is the specification for the ia32 assembler Firm-operations
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
13 # The node description is done as a perl hash initializer with the
14 # following structure:
19 # op_flags => "N|L|C|X|I|F|Y|H|c|K",
20 # irn_flags => "R|N|I|S"
21 # arity => "0|1|2|3 ... |variable|dynamic|any",
22 # state => "floats|pinned|mem_pinned|exc_pinned",
24 # { type => "type 1", name => "name 1" },
25 # { type => "type 2", name => "name 2" },
28 # comment => "any comment for constructor",
29 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 # cmp_attr => "c source code for comparing node attributes",
31 # emit => "emit code with templates",
32 # attr => "attitional attribute arguments for constructor"
33 # init_attr => "emit attribute initialization template"
34 # rd_constructor => "c source code which constructs an ir_node"
35 # attr_type => "name of the attribute struct",
38 # ... # (all nodes you need to describe)
40 # ); # close the %nodes initializer
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
46 # C irop_flag_commutative
47 # X irop_flag_cfopcode
48 # I irop_flag_ip_cfopcode
51 # H irop_flag_highlevel
52 # c irop_flag_constlike
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
59 # I ignore for register allocation
60 # S modifies stack pointer
62 # state: state of the operation, OPTIONAL (default is "floats")
64 # arity: arity of the operation, MUST NOT BE OMITTED
66 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
67 # are always the first 3 arguments and are always autmatically
69 # If this key is missing the following arguments will be created:
70 # for i = 1 .. arity: ir_node *op_i
73 # outs: if a node defines more than one output, the names of the projections
74 # nodes having outs having automatically the mode mode_T
75 # One can also annotate some flags for each out, additional to irn_flags.
76 # They are separated from name with a colon ':', and concatenated by pipe '|'
77 # Only I and S are available at the moment (same meaning as in irn_flags).
78 # example: [ "frame:I", "stack:I|S", "M" ]
80 # comment: OPTIONAL comment for the node constructor
82 # rd_constructor: for every operation there will be a
83 # new_rd_<arch>_<op-name> function with the arguments from above
84 # which creates the ir_node corresponding to the defined operation
85 # you can either put the complete source code of this function here
87 # This key is OPTIONAL. If omitted, the following constructor will
89 # if (!op_<arch>_<op-name>) assert(0);
93 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
96 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
100 # 0 - no special type
101 # 1 - caller save (register must be saved by the caller of a function)
102 # 2 - callee save (register must be saved by the called function)
103 # 4 - ignore (do not assign this register)
104 # 8 - emitter can choose an arbitrary register of this class
105 # 16 - the register is a virtual one
106 # 32 - register represents a state
107 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
110 { name => "edx", type => 1 },
111 { name => "ecx", type => 1 },
112 { name => "eax", type => 1 },
113 { name => "ebx", type => 2 },
114 { name => "esi", type => 2 },
115 { name => "edi", type => 2 },
116 { name => "ebp", type => 2 },
117 { name => "esp", type => 4 },
118 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
119 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
120 { mode => "mode_Iu" }
123 { name => "mm0", type => 4 },
124 { name => "mm1", type => 4 },
125 { name => "mm2", type => 4 },
126 { name => "mm3", type => 4 },
127 { name => "mm4", type => 4 },
128 { name => "mm5", type => 4 },
129 { name => "mm6", type => 4 },
130 { name => "mm7", type => 4 },
131 { mode => "mode_E", flags => "manual_ra" }
134 { name => "xmm0", type => 1 },
135 { name => "xmm1", type => 1 },
136 { name => "xmm2", type => 1 },
137 { name => "xmm3", type => 1 },
138 { name => "xmm4", type => 1 },
139 { name => "xmm5", type => 1 },
140 { name => "xmm6", type => 1 },
141 { name => "xmm7", type => 1 },
142 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
143 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
147 { name => "vf0", type => 1 | 16 },
148 { name => "vf1", type => 1 | 16 },
149 { name => "vf2", type => 1 | 16 },
150 { name => "vf3", type => 1 | 16 },
151 { name => "vf4", type => 1 | 16 },
152 { name => "vf5", type => 1 | 16 },
153 { name => "vf6", type => 1 | 16 },
154 { name => "vf7", type => 1 | 16 },
155 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
156 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
160 { name => "st0", realname => "st", type => 4 },
161 { name => "st1", realname => "st(1)", type => 4 },
162 { name => "st2", realname => "st(2)", type => 4 },
163 { name => "st3", realname => "st(3)", type => 4 },
164 { name => "st4", realname => "st(4)", type => 4 },
165 { name => "st5", realname => "st(5)", type => 4 },
166 { name => "st6", realname => "st(6)", type => 4 },
167 { name => "st7", realname => "st(7)", type => 4 },
168 { mode => "mode_E", flags => "manual_ra" }
170 fp_cw => [ # the floating point control word
171 { name => "fpcw", type => 4|32 },
172 { mode => "mode_fpcw", flags => "manual_ra|state" }
175 { name => "eflags", type => 0 },
176 { mode => "mode_Iu", flags => "manual_ra" }
181 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
182 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
183 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
184 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
189 bundels_per_cycle => 1
193 S0 => "${arch}_emit_source_register(node, 0);",
194 S1 => "${arch}_emit_source_register(node, 1);",
195 S2 => "${arch}_emit_source_register(node, 2);",
196 S3 => "${arch}_emit_source_register(node, 3);",
197 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
198 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
199 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
200 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
201 D0 => "${arch}_emit_dest_register(node, 0);",
202 D1 => "${arch}_emit_dest_register(node, 1);",
203 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
204 X0 => "${arch}_emit_x87_register(node, 0);",
205 X1 => "${arch}_emit_x87_register(node, 1);",
206 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
207 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
208 ia32_emit_mode_suffix(node);",
209 M => "${arch}_emit_mode_suffix(node);",
210 XM => "${arch}_emit_x87_mode_suffix(node);",
211 XXM => "${arch}_emit_xmm_mode_suffix(node);",
212 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
213 AM => "${arch}_emit_am(node);",
214 unop3 => "${arch}_emit_unop(node, 3);",
215 unop4 => "${arch}_emit_unop(node, 4);",
216 unop5 => "${arch}_emit_unop(node, 5);",
217 DAM0 => "${arch}_emit_am_or_dest_register(node, 0);",
218 binop => "${arch}_emit_binop(node);",
219 x87_binop => "${arch}_emit_x87_binop(node);",
220 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
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 "full,binary") {
249 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
250 } elsif($am eq "full,unary") {
251 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
252 } elsif($am eq "source,unary") {
253 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_unary);";
254 } elsif($am eq "source,binary") {
255 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
256 } elsif($am eq "dest,unary") {
257 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
258 } elsif($am eq "dest,binary") {
259 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
260 } elsif($am eq "dest,ternary") {
261 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
262 } elsif($am eq "source,ternary") {
263 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
264 } elsif($am eq "none") {
267 die("Invalid address mode '$am' specified on op $name");
270 if($node->{state} ne "exc_pinned"
271 and $node->{state} ne "pinned") {
272 die("AM nodes must have pinned or AM pinned state ($name)");
278 $custom_init_attr_func = \&ia32_custom_init_attr;
281 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
284 "\tinit_ia32_x87_attributes(res);",
286 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
287 "\tinit_ia32_x87_attributes(res);".
288 "\tinit_ia32_asm_attributes(res);",
289 ia32_immediate_attr_t =>
290 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
291 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
293 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
294 "\tinit_ia32_copyb_attributes(res, size);",
295 ia32_condcode_attr_t =>
296 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
297 "\tinit_ia32_condcode_attributes(res, pnc);",
301 ia32_attr_t => "ia32_compare_nodes_attr",
302 ia32_x87_attr_t => "ia32_compare_x87_attr",
303 ia32_asm_attr_t => "ia32_compare_asm_attr",
304 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
305 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
306 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
312 $mode_xmm = "mode_E";
313 $mode_gp = "mode_Iu";
314 $mode_flags = "mode_Iu";
315 $mode_fpcw = "mode_fpcw";
316 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
317 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
318 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
326 reg_req => { out => [ "gp_NOREG" ] },
327 attr => "ir_entity *symconst, int symconst_sign, long offset",
328 attr_type => "ia32_immediate_attr_t",
336 out_arity => "variable",
337 attr_type => "ia32_asm_attr_t",
338 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
339 init_attr => "attr->asm_text = asm_text;\n".
340 "\tattr->register_map = register_map;\n",
348 reg_req => { out => [ "gp" ] },
353 cmp_attr => "return 1;",
356 #-----------------------------------------------------------------#
359 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
360 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
361 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
362 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
365 #-----------------------------------------------------------------#
367 # commutative operations
371 state => "exc_pinned",
372 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5", "none", "flags" ] },
373 ins => [ "base", "index", "mem", "left", "right" ],
374 emit => '. add%M %binop',
379 modified_flags => $status_flags
384 state => "exc_pinned",
385 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
386 ins => [ "base", "index", "mem", "val" ],
387 emit => ". add%M %SI3, %AM",
391 modified_flags => $status_flags
396 state => "exc_pinned",
397 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
398 ins => [ "base", "index", "mem", "val" ],
399 emit => ". add%M %SB3, %AM",
403 modified_flags => $status_flags
407 state => "exc_pinned",
408 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 in_r5" ] },
409 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
410 emit => '. adc%M %binop',
415 modified_flags => $status_flags
420 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
421 ins => [ "left", "right" ],
425 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
426 ins => [ "left", "right", "eflags" ],
430 # we should not rematrialize this node. It produces 2 results and has
431 # very strict constrains
432 state => "exc_pinned",
433 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
434 ins => [ "base", "index", "mem", "val_high", "val_low" ],
435 emit => '. mul%M %unop4',
436 outs => [ "EAX", "EDX", "M" ],
437 am => "source,binary",
440 modified_flags => $status_flags
444 # we should not rematrialize this node. It produces 2 results and has
445 # very strict constrains
447 cmp_attr => "return 1;",
448 outs => [ "EAX", "EDX", "M" ],
454 state => "exc_pinned",
455 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
456 ins => [ "base", "index", "mem", "left", "right" ],
457 emit => '. imul%M %binop',
458 am => "source,binary",
462 modified_flags => $status_flags
467 state => "exc_pinned",
468 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
469 ins => [ "base", "index", "mem", "val_high", "val_low" ],
470 emit => '. imul%M %unop4',
471 outs => [ "EAX", "EDX", "M" ],
472 am => "source,binary",
475 modified_flags => $status_flags
479 # we should not rematrialize this node. It produces 2 results and has
480 # very strict constrains
482 cmp_attr => "return 1;",
483 outs => [ "EAX", "EDX", "M" ],
489 state => "exc_pinned",
490 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
491 ins => [ "base", "index", "mem", "left", "right" ],
492 op_modes => "commutative | am | immediate | mode_neutral",
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" ], out => [ "in_r4 in_r5" ] },
529 ins => [ "base", "index", "mem", "left", "right" ],
531 emit => '. or%M %binop',
535 modified_flags => $status_flags
540 state => "exc_pinned",
541 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
542 ins => [ "base", "index", "mem", "val" ],
543 emit => '. or%M %SI3, %AM',
547 modified_flags => $status_flags
552 state => "exc_pinned",
553 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
554 ins => [ "base", "index", "mem", "val" ],
555 emit => '. or%M %SB3, %AM',
559 modified_flags => $status_flags
564 state => "exc_pinned",
565 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
566 ins => [ "base", "index", "mem", "left", "right" ],
568 emit => '. xor%M %binop',
572 modified_flags => $status_flags
577 state => "exc_pinned",
578 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
579 ins => [ "base", "index", "mem", "val" ],
580 emit => '. xor%M %SI3, %AM',
584 modified_flags => $status_flags
589 state => "exc_pinned",
590 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
591 ins => [ "base", "index", "mem", "val" ],
592 emit => '. xor%M %SB3, %AM',
596 modified_flags => $status_flags
599 # not commutative operations
603 state => "exc_pinned",
604 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4", "none", "flags" ] },
605 ins => [ "base", "index", "mem", "left", "right" ],
607 emit => '. sub%M %binop',
611 modified_flags => $status_flags
616 state => "exc_pinned",
617 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
618 ins => [ "base", "index", "mem", "val" ],
619 emit => '. sub%M %SI3, %AM',
623 modified_flags => $status_flags
628 state => "exc_pinned",
629 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
630 ins => [ "base", "index", "mem", "val" ],
631 emit => '. sub%M %SB3, %AM',
635 modified_flags => $status_flags
639 state => "exc_pinned",
640 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 !in_r5" ] },
641 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
643 emit => '. sbb%M %binop',
647 modified_flags => $status_flags
651 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
652 ins => [ "left", "right" ],
656 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
657 ins => [ "left", "right", "eflags" ],
662 state => "exc_pinned",
663 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "none", "none", "edx" ] },
664 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
665 outs => [ "div_res", "M", "unused", "mod_res" ],
666 am => "source,ternary",
667 emit => ". idiv%M %unop5",
670 modified_flags => $status_flags
675 state => "exc_pinned",
676 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "none", "none", "edx" ] },
677 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
678 outs => [ "div_res", "M", "unused", "mod_res" ],
679 am => "source,ternary",
680 emit => ". div%M %unop5",
683 modified_flags => $status_flags
688 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
689 ins => [ "left", "right" ],
690 emit => '. shl %SB1, %S0',
694 modified_flags => $status_flags
699 state => "exc_pinned",
700 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
701 ins => [ "base", "index", "mem", "count" ],
702 emit => '. shl%M %SB3, %AM',
706 modified_flags => $status_flags
710 cmp_attr => "return 1;",
711 ins => [ "left", "right", "dep" ],
712 # value, cnt, dependency
718 # see ShrD about the strange out constraint
719 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
720 ins => [ "left_high", "left_low", "right" ],
721 emit => ". shld%M %SB2, %S1, %S0\n".
726 modified_flags => $status_flags
730 cmp_attr => "return 1;",
731 ins => [ "high", "low", "count" ],
737 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
738 ins => [ "val", "count" ],
739 emit => '. shr %SB1, %S0',
743 modified_flags => $status_flags
748 state => "exc_pinned",
749 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
750 ins => [ "base", "index", "mem", "count" ],
751 emit => '. shr%M %SB3, %AM',
755 modified_flags => $status_flags
759 cmp_attr => "return 1;",
760 ins => [ "left", "right", "dep" ],
761 # value, cnt, dependency
766 # What's going on with the out constraint here? We would like to write
767 # "in_r2" and be done. However in firm we only support should_be_same
768 # constraints at the moment. Which means they could be non-fullfilled in
769 # some cases. Now when all values happen to live through the node, out
770 # is ecx and in_r2 not ecx, then we're screwed. Because in this case we
771 # need a 4th Register.
773 # The best solution for this is extending the register allocator to support
774 # must_be_same constraints which create a copy when the in_r2 value
775 # lives through (this ensures that we have the 4th register in the cases
776 # when we need it and can always fix the situation).
778 # For now I'm doing this ultra ugly !in hack which allocates 4 registers
779 # and creates an extra mov
781 reg_req => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
782 ins => [ "left_high", "left_low", "right" ],
783 emit => ". shrd%M %SB2, %S1, %S0\n".
788 modified_flags => $status_flags
792 cmp_attr => "return 1;",
794 ins => [ "high", "low", "count" ],
799 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
800 ins => [ "val", "count" ],
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 => [ "left", "right", "dep" ],
823 # value, cnt, dependency
829 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
830 ins => [ "val", "count" ],
831 emit => '. ror %SB1, %S0',
835 modified_flags => $status_flags
840 state => "exc_pinned",
841 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
842 ins => [ "base", "index", "mem", "count" ],
843 emit => '. ror%M %SB3, %AM',
847 modified_flags => $status_flags
852 reg_req => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
853 ins => [ "val", "count" ],
854 emit => '. rol %SB1, %S0',
858 modified_flags => $status_flags
863 state => "exc_pinned",
864 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
865 ins => [ "base", "index", "mem", "count" ],
866 emit => '. rol%M %SB3, %AM',
870 modified_flags => $status_flags
877 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
883 modified_flags => $status_flags
888 state => "exc_pinned",
889 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
890 ins => [ "base", "index", "mem" ],
891 emit => '. neg%M %AM',
895 modified_flags => $status_flags
900 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
901 outs => [ "low_res", "high_res" ],
904 modified_flags => $status_flags
910 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
915 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
920 state => "exc_pinned",
921 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
922 ins => [ "base", "index", "mem" ],
923 emit => '. inc%M %AM',
927 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
932 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
937 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
942 state => "exc_pinned",
943 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
944 ins => [ "base", "index", "mem" ],
945 emit => '. dec%M %AM',
949 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
954 reg_req => { in => [ "gp" ], out => [ "in_r1" ] },
964 state => "exc_pinned",
965 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
966 ins => [ "base", "index", "mem" ],
967 emit => '. not%M %AM',
977 state => "exc_pinned",
978 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
979 ins => [ "base", "index", "mem", "left", "right" ],
980 outs => [ "eflags" ],
981 am => "source,binary",
982 emit => '. cmp%M %binop',
983 attr => "int ins_permuted, int cmp_unsigned",
984 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
985 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
989 modified_flags => $status_flags
994 state => "exc_pinned",
995 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
996 ins => [ "base", "index", "mem", "left", "right" ],
997 outs => [ "eflags" ],
998 am => "source,binary",
999 emit => '. cmpb %binop',
1000 attr => "int ins_permuted, int cmp_unsigned",
1001 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1002 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1005 mode => $mode_flags,
1006 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 => '. test%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 => '. testb %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 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1046 ins => [ "eflags" ],
1047 attr_type => "ia32_condcode_attr_t",
1048 attr => "pn_Cmp pnc, int ins_permuted",
1049 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1050 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1051 emit => '. set%CMP0 %DB0',
1059 # (note: leave the false,true order intact to make it compatible with other
1061 state => "exc_pinned",
1062 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1063 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1064 am => "source,binary",
1065 attr_type => "ia32_condcode_attr_t",
1066 attr => "int ins_permuted, pn_Cmp pnc",
1067 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1075 op_flags => "L|X|Y",
1076 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1077 ins => [ "eflags" ],
1078 outs => [ "false", "true" ],
1079 attr_type => "ia32_condcode_attr_t",
1080 attr => "pn_Cmp pnc",
1082 units => [ "BRANCH" ],
1087 op_flags => "L|X|Y",
1088 reg_req => { in => [ "gp" ], out => [ "none" ] },
1090 attr_type => "ia32_condcode_attr_t",
1091 attr => "pn_Cmp pnc",
1093 units => [ "BRANCH" ],
1094 modified_flags => $status_flags,
1100 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1101 ins => [ "base", "index", "mem", "target" ],
1102 am => "source,unary",
1103 emit => '. jmp *%unop3',
1105 units => [ "BRANCH" ],
1112 reg_req => { out => [ "gp" ] },
1114 attr => "ir_entity *symconst, int symconst_sign, long offset",
1115 attr_type => "ia32_immediate_attr_t",
1124 reg_req => { out => [ "gp_UKNWN" ] },
1135 reg_req => { out => [ "vfp_UKNWN" ] },
1140 attr_type => "ia32_x87_attr_t",
1147 reg_req => { out => [ "xmm_UKNWN" ] },
1158 reg_req => { out => [ "gp_NOREG" ] },
1169 reg_req => { out => [ "vfp_NOREG" ] },
1174 attr_type => "ia32_x87_attr_t",
1181 reg_req => { out => [ "xmm_NOREG" ] },
1192 reg_req => { out => [ "fp_cw" ] },
1196 modified_flags => $fpcw_flags
1202 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1203 ins => [ "base", "index", "mem" ],
1205 emit => ". fldcw %AM",
1208 modified_flags => $fpcw_flags
1214 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1215 ins => [ "base", "index", "mem", "fpcw" ],
1217 emit => ". fnstcw %AM",
1223 # we should not rematrialize this node. It has very strict constraints.
1224 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1225 ins => [ "val", "globbered" ],
1234 # Note that we add additional latency values depending on address mode, so a
1235 # lateny of 0 for load is correct
1239 state => "exc_pinned",
1240 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1241 ins => [ "base", "index", "mem" ],
1242 outs => [ "res", "M" ],
1244 emit => ". mov%SE%ME%.l %AM, %D0",
1250 cmp_attr => "return 1;",
1251 outs => [ "res", "M" ],
1257 cmp_attr => "return 1;",
1258 state => "exc_pinned",
1265 state => "exc_pinned",
1266 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1267 ins => [ "base", "index", "mem", "val" ],
1268 emit => '. mov%M %SI3, %AM',
1276 state => "exc_pinned",
1277 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1278 ins => [ "base", "index", "mem", "val" ],
1279 emit => '. mov%M %SB3, %AM',
1287 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1288 ins => [ "base", "index" ],
1289 emit => '. leal %AM, %D0',
1293 # lea doesn't modify the flags, but setting this seems advantageous since it
1294 # increases chances that the Lea is transformed back to an Add
1295 modified_flags => 1,
1299 state => "exc_pinned",
1300 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp", "none" ] },
1301 ins => [ "base", "index", "mem", "val", "stack" ],
1302 emit => '. push%M %unop4',
1303 outs => [ "stack:I|S", "M" ],
1304 am => "source,binary",
1310 state => "exc_pinned",
1311 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1312 emit => '. pop%M %DAM0',
1313 outs => [ "res", "M", "unused", "stack:I|S" ],
1314 ins => [ "base", "index", "mem", "stack" ],
1316 latency => 3, # Pop is more expensive than Push on Athlon
1321 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1323 outs => [ "frame:I", "stack:I|S", "M" ],
1329 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1331 outs => [ "frame:I", "stack:I|S" ],
1339 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1340 ins => [ "base", "index", "mem", "stack", "size" ],
1341 am => "source,binary",
1342 emit => '. addl %binop',
1344 outs => [ "stack:S", "M" ],
1346 modified_flags => $status_flags
1352 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1353 ins => [ "base", "index", "mem", "stack", "size" ],
1354 am => "source,binary",
1355 emit => ". subl %binop\n".
1356 ". movl %%esp, %D1",
1358 outs => [ "stack:I|S", "addr", "M" ],
1360 modified_flags => $status_flags
1365 reg_req => { out => [ "gp" ] },
1371 #-----------------------------------------------------------------------------#
1372 # _____ _____ ______ __ _ _ _ #
1373 # / ____/ ____| ____| / _| | | | | | #
1374 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1375 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1376 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1377 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1378 #-----------------------------------------------------------------------------#
1382 reg_req => { out => [ "xmm" ] },
1383 emit => '. xorp%XSD %D0, %D0',
1389 # commutative operations
1393 state => "exc_pinned",
1394 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1395 ins => [ "base", "index", "mem", "left", "right" ],
1396 am => "source,binary",
1397 emit => '. add%XXM %binop',
1405 state => "exc_pinned",
1406 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1407 ins => [ "base", "index", "mem", "left", "right" ],
1408 am => "source,binary",
1409 emit => '. mul%XXM %binop',
1417 state => "exc_pinned",
1418 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1419 ins => [ "base", "index", "mem", "left", "right" ],
1420 am => "source,binary",
1421 emit => '. max%XXM %binop',
1429 state => "exc_pinned",
1430 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1431 ins => [ "base", "index", "mem", "left", "right" ],
1432 am => "source,binary",
1433 emit => '. min%XXM %binop',
1441 state => "exc_pinned",
1442 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1443 ins => [ "base", "index", "mem", "left", "right" ],
1444 am => "source,binary",
1445 emit => '. andp%XSD %binop',
1453 state => "exc_pinned",
1454 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1455 ins => [ "base", "index", "mem", "left", "right" ],
1456 am => "source,binary",
1457 emit => '. orp%XSD %binop',
1465 state => "exc_pinned",
1466 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1467 ins => [ "base", "index", "mem", "left", "right" ],
1468 am => "source,binary",
1469 emit => '. xorp%XSD %binop',
1475 # not commutative operations
1479 state => "exc_pinned",
1480 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1481 ins => [ "base", "index", "mem", "left", "right" ],
1482 am => "source,binary",
1483 emit => '. andnp%XSD %binop',
1491 state => "exc_pinned",
1492 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1493 ins => [ "base", "index", "mem", "left", "right" ],
1494 am => "source,binary",
1495 emit => '. sub%XXM %binop',
1503 state => "exc_pinned",
1504 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1505 ins => [ "base", "index", "mem", "left", "right" ],
1506 am => "source,binary",
1507 outs => [ "res", "M" ],
1508 emit => '. div%XXM %binop',
1517 state => "exc_pinned",
1518 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1519 ins => [ "base", "index", "mem", "left", "right" ],
1520 outs => [ "flags" ],
1521 am => "source,binary",
1522 attr => "int ins_permuted",
1523 init_attr => "attr->data.ins_permuted = ins_permuted;",
1524 emit => ' .ucomi%XXM %binop',
1527 mode => $mode_flags,
1528 modified_flags => 1,
1535 state => "exc_pinned",
1536 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1537 ins => [ "base", "index", "mem" ],
1538 emit => '. mov%XXM %AM, %D0',
1539 attr => "ir_mode *load_mode",
1540 init_attr => "attr->ls_mode = load_mode;",
1541 outs => [ "res", "M" ],
1548 state => "exc_pinned",
1549 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1550 ins => [ "base", "index", "mem", "val" ],
1551 emit => '. mov%XXM %S3, %AM',
1559 state => "exc_pinned",
1560 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1561 ins => [ "base", "index", "mem", "val" ],
1562 emit => '. mov%XXM %S3, %AM',
1570 state => "exc_pinned",
1571 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1572 ins => [ "base", "index", "mem", "val" ],
1573 am => "source,unary",
1574 emit => '. cvtsi2ss %unop3, %D0',
1582 state => "exc_pinned",
1583 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1584 ins => [ "base", "index", "mem", "val" ],
1585 am => "source,unary",
1586 emit => '. cvtsi2sd %unop3, %D0',
1595 cmp_attr => "return 1;",
1601 cmp_attr => "return 1;",
1610 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1611 outs => [ "DST", "SRC", "CNT", "M" ],
1612 attr_type => "ia32_copyb_attr_t",
1613 attr => "unsigned size",
1616 # we don't care about this flag, so no need to mark this node
1617 # modified_flags => [ "DF" ]
1623 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1624 outs => [ "DST", "SRC", "M" ],
1625 attr_type => "ia32_copyb_attr_t",
1626 attr => "unsigned size",
1629 # we don't care about this flag, so no need to mark this node
1630 # modified_flags => [ "DF" ]
1636 state => "exc_pinned",
1637 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1638 ins => [ "base", "index", "mem", "val" ],
1639 am => "source,unary",
1642 attr => "ir_mode *smaller_mode",
1643 init_attr => "attr->ls_mode = smaller_mode;",
1648 state => "exc_pinned",
1649 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1650 ins => [ "base", "index", "mem", "val" ],
1651 am => "source,unary",
1654 attr => "ir_mode *smaller_mode",
1655 init_attr => "attr->ls_mode = smaller_mode;",
1660 state => "exc_pinned",
1661 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1662 ins => [ "base", "index", "mem", "val" ],
1663 am => "source,unary",
1670 state => "exc_pinned",
1671 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1672 ins => [ "base", "index", "mem", "val" ],
1673 am => "source,unary",
1680 state => "exc_pinned",
1681 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1682 ins => [ "base", "index", "mem", "val" ],
1683 am => "source,unary",
1689 #----------------------------------------------------------#
1691 # (_) | | | | / _| | | | #
1692 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1693 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1694 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1695 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1697 # _ __ ___ __| | ___ ___ #
1698 # | '_ \ / _ \ / _` |/ _ \/ __| #
1699 # | | | | (_) | (_| | __/\__ \ #
1700 # |_| |_|\___/ \__,_|\___||___/ #
1701 #----------------------------------------------------------#
1703 # rematerialisation disabled for all float nodes for now, because the fpcw
1704 # handler runs before spilling and we might end up with wrong fpcw then
1708 state => "exc_pinned",
1709 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1710 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1711 am => "source,binary",
1715 attr_type => "ia32_x87_attr_t",
1720 state => "exc_pinned",
1721 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1722 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1723 am => "source,binary",
1727 attr_type => "ia32_x87_attr_t",
1732 state => "exc_pinned",
1733 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1734 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1735 am => "source,binary",
1739 attr_type => "ia32_x87_attr_t",
1743 state => "exc_pinned",
1744 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1745 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1746 am => "source,binary",
1747 outs => [ "res", "M" ],
1750 attr_type => "ia32_x87_attr_t",
1754 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1755 ins => [ "left", "right", "fpcw" ],
1759 attr_type => "ia32_x87_attr_t",
1764 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1769 attr_type => "ia32_x87_attr_t",
1774 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1779 attr_type => "ia32_x87_attr_t",
1782 # virtual Load and Store
1787 state => "exc_pinned",
1788 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1789 ins => [ "base", "index", "mem" ],
1790 outs => [ "res", "M" ],
1791 attr => "ir_mode *load_mode",
1792 init_attr => "attr->attr.ls_mode = load_mode;",
1795 attr_type => "ia32_x87_attr_t",
1801 state => "exc_pinned",
1802 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1803 ins => [ "base", "index", "mem", "val" ],
1804 attr => "ir_mode *store_mode",
1805 init_attr => "attr->attr.ls_mode = store_mode;",
1809 attr_type => "ia32_x87_attr_t",
1815 state => "exc_pinned",
1816 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1817 outs => [ "res", "M" ],
1818 ins => [ "base", "index", "mem" ],
1821 attr_type => "ia32_x87_attr_t",
1825 cmp_attr => "return 1;",
1826 outs => [ "res", "M" ],
1831 state => "exc_pinned",
1832 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1833 ins => [ "base", "index", "mem", "val", "fpcw" ],
1837 attr_type => "ia32_x87_attr_t",
1841 cmp_attr => "return 1;",
1842 state => "exc_pinned",
1852 reg_req => { out => [ "vfp" ] },
1856 attr_type => "ia32_x87_attr_t",
1861 reg_req => { out => [ "vfp" ] },
1865 attr_type => "ia32_x87_attr_t",
1870 reg_req => { out => [ "vfp" ] },
1874 attr_type => "ia32_x87_attr_t",
1879 reg_req => { out => [ "vfp" ] },
1883 attr_type => "ia32_x87_attr_t",
1888 reg_req => { out => [ "vfp" ] },
1892 attr_type => "ia32_x87_attr_t",
1897 reg_req => { out => [ "vfp" ] },
1901 attr_type => "ia32_x87_attr_t",
1906 reg_req => { out => [ "vfp" ] },
1910 attr_type => "ia32_x87_attr_t",
1916 # we can't allow to rematerialize this node so we don't have
1917 # accidently produce Phi(Fucom, Fucom(ins_permuted))
1919 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1920 ins => [ "left", "right" ],
1921 outs => [ "flags" ],
1922 attr => "int ins_permuted",
1923 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1926 attr_type => "ia32_x87_attr_t",
1932 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
1933 ins => [ "left", "right" ],
1934 outs => [ "flags" ],
1935 attr => "int ins_permuted",
1936 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1939 attr_type => "ia32_x87_attr_t",
1945 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
1947 outs => [ "flags" ],
1948 attr => "int ins_permuted",
1949 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1952 attr_type => "ia32_x87_attr_t",
1958 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
1960 outs => [ "flags" ],
1964 mode => $mode_flags,
1967 #------------------------------------------------------------------------#
1968 # ___ _____ __ _ _ _ #
1969 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1970 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1971 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1972 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1973 #------------------------------------------------------------------------#
1975 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1976 # are swapped, we work this around in the emitter...
1979 state => "exc_pinned",
1980 rd_constructor => "NONE",
1982 emit => '. fadd%XM %x87_binop',
1984 attr_type => "ia32_x87_attr_t",
1988 state => "exc_pinned",
1989 rd_constructor => "NONE",
1991 emit => '. faddp%XM %x87_binop',
1993 attr_type => "ia32_x87_attr_t",
1997 state => "exc_pinned",
1998 rd_constructor => "NONE",
2000 emit => '. fmul%XM %x87_binop',
2002 attr_type => "ia32_x87_attr_t",
2006 state => "exc_pinned",
2007 rd_constructor => "NONE",
2009 emit => '. fmulp%XM %x87_binop',,
2011 attr_type => "ia32_x87_attr_t",
2015 state => "exc_pinned",
2016 rd_constructor => "NONE",
2018 emit => '. fsub%XM %x87_binop',
2020 attr_type => "ia32_x87_attr_t",
2024 state => "exc_pinned",
2025 rd_constructor => "NONE",
2027 # see note about gas bugs
2028 emit => '. fsubrp%XM %x87_binop',
2030 attr_type => "ia32_x87_attr_t",
2034 state => "exc_pinned",
2035 rd_constructor => "NONE",
2038 emit => '. fsubr%XM %x87_binop',
2040 attr_type => "ia32_x87_attr_t",
2044 state => "exc_pinned",
2045 rd_constructor => "NONE",
2048 # see note about gas bugs
2049 emit => '. fsubp%XM %x87_binop',
2051 attr_type => "ia32_x87_attr_t",
2055 rd_constructor => "NONE",
2059 attr_type => "ia32_x87_attr_t",
2062 # this node is just here, to keep the simulator running
2063 # we can omit this when a fprem simulation function exists
2065 rd_constructor => "NONE",
2067 emit => '. fprem1\n'.
2070 attr_type => "ia32_x87_attr_t",
2074 state => "exc_pinned",
2075 rd_constructor => "NONE",
2077 emit => '. fdiv%XM %x87_binop',
2079 attr_type => "ia32_x87_attr_t",
2083 state => "exc_pinned",
2084 rd_constructor => "NONE",
2086 # see note about gas bugs
2087 emit => '. fdivrp%XM %x87_binop',
2089 attr_type => "ia32_x87_attr_t",
2093 state => "exc_pinned",
2094 rd_constructor => "NONE",
2096 emit => '. fdivr%XM %x87_binop',
2098 attr_type => "ia32_x87_attr_t",
2102 state => "exc_pinned",
2103 rd_constructor => "NONE",
2105 # see note about gas bugs
2106 emit => '. fdivp%XM %x87_binop',
2108 attr_type => "ia32_x87_attr_t",
2112 rd_constructor => "NONE",
2116 attr_type => "ia32_x87_attr_t",
2121 rd_constructor => "NONE",
2125 attr_type => "ia32_x87_attr_t",
2128 # x87 Load and Store
2131 rd_constructor => "NONE",
2132 op_flags => "R|L|F",
2133 state => "exc_pinned",
2135 emit => '. fld%XM %AM',
2136 attr_type => "ia32_x87_attr_t",
2141 rd_constructor => "NONE",
2142 op_flags => "R|L|F",
2143 state => "exc_pinned",
2145 emit => '. fst%XM %AM',
2147 attr_type => "ia32_x87_attr_t",
2152 rd_constructor => "NONE",
2153 op_flags => "R|L|F",
2154 state => "exc_pinned",
2156 emit => '. fstp%XM %AM',
2158 attr_type => "ia32_x87_attr_t",
2165 state => "exc_pinned",
2166 rd_constructor => "NONE",
2168 emit => '. fild%M %AM',
2169 attr_type => "ia32_x87_attr_t",
2174 state => "exc_pinned",
2175 rd_constructor => "NONE",
2177 emit => '. fist%M %AM',
2179 attr_type => "ia32_x87_attr_t",
2184 state => "exc_pinned",
2185 rd_constructor => "NONE",
2187 emit => '. fistp%M %AM',
2189 attr_type => "ia32_x87_attr_t",
2196 op_flags => "R|c|K",
2198 reg_req => { out => [ "vfp" ] },
2200 attr_type => "ia32_x87_attr_t",
2205 op_flags => "R|c|K",
2207 reg_req => { out => [ "vfp" ] },
2209 attr_type => "ia32_x87_attr_t",
2214 op_flags => "R|c|K",
2216 reg_req => { out => [ "vfp" ] },
2218 attr_type => "ia32_x87_attr_t",
2223 op_flags => "R|c|K",
2225 reg_req => { out => [ "vfp" ] },
2227 attr_type => "ia32_x87_attr_t",
2232 op_flags => "R|c|K",
2234 reg_req => { out => [ "vfp" ] },
2236 attr_type => "ia32_x87_attr_t",
2241 op_flags => "R|c|K",
2243 reg_req => { out => [ "vfp" ] },
2244 emit => '. fldll2t',
2245 attr_type => "ia32_x87_attr_t",
2250 op_flags => "R|c|K",
2252 reg_req => { out => [ "vfp" ] },
2254 attr_type => "ia32_x87_attr_t",
2259 # Note that it is NEVER allowed to do CSE on these nodes
2260 # Moreover, note the virtual register requierements!
2265 cmp_attr => "return 1;",
2266 emit => '. fxch %X0',
2267 attr_type => "ia32_x87_attr_t",
2275 cmp_attr => "return 1;",
2276 emit => '. fld %X0',
2277 attr_type => "ia32_x87_attr_t",
2283 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2284 cmp_attr => "return 1;",
2285 emit => '. fld %X0',
2286 attr_type => "ia32_x87_attr_t",
2293 cmp_attr => "return 1;",
2294 emit => '. fstp %X0',
2295 attr_type => "ia32_x87_attr_t",
2303 cmp_attr => "return 1;",
2304 emit => '. ffreep %X0',
2305 attr_type => "ia32_x87_attr_t",
2313 cmp_attr => "return 1;",
2315 attr_type => "ia32_x87_attr_t",
2323 cmp_attr => "return 1;",
2325 attr_type => "ia32_x87_attr_t",
2334 emit => ". fucom %X1\n".
2336 attr_type => "ia32_x87_attr_t",
2342 emit => ". fucomp %X1\n".
2344 attr_type => "ia32_x87_attr_t",
2350 emit => ". fucompp\n".
2352 attr_type => "ia32_x87_attr_t",
2358 emit => '. fucomi %X1',
2359 attr_type => "ia32_x87_attr_t",
2365 emit => '. fucompi %X1',
2366 attr_type => "ia32_x87_attr_t",
2374 attr_type => "ia32_x87_attr_t",
2379 # -------------------------------------------------------------------------------- #
2380 # ____ ____ _____ _ _ #
2381 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2382 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2383 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2384 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2386 # -------------------------------------------------------------------------------- #
2389 # Spilling and reloading of SSE registers, hardcoded, not generated #
2393 state => "exc_pinned",
2394 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2395 emit => '. movdqu %D0, %AM',
2396 outs => [ "res", "M" ],
2403 state => "exc_pinned",
2404 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2405 ins => [ "base", "index", "mem", "val" ],
2406 emit => '. movdqu %binop',
2414 # Include the generated SIMD node specification written by the SIMD optimization
2415 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2416 unless ($return = do $my_script_name) {
2417 warn "couldn't parse $my_script_name: $@" if $@;
2418 warn "couldn't do $my_script_name: $!" unless defined $return;
2419 warn "couldn't run $my_script_name" unless $return;
2422 # Transform some attributes
2423 foreach my $op (keys(%nodes)) {
2424 my $node = $nodes{$op};
2425 my $op_attr_init = $node->{op_attr_init};
2427 if(defined($op_attr_init)) {
2428 $op_attr_init .= "\n\t";
2433 if(!defined($node->{latency})) {
2435 $node->{latency} = 0;
2437 die("Latency missing for op $op");
2440 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2442 $node->{op_attr_init} = $op_attr_init;