3 # This is the specification for the ia32 assembler Firm-operations
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
13 # The node description is done as a perl hash initializer with the
14 # following structure:
19 # op_flags => "N|L|C|X|I|F|Y|H|c|K",
20 # irn_flags => "R|N|I|S"
21 # arity => "0|1|2|3 ... |variable|dynamic|any",
22 # state => "floats|pinned|mem_pinned|exc_pinned",
24 # { type => "type 1", name => "name 1" },
25 # { type => "type 2", name => "name 2" },
28 # comment => "any comment for constructor",
29 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 # cmp_attr => "c source code for comparing node attributes",
31 # emit => "emit code with templates",
32 # attr => "attitional attribute arguments for constructor"
33 # init_attr => "emit attribute initialization template"
34 # rd_constructor => "c source code which constructs an ir_node"
35 # attr_type => "name of the attribute struct",
38 # ... # (all nodes you need to describe)
40 # ); # close the %nodes initializer
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
46 # C irop_flag_commutative
47 # X irop_flag_cfopcode
48 # I irop_flag_ip_cfopcode
51 # H irop_flag_highlevel
52 # c irop_flag_constlike
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
59 # I ignore for register allocation
60 # S modifies stack pointer
62 # state: state of the operation, OPTIONAL (default is "floats")
64 # arity: arity of the operation, MUST NOT BE OMITTED
66 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
67 # are always the first 3 arguments and are always autmatically
69 # If this key is missing the following arguments will be created:
70 # for i = 1 .. arity: ir_node *op_i
73 # outs: if a node defines more than one output, the names of the projections
74 # nodes having outs having automatically the mode mode_T
75 # One can also annotate some flags for each out, additional to irn_flags.
76 # They are separated from name with a colon ':', and concatenated by pipe '|'
77 # Only I and S are available at the moment (same meaning as in irn_flags).
78 # example: [ "frame:I", "stack:I|S", "M" ]
80 # comment: OPTIONAL comment for the node constructor
82 # rd_constructor: for every operation there will be a
83 # new_rd_<arch>_<op-name> function with the arguments from above
84 # which creates the ir_node corresponding to the defined operation
85 # you can either put the complete source code of this function here
87 # This key is OPTIONAL. If omitted, the following constructor will
89 # if (!op_<arch>_<op-name>) assert(0);
93 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
96 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
100 # 0 - no special type
101 # 1 - caller save (register must be saved by the caller of a function)
102 # 2 - callee save (register must be saved by the called function)
103 # 4 - ignore (do not assign this register)
104 # 8 - emitter can choose an arbitrary register of this class
105 # 16 - the register is a virtual one
106 # 32 - register represents a state
107 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
110 { name => "edx", type => 1 },
111 { name => "ecx", type => 1 },
112 { name => "eax", type => 1 },
113 { name => "ebx", type => 2 },
114 { name => "esi", type => 2 },
115 { name => "edi", type => 2 },
116 { name => "ebp", type => 2 },
117 { name => "esp", type => 4 },
118 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
119 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
120 { mode => "mode_Iu" }
123 { name => "mm0", type => 4 },
124 { name => "mm1", type => 4 },
125 { name => "mm2", type => 4 },
126 { name => "mm3", type => 4 },
127 { name => "mm4", type => 4 },
128 { name => "mm5", type => 4 },
129 { name => "mm6", type => 4 },
130 { name => "mm7", type => 4 },
131 { mode => "mode_E", flags => "manual_ra" }
134 { name => "xmm0", type => 1 },
135 { name => "xmm1", type => 1 },
136 { name => "xmm2", type => 1 },
137 { name => "xmm3", type => 1 },
138 { name => "xmm4", type => 1 },
139 { name => "xmm5", type => 1 },
140 { name => "xmm6", type => 1 },
141 { name => "xmm7", type => 1 },
142 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
143 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
147 { name => "vf0", type => 1 | 16 },
148 { name => "vf1", type => 1 | 16 },
149 { name => "vf2", type => 1 | 16 },
150 { name => "vf3", type => 1 | 16 },
151 { name => "vf4", type => 1 | 16 },
152 { name => "vf5", type => 1 | 16 },
153 { name => "vf6", type => 1 | 16 },
154 { name => "vf7", type => 1 | 16 },
155 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
156 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
160 { name => "st0", realname => "st", type => 4 },
161 { name => "st1", realname => "st(1)", type => 4 },
162 { name => "st2", realname => "st(2)", type => 4 },
163 { name => "st3", realname => "st(3)", type => 4 },
164 { name => "st4", realname => "st(4)", type => 4 },
165 { name => "st5", realname => "st(5)", type => 4 },
166 { name => "st6", realname => "st(6)", type => 4 },
167 { name => "st7", realname => "st(7)", type => 4 },
168 { mode => "mode_E", flags => "manual_ra" }
170 fp_cw => [ # the floating point control word
171 { name => "fpcw", type => 4|32 },
172 { mode => "mode_fpcw", flags => "manual_ra|state" }
175 { name => "eflags", type => 0 },
176 { mode => "mode_Iu", flags => "manual_ra" }
181 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
182 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
183 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
184 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
189 bundels_per_cycle => 1
193 S0 => "${arch}_emit_source_register(node, 0);",
194 S1 => "${arch}_emit_source_register(node, 1);",
195 S2 => "${arch}_emit_source_register(node, 2);",
196 S3 => "${arch}_emit_source_register(node, 3);",
197 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
198 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
199 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
200 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
201 D0 => "${arch}_emit_dest_register(node, 0);",
202 D1 => "${arch}_emit_dest_register(node, 1);",
203 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
204 X0 => "${arch}_emit_x87_register(node, 0);",
205 X1 => "${arch}_emit_x87_register(node, 1);",
206 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
207 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
208 ia32_emit_mode_suffix(node);",
209 M => "${arch}_emit_mode_suffix(node);",
210 XM => "${arch}_emit_x87_mode_suffix(node);",
211 XXM => "${arch}_emit_xmm_mode_suffix(node);",
212 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
213 AM => "${arch}_emit_am(node);",
214 unop3 => "${arch}_emit_unop(node, 3);",
215 unop4 => "${arch}_emit_unop(node, 4);",
216 unop5 => "${arch}_emit_unop(node, 5);",
217 DAM0 => "${arch}_emit_am_or_dest_register(node, 0);",
218 binop => "${arch}_emit_binop(node);",
219 x87_binop => "${arch}_emit_x87_binop(node);",
220 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
221 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
224 #--------------------------------------------------#
227 # _ __ _____ __ _ _ __ ___ _ __ ___ #
228 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
229 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
230 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
233 #--------------------------------------------------#
235 $default_op_attr_type = "ia32_op_attr_t";
236 $default_attr_type = "ia32_attr_t";
237 $default_copy_attr = "ia32_copy_attr";
239 sub ia32_custom_init_attr {
244 if(defined($node->{modified_flags})) {
245 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
247 if(defined($node->{am})) {
248 my $am = $node->{am};
249 if($am eq "full,binary") {
250 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
251 } elsif($am eq "full,unary") {
252 $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
253 } elsif($am eq "source,unary") {
254 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_unary);";
255 } elsif($am eq "source,binary") {
256 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
257 } elsif($am eq "dest,unary") {
258 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
259 } elsif($am eq "dest,binary") {
260 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
261 } elsif($am eq "dest,ternary") {
262 $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
263 } elsif($am eq "source,ternary") {
264 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
265 } elsif($am eq "none") {
268 die("Invalid address mode '$am' specified on op $name");
271 if($node->{state} ne "exc_pinned"
272 and $node->{state} ne "pinned") {
273 die("AM nodes must have pinned or AM pinned state ($name)");
279 $custom_init_attr_func = \&ia32_custom_init_attr;
282 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
284 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
285 "\tinit_ia32_x87_attributes(res);",
287 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
288 "\tinit_ia32_x87_attributes(res);".
289 "\tinit_ia32_asm_attributes(res);",
290 ia32_immediate_attr_t =>
291 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_copyb_attributes(res, size);",
296 ia32_condcode_attr_t =>
297 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
298 "\tinit_ia32_condcode_attributes(res, pnc);",
302 ia32_attr_t => "ia32_compare_nodes_attr",
303 ia32_x87_attr_t => "ia32_compare_x87_attr",
304 ia32_asm_attr_t => "ia32_compare_asm_attr",
305 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
306 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
307 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
313 $mode_xmm = "mode_E";
314 $mode_gp = "mode_Iu";
315 $mode_flags = "mode_Iu";
316 $mode_fpcw = "mode_fpcw";
317 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
318 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
319 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
327 reg_req => { out => [ "gp_NOREG" ] },
328 attr => "ir_entity *symconst, int symconst_sign, long offset",
329 attr_type => "ia32_immediate_attr_t",
337 out_arity => "variable",
338 attr_type => "ia32_asm_attr_t",
339 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
340 init_attr => "attr->asm_text = asm_text;\n".
341 "\tattr->register_map = register_map;\n",
349 reg_req => { out => [ "gp" ] },
354 cmp_attr => "return 1;",
357 #-----------------------------------------------------------------#
360 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
361 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
362 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
363 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
366 #-----------------------------------------------------------------#
368 # commutative operations
372 state => "exc_pinned",
373 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
374 out => [ "in_r4 in_r5", "flags", "none" ] },
375 ins => [ "base", "index", "mem", "left", "right" ],
376 emit => '. add%M %binop',
381 modified_flags => $status_flags
386 state => "exc_pinned",
387 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
388 ins => [ "base", "index", "mem", "val" ],
389 emit => ". add%M %SI3, %AM",
393 modified_flags => $status_flags
398 state => "exc_pinned",
399 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
400 ins => [ "base", "index", "mem", "val" ],
401 emit => ". add%M %SB3, %AM",
405 modified_flags => $status_flags
409 state => "exc_pinned",
410 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
411 out => [ "in_r4 in_r5", "flags", "none" ] },
412 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
413 emit => '. adc%M %binop',
418 modified_flags => $status_flags
423 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
424 ins => [ "left", "right" ],
428 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
429 ins => [ "left", "right", "eflags" ],
433 # we should not rematrialize this node. It produces 2 results and has
434 # very strict constrains
435 state => "exc_pinned",
436 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
437 out => [ "eax", "edx", "none" ] },
438 ins => [ "base", "index", "mem", "val_high", "val_low" ],
439 emit => '. mul%M %unop4',
440 outs => [ "res_low", "res_high", "M" ],
441 am => "source,binary",
444 modified_flags => $status_flags
448 # we should not rematrialize this node. It produces 2 results and has
449 # very strict constrains
451 cmp_attr => "return 1;",
452 outs => [ "EAX", "EDX", "M" ],
458 state => "exc_pinned",
459 # TODO: adjust out requirements for the 3 operand form
460 # (no need for should_be_same then)
461 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
462 out => [ "in_r4 in_r5", "flags", "none" ] },
463 ins => [ "base", "index", "mem", "left", "right" ],
464 outs => [ "res", "flags", "M" ],
465 am => "source,binary",
469 modified_flags => $status_flags
474 state => "exc_pinned",
475 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
476 out => [ "eax", "edx", "none" ] },
477 ins => [ "base", "index", "mem", "val_high", "val_low" ],
478 emit => '. imul%M %unop4',
479 outs => [ "res_low", "res_high", "M" ],
480 am => "source,binary",
483 modified_flags => $status_flags
488 cmp_attr => "return 1;",
489 outs => [ "res_low", "res_high", "M" ],
495 state => "exc_pinned",
496 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
497 out => [ "in_r4 in_r5", "flags", "none" ] },
498 ins => [ "base", "index", "mem", "left", "right" ],
499 outs => [ "res", "flags", "M" ],
500 op_modes => "commutative | am | immediate | mode_neutral",
502 emit => '. and%M %binop',
506 modified_flags => $status_flags
511 state => "exc_pinned",
512 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
513 ins => [ "base", "index", "mem", "val" ],
514 emit => '. and%M %SI3, %AM',
518 modified_flags => $status_flags
523 state => "exc_pinned",
524 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
525 ins => [ "base", "index", "mem", "val" ],
526 emit => '. and%M %SB3, %AM',
530 modified_flags => $status_flags
535 state => "exc_pinned",
536 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
537 out => [ "in_r4 in_r5", "flags", "none" ] },
538 ins => [ "base", "index", "mem", "left", "right" ],
539 outs => [ "res", "flags", "M" ],
541 emit => '. or%M %binop',
545 modified_flags => $status_flags
550 state => "exc_pinned",
551 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
552 ins => [ "base", "index", "mem", "val" ],
553 emit => '. or%M %SI3, %AM',
557 modified_flags => $status_flags
562 state => "exc_pinned",
563 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
564 ins => [ "base", "index", "mem", "val" ],
565 emit => '. or%M %SB3, %AM',
569 modified_flags => $status_flags
574 state => "exc_pinned",
575 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
576 out => [ "in_r4 in_r5", "flags", "none" ] },
577 ins => [ "base", "index", "mem", "left", "right" ],
578 outs => [ "res", "flags", "M" ],
580 emit => '. xor%M %binop',
584 modified_flags => $status_flags
589 state => "exc_pinned",
590 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
591 ins => [ "base", "index", "mem", "val" ],
592 emit => '. xor%M %SI3, %AM',
596 modified_flags => $status_flags
601 state => "exc_pinned",
602 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
603 ins => [ "base", "index", "mem", "val" ],
604 emit => '. xor%M %SB3, %AM',
608 modified_flags => $status_flags
611 # not commutative operations
615 state => "exc_pinned",
616 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
617 out => [ "in_r4", "flags", "none" ] },
618 ins => [ "base", "index", "mem", "left", "right" ],
619 outs => [ "res", "flags", "M" ],
621 emit => '. sub%M %binop',
625 modified_flags => $status_flags
630 state => "exc_pinned",
631 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
632 ins => [ "base", "index", "mem", "val" ],
633 emit => '. sub%M %SI3, %AM',
637 modified_flags => $status_flags
642 state => "exc_pinned",
643 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
644 ins => [ "base", "index", "mem", "val" ],
645 emit => '. sub%M %SB3, %AM',
649 modified_flags => $status_flags
653 state => "exc_pinned",
654 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
655 out => [ "in_r4 !in_r5", "flags", "none" ] },
656 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
657 outs => [ "res", "flags", "M" ],
659 emit => '. sbb%M %binop',
663 modified_flags => $status_flags
667 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
668 ins => [ "left", "right" ],
672 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
673 ins => [ "left", "right", "eflags" ],
678 state => "exc_pinned",
679 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ],
680 out => [ "eax", "flags", "none", "edx" ] },
681 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
682 outs => [ "div_res", "flags", "M", "mod_res" ],
683 am => "source,ternary",
684 emit => ". idiv%M %unop5",
687 modified_flags => $status_flags
692 state => "exc_pinned",
693 reg_req => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ],
694 out => [ "eax", "flags", "none", "edx" ] },
695 ins => [ "base", "index", "mem", "left_low", "left_high", "right" ],
696 outs => [ "div_res", "flags", "M", "mod_res" ],
697 am => "source,ternary",
698 emit => ". div%M %unop5",
701 modified_flags => $status_flags
706 reg_req => { in => [ "gp", "ecx" ],
707 out => [ "in_r1 !in_r2", "flags" ] },
708 ins => [ "val", "count" ],
709 outs => [ "res", "flags" ],
710 emit => '. shl %SB1, %S0',
714 modified_flags => $status_flags
719 state => "exc_pinned",
720 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
721 ins => [ "base", "index", "mem", "count" ],
722 emit => '. shl%M %SB3, %AM',
726 modified_flags => $status_flags
730 cmp_attr => "return 1;",
731 ins => [ "val", "count", "dep" ],
737 reg_req => { in => [ "gp", "gp", "ecx" ],
738 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
739 ins => [ "val_high", "val_low", "count" ],
740 outs => [ "res", "flags" ],
741 emit => ". shld%M %SB2, %S1, %D0",
745 modified_flags => $status_flags
749 cmp_attr => "return 1;",
750 ins => [ "val_high", "val_low", "count" ],
756 reg_req => { in => [ "gp", "ecx" ],
757 out => [ "in_r1 !in_r2", "flags" ] },
758 ins => [ "val", "count" ],
759 outs => [ "res", "flags" ],
760 emit => '. shr %SB1, %S0',
764 modified_flags => $status_flags
769 state => "exc_pinned",
770 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
771 ins => [ "base", "index", "mem", "count" ],
772 emit => '. shr%M %SB3, %AM',
776 modified_flags => $status_flags
780 cmp_attr => "return 1;",
781 ins => [ "val", "count", "dep" ],
787 reg_req => { in => [ "gp", "gp", "ecx" ],
788 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
789 ins => [ "val_high", "val_low", "count" ],
790 outs => [ "res", "flags" ],
791 emit => ". shrd%M %SB2, %S1, %D0",
795 modified_flags => $status_flags
799 cmp_attr => "return 1;",
801 ins => [ "val_high", "val_low", "count" ],
806 reg_req => { in => [ "gp", "ecx" ],
807 out => [ "in_r1 !in_r2", "flags" ] },
808 ins => [ "val", "count" ],
809 outs => [ "res", "flags" ],
810 emit => '. sar %SB1, %S0',
814 modified_flags => $status_flags
819 state => "exc_pinned",
820 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
821 ins => [ "base", "index", "mem", "count" ],
822 emit => '. sar%M %SB3, %AM',
826 modified_flags => $status_flags
830 cmp_attr => "return 1;",
831 ins => [ "val", "count", "dep" ],
837 reg_req => { in => [ "gp", "ecx" ],
838 out => [ "in_r1 !in_r2", "flags" ] },
839 ins => [ "val", "count" ],
840 outs => [ "res", "flags" ],
841 emit => '. ror %SB1, %S0',
845 modified_flags => $status_flags
850 state => "exc_pinned",
851 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
852 ins => [ "base", "index", "mem", "count" ],
853 emit => '. ror%M %SB3, %AM',
857 modified_flags => $status_flags
862 reg_req => { in => [ "gp", "ecx" ],
863 out => [ "in_r1 !in_r2", "flags" ] },
864 ins => [ "val", "count" ],
865 outs => [ "res", "flags" ],
866 emit => '. rol %SB1, %S0',
870 modified_flags => $status_flags
875 state => "exc_pinned",
876 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
877 ins => [ "base", "index", "mem", "count" ],
878 emit => '. rol%M %SB3, %AM',
882 modified_flags => $status_flags
889 reg_req => { in => [ "gp" ],
890 out => [ "in_r1", "flags" ] },
893 outs => [ "res", "flags" ],
897 modified_flags => $status_flags
902 state => "exc_pinned",
903 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
904 ins => [ "base", "index", "mem" ],
905 emit => '. neg%M %AM',
909 modified_flags => $status_flags
914 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
915 outs => [ "low_res", "high_res" ],
918 modified_flags => $status_flags
924 reg_req => { in => [ "gp" ],
925 out => [ "in_r1", "flags" ] },
926 outs => [ "res", "flags" ],
931 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
936 state => "exc_pinned",
937 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
938 ins => [ "base", "index", "mem" ],
939 emit => '. inc%M %AM',
943 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
948 reg_req => { in => [ "gp" ],
949 out => [ "in_r1", "flags" ] },
950 outs => [ "res", "flags" ],
955 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
960 state => "exc_pinned",
961 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
962 ins => [ "base", "index", "mem" ],
963 emit => '. dec%M %AM',
967 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
972 reg_req => { in => [ "gp" ],
973 out => [ "in_r1", "flags" ] },
975 outs => [ "res", "flags" ],
985 state => "exc_pinned",
986 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
987 ins => [ "base", "index", "mem" ],
988 emit => '. not%M %AM',
999 state => "exc_pinned",
1000 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1001 ins => [ "base", "index", "mem", "left", "right" ],
1002 outs => [ "eflags" ],
1003 am => "source,binary",
1004 emit => '. cmp%M %binop',
1005 attr => "int ins_permuted, int cmp_unsigned",
1006 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1007 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1010 mode => $mode_flags,
1011 modified_flags => $status_flags
1016 state => "exc_pinned",
1017 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1018 ins => [ "base", "index", "mem", "left", "right" ],
1019 outs => [ "eflags" ],
1020 am => "source,binary",
1021 emit => '. cmpb %binop',
1022 attr => "int ins_permuted, int cmp_unsigned",
1023 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1024 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1027 mode => $mode_flags,
1028 modified_flags => $status_flags
1033 state => "exc_pinned",
1034 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1035 ins => [ "base", "index", "mem", "left", "right" ],
1036 outs => [ "eflags" ],
1037 am => "source,binary",
1038 emit => '. test%M %binop',
1039 attr => "int ins_permuted, int cmp_unsigned",
1040 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1041 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1044 mode => $mode_flags,
1045 modified_flags => $status_flags
1050 state => "exc_pinned",
1051 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1052 ins => [ "base", "index", "mem", "left", "right" ],
1053 outs => [ "eflags" ],
1054 am => "source,binary",
1055 emit => '. testb %binop',
1056 attr => "int ins_permuted, int cmp_unsigned",
1057 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1058 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1061 mode => $mode_flags,
1062 modified_flags => $status_flags
1067 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1068 ins => [ "eflags" ],
1069 attr_type => "ia32_condcode_attr_t",
1070 attr => "pn_Cmp pnc, int ins_permuted",
1071 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1072 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1073 emit => '. set%CMP0 %DB0',
1081 state => "exc_pinned",
1082 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1083 ins => [ "base", "index", "mem","eflags" ],
1084 attr_type => "ia32_condcode_attr_t",
1085 attr => "pn_Cmp pnc, int ins_permuted",
1086 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1087 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1088 emit => '. set%CMP3 %AM',
1096 # (note: leave the false,true order intact to make it compatible with other
1098 state => "exc_pinned",
1099 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1100 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1101 am => "source,binary",
1102 attr_type => "ia32_condcode_attr_t",
1103 attr => "int ins_permuted, pn_Cmp pnc",
1104 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1112 op_flags => "L|X|Y",
1113 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1114 ins => [ "eflags" ],
1115 outs => [ "false", "true" ],
1116 attr_type => "ia32_condcode_attr_t",
1117 attr => "pn_Cmp pnc",
1119 units => [ "BRANCH" ],
1124 op_flags => "L|X|Y",
1125 reg_req => { in => [ "gp" ], out => [ "none" ] },
1127 attr_type => "ia32_condcode_attr_t",
1128 attr => "pn_Cmp pnc",
1130 units => [ "BRANCH" ],
1131 modified_flags => $status_flags,
1137 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1138 ins => [ "base", "index", "mem", "target" ],
1139 am => "source,unary",
1140 emit => '. jmp *%unop3',
1142 units => [ "BRANCH" ],
1149 reg_req => { out => [ "gp" ] },
1151 attr => "ir_entity *symconst, int symconst_sign, long offset",
1152 attr_type => "ia32_immediate_attr_t",
1161 reg_req => { out => [ "gp_UKNWN" ] },
1172 reg_req => { out => [ "vfp_UKNWN" ] },
1177 attr_type => "ia32_x87_attr_t",
1184 reg_req => { out => [ "xmm_UKNWN" ] },
1195 reg_req => { out => [ "gp_NOREG" ] },
1206 reg_req => { out => [ "vfp_NOREG" ] },
1211 attr_type => "ia32_x87_attr_t",
1218 reg_req => { out => [ "xmm_NOREG" ] },
1229 reg_req => { out => [ "fp_cw" ] },
1233 modified_flags => $fpcw_flags
1239 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1240 ins => [ "base", "index", "mem" ],
1242 emit => ". fldcw %AM",
1245 modified_flags => $fpcw_flags
1251 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1252 ins => [ "base", "index", "mem", "fpcw" ],
1254 emit => ". fnstcw %AM",
1262 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1270 # we should not rematrialize this node. It has very strict constraints.
1271 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1272 ins => [ "val", "globbered" ],
1281 # Note that we add additional latency values depending on address mode, so a
1282 # lateny of 0 for load is correct
1286 state => "exc_pinned",
1287 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1288 ins => [ "base", "index", "mem" ],
1289 outs => [ "res", "M" ],
1291 emit => ". mov%SE%ME%.l %AM, %D0",
1297 cmp_attr => "return 1;",
1298 outs => [ "res", "M" ],
1304 cmp_attr => "return 1;",
1305 state => "exc_pinned",
1312 state => "exc_pinned",
1313 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1314 ins => [ "base", "index", "mem", "val" ],
1315 emit => '. mov%M %SI3, %AM',
1323 state => "exc_pinned",
1324 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1325 ins => [ "base", "index", "mem", "val" ],
1326 emit => '. mov%M %SB3, %AM',
1334 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1335 ins => [ "base", "index" ],
1336 emit => '. leal %AM, %D0',
1340 # lea doesn't modify the flags, but setting this seems advantageous since it
1341 # increases chances that the Lea is transformed back to an Add
1342 modified_flags => 1,
1346 state => "exc_pinned",
1347 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp", "none" ] },
1348 ins => [ "base", "index", "mem", "val", "stack" ],
1349 emit => '. push%M %unop4',
1350 outs => [ "stack:I|S", "M" ],
1351 am => "source,binary",
1357 state => "exc_pinned",
1358 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1359 emit => '. pop%M %DAM0',
1360 outs => [ "res", "M", "unused", "stack:I|S" ],
1361 ins => [ "base", "index", "mem", "stack" ],
1363 latency => 3, # Pop is more expensive than Push on Athlon
1368 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1370 outs => [ "frame:I", "stack:I|S", "M" ],
1376 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1378 outs => [ "frame:I", "stack:I|S" ],
1386 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1387 ins => [ "base", "index", "mem", "stack", "size" ],
1388 am => "source,binary",
1389 emit => '. addl %binop',
1391 outs => [ "stack:S", "M" ],
1393 modified_flags => $status_flags
1399 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1400 ins => [ "base", "index", "mem", "stack", "size" ],
1401 am => "source,binary",
1402 emit => ". subl %binop\n".
1403 ". movl %%esp, %D1",
1405 outs => [ "stack:I|S", "addr", "M" ],
1407 modified_flags => $status_flags
1412 reg_req => { out => [ "gp" ] },
1418 #-----------------------------------------------------------------------------#
1419 # _____ _____ ______ __ _ _ _ #
1420 # / ____/ ____| ____| / _| | | | | | #
1421 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1422 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1423 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1424 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1425 #-----------------------------------------------------------------------------#
1429 reg_req => { out => [ "xmm" ] },
1430 emit => '. xorp%XSD %D0, %D0',
1436 # commutative operations
1440 state => "exc_pinned",
1441 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1442 ins => [ "base", "index", "mem", "left", "right" ],
1443 am => "source,binary",
1444 emit => '. add%XXM %binop',
1452 state => "exc_pinned",
1453 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1454 ins => [ "base", "index", "mem", "left", "right" ],
1455 am => "source,binary",
1456 emit => '. mul%XXM %binop',
1464 state => "exc_pinned",
1465 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1466 ins => [ "base", "index", "mem", "left", "right" ],
1467 am => "source,binary",
1468 emit => '. max%XXM %binop',
1476 state => "exc_pinned",
1477 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1478 ins => [ "base", "index", "mem", "left", "right" ],
1479 am => "source,binary",
1480 emit => '. min%XXM %binop',
1488 state => "exc_pinned",
1489 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1490 ins => [ "base", "index", "mem", "left", "right" ],
1491 am => "source,binary",
1492 emit => '. andp%XSD %binop',
1500 state => "exc_pinned",
1501 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1502 ins => [ "base", "index", "mem", "left", "right" ],
1503 am => "source,binary",
1504 emit => '. orp%XSD %binop',
1512 state => "exc_pinned",
1513 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1514 ins => [ "base", "index", "mem", "left", "right" ],
1515 am => "source,binary",
1516 emit => '. xorp%XSD %binop',
1522 # not commutative operations
1526 state => "exc_pinned",
1527 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1528 ins => [ "base", "index", "mem", "left", "right" ],
1529 am => "source,binary",
1530 emit => '. andnp%XSD %binop',
1538 state => "exc_pinned",
1539 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1540 ins => [ "base", "index", "mem", "left", "right" ],
1541 am => "source,binary",
1542 emit => '. sub%XXM %binop',
1550 state => "exc_pinned",
1551 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1552 ins => [ "base", "index", "mem", "left", "right" ],
1553 am => "source,binary",
1554 outs => [ "res", "M" ],
1555 emit => '. div%XXM %binop',
1564 state => "exc_pinned",
1565 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1566 ins => [ "base", "index", "mem", "left", "right" ],
1567 outs => [ "flags" ],
1568 am => "source,binary",
1569 attr => "int ins_permuted",
1570 init_attr => "attr->data.ins_permuted = ins_permuted;",
1571 emit => ' .ucomi%XXM %binop',
1574 mode => $mode_flags,
1575 modified_flags => 1,
1582 state => "exc_pinned",
1583 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1584 ins => [ "base", "index", "mem" ],
1585 emit => '. mov%XXM %AM, %D0',
1586 attr => "ir_mode *load_mode",
1587 init_attr => "attr->ls_mode = load_mode;",
1588 outs => [ "res", "M" ],
1595 state => "exc_pinned",
1596 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1597 ins => [ "base", "index", "mem", "val" ],
1598 emit => '. mov%XXM %S3, %AM',
1606 state => "exc_pinned",
1607 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1608 ins => [ "base", "index", "mem", "val" ],
1609 emit => '. mov%XXM %S3, %AM',
1617 state => "exc_pinned",
1618 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1619 ins => [ "base", "index", "mem", "val" ],
1620 am => "source,unary",
1621 emit => '. cvtsi2ss %unop3, %D0',
1629 state => "exc_pinned",
1630 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1631 ins => [ "base", "index", "mem", "val" ],
1632 am => "source,unary",
1633 emit => '. cvtsi2sd %unop3, %D0',
1642 cmp_attr => "return 1;",
1648 cmp_attr => "return 1;",
1657 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1658 outs => [ "DST", "SRC", "CNT", "M" ],
1659 attr_type => "ia32_copyb_attr_t",
1660 attr => "unsigned size",
1663 # we don't care about this flag, so no need to mark this node
1664 # modified_flags => [ "DF" ]
1670 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1671 outs => [ "DST", "SRC", "M" ],
1672 attr_type => "ia32_copyb_attr_t",
1673 attr => "unsigned size",
1676 # we don't care about this flag, so no need to mark this node
1677 # modified_flags => [ "DF" ]
1683 state => "exc_pinned",
1684 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1685 ins => [ "base", "index", "mem", "val" ],
1686 am => "source,unary",
1689 attr => "ir_mode *smaller_mode",
1690 init_attr => "attr->ls_mode = smaller_mode;",
1695 state => "exc_pinned",
1696 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1697 ins => [ "base", "index", "mem", "val" ],
1698 am => "source,unary",
1701 attr => "ir_mode *smaller_mode",
1702 init_attr => "attr->ls_mode = smaller_mode;",
1707 state => "exc_pinned",
1708 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1709 ins => [ "base", "index", "mem", "val" ],
1710 am => "source,unary",
1717 state => "exc_pinned",
1718 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1719 ins => [ "base", "index", "mem", "val" ],
1720 am => "source,unary",
1727 state => "exc_pinned",
1728 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1729 ins => [ "base", "index", "mem", "val" ],
1730 am => "source,unary",
1736 #----------------------------------------------------------#
1738 # (_) | | | | / _| | | | #
1739 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1740 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1741 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1742 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1744 # _ __ ___ __| | ___ ___ #
1745 # | '_ \ / _ \ / _` |/ _ \/ __| #
1746 # | | | | (_) | (_| | __/\__ \ #
1747 # |_| |_|\___/ \__,_|\___||___/ #
1748 #----------------------------------------------------------#
1750 # rematerialisation disabled for all float nodes for now, because the fpcw
1751 # handler runs before spilling and we might end up with wrong fpcw then
1755 state => "exc_pinned",
1756 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1757 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1758 am => "source,binary",
1762 attr_type => "ia32_x87_attr_t",
1767 state => "exc_pinned",
1768 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1769 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1770 am => "source,binary",
1774 attr_type => "ia32_x87_attr_t",
1779 state => "exc_pinned",
1780 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1781 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1782 am => "source,binary",
1786 attr_type => "ia32_x87_attr_t",
1790 state => "exc_pinned",
1791 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1792 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1793 am => "source,binary",
1794 outs => [ "res", "M" ],
1797 attr_type => "ia32_x87_attr_t",
1801 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1802 ins => [ "left", "right", "fpcw" ],
1806 attr_type => "ia32_x87_attr_t",
1811 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1816 attr_type => "ia32_x87_attr_t",
1821 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1826 attr_type => "ia32_x87_attr_t",
1829 # virtual Load and Store
1834 state => "exc_pinned",
1835 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1836 ins => [ "base", "index", "mem" ],
1837 outs => [ "res", "M" ],
1838 attr => "ir_mode *load_mode",
1839 init_attr => "attr->attr.ls_mode = load_mode;",
1842 attr_type => "ia32_x87_attr_t",
1848 state => "exc_pinned",
1849 reg_req => { in => [ "gp", "gp", "none", "vfp" ] },
1850 ins => [ "base", "index", "mem", "val" ],
1851 attr => "ir_mode *store_mode",
1852 init_attr => "attr->attr.ls_mode = store_mode;",
1856 attr_type => "ia32_x87_attr_t",
1862 state => "exc_pinned",
1863 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1864 outs => [ "res", "M" ],
1865 ins => [ "base", "index", "mem" ],
1868 attr_type => "ia32_x87_attr_t",
1872 cmp_attr => "return 1;",
1873 outs => [ "res", "M" ],
1878 state => "exc_pinned",
1879 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1880 ins => [ "base", "index", "mem", "val", "fpcw" ],
1884 attr_type => "ia32_x87_attr_t",
1888 cmp_attr => "return 1;",
1889 state => "exc_pinned",
1899 reg_req => { out => [ "vfp" ] },
1903 attr_type => "ia32_x87_attr_t",
1908 reg_req => { out => [ "vfp" ] },
1912 attr_type => "ia32_x87_attr_t",
1917 reg_req => { out => [ "vfp" ] },
1921 attr_type => "ia32_x87_attr_t",
1926 reg_req => { out => [ "vfp" ] },
1930 attr_type => "ia32_x87_attr_t",
1935 reg_req => { out => [ "vfp" ] },
1939 attr_type => "ia32_x87_attr_t",
1944 reg_req => { out => [ "vfp" ] },
1948 attr_type => "ia32_x87_attr_t",
1953 reg_req => { out => [ "vfp" ] },
1957 attr_type => "ia32_x87_attr_t",
1963 # we can't allow to rematerialize this node so we don't have
1964 # accidently produce Phi(Fucom, Fucom(ins_permuted))
1966 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1967 ins => [ "left", "right" ],
1968 outs => [ "flags" ],
1969 attr => "int ins_permuted",
1970 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1973 attr_type => "ia32_x87_attr_t",
1979 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
1980 ins => [ "left", "right" ],
1981 outs => [ "flags" ],
1982 attr => "int ins_permuted",
1983 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1986 attr_type => "ia32_x87_attr_t",
1992 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
1994 outs => [ "flags" ],
1995 attr => "int ins_permuted",
1996 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1999 attr_type => "ia32_x87_attr_t",
2005 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2007 outs => [ "flags" ],
2011 mode => $mode_flags,
2014 #------------------------------------------------------------------------#
2015 # ___ _____ __ _ _ _ #
2016 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2017 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2018 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2019 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2020 #------------------------------------------------------------------------#
2022 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2023 # are swapped, we work this around in the emitter...
2026 state => "exc_pinned",
2027 rd_constructor => "NONE",
2029 emit => '. fadd%XM %x87_binop',
2031 attr_type => "ia32_x87_attr_t",
2035 state => "exc_pinned",
2036 rd_constructor => "NONE",
2038 emit => '. faddp%XM %x87_binop',
2040 attr_type => "ia32_x87_attr_t",
2044 state => "exc_pinned",
2045 rd_constructor => "NONE",
2047 emit => '. fmul%XM %x87_binop',
2049 attr_type => "ia32_x87_attr_t",
2053 state => "exc_pinned",
2054 rd_constructor => "NONE",
2056 emit => '. fmulp%XM %x87_binop',,
2058 attr_type => "ia32_x87_attr_t",
2062 state => "exc_pinned",
2063 rd_constructor => "NONE",
2065 emit => '. fsub%XM %x87_binop',
2067 attr_type => "ia32_x87_attr_t",
2071 state => "exc_pinned",
2072 rd_constructor => "NONE",
2074 # see note about gas bugs
2075 emit => '. fsubrp%XM %x87_binop',
2077 attr_type => "ia32_x87_attr_t",
2081 state => "exc_pinned",
2082 rd_constructor => "NONE",
2085 emit => '. fsubr%XM %x87_binop',
2087 attr_type => "ia32_x87_attr_t",
2091 state => "exc_pinned",
2092 rd_constructor => "NONE",
2095 # see note about gas bugs
2096 emit => '. fsubp%XM %x87_binop',
2098 attr_type => "ia32_x87_attr_t",
2102 rd_constructor => "NONE",
2106 attr_type => "ia32_x87_attr_t",
2109 # this node is just here, to keep the simulator running
2110 # we can omit this when a fprem simulation function exists
2112 rd_constructor => "NONE",
2114 emit => '. fprem1\n'.
2117 attr_type => "ia32_x87_attr_t",
2121 state => "exc_pinned",
2122 rd_constructor => "NONE",
2124 emit => '. fdiv%XM %x87_binop',
2126 attr_type => "ia32_x87_attr_t",
2130 state => "exc_pinned",
2131 rd_constructor => "NONE",
2133 # see note about gas bugs
2134 emit => '. fdivrp%XM %x87_binop',
2136 attr_type => "ia32_x87_attr_t",
2140 state => "exc_pinned",
2141 rd_constructor => "NONE",
2143 emit => '. fdivr%XM %x87_binop',
2145 attr_type => "ia32_x87_attr_t",
2149 state => "exc_pinned",
2150 rd_constructor => "NONE",
2152 # see note about gas bugs
2153 emit => '. fdivp%XM %x87_binop',
2155 attr_type => "ia32_x87_attr_t",
2159 rd_constructor => "NONE",
2163 attr_type => "ia32_x87_attr_t",
2168 rd_constructor => "NONE",
2172 attr_type => "ia32_x87_attr_t",
2175 # x87 Load and Store
2178 rd_constructor => "NONE",
2179 op_flags => "R|L|F",
2180 state => "exc_pinned",
2182 emit => '. fld%XM %AM',
2183 attr_type => "ia32_x87_attr_t",
2188 rd_constructor => "NONE",
2189 op_flags => "R|L|F",
2190 state => "exc_pinned",
2192 emit => '. fst%XM %AM',
2194 attr_type => "ia32_x87_attr_t",
2199 rd_constructor => "NONE",
2200 op_flags => "R|L|F",
2201 state => "exc_pinned",
2203 emit => '. fstp%XM %AM',
2205 attr_type => "ia32_x87_attr_t",
2212 state => "exc_pinned",
2213 rd_constructor => "NONE",
2215 emit => '. fild%M %AM',
2216 attr_type => "ia32_x87_attr_t",
2221 state => "exc_pinned",
2222 rd_constructor => "NONE",
2224 emit => '. fist%M %AM',
2226 attr_type => "ia32_x87_attr_t",
2231 state => "exc_pinned",
2232 rd_constructor => "NONE",
2234 emit => '. fistp%M %AM',
2236 attr_type => "ia32_x87_attr_t",
2243 op_flags => "R|c|K",
2245 reg_req => { out => [ "vfp" ] },
2247 attr_type => "ia32_x87_attr_t",
2252 op_flags => "R|c|K",
2254 reg_req => { out => [ "vfp" ] },
2256 attr_type => "ia32_x87_attr_t",
2261 op_flags => "R|c|K",
2263 reg_req => { out => [ "vfp" ] },
2265 attr_type => "ia32_x87_attr_t",
2270 op_flags => "R|c|K",
2272 reg_req => { out => [ "vfp" ] },
2274 attr_type => "ia32_x87_attr_t",
2279 op_flags => "R|c|K",
2281 reg_req => { out => [ "vfp" ] },
2283 attr_type => "ia32_x87_attr_t",
2288 op_flags => "R|c|K",
2290 reg_req => { out => [ "vfp" ] },
2291 emit => '. fldll2t',
2292 attr_type => "ia32_x87_attr_t",
2297 op_flags => "R|c|K",
2299 reg_req => { out => [ "vfp" ] },
2301 attr_type => "ia32_x87_attr_t",
2306 # Note that it is NEVER allowed to do CSE on these nodes
2307 # Moreover, note the virtual register requierements!
2312 cmp_attr => "return 1;",
2313 emit => '. fxch %X0',
2314 attr_type => "ia32_x87_attr_t",
2322 cmp_attr => "return 1;",
2323 emit => '. fld %X0',
2324 attr_type => "ia32_x87_attr_t",
2330 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2331 cmp_attr => "return 1;",
2332 emit => '. fld %X0',
2333 attr_type => "ia32_x87_attr_t",
2340 cmp_attr => "return 1;",
2341 emit => '. fstp %X0',
2342 attr_type => "ia32_x87_attr_t",
2350 cmp_attr => "return 1;",
2351 emit => '. ffreep %X0',
2352 attr_type => "ia32_x87_attr_t",
2360 cmp_attr => "return 1;",
2362 attr_type => "ia32_x87_attr_t",
2370 cmp_attr => "return 1;",
2372 attr_type => "ia32_x87_attr_t",
2381 emit => ". fucom %X1\n".
2383 attr_type => "ia32_x87_attr_t",
2389 emit => ". fucomp %X1\n".
2391 attr_type => "ia32_x87_attr_t",
2397 emit => ". fucompp\n".
2399 attr_type => "ia32_x87_attr_t",
2405 emit => '. fucomi %X1',
2406 attr_type => "ia32_x87_attr_t",
2412 emit => '. fucompi %X1',
2413 attr_type => "ia32_x87_attr_t",
2421 attr_type => "ia32_x87_attr_t",
2426 # -------------------------------------------------------------------------------- #
2427 # ____ ____ _____ _ _ #
2428 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2429 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2430 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2431 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2433 # -------------------------------------------------------------------------------- #
2436 # Spilling and reloading of SSE registers, hardcoded, not generated #
2440 state => "exc_pinned",
2441 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2442 emit => '. movdqu %D0, %AM',
2443 outs => [ "res", "M" ],
2450 state => "exc_pinned",
2451 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2452 ins => [ "base", "index", "mem", "val" ],
2453 emit => '. movdqu %binop',
2461 # Include the generated SIMD node specification written by the SIMD optimization
2462 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2463 unless ($return = do $my_script_name) {
2464 warn "couldn't parse $my_script_name: $@" if $@;
2465 warn "couldn't do $my_script_name: $!" unless defined $return;
2466 warn "couldn't run $my_script_name" unless $return;
2469 # Transform some attributes
2470 foreach my $op (keys(%nodes)) {
2471 my $node = $nodes{$op};
2472 my $op_attr_init = $node->{op_attr_init};
2474 if(defined($op_attr_init)) {
2475 $op_attr_init .= "\n\t";
2480 if(!defined($node->{latency})) {
2482 $node->{latency} = 0;
2484 die("Latency missing for op $op");
2487 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2489 $node->{op_attr_init} = $op_attr_init;