3 # This is the specification for the ia32 assembler Firm-operations
7 # The node description is done as a perl hash initializer with the
13 # op_flags => "N|L|C|X|I|F|Y|H|c|K|n",
15 # arity => "0|1|2|3 ... |variable|dynamic|any",
16 # state => "floats|pinned|mem_pinned|exc_pinned",
18 # { type => "type 1", name => "name 1" },
19 # { type => "type 2", name => "name 2" },
22 # comment => "any comment for constructor",
23 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
24 # cmp_attr => "c source code for comparing node attributes",
25 # outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts
26 # ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts
27 # mode => "mode_Iu" # optional, predefines the mode
28 # emit => "emit code with templates",
29 # attr => "additional attribute arguments for constructor",
30 # init_attr => "emit attribute initialization template",
31 # hash_func => "name of the hash function for this operation",
32 # latency => "latency of this operation (can be float)"
33 # attr_type => "name of the attribute struct",
34 # modified_flags => [ "CF", ... ] # optional, list of modified flags
37 # ... # (all nodes you need to describe)
39 # ); # close the %nodes initializer
41 # op_flags: flags for the operation, OPTIONAL (default is "N")
42 # the op_flags correspond to the firm irop_flags:
45 # C irop_flag_commutative
46 # X irop_flag_cfopcode
47 # I irop_flag_ip_cfopcode
50 # H irop_flag_highlevel
51 # c irop_flag_constlike
53 # NB irop_flag_dump_noblock
54 # NI irop_flag_dump_noinput
56 # irn_flags: special node flags, OPTIONAL (default is 0)
57 # following irn_flags are supported:
61 # state: state of the operation, OPTIONAL (default is "floats")
63 # arity: arity of the operation, MUST NOT BE OMITTED
65 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
66 # are always the first 3 arguments and are always autmatically
68 # If this key is missing the following arguments will be created:
69 # for i = 1 .. arity: ir_node *op_i
72 # outs: if a node defines more than one output, the names of the projections
73 # nodes having outs having automatically the mode mode_T
74 # example: [ "frame", "stack", "M" ]
76 # comment: OPTIONAL comment for the node constructor
78 # rd_constructor: for every operation there will be a
79 # new_rd_<arch>_<op-name> function with the arguments from above
80 # which creates the ir_node corresponding to the defined operation
81 # you can either put the complete source code of this function here
83 # This key is OPTIONAL. If omitted, the following constructor will
85 # if (!op_<arch>_<op-name>) assert(0);
89 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
92 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
97 # 1 - caller save (register must be saved by the caller of a function)
98 # 2 - callee save (register must be saved by the called function)
99 # 4 - ignore (do not automatically assign this register)
100 # 8 - emitter can choose an arbitrary register of this class
101 # 16 - the register is a virtual one
102 # 32 - register represents a state
103 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
106 { name => "edx", type => 1 },
107 { name => "ecx", type => 1 },
108 { name => "eax", type => 1 },
109 { name => "ebx", type => 2 },
110 { name => "esi", type => 2 },
111 { name => "edi", type => 2 },
112 { name => "ebp", type => 2 },
113 { name => "esp", type => 4 },
114 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
115 { mode => "mode_Iu" }
118 { name => "mm0", type => 4 },
119 { name => "mm1", type => 4 },
120 { name => "mm2", type => 4 },
121 { name => "mm3", type => 4 },
122 { name => "mm4", type => 4 },
123 { name => "mm5", type => 4 },
124 { name => "mm6", type => 4 },
125 { name => "mm7", type => 4 },
126 { mode => "mode_E", flags => "manual_ra" }
129 { name => "xmm0", type => 1 },
130 { name => "xmm1", type => 1 },
131 { name => "xmm2", type => 1 },
132 { name => "xmm3", type => 1 },
133 { name => "xmm4", type => 1 },
134 { name => "xmm5", type => 1 },
135 { name => "xmm6", type => 1 },
136 { name => "xmm7", type => 1 },
137 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
141 { name => "vf0", type => 1 },
142 { name => "vf1", type => 1 },
143 { name => "vf2", type => 1 },
144 { name => "vf3", type => 1 },
145 { name => "vf4", type => 1 },
146 { name => "vf5", type => 1 },
147 { name => "vf6", type => 1 },
148 { name => "vf7", type => 1 },
149 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
153 { name => "st0", realname => "st", type => 4 },
154 { name => "st1", realname => "st(1)", type => 4 },
155 { name => "st2", realname => "st(2)", type => 4 },
156 { name => "st3", realname => "st(3)", type => 4 },
157 { name => "st4", realname => "st(4)", type => 4 },
158 { name => "st5", realname => "st(5)", type => 4 },
159 { name => "st6", realname => "st(6)", type => 4 },
160 { name => "st7", realname => "st(7)", type => 4 },
161 { mode => "mode_E", flags => "manual_ra" }
163 fp_cw => [ # the floating point control word
164 { name => "fpcw", type => 4|32 },
165 { mode => "mode_fpcw", flags => "manual_ra|state" }
168 { name => "eflags", type => 0 },
169 { mode => "mode_Iu", flags => "manual_ra" }
174 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
175 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
176 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
177 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
182 bundels_per_cycle => 1
186 S0 => "${arch}_emit_source_register(node, 0);",
187 S1 => "${arch}_emit_source_register(node, 1);",
188 S2 => "${arch}_emit_source_register(node, 2);",
189 S3 => "${arch}_emit_source_register(node, 3);",
190 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
191 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
192 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
193 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
194 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
195 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
196 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
197 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
198 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
199 D0 => "${arch}_emit_dest_register(node, 0);",
200 D1 => "${arch}_emit_dest_register(node, 1);",
201 DS0 => "${arch}_emit_dest_register_size(node, 0);",
202 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
203 X0 => "${arch}_emit_x87_register(node, 0);",
204 X1 => "${arch}_emit_x87_register(node, 1);",
205 EX => "${arch}_emit_extend_suffix(node);",
206 M => "${arch}_emit_mode_suffix(node);",
207 XM => "${arch}_emit_x87_mode_suffix(node);",
208 XXM => "${arch}_emit_xmm_mode_suffix(node);",
209 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
210 AM => "${arch}_emit_am(node);",
211 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
212 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
213 binop => "${arch}_emit_binop(node);",
214 x87_binop => "${arch}_emit_x87_binop(node);",
215 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
221 $default_op_attr_type = "ia32_op_attr_t";
222 $default_attr_type = "ia32_attr_t";
223 $default_copy_attr = "ia32_copy_attr";
225 sub ia32_custom_init_attr {
231 if(defined($node->{modified_flags})) {
232 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
234 if(defined($node->{am})) {
235 my $am = $node->{am};
236 if($am eq "source,unary") {
237 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
238 } elsif($am eq "source,binary") {
239 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
240 } elsif($am eq "none") {
243 die("Invalid address mode '$am' specified on op $name");
246 if($node->{state} ne "exc_pinned"
247 and $node->{state} ne "pinned") {
248 die("AM nodes must have pinned or AM pinned state ($name)");
254 $custom_init_attr_func = \&ia32_custom_init_attr;
258 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
259 "\tinit_ia32_x87_attributes(res);".
260 "\tinit_ia32_asm_attributes(res);",
262 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);",
264 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
265 "\tinit_ia32_call_attributes(res, pop, call_tp);",
266 ia32_condcode_attr_t =>
267 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
268 "\tinit_ia32_condcode_attributes(res, pnc);",
270 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
271 "\tinit_ia32_copyb_attributes(res, size);",
272 ia32_immediate_attr_t =>
273 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
274 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
276 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
277 "\tinit_ia32_x87_attributes(res);",
278 ia32_climbframe_attr_t =>
279 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
280 "\tinit_ia32_climbframe_attributes(res, count);",
284 ia32_asm_attr_t => "ia32_compare_asm_attr",
285 ia32_attr_t => "ia32_compare_nodes_attr",
286 ia32_call_attr_t => "ia32_compare_call_attr",
287 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
288 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
289 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
290 ia32_x87_attr_t => "ia32_compare_x87_attr",
291 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
297 $mode_xmm = "mode_E";
298 $mode_gp = "mode_Iu";
299 $mode_flags = "mode_Iu";
300 $mode_fpcw = "mode_fpcw";
301 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
302 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
303 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
304 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
311 reg_req => { out => [ "gp_NOREG:I" ] },
312 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
313 attr_type => "ia32_immediate_attr_t",
314 hash_func => "ia32_hash_Immediate",
322 out_arity => "variable",
323 attr_type => "ia32_asm_attr_t",
324 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
325 init_attr => "attr->asm_text = asm_text;\n".
326 "\tattr->register_map = register_map;\n",
328 modified_flags => $status_flags,
331 # "allocates" a free register
335 reg_req => { out => [ "gp" ] },
340 cmp_attr => "return 1;",
345 state => "exc_pinned",
346 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
347 out => [ "in_r4 in_r5", "flags", "none" ] },
348 ins => [ "base", "index", "mem", "left", "right" ],
349 outs => [ "res", "flags", "M" ],
350 emit => '. add%M %binop',
351 am => "source,binary",
355 modified_flags => $status_flags
360 state => "exc_pinned",
361 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
362 ins => [ "base", "index", "mem", "val" ],
363 emit => ". add%M %SI3, %AM",
367 modified_flags => $status_flags
372 state => "exc_pinned",
373 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
374 ins => [ "base", "index", "mem", "val" ],
375 emit => ". add%M %SB3, %AM",
379 modified_flags => $status_flags
383 state => "exc_pinned",
384 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
385 out => [ "in_r4 in_r5", "flags", "none" ] },
386 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
387 outs => [ "res", "flags", "M" ],
388 emit => '. adc%M %binop',
389 am => "source,binary",
393 modified_flags => $status_flags
398 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
399 ins => [ "left", "right" ],
403 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
404 ins => [ "left", "right", "eflags" ],
408 # we should not rematrialize this node. It produces 2 results and has
409 # very strict constraints
410 state => "exc_pinned",
411 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
412 out => [ "eax", "flags", "none", "edx" ] },
413 ins => [ "base", "index", "mem", "left", "right" ],
414 emit => '. mul%M %unop4',
415 outs => [ "res_low", "flags", "M", "res_high" ],
416 am => "source,binary",
419 modified_flags => $status_flags
423 # we should not rematrialize this node. It produces 2 results and has
424 # very strict constraints
426 cmp_attr => "return 1;",
427 reg_req => { in => [ "none", "none" ],
428 out => [ "none", "none", "none", "none" ] },
429 ins => [ "left", "right" ],
430 outs => [ "res_low", "flags", "M", "res_high" ],
435 state => "exc_pinned",
436 # TODO: adjust out requirements for the 3 operand form
437 # (no need for should_be_same then)
438 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
439 out => [ "in_r4 in_r5", "flags", "none" ] },
440 ins => [ "base", "index", "mem", "left", "right" ],
441 outs => [ "res", "flags", "M" ],
442 am => "source,binary",
446 modified_flags => $status_flags
451 state => "exc_pinned",
452 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
453 out => [ "eax", "flags", "none", "edx" ] },
454 ins => [ "base", "index", "mem", "left", "right" ],
455 emit => '. imul%M %unop4',
456 outs => [ "res_low", "flags", "M", "res_high" ],
457 am => "source,binary",
460 modified_flags => $status_flags
465 cmp_attr => "return 1;",
466 reg_req => { in => [ "none", "none" ],
467 out => [ "none", "none", "none", "none" ] },
468 ins => [ "left", "right" ],
469 outs => [ "res_low", "flags", "M", "res_high" ],
474 state => "exc_pinned",
475 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
476 out => [ "in_r4 in_r5", "flags", "none" ] },
477 ins => [ "base", "index", "mem", "left", "right" ],
478 outs => [ "res", "flags", "M" ],
479 am => "source,binary",
480 emit => '. and%M %binop',
484 modified_flags => $status_flags
489 state => "exc_pinned",
490 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
491 ins => [ "base", "index", "mem", "val" ],
492 emit => '. and%M %SI3, %AM',
496 modified_flags => $status_flags
501 state => "exc_pinned",
502 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
503 ins => [ "base", "index", "mem", "val" ],
504 emit => '. and%M %SB3, %AM',
508 modified_flags => $status_flags
513 state => "exc_pinned",
514 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
515 out => [ "in_r4 in_r5", "flags", "none" ] },
516 ins => [ "base", "index", "mem", "left", "right" ],
517 outs => [ "res", "flags", "M" ],
518 am => "source,binary",
519 emit => '. or%M %binop',
523 modified_flags => $status_flags
528 state => "exc_pinned",
529 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
530 ins => [ "base", "index", "mem", "val" ],
531 emit => '. or%M %SI3, %AM',
535 modified_flags => $status_flags
540 state => "exc_pinned",
541 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
542 ins => [ "base", "index", "mem", "val" ],
543 emit => '. or%M %SB3, %AM',
547 modified_flags => $status_flags
552 state => "exc_pinned",
553 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
554 out => [ "in_r4 in_r5", "flags", "none" ] },
555 ins => [ "base", "index", "mem", "left", "right" ],
556 outs => [ "res", "flags", "M" ],
557 am => "source,binary",
558 emit => '. xor%M %binop',
562 modified_flags => $status_flags
568 reg_req => { out => [ "gp", "flags" ] },
569 outs => [ "res", "flags" ],
570 emit => ". xor%M %D0, %D0",
574 modified_flags => $status_flags
579 state => "exc_pinned",
580 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
581 ins => [ "base", "index", "mem", "val" ],
582 emit => '. xor%M %SI3, %AM',
586 modified_flags => $status_flags
591 state => "exc_pinned",
592 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
593 ins => [ "base", "index", "mem", "val" ],
594 emit => '. xor%M %SB3, %AM',
598 modified_flags => $status_flags
603 state => "exc_pinned",
604 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
605 out => [ "in_r4", "flags", "none" ] },
606 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
607 outs => [ "res", "flags", "M" ],
608 am => "source,binary",
609 emit => '. sub%M %binop',
613 modified_flags => $status_flags
618 state => "exc_pinned",
619 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
620 ins => [ "base", "index", "mem", "subtrahend" ],
621 emit => '. sub%M %SI3, %AM',
625 modified_flags => $status_flags
630 state => "exc_pinned",
631 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
632 ins => [ "base", "index", "mem", "subtrahend" ],
633 emit => '. sub%M %SB3, %AM',
637 modified_flags => $status_flags
641 state => "exc_pinned",
642 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
643 out => [ "in_r4 !in_r5", "flags", "none" ] },
644 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
645 outs => [ "res", "flags", "M" ],
646 am => "source,binary",
647 emit => '. sbb%M %binop',
651 modified_flags => $status_flags
655 # Spiller currently fails when rematerializing flag consumers
657 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
658 outs => [ "res", "flags" ],
659 emit => ". sbb%M %D0, %D0",
663 modified_flags => $status_flags
667 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
668 ins => [ "minuend", "subtrahend" ],
672 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
673 ins => [ "minuend", "subtrahend", "eflags" ],
678 state => "exc_pinned",
679 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
680 out => [ "eax", "flags", "none", "edx", "none" ] },
681 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
682 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
683 am => "source,unary",
684 emit => ". idiv%M %unop3",
687 modified_flags => $status_flags
692 state => "exc_pinned",
693 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
694 out => [ "eax", "flags", "none", "edx", "none" ] },
695 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
696 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
697 am => "source,unary",
698 emit => ". div%M %unop3",
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%M %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 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
732 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 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
751 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%M %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 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
782 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;",
800 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
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%M %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" ],
832 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
837 reg_req => { in => [ "gp", "ecx" ],
838 out => [ "in_r1 !in_r2", "flags" ] },
839 ins => [ "val", "count" ],
840 outs => [ "res", "flags" ],
841 emit => '. ror%M %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%M %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
887 reg_req => { in => [ "gp" ],
888 out => [ "in_r1", "flags" ] },
889 emit => '. neg%M %S0',
891 outs => [ "res", "flags" ],
895 modified_flags => $status_flags
900 state => "exc_pinned",
901 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
902 ins => [ "base", "index", "mem" ],
903 emit => '. neg%M %AM',
907 modified_flags => $status_flags
912 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
913 outs => [ "low_res", "high_res" ],
916 modified_flags => $status_flags
922 reg_req => { in => [ "gp" ],
923 out => [ "in_r1", "flags" ] },
925 outs => [ "res", "flags" ],
926 emit => '. inc%M %S0',
930 modified_flags => $status_flags_wo_cf
935 state => "exc_pinned",
936 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
937 ins => [ "base", "index", "mem" ],
938 emit => '. inc%M %AM',
942 modified_flags => $status_flags_wo_cf
947 reg_req => { in => [ "gp" ],
948 out => [ "in_r1", "flags" ] },
950 outs => [ "res", "flags" ],
951 emit => '. dec%M %S0',
955 modified_flags => $status_flags_wo_cf
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 => $status_flags_wo_cf
972 reg_req => { in => [ "gp" ],
973 out => [ "in_r1" ] },
976 emit => '. not%M %S0',
985 state => "exc_pinned",
986 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
987 ins => [ "base", "index", "mem" ],
988 emit => '. not%M %AM',
996 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1000 mode => $mode_flags,
1001 modified_flags => $status_flags
1005 reg_req => { out => [ "flags" ] },
1009 mode => $mode_flags,
1010 modified_flags => $status_flags
1015 state => "exc_pinned",
1016 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1017 out => [ "flags", "none", "none" ] },
1018 ins => [ "base", "index", "mem", "left", "right" ],
1019 outs => [ "eflags", "unused", "M" ],
1020 am => "source,binary",
1021 emit => '. cmp%M %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", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1035 out => [ "flags", "none", "none" ] },
1036 ins => [ "base", "index", "mem", "left", "right" ],
1037 outs => [ "eflags", "unused", "M" ],
1038 am => "source,binary",
1039 emit => '. cmpb %binop',
1040 attr => "int ins_permuted, int cmp_unsigned",
1041 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1042 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1045 mode => $mode_flags,
1046 modified_flags => $status_flags
1051 state => "exc_pinned",
1052 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
1053 out => [ "flags", "none", "none" ] },
1054 ins => [ "base", "index", "mem", "left", "right" ],
1055 outs => [ "eflags", "unused", "M" ],
1056 am => "source,binary",
1057 emit => '. test%M %binop',
1058 attr => "int ins_permuted, int cmp_unsigned",
1059 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1060 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1063 mode => $mode_flags,
1064 modified_flags => $status_flags
1069 state => "exc_pinned",
1070 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1071 out => [ "flags", "none", "none" ] },
1072 ins => [ "base", "index", "mem", "left", "right" ],
1073 outs => [ "eflags", "unused", "M" ],
1074 am => "source,binary",
1075 emit => '. testb %binop',
1076 attr => "int ins_permuted, int cmp_unsigned",
1077 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1078 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1081 mode => $mode_flags,
1082 modified_flags => $status_flags
1087 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1088 ins => [ "eflags" ],
1090 attr_type => "ia32_condcode_attr_t",
1091 attr => "pn_Cmp pnc",
1092 # The way we handle Setcc with float nodes (potentially) destroys the flags
1093 # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
1094 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
1095 . "\tif ((pnc & ia32_pn_Cmp_float) && ((pnc & 0xf) != pn_Cmp_Uo) && ((pnc & 0xf) != pn_Cmp_Leg)) {\n"
1096 . "\t\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n"
1097 . "\t\t/* attr->latency = 3; */\n"
1106 state => "exc_pinned",
1107 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1108 ins => [ "base", "index", "mem","eflags" ],
1109 attr_type => "ia32_condcode_attr_t",
1110 attr => "pn_Cmp pnc",
1111 init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
1112 emit => '. set%CMP3 %AM',
1120 state => "exc_pinned",
1121 # (note: leave the false,true order intact to make it compatible with other
1123 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1124 out => [ "in_r4 in_r5", "flags", "none" ] },
1125 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1126 outs => [ "res", "flags", "M" ],
1127 am => "source,binary",
1128 attr_type => "ia32_condcode_attr_t",
1129 attr => "pn_Cmp pnc",
1137 op_flags => "L|X|Y",
1138 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1139 ins => [ "eflags" ],
1140 outs => [ "false", "true" ],
1141 attr_type => "ia32_condcode_attr_t",
1142 attr => "pn_Cmp pnc",
1144 units => [ "BRANCH" ],
1149 op_flags => "L|X|Y",
1150 reg_req => { in => [ "gp" ] },
1152 attr_type => "ia32_condcode_attr_t",
1155 units => [ "BRANCH" ],
1156 modified_flags => $status_flags,
1157 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1164 reg_req => { out => [ "none" ] },
1166 units => [ "BRANCH" ],
1173 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1174 ins => [ "base", "index", "mem", "target" ],
1175 am => "source,unary",
1176 emit => '. jmp *%unop3',
1178 units => [ "BRANCH" ],
1180 init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
1186 reg_req => { out => [ "gp" ] },
1188 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1189 attr_type => "ia32_immediate_attr_t",
1197 reg_req => { out => [ "gp" ] },
1205 reg_req => { out => [ "gp" ] },
1209 modified_flags => $status_flags,
1214 op_flags => "c|NB|NI",
1215 reg_req => { out => [ "gp_NOREG:I" ] },
1224 op_flags => "c|NB|NI",
1225 reg_req => { out => [ "vfp_NOREG:I" ] },
1230 attr_type => "ia32_x87_attr_t",
1235 op_flags => "c|NB|NI",
1236 reg_req => { out => [ "xmm_NOREG:I" ] },
1246 reg_req => { out => [ "fpcw:I" ] },
1250 modified_flags => $fpcw_flags
1256 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1257 ins => [ "base", "index", "mem" ],
1259 emit => ". fldcw %AM",
1262 modified_flags => $fpcw_flags
1268 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1269 ins => [ "base", "index", "mem", "fpcw" ],
1271 emit => ". fnstcw %AM",
1279 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1287 # we should not rematrialize this node. It has very strict constraints.
1288 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1289 ins => [ "val", "clobbered" ],
1298 # Note that we add additional latency values depending on address mode, so a
1299 # lateny of 0 for load is correct
1303 state => "exc_pinned",
1304 reg_req => { in => [ "gp", "gp", "none" ],
1305 out => [ "gp", "none", "none", "none" ] },
1306 ins => [ "base", "index", "mem" ],
1307 outs => [ "res", "unused", "M", "X_exc" ],
1309 emit => ". mov%EX%.l %AM, %D0",
1315 state => "exc_pinned",
1316 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1317 ins => [ "base", "index", "mem", "val" ],
1318 outs => [ "M", "X_exc" ],
1319 emit => '. mov%M %SI3, %AM',
1327 state => "exc_pinned",
1328 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1329 ins => [ "base", "index", "mem", "val" ],
1330 outs => [ "M", "X_exc" ],
1331 emit => '. mov%M %SB3, %AM',
1339 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1340 ins => [ "base", "index" ],
1341 emit => '. leal %AM, %D0',
1345 # lea doesn't modify the flags, but setting this seems advantageous since it
1346 # increases chances that the Lea is transformed back to an Add
1347 modified_flags => 1,
1351 state => "exc_pinned",
1352 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1353 ins => [ "base", "index", "mem", "val", "stack" ],
1354 emit => '. push%M %unop3',
1355 outs => [ "stack", "M" ],
1356 am => "source,unary",
1362 state => "exc_pinned",
1363 reg_req => { in => [ "esp" ], out => [ "esp:I|S" ] },
1365 outs => [ "stack" ],
1366 emit => '. pushl %%eax',
1373 state => "exc_pinned",
1374 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1375 ins => [ "mem", "stack" ],
1376 outs => [ "res", "M", "unused", "stack" ],
1377 emit => '. pop%M %D0',
1378 latency => 3, # Pop is more expensive than Push on Athlon
1383 state => "exc_pinned",
1384 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1385 ins => [ "mem", "stack" ],
1386 outs => [ "res", "M", "unused", "stack" ],
1387 emit => '. pop%M %D0',
1388 latency => 3, # Pop is more expensive than Push on Athlon
1393 state => "exc_pinned",
1394 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1395 ins => [ "base", "index", "mem", "stack" ],
1396 outs => [ "unused0", "M", "unused1", "stack" ],
1397 emit => '. pop%M %AM',
1398 latency => 3, # Pop is more expensive than Push on Athlon
1403 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1405 outs => [ "frame", "stack", "M" ],
1411 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1413 outs => [ "frame", "stack" ],
1420 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1421 ins => [ "base", "index", "mem", "stack", "size" ],
1422 am => "source,binary",
1423 emit => '. addl %binop',
1425 outs => [ "stack", "M" ],
1427 modified_flags => $status_flags
1432 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1433 ins => [ "base", "index", "mem", "stack", "size" ],
1434 am => "source,binary",
1435 emit => ". subl %binop\n".
1436 ". movl %%esp, %D1",
1438 outs => [ "stack", "addr", "M" ],
1440 modified_flags => $status_flags
1453 reg_req => { out => [ "gp" ] },
1459 # BT supports source address mode, but this is unused yet
1463 state => "exc_pinned",
1464 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1465 ins => [ "left", "right" ],
1466 emit => '. bt%M %S1, %S0',
1469 mode => $mode_flags,
1470 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1475 state => "exc_pinned",
1476 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1477 out => [ "gp", "flags", "none" ] },
1478 ins => [ "base", "index", "mem", "operand" ],
1479 outs => [ "res", "flags", "M" ],
1480 am => "source,binary",
1481 emit => '. bsf%M %unop3, %D0',
1485 modified_flags => $status_flags
1490 state => "exc_pinned",
1491 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1492 out => [ "gp", "flags", "none" ] },
1493 ins => [ "base", "index", "mem", "operand" ],
1494 outs => [ "res", "flags", "M" ],
1495 am => "source,binary",
1496 emit => '. bsr%M %unop3, %D0',
1500 modified_flags => $status_flags
1504 # SSE4.2 or SSE4a popcnt instruction
1508 state => "exc_pinned",
1509 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1510 out => [ "gp", "flags", "none" ] },
1511 ins => [ "base", "index", "mem", "operand" ],
1512 outs => [ "res", "flags", "M" ],
1513 am => "source,binary",
1514 emit => '. popcnt%M %unop3, %D0',
1518 modified_flags => $status_flags
1522 state => "exc_pinned",
1524 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1525 out => [ "esp:I|S", "fpcw:I", "none", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ]
1527 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1528 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1529 attr_type => "ia32_call_attr_t",
1530 attr => "unsigned pop, ir_type *call_tp",
1531 am => "source,unary",
1532 units => [ "BRANCH" ],
1533 latency => 4, # random number
1534 modified_flags => $status_flags
1538 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1540 # PS: try gcc __builtin_frame_address(100000) :-)
1543 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1544 ins => [ "frame", "cnt", "tmp" ],
1546 latency => 4, # random number
1547 attr_type => "ia32_climbframe_attr_t",
1548 attr => "unsigned count",
1558 reg_req => { in => [ "gp" ],
1559 out => [ "in_r1" ] },
1560 emit => '. bswap%M %S0',
1568 # bswap16, use xchg here
1572 reg_req => { in => [ "eax ebx ecx edx" ],
1573 out => [ "in_r1" ] },
1574 emit => '. xchg %SB0, %SH0',
1586 reg_req => { in => [ "none" ], out => [ "none" ] },
1595 # Undefined Instruction on ALL x86 CPU's
1599 reg_req => { in => [ "none" ], out => [ "none" ] },
1602 emit => ". .value 0x0b0f",
1613 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1614 ins => [ "port", "value", "mem" ],
1615 emit => '. out%M %SS0, %SI1',
1619 modified_flags => $status_flags
1628 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1629 ins => [ "port", "mem" ],
1630 outs => [ "res", "M" ],
1631 emit => '. in%M %DS0, %SS0',
1635 modified_flags => $status_flags
1639 # Intel style prefetching
1643 state => "exc_pinned",
1644 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1645 ins => [ "base", "index", "mem" ],
1648 emit => ". prefetcht0 %AM",
1654 state => "exc_pinned",
1655 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1656 ins => [ "base", "index", "mem" ],
1659 emit => ". prefetcht1 %AM",
1665 state => "exc_pinned",
1666 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1667 ins => [ "base", "index", "mem" ],
1670 emit => ". prefetcht2 %AM",
1676 state => "exc_pinned",
1677 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1678 ins => [ "base", "index", "mem" ],
1681 emit => ". prefetchnta %AM",
1686 # 3DNow! prefetch instructions
1690 state => "exc_pinned",
1691 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1692 ins => [ "base", "index", "mem" ],
1695 emit => ". prefetch %AM",
1701 state => "exc_pinned",
1702 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1703 ins => [ "base", "index", "mem" ],
1706 emit => ". prefetchw %AM",
1713 reg_req => { out => [ "xmm" ] },
1714 emit => '. xorp%XSD %D0, %D0',
1723 reg_req => { out => [ "xmm" ] },
1731 reg_req => { out => [ "xmm" ] },
1732 emit => '. pxor %D0, %D0',
1738 # produces all 1 bits
1741 reg_req => { out => [ "xmm" ] },
1742 emit => '. pcmpeqb %D0, %D0',
1748 # integer shift left, dword
1751 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1752 emit => '. pslld %SI1, %D0',
1758 # integer shift left, qword
1761 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1762 emit => '. psllq %SI1, %D0',
1768 # integer shift right, dword
1771 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1772 emit => '. psrld %SI1, %D0',
1778 # mov from integer to SSE register
1781 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1782 emit => '. movd %S0, %D0',
1790 state => "exc_pinned",
1791 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1792 out => [ "in_r4 in_r5", "flags", "none" ] },
1793 ins => [ "base", "index", "mem", "left", "right" ],
1794 outs => [ "res", "flags", "M" ],
1795 am => "source,binary",
1796 emit => '. add%XXM %binop',
1804 state => "exc_pinned",
1805 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1806 out => [ "in_r4 in_r5", "flags", "none" ] },
1807 ins => [ "base", "index", "mem", "left", "right" ],
1808 outs => [ "res", "flags", "M" ],
1809 am => "source,binary",
1810 emit => '. mul%XXM %binop',
1818 state => "exc_pinned",
1819 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1820 out => [ "in_r4 in_r5", "flags", "none" ] },
1821 ins => [ "base", "index", "mem", "left", "right" ],
1822 outs => [ "res", "flags", "M" ],
1823 am => "source,binary",
1824 emit => '. max%XXM %binop',
1832 state => "exc_pinned",
1833 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1834 out => [ "in_r4 in_r5", "flags", "none" ] },
1835 ins => [ "base", "index", "mem", "left", "right" ],
1836 outs => [ "res", "flags", "M" ],
1837 am => "source,binary",
1838 emit => '. min%XXM %binop',
1846 state => "exc_pinned",
1847 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1848 out => [ "in_r4 in_r5", "flags", "none" ] },
1849 ins => [ "base", "index", "mem", "left", "right" ],
1850 outs => [ "res", "flags", "M" ],
1851 am => "source,binary",
1852 emit => '. andp%XSD %binop',
1860 state => "exc_pinned",
1861 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1862 out => [ "in_r4 in_r5", "flags", "none" ] },
1863 ins => [ "base", "index", "mem", "left", "right" ],
1864 outs => [ "res", "flags", "M" ],
1865 am => "source,binary",
1866 emit => '. orp%XSD %binop',
1874 state => "exc_pinned",
1875 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1876 out => [ "in_r4 in_r5", "flags", "none" ] },
1877 ins => [ "base", "index", "mem", "left", "right" ],
1878 outs => [ "res", "flags", "M" ],
1879 am => "source,binary",
1880 emit => '. xorp%XSD %binop',
1888 state => "exc_pinned",
1889 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1890 out => [ "in_r4 !in_r5", "flags", "none" ] },
1891 ins => [ "base", "index", "mem", "left", "right" ],
1892 outs => [ "res", "flags", "M" ],
1893 am => "source,binary",
1894 emit => '. andnp%XSD %binop',
1902 state => "exc_pinned",
1903 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1904 out => [ "in_r4", "flags", "none" ] },
1905 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1906 outs => [ "res", "flags", "M" ],
1907 am => "source,binary",
1908 emit => '. sub%XXM %binop',
1916 state => "exc_pinned",
1917 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1918 out => [ "in_r4 !in_r5", "flags", "none" ] },
1919 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1920 outs => [ "res", "flags", "M" ],
1921 am => "source,binary",
1922 emit => '. div%XXM %binop',
1929 state => "exc_pinned",
1930 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1931 out => [ "eflags" ] },
1932 ins => [ "base", "index", "mem", "left", "right" ],
1933 outs => [ "flags" ],
1934 am => "source,binary",
1935 attr => "int ins_permuted",
1936 init_attr => "attr->data.ins_permuted = ins_permuted;",
1937 emit => ' .ucomi%XXM %binop',
1940 mode => $mode_flags,
1941 modified_flags => 1,
1946 state => "exc_pinned",
1947 reg_req => { in => [ "gp", "gp", "none" ],
1948 out => [ "xmm", "none", "none", "none" ] },
1949 ins => [ "base", "index", "mem" ],
1950 outs => [ "res", "unused", "M", "X_exc" ],
1951 emit => '. mov%XXM %AM, %D0',
1952 attr => "ir_mode *load_mode",
1953 init_attr => "attr->ls_mode = load_mode;",
1960 state => "exc_pinned",
1961 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1962 ins => [ "base", "index", "mem", "val" ],
1963 outs => [ "M", "X_exc" ],
1964 emit => '. mov%XXM %S3, %AM',
1972 state => "exc_pinned",
1973 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
1974 ins => [ "base", "index", "mem", "val" ],
1976 emit => '. mov%XXM %S3, %AM',
1984 state => "exc_pinned",
1985 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1986 ins => [ "base", "index", "mem", "val" ],
1987 am => "source,unary",
1988 emit => '. cvtsi2ss %unop3, %D0',
1996 state => "exc_pinned",
1997 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1998 ins => [ "base", "index", "mem", "val" ],
1999 am => "source,unary",
2000 emit => '. cvtsi2sd %unop3, %D0',
2009 cmp_attr => "return 1;",
2010 ins => [ "val_high", "val_low" ],
2011 reg_req => { in => [ "none", "none" ], out => [ "none" ] }
2016 cmp_attr => "return 1;",
2018 outs => [ "res_high", "res_low" ],
2019 reg_req => { in => [ "none" ], out => [ "none", "none" ] }
2025 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2026 outs => [ "DST", "SRC", "CNT", "M" ],
2027 attr_type => "ia32_copyb_attr_t",
2028 attr => "unsigned size",
2031 # we don't care about this flag, so no need to mark this node
2032 # modified_flags => [ "DF" ]
2038 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2039 outs => [ "DST", "SRC", "M" ],
2040 attr_type => "ia32_copyb_attr_t",
2041 attr => "unsigned size",
2044 # we don't care about this flag, so no need to mark this node
2045 # modified_flags => [ "DF" ]
2049 state => "exc_pinned",
2050 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2060 state => "exc_pinned",
2061 reg_req => { in => [ "gp", "gp", "none", "gp" ],
2062 out => [ "gp", "none", "none" ] },
2063 ins => [ "base", "index", "mem", "val" ],
2064 outs => [ "res", "flags", "M" ],
2065 am => "source,unary",
2068 attr => "ir_mode *smaller_mode",
2069 init_attr => "attr->ls_mode = smaller_mode;",
2074 state => "exc_pinned",
2075 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2076 out => [ "gp", "none", "none" ] },
2077 ins => [ "base", "index", "mem", "val" ],
2078 outs => [ "res", "flags", "M" ],
2079 am => "source,unary",
2082 attr => "ir_mode *smaller_mode",
2083 init_attr => "attr->ls_mode = smaller_mode;",
2088 state => "exc_pinned",
2089 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2090 ins => [ "base", "index", "mem", "val" ],
2091 am => "source,unary",
2098 state => "exc_pinned",
2099 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2100 ins => [ "base", "index", "mem", "val" ],
2101 am => "source,unary",
2108 state => "exc_pinned",
2109 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2110 ins => [ "base", "index", "mem", "val" ],
2111 am => "source,unary",
2117 # rematerialisation disabled for all float nodes for now, because the fpcw
2118 # handler runs before spilling and we might end up with wrong fpcw then
2122 state => "exc_pinned",
2123 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2124 out => [ "vfp", "none", "none" ] },
2125 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2126 outs => [ "res", "dummy", "M" ],
2127 am => "source,binary",
2131 attr_type => "ia32_x87_attr_t",
2136 state => "exc_pinned",
2137 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2138 out => [ "vfp", "none", "none" ] },
2139 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2140 outs => [ "res", "dummy", "M" ],
2141 am => "source,binary",
2145 attr_type => "ia32_x87_attr_t",
2150 state => "exc_pinned",
2151 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2152 out => [ "vfp", "none", "none" ] },
2153 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2154 outs => [ "res", "dummy", "M" ],
2155 am => "source,binary",
2159 attr_type => "ia32_x87_attr_t",
2163 state => "exc_pinned",
2164 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ],
2165 out => [ "vfp", "none", "none" ] },
2166 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2167 outs => [ "res", "dummy", "M" ],
2168 am => "source,binary",
2171 attr_type => "ia32_x87_attr_t",
2175 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2176 ins => [ "left", "right", "fpcw" ],
2180 attr_type => "ia32_x87_attr_t",
2185 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2190 attr_type => "ia32_x87_attr_t",
2195 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2200 attr_type => "ia32_x87_attr_t",
2206 state => "exc_pinned",
2207 reg_req => { in => [ "gp", "gp", "none" ],
2208 out => [ "vfp", "none", "none", "none" ] },
2209 ins => [ "base", "index", "mem" ],
2210 outs => [ "res", "unused", "M", "X_exc" ],
2211 attr => "ir_mode *load_mode",
2212 init_attr => "attr->attr.ls_mode = load_mode;",
2215 attr_type => "ia32_x87_attr_t",
2221 state => "exc_pinned",
2222 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2223 out => [ "none", "none" ] },
2224 ins => [ "base", "index", "mem", "val" ],
2225 outs => [ "M", "X_exc" ],
2226 attr => "ir_mode *store_mode",
2227 init_attr => "attr->attr.ls_mode = store_mode;",
2231 attr_type => "ia32_x87_attr_t",
2235 state => "exc_pinned",
2236 reg_req => { in => [ "gp", "gp", "none" ],
2237 out => [ "vfp", "none", "none" ] },
2238 outs => [ "res", "unused", "M" ],
2239 ins => [ "base", "index", "mem" ],
2242 attr_type => "ia32_x87_attr_t",
2246 state => "exc_pinned",
2247 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2248 ins => [ "base", "index", "mem", "val", "fpcw" ],
2253 attr_type => "ia32_x87_attr_t",
2256 # SSE3 fisttp instruction
2258 state => "exc_pinned",
2259 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2260 ins => [ "base", "index", "mem", "val" ],
2261 outs => [ "res", "M" ],
2264 attr_type => "ia32_x87_attr_t",
2269 reg_req => { out => [ "vfp" ] },
2274 attr_type => "ia32_x87_attr_t",
2279 reg_req => { out => [ "vfp" ] },
2284 attr_type => "ia32_x87_attr_t",
2289 reg_req => { out => [ "vfp" ] },
2294 attr_type => "ia32_x87_attr_t",
2299 reg_req => { out => [ "vfp" ] },
2304 attr_type => "ia32_x87_attr_t",
2309 reg_req => { out => [ "vfp" ] },
2314 attr_type => "ia32_x87_attr_t",
2319 reg_req => { out => [ "vfp" ] },
2324 attr_type => "ia32_x87_attr_t",
2329 reg_req => { out => [ "vfp" ] },
2334 attr_type => "ia32_x87_attr_t",
2338 # we can't allow to rematerialize this node so we don't
2339 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2341 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2342 ins => [ "left", "right" ],
2343 outs => [ "flags" ],
2344 attr => "int ins_permuted",
2345 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2348 attr_type => "ia32_x87_attr_t",
2354 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2355 ins => [ "left", "right" ],
2356 outs => [ "flags" ],
2357 attr => "int ins_permuted",
2358 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2361 attr_type => "ia32_x87_attr_t",
2367 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2369 outs => [ "flags" ],
2370 attr => "int ins_permuted",
2371 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2374 attr_type => "ia32_x87_attr_t",
2380 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2382 outs => [ "flags" ],
2386 mode => $mode_flags,
2390 state => "exc_pinned",
2391 emit => '. fadd%XM %x87_binop',
2393 attr_type => "ia32_x87_attr_t",
2398 state => "exc_pinned",
2399 emit => '. faddp%XM %x87_binop',
2401 attr_type => "ia32_x87_attr_t",
2406 state => "exc_pinned",
2407 emit => '. fmul%XM %x87_binop',
2409 attr_type => "ia32_x87_attr_t",
2414 state => "exc_pinned",
2415 emit => '. fmulp%XM %x87_binop',,
2417 attr_type => "ia32_x87_attr_t",
2422 state => "exc_pinned",
2423 emit => '. fsub%XM %x87_binop',
2425 attr_type => "ia32_x87_attr_t",
2429 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2430 # are swapped, we work this around in the emitter...
2433 state => "exc_pinned",
2434 # see note about gas bugs
2435 emit => '. fsubrp%XM %x87_binop',
2437 attr_type => "ia32_x87_attr_t",
2442 state => "exc_pinned",
2444 emit => '. fsubr%XM %x87_binop',
2446 attr_type => "ia32_x87_attr_t",
2451 state => "exc_pinned",
2453 # see note about gas bugs before fsubp
2454 emit => '. fsubp%XM %x87_binop',
2456 attr_type => "ia32_x87_attr_t",
2463 attr_type => "ia32_x87_attr_t",
2467 # this node is just here, to keep the simulator running
2468 # we can omit this when a fprem simulation function exists
2470 emit => '. fprem1\n'.
2473 attr_type => "ia32_x87_attr_t",
2478 state => "exc_pinned",
2479 emit => '. fdiv%XM %x87_binop',
2481 attr_type => "ia32_x87_attr_t",
2486 state => "exc_pinned",
2487 # see note about gas bugs before fsubp
2488 emit => '. fdivrp%XM %x87_binop',
2490 attr_type => "ia32_x87_attr_t",
2495 state => "exc_pinned",
2496 emit => '. fdivr%XM %x87_binop',
2498 attr_type => "ia32_x87_attr_t",
2503 state => "exc_pinned",
2504 # see note about gas bugs before fsubp
2505 emit => '. fdivp%XM %x87_binop',
2507 attr_type => "ia32_x87_attr_t",
2514 attr_type => "ia32_x87_attr_t",
2522 attr_type => "ia32_x87_attr_t",
2527 op_flags => "R|L|F",
2528 state => "exc_pinned",
2529 emit => '. fld%XM %AM',
2530 attr_type => "ia32_x87_attr_t",
2536 op_flags => "R|L|F",
2537 state => "exc_pinned",
2538 emit => '. fst%XM %AM',
2540 attr_type => "ia32_x87_attr_t",
2546 op_flags => "R|L|F",
2547 state => "exc_pinned",
2548 emit => '. fstp%XM %AM',
2550 attr_type => "ia32_x87_attr_t",
2556 state => "exc_pinned",
2557 emit => '. fild%XM %AM',
2558 attr_type => "ia32_x87_attr_t",
2564 state => "exc_pinned",
2565 emit => '. fist%XM %AM',
2567 attr_type => "ia32_x87_attr_t",
2573 state => "exc_pinned",
2574 emit => '. fistp%XM %AM',
2576 attr_type => "ia32_x87_attr_t",
2581 # SSE3 fisttp instruction
2583 state => "exc_pinned",
2584 emit => '. fisttp%XM %AM',
2586 attr_type => "ia32_x87_attr_t",
2592 op_flags => "R|c|K",
2594 reg_req => { out => [ "vfp" ] },
2596 attr_type => "ia32_x87_attr_t",
2601 op_flags => "R|c|K",
2603 reg_req => { out => [ "vfp" ] },
2605 attr_type => "ia32_x87_attr_t",
2610 op_flags => "R|c|K",
2612 reg_req => { out => [ "vfp" ] },
2614 attr_type => "ia32_x87_attr_t",
2619 op_flags => "R|c|K",
2621 reg_req => { out => [ "vfp" ] },
2623 attr_type => "ia32_x87_attr_t",
2628 op_flags => "R|c|K",
2630 reg_req => { out => [ "vfp" ] },
2632 attr_type => "ia32_x87_attr_t",
2637 op_flags => "R|c|K",
2639 reg_req => { out => [ "vfp" ] },
2640 emit => '. fldll2t',
2641 attr_type => "ia32_x87_attr_t",
2646 op_flags => "R|c|K",
2648 reg_req => { out => [ "vfp" ] },
2650 attr_type => "ia32_x87_attr_t",
2655 # Note that it is NEVER allowed to do CSE on these nodes
2656 # Moreover, note the virtual register requierements!
2660 reg_req => { out => [ "none" ] },
2661 cmp_attr => "return 1;",
2662 emit => '. fxch %X0',
2663 attr_type => "ia32_x87_attr_t",
2670 reg_req => { out => [ "none" ] },
2671 cmp_attr => "return 1;",
2672 emit => '. fld %X0',
2673 attr_type => "ia32_x87_attr_t",
2679 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2680 cmp_attr => "return 1;",
2681 emit => '. fld %X0',
2682 attr_type => "ia32_x87_attr_t",
2688 reg_req => { out => [ "none" ] },
2689 cmp_attr => "return 1;",
2690 emit => '. fstp %X0',
2691 attr_type => "ia32_x87_attr_t",
2698 reg_req => { out => [ "none" ] },
2699 cmp_attr => "return 1;",
2700 emit => '. ffreep %X0',
2701 attr_type => "ia32_x87_attr_t",
2708 reg_req => { out => [ "none" ] },
2709 cmp_attr => "return 1;",
2711 attr_type => "ia32_x87_attr_t",
2718 reg_req => { out => [ "none" ] },
2719 cmp_attr => "return 1;",
2721 attr_type => "ia32_x87_attr_t",
2728 emit => ". fucom %X1\n".
2730 attr_type => "ia32_x87_attr_t",
2736 emit => ". fucomp %X1\n".
2738 attr_type => "ia32_x87_attr_t",
2744 emit => ". fucompp\n".
2746 attr_type => "ia32_x87_attr_t",
2752 emit => '. fucomi %X1',
2753 attr_type => "ia32_x87_attr_t",
2759 emit => '. fucompi %X1',
2760 attr_type => "ia32_x87_attr_t",
2768 attr_type => "ia32_x87_attr_t",
2772 # Spilling and reloading of SSE registers, hardcoded, not generated #
2776 state => "exc_pinned",
2777 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2778 emit => '. movdqu %D0, %AM',
2779 outs => [ "res", "M" ],
2786 state => "exc_pinned",
2787 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2788 ins => [ "base", "index", "mem", "val" ],
2789 emit => '. movdqu %binop',
2797 # Transform some attributes
2798 foreach my $op (keys(%nodes)) {
2799 my $node = $nodes{$op};
2800 my $op_attr_init = $node->{op_attr_init};
2802 if(defined($op_attr_init)) {
2803 $op_attr_init .= "\n\t";
2808 if(!defined($node->{latency})) {
2810 $node->{latency} = 0;
2812 die("Latency missing for op $op");
2815 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2817 $node->{op_attr_init} = $op_attr_init;