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",
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 # outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts
32 # ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts
33 # mode => "mode_Iu" # optional, predefines the mode
34 # emit => "emit code with templates",
35 # attr => "additional attribute arguments for constructor",
36 # init_attr => "emit attribute initialization template",
37 # rd_constructor => "c source code which constructs an ir_node",
38 # hash_func => "name of the hash function for this operation",
39 # latency => "latency of this operation (can be float)"
40 # attr_type => "name of the attribute struct",
41 # modified_flags => [ "CF", ... ] # optional, list of modified flags
44 # ... # (all nodes you need to describe)
46 # ); # close the %nodes initializer
48 # op_flags: flags for the operation, OPTIONAL (default is "N")
49 # the op_flags correspond to the firm irop_flags:
52 # C irop_flag_commutative
53 # X irop_flag_cfopcode
54 # I irop_flag_ip_cfopcode
57 # H irop_flag_highlevel
58 # c irop_flag_constlike
60 # NB irop_flag_dump_noblock
61 # NI irop_flag_dump_noinput
63 # irn_flags: special node flags, OPTIONAL (default is 0)
64 # following irn_flags are supported:
68 # state: state of the operation, OPTIONAL (default is "floats")
70 # arity: arity of the operation, MUST NOT BE OMITTED
72 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
73 # are always the first 3 arguments and are always autmatically
75 # If this key is missing the following arguments will be created:
76 # for i = 1 .. arity: ir_node *op_i
79 # outs: if a node defines more than one output, the names of the projections
80 # nodes having outs having automatically the mode mode_T
81 # example: [ "frame", "stack", "M" ]
83 # comment: OPTIONAL comment for the node constructor
85 # rd_constructor: for every operation there will be a
86 # new_rd_<arch>_<op-name> function with the arguments from above
87 # which creates the ir_node corresponding to the defined operation
88 # you can either put the complete source code of this function here
90 # This key is OPTIONAL. If omitted, the following constructor will
92 # if (!op_<arch>_<op-name>) assert(0);
96 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
99 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
103 # 0 - no special type
104 # 1 - caller save (register must be saved by the caller of a function)
105 # 2 - callee save (register must be saved by the called function)
106 # 4 - ignore (do not automatically assign this register)
107 # 8 - emitter can choose an arbitrary register of this class
108 # 16 - the register is a virtual one
109 # 32 - register represents a state
110 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
113 { name => "edx", type => 1 },
114 { name => "ecx", type => 1 },
115 { name => "eax", type => 1 },
116 { name => "ebx", type => 2 },
117 { name => "esi", type => 2 },
118 { name => "edi", type => 2 },
119 { name => "ebp", type => 2 },
120 { name => "esp", type => 4 },
121 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
122 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
123 { mode => "mode_Iu" }
126 { name => "mm0", type => 4 },
127 { name => "mm1", type => 4 },
128 { name => "mm2", type => 4 },
129 { name => "mm3", type => 4 },
130 { name => "mm4", type => 4 },
131 { name => "mm5", type => 4 },
132 { name => "mm6", type => 4 },
133 { name => "mm7", type => 4 },
134 { mode => "mode_E", flags => "manual_ra" }
137 { name => "xmm0", type => 1 },
138 { name => "xmm1", type => 1 },
139 { name => "xmm2", type => 1 },
140 { name => "xmm3", type => 1 },
141 { name => "xmm4", type => 1 },
142 { name => "xmm5", type => 1 },
143 { name => "xmm6", type => 1 },
144 { name => "xmm7", type => 1 },
145 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
146 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
150 { name => "vf0", type => 1 },
151 { name => "vf1", type => 1 },
152 { name => "vf2", type => 1 },
153 { name => "vf3", type => 1 },
154 { name => "vf4", type => 1 },
155 { name => "vf5", type => 1 },
156 { name => "vf6", type => 1 },
157 { name => "vf7", type => 1 },
158 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
159 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
163 { name => "st0", realname => "st", type => 4 },
164 { name => "st1", realname => "st(1)", type => 4 },
165 { name => "st2", realname => "st(2)", type => 4 },
166 { name => "st3", realname => "st(3)", type => 4 },
167 { name => "st4", realname => "st(4)", type => 4 },
168 { name => "st5", realname => "st(5)", type => 4 },
169 { name => "st6", realname => "st(6)", type => 4 },
170 { name => "st7", realname => "st(7)", type => 4 },
171 { mode => "mode_E", flags => "manual_ra" }
173 fp_cw => [ # the floating point control word
174 { name => "fpcw", type => 4|32 },
175 { mode => "mode_fpcw", flags => "manual_ra|state" }
178 { name => "eflags", type => 0 },
179 { mode => "mode_Iu", flags => "manual_ra" }
184 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
185 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
186 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
187 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
192 bundels_per_cycle => 1
196 S0 => "${arch}_emit_source_register(node, 0);",
197 S1 => "${arch}_emit_source_register(node, 1);",
198 S2 => "${arch}_emit_source_register(node, 2);",
199 S3 => "${arch}_emit_source_register(node, 3);",
200 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
201 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
202 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
203 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
204 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
205 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
206 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
207 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
208 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
209 D0 => "${arch}_emit_dest_register(node, 0);",
210 D1 => "${arch}_emit_dest_register(node, 1);",
211 DS0 => "${arch}_emit_dest_register_size(node, 0);",
212 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
213 X0 => "${arch}_emit_x87_register(node, 0);",
214 X1 => "${arch}_emit_x87_register(node, 1);",
215 EX => "${arch}_emit_extend_suffix(node);",
216 M => "${arch}_emit_mode_suffix(node);",
217 XM => "${arch}_emit_x87_mode_suffix(node);",
218 XXM => "${arch}_emit_xmm_mode_suffix(node);",
219 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
220 AM => "${arch}_emit_am(node);",
221 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
222 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
223 binop => "${arch}_emit_binop(node);",
224 x87_binop => "${arch}_emit_x87_binop(node);",
225 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
226 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
229 #--------------------------------------------------#
232 # _ __ _____ __ _ _ __ ___ _ __ ___ #
233 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
234 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
235 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
238 #--------------------------------------------------#
240 $default_op_attr_type = "ia32_op_attr_t";
241 $default_attr_type = "ia32_attr_t";
242 $default_copy_attr = "ia32_copy_attr";
244 sub ia32_custom_init_attr {
249 if(defined($node->{modified_flags})) {
250 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
252 if(defined($node->{am})) {
253 my $am = $node->{am};
254 if($am eq "source,unary") {
255 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
256 } elsif($am eq "source,binary") {
257 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
258 } elsif($am eq "none") {
261 die("Invalid address mode '$am' specified on op $name");
264 if($node->{state} ne "exc_pinned"
265 and $node->{state} ne "pinned") {
266 die("AM nodes must have pinned or AM pinned state ($name)");
272 $custom_init_attr_func = \&ia32_custom_init_attr;
276 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
277 "\tinit_ia32_x87_attributes(res);".
278 "\tinit_ia32_asm_attributes(res);",
280 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);",
282 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
283 "\tinit_ia32_call_attributes(res, pop, call_tp);",
284 ia32_condcode_attr_t =>
285 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_condcode_attributes(res, pnc);",
288 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
289 "\tinit_ia32_copyb_attributes(res, size);",
290 ia32_immediate_attr_t =>
291 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, no_pic_adjust, offset);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_x87_attributes(res);",
296 ia32_climbframe_attr_t =>
297 "\tinit_ia32_attributes(res, flags, in_reqs, exec_units, n_res);\n".
298 "\tinit_ia32_climbframe_attributes(res, count);",
302 ia32_asm_attr_t => "ia32_compare_asm_attr",
303 ia32_attr_t => "ia32_compare_nodes_attr",
304 ia32_call_attr_t => "ia32_compare_call_attr",
305 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
306 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
307 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
308 ia32_x87_attr_t => "ia32_compare_x87_attr",
309 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
315 $mode_xmm = "mode_E";
316 $mode_gp = "mode_Iu";
317 $mode_flags = "mode_Iu";
318 $mode_fpcw = "mode_fpcw";
319 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
320 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
321 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
322 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
329 reg_req => { out => [ "gp_NOREG:I" ] },
330 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
331 attr_type => "ia32_immediate_attr_t",
332 hash_func => "ia32_hash_Immediate",
340 out_arity => "variable",
341 attr_type => "ia32_asm_attr_t",
342 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
343 init_attr => "attr->asm_text = asm_text;\n".
344 "\tattr->register_map = register_map;\n",
346 modified_flags => $status_flags,
349 # "allocates" a free register
353 reg_req => { out => [ "gp" ] },
358 cmp_attr => "return 1;",
361 #-----------------------------------------------------------------#
364 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
365 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
366 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
367 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
370 #-----------------------------------------------------------------#
372 # commutative operations
376 state => "exc_pinned",
377 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
378 out => [ "in_r4 in_r5", "flags", "none" ] },
379 ins => [ "base", "index", "mem", "left", "right" ],
380 outs => [ "res", "flags", "M" ],
381 emit => '. add%M %binop',
382 am => "source,binary",
386 modified_flags => $status_flags
391 state => "exc_pinned",
392 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
393 ins => [ "base", "index", "mem", "val" ],
394 emit => ". add%M %SI3, %AM",
398 modified_flags => $status_flags
403 state => "exc_pinned",
404 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
405 ins => [ "base", "index", "mem", "val" ],
406 emit => ". add%M %SB3, %AM",
410 modified_flags => $status_flags
414 state => "exc_pinned",
415 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
416 out => [ "in_r4 in_r5", "flags", "none" ] },
417 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
418 outs => [ "res", "flags", "M" ],
419 emit => '. adc%M %binop',
420 am => "source,binary",
424 modified_flags => $status_flags
429 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
430 ins => [ "left", "right" ],
434 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
435 ins => [ "left", "right", "eflags" ],
439 # we should not rematrialize this node. It produces 2 results and has
440 # very strict constraints
441 state => "exc_pinned",
442 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
443 out => [ "eax", "flags", "none", "edx" ] },
444 ins => [ "base", "index", "mem", "left", "right" ],
445 emit => '. mul%M %unop4',
446 outs => [ "res_low", "flags", "M", "res_high" ],
447 am => "source,binary",
450 modified_flags => $status_flags
454 # we should not rematrialize this node. It produces 2 results and has
455 # very strict constraints
457 cmp_attr => "return 1;",
458 reg_req => { in => [ "none", "none" ],
459 out => [ "none", "none", "none", "none" ] },
460 ins => [ "left", "right" ],
461 outs => [ "res_low", "flags", "M", "res_high" ],
466 state => "exc_pinned",
467 # TODO: adjust out requirements for the 3 operand form
468 # (no need for should_be_same then)
469 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
470 out => [ "in_r4 in_r5", "flags", "none" ] },
471 ins => [ "base", "index", "mem", "left", "right" ],
472 outs => [ "res", "flags", "M" ],
473 am => "source,binary",
477 modified_flags => $status_flags
482 state => "exc_pinned",
483 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
484 out => [ "eax", "flags", "none", "edx" ] },
485 ins => [ "base", "index", "mem", "left", "right" ],
486 emit => '. imul%M %unop4',
487 outs => [ "res_low", "flags", "M", "res_high" ],
488 am => "source,binary",
491 modified_flags => $status_flags
496 cmp_attr => "return 1;",
497 reg_req => { in => [ "none", "none" ],
498 out => [ "none", "none", "none", "none" ] },
499 ins => [ "left", "right" ],
500 outs => [ "res_low", "flags", "M", "res_high" ],
505 state => "exc_pinned",
506 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
507 out => [ "in_r4 in_r5", "flags", "none" ] },
508 ins => [ "base", "index", "mem", "left", "right" ],
509 outs => [ "res", "flags", "M" ],
510 op_modes => "commutative | am | immediate | mode_neutral",
511 am => "source,binary",
512 emit => '. and%M %binop',
516 modified_flags => $status_flags
521 state => "exc_pinned",
522 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
523 ins => [ "base", "index", "mem", "val" ],
524 emit => '. and%M %SI3, %AM',
528 modified_flags => $status_flags
533 state => "exc_pinned",
534 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
535 ins => [ "base", "index", "mem", "val" ],
536 emit => '. and%M %SB3, %AM',
540 modified_flags => $status_flags
545 state => "exc_pinned",
546 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
547 out => [ "in_r4 in_r5", "flags", "none" ] },
548 ins => [ "base", "index", "mem", "left", "right" ],
549 outs => [ "res", "flags", "M" ],
550 am => "source,binary",
551 emit => '. or%M %binop',
555 modified_flags => $status_flags
560 state => "exc_pinned",
561 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
562 ins => [ "base", "index", "mem", "val" ],
563 emit => '. or%M %SI3, %AM',
567 modified_flags => $status_flags
572 state => "exc_pinned",
573 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
574 ins => [ "base", "index", "mem", "val" ],
575 emit => '. or%M %SB3, %AM',
579 modified_flags => $status_flags
584 state => "exc_pinned",
585 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
586 out => [ "in_r4 in_r5", "flags", "none" ] },
587 ins => [ "base", "index", "mem", "left", "right" ],
588 outs => [ "res", "flags", "M" ],
589 am => "source,binary",
590 emit => '. xor%M %binop',
594 modified_flags => $status_flags
600 reg_req => { out => [ "gp", "flags" ] },
601 outs => [ "res", "flags" ],
602 emit => ". xor%M %D0, %D0",
606 modified_flags => $status_flags
611 state => "exc_pinned",
612 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
613 ins => [ "base", "index", "mem", "val" ],
614 emit => '. xor%M %SI3, %AM',
618 modified_flags => $status_flags
623 state => "exc_pinned",
624 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
625 ins => [ "base", "index", "mem", "val" ],
626 emit => '. xor%M %SB3, %AM',
630 modified_flags => $status_flags
633 # not commutative operations
637 state => "exc_pinned",
638 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
639 out => [ "in_r4", "flags", "none" ] },
640 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
641 outs => [ "res", "flags", "M" ],
642 am => "source,binary",
643 emit => '. sub%M %binop',
647 modified_flags => $status_flags
652 state => "exc_pinned",
653 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
654 ins => [ "base", "index", "mem", "subtrahend" ],
655 emit => '. sub%M %SI3, %AM',
659 modified_flags => $status_flags
664 state => "exc_pinned",
665 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
666 ins => [ "base", "index", "mem", "subtrahend" ],
667 emit => '. sub%M %SB3, %AM',
671 modified_flags => $status_flags
675 state => "exc_pinned",
676 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
677 out => [ "in_r4 !in_r5", "flags", "none" ] },
678 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
679 outs => [ "res", "flags", "M" ],
680 am => "source,binary",
681 emit => '. sbb%M %binop',
685 modified_flags => $status_flags
690 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
691 outs => [ "res", "flags" ],
692 emit => ". sbb%M %D0, %D0",
696 modified_flags => $status_flags
700 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
701 ins => [ "minuend", "subtrahend" ],
705 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
706 ins => [ "minuend", "subtrahend", "eflags" ],
711 state => "exc_pinned",
712 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
713 out => [ "eax", "flags", "none", "edx", "none" ] },
714 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
715 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
716 am => "source,unary",
717 emit => ". idiv%M %unop3",
720 modified_flags => $status_flags
725 state => "exc_pinned",
726 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
727 out => [ "eax", "flags", "none", "edx", "none" ] },
728 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
729 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
730 am => "source,unary",
731 emit => ". div%M %unop3",
734 modified_flags => $status_flags
739 reg_req => { in => [ "gp", "ecx" ],
740 out => [ "in_r1 !in_r2", "flags" ] },
741 ins => [ "val", "count" ],
742 outs => [ "res", "flags" ],
743 emit => '. shl%M %SB1, %S0',
747 modified_flags => $status_flags
752 state => "exc_pinned",
753 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
754 ins => [ "base", "index", "mem", "count" ],
755 emit => '. shl%M %SB3, %AM',
759 modified_flags => $status_flags
763 cmp_attr => "return 1;",
764 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
765 ins => [ "val", "count", "dep" ],
770 reg_req => { in => [ "gp", "gp", "ecx" ],
771 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
772 ins => [ "val_high", "val_low", "count" ],
773 outs => [ "res", "flags" ],
774 emit => ". shld%M %SB2, %S1, %D0",
778 modified_flags => $status_flags
782 cmp_attr => "return 1;",
783 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
784 ins => [ "val_high", "val_low", "count" ],
789 reg_req => { in => [ "gp", "ecx" ],
790 out => [ "in_r1 !in_r2", "flags" ] },
791 ins => [ "val", "count" ],
792 outs => [ "res", "flags" ],
793 emit => '. shr%M %SB1, %S0',
797 modified_flags => $status_flags
802 state => "exc_pinned",
803 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
804 ins => [ "base", "index", "mem", "count" ],
805 emit => '. shr%M %SB3, %AM',
809 modified_flags => $status_flags
813 cmp_attr => "return 1;",
814 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
815 ins => [ "val", "count", "dep" ],
820 reg_req => { in => [ "gp", "gp", "ecx" ],
821 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
822 ins => [ "val_high", "val_low", "count" ],
823 outs => [ "res", "flags" ],
824 emit => ". shrd%M %SB2, %S1, %D0",
828 modified_flags => $status_flags
832 cmp_attr => "return 1;",
833 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
834 ins => [ "val_high", "val_low", "count" ],
839 reg_req => { in => [ "gp", "ecx" ],
840 out => [ "in_r1 !in_r2", "flags" ] },
841 ins => [ "val", "count" ],
842 outs => [ "res", "flags" ],
843 emit => '. sar%M %SB1, %S0',
847 modified_flags => $status_flags
852 state => "exc_pinned",
853 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
854 ins => [ "base", "index", "mem", "count" ],
855 emit => '. sar%M %SB3, %AM',
859 modified_flags => $status_flags
863 cmp_attr => "return 1;",
864 ins => [ "val", "count", "dep" ],
865 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
870 reg_req => { in => [ "gp", "ecx" ],
871 out => [ "in_r1 !in_r2", "flags" ] },
872 ins => [ "val", "count" ],
873 outs => [ "res", "flags" ],
874 emit => '. ror%M %SB1, %S0',
878 modified_flags => $status_flags
883 state => "exc_pinned",
884 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
885 ins => [ "base", "index", "mem", "count" ],
886 emit => '. ror%M %SB3, %AM',
890 modified_flags => $status_flags
895 reg_req => { in => [ "gp", "ecx" ],
896 out => [ "in_r1 !in_r2", "flags" ] },
897 ins => [ "val", "count" ],
898 outs => [ "res", "flags" ],
899 emit => '. rol%M %SB1, %S0',
903 modified_flags => $status_flags
908 state => "exc_pinned",
909 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
910 ins => [ "base", "index", "mem", "count" ],
911 emit => '. rol%M %SB3, %AM',
915 modified_flags => $status_flags
922 reg_req => { in => [ "gp" ],
923 out => [ "in_r1", "flags" ] },
924 emit => '. neg%M %S0',
926 outs => [ "res", "flags" ],
930 modified_flags => $status_flags
935 state => "exc_pinned",
936 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
937 ins => [ "base", "index", "mem" ],
938 emit => '. neg%M %AM',
942 modified_flags => $status_flags
947 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
948 outs => [ "low_res", "high_res" ],
951 modified_flags => $status_flags
957 reg_req => { in => [ "gp" ],
958 out => [ "in_r1", "flags" ] },
960 outs => [ "res", "flags" ],
961 emit => '. inc%M %S0',
965 modified_flags => $status_flags_wo_cf
970 state => "exc_pinned",
971 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
972 ins => [ "base", "index", "mem" ],
973 emit => '. inc%M %AM',
977 modified_flags => $status_flags_wo_cf
982 reg_req => { in => [ "gp" ],
983 out => [ "in_r1", "flags" ] },
985 outs => [ "res", "flags" ],
986 emit => '. dec%M %S0',
990 modified_flags => $status_flags_wo_cf
995 state => "exc_pinned",
996 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
997 ins => [ "base", "index", "mem" ],
998 emit => '. dec%M %AM',
1002 modified_flags => $status_flags_wo_cf
1007 reg_req => { in => [ "gp" ],
1008 out => [ "in_r1", "flags" ] },
1010 outs => [ "res", "flags" ],
1011 emit => '. not%M %S0',
1020 state => "exc_pinned",
1021 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1022 ins => [ "base", "index", "mem" ],
1023 emit => '. not%M %AM',
1031 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1035 mode => $mode_flags,
1036 modified_flags => $status_flags
1040 reg_req => { out => [ "flags" ] },
1044 mode => $mode_flags,
1045 modified_flags => $status_flags
1052 state => "exc_pinned",
1053 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1054 out => [ "flags", "none", "none" ] },
1055 ins => [ "base", "index", "mem", "left", "right" ],
1056 outs => [ "eflags", "unused", "M" ],
1057 am => "source,binary",
1058 emit => '. cmp%M %binop',
1059 attr => "int ins_permuted, int cmp_unsigned",
1060 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1061 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1064 mode => $mode_flags,
1065 modified_flags => $status_flags
1070 state => "exc_pinned",
1071 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1072 out => [ "flags", "none", "none" ] },
1073 ins => [ "base", "index", "mem", "left", "right" ],
1074 outs => [ "eflags", "unused", "M" ],
1075 am => "source,binary",
1076 emit => '. cmpb %binop',
1077 attr => "int ins_permuted, int cmp_unsigned",
1078 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1079 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1082 mode => $mode_flags,
1083 modified_flags => $status_flags
1088 state => "exc_pinned",
1089 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
1090 out => [ "flags", "none", "none" ] },
1091 ins => [ "base", "index", "mem", "left", "right" ],
1092 outs => [ "eflags", "unused", "M" ],
1093 am => "source,binary",
1094 emit => '. test%M %binop',
1095 attr => "int ins_permuted, int cmp_unsigned",
1096 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1097 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1100 mode => $mode_flags,
1101 modified_flags => $status_flags
1106 state => "exc_pinned",
1107 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1108 out => [ "flags", "none", "none" ] },
1109 ins => [ "base", "index", "mem", "left", "right" ],
1110 outs => [ "eflags", "unused", "M" ],
1111 am => "source,binary",
1112 emit => '. testb %binop',
1113 attr => "int ins_permuted, int cmp_unsigned",
1114 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1115 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1118 mode => $mode_flags,
1119 modified_flags => $status_flags
1124 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1125 ins => [ "eflags" ],
1126 attr_type => "ia32_condcode_attr_t",
1127 attr => "pn_Cmp pnc, int ins_permuted",
1128 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1129 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1130 emit => '. set%CMP0 %DB0',
1138 state => "exc_pinned",
1139 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1140 ins => [ "base", "index", "mem","eflags" ],
1141 attr_type => "ia32_condcode_attr_t",
1142 attr => "pn_Cmp pnc, int ins_permuted",
1143 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1144 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1145 emit => '. set%CMP3 %AM',
1153 # (note: leave the false,true order intact to make it compatible with other
1155 state => "exc_pinned",
1156 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1157 out => [ "in_r4 in_r5", "flags", "none" ] },
1158 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1159 outs => [ "res", "flags", "M" ],
1160 am => "source,binary",
1161 attr_type => "ia32_condcode_attr_t",
1162 attr => "int ins_permuted, pn_Cmp pnc",
1163 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1171 op_flags => "L|X|Y",
1172 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1173 ins => [ "eflags" ],
1174 outs => [ "false", "true" ],
1175 attr_type => "ia32_condcode_attr_t",
1176 attr => "pn_Cmp pnc",
1178 units => [ "BRANCH" ],
1183 op_flags => "L|X|Y",
1184 reg_req => { in => [ "gp" ],
1187 attr_type => "ia32_condcode_attr_t",
1190 units => [ "BRANCH" ],
1191 modified_flags => $status_flags,
1197 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1198 ins => [ "base", "index", "mem", "target" ],
1199 am => "source,unary",
1200 emit => '. jmp *%unop3',
1202 units => [ "BRANCH" ],
1209 reg_req => { out => [ "gp" ] },
1211 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1212 attr_type => "ia32_immediate_attr_t",
1219 reg_req => { out => [ "gp" ] },
1223 modified_flags => $status_flags,
1229 reg_req => { out => [ "gp_UKNWN:I" ] },
1239 reg_req => { out => [ "vfp_UKNWN:I" ] },
1244 attr_type => "ia32_x87_attr_t",
1250 reg_req => { out => [ "xmm_UKNWN:I" ] },
1259 op_flags => "c|NB|NI",
1260 reg_req => { out => [ "gp_NOREG:I" ] },
1269 op_flags => "c|NB|NI",
1270 reg_req => { out => [ "vfp_NOREG:I" ] },
1275 attr_type => "ia32_x87_attr_t",
1280 op_flags => "c|NB|NI",
1281 reg_req => { out => [ "xmm_NOREG:I" ] },
1291 reg_req => { out => [ "fpcw:I" ] },
1295 modified_flags => $fpcw_flags
1301 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1302 ins => [ "base", "index", "mem" ],
1304 emit => ". fldcw %AM",
1307 modified_flags => $fpcw_flags
1313 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1314 ins => [ "base", "index", "mem", "fpcw" ],
1316 emit => ". fnstcw %AM",
1324 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1332 # we should not rematrialize this node. It has very strict constraints.
1333 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1334 ins => [ "val", "clobbered" ],
1343 # Note that we add additional latency values depending on address mode, so a
1344 # lateny of 0 for load is correct
1348 state => "exc_pinned",
1349 reg_req => { in => [ "gp", "gp", "none" ],
1350 out => [ "gp", "none", "none", "none" ] },
1351 ins => [ "base", "index", "mem" ],
1352 outs => [ "res", "unused", "M", "X_exc" ],
1354 emit => ". mov%EX%.l %AM, %D0",
1360 state => "exc_pinned",
1361 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1362 ins => [ "base", "index", "mem", "val" ],
1363 outs => [ "M", "X_exc" ],
1364 emit => '. mov%M %SI3, %AM',
1372 state => "exc_pinned",
1373 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1374 ins => [ "base", "index", "mem", "val" ],
1375 outs => [ "M", "X_exc" ],
1376 emit => '. mov%M %SB3, %AM',
1384 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1385 ins => [ "base", "index" ],
1386 emit => '. leal %AM, %D0',
1390 # lea doesn't modify the flags, but setting this seems advantageous since it
1391 # increases chances that the Lea is transformed back to an Add
1392 modified_flags => 1,
1396 state => "exc_pinned",
1397 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1398 ins => [ "base", "index", "mem", "val", "stack" ],
1399 emit => '. push%M %unop3',
1400 outs => [ "stack", "M" ],
1401 am => "source,unary",
1407 state => "exc_pinned",
1408 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1409 ins => [ "mem", "stack" ],
1410 outs => [ "res", "M", "unused", "stack" ],
1411 emit => '. pop%M %D0',
1412 latency => 3, # Pop is more expensive than Push on Athlon
1417 state => "exc_pinned",
1418 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1419 ins => [ "mem", "stack" ],
1420 outs => [ "res", "M", "unused", "stack" ],
1421 emit => '. pop%M %D0',
1422 latency => 3, # Pop is more expensive than Push on Athlon
1427 state => "exc_pinned",
1428 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1429 ins => [ "base", "index", "mem", "stack" ],
1430 outs => [ "unused0", "M", "unused1", "stack" ],
1431 emit => '. pop%M %AM',
1432 latency => 3, # Pop is more expensive than Push on Athlon
1437 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1439 outs => [ "frame", "stack", "M" ],
1445 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1447 outs => [ "frame", "stack" ],
1454 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1455 ins => [ "base", "index", "mem", "stack", "size" ],
1456 am => "source,binary",
1457 emit => '. addl %binop',
1459 outs => [ "stack", "M" ],
1461 modified_flags => $status_flags
1466 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1467 ins => [ "base", "index", "mem", "stack", "size" ],
1468 am => "source,binary",
1469 emit => ". subl %binop\n".
1470 ". movl %%esp, %D1",
1472 outs => [ "stack", "addr", "M" ],
1474 modified_flags => $status_flags
1487 reg_req => { out => [ "gp" ] },
1493 # BT supports source address mode, but this is unused yet
1497 state => "exc_pinned",
1498 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1499 ins => [ "left", "right" ],
1500 emit => '. bt%M %S1, %S0',
1503 mode => $mode_flags,
1504 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1509 state => "exc_pinned",
1510 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1511 out => [ "gp", "flags", "none" ] },
1512 ins => [ "base", "index", "mem", "operand" ],
1513 outs => [ "res", "flags", "M" ],
1514 am => "source,binary",
1515 emit => '. bsf%M %unop3, %D0',
1519 modified_flags => $status_flags
1524 state => "exc_pinned",
1525 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1526 out => [ "gp", "flags", "none" ] },
1527 ins => [ "base", "index", "mem", "operand" ],
1528 outs => [ "res", "flags", "M" ],
1529 am => "source,binary",
1530 emit => '. bsr%M %unop3, %D0',
1534 modified_flags => $status_flags
1538 # SSE4.2 or SSE4a popcnt instruction
1542 state => "exc_pinned",
1543 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1544 out => [ "gp", "flags", "none" ] },
1545 ins => [ "base", "index", "mem", "operand" ],
1546 outs => [ "res", "flags", "M" ],
1547 am => "source,binary",
1548 emit => '. popcnt%M %unop3, %D0',
1552 modified_flags => $status_flags
1556 state => "exc_pinned",
1558 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1559 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" ]
1561 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1562 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1563 attr_type => "ia32_call_attr_t",
1564 attr => "unsigned pop, ir_type *call_tp",
1565 am => "source,unary",
1566 units => [ "BRANCH" ],
1567 latency => 4, # random number
1568 modified_flags => $status_flags
1572 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1574 # PS: try gcc __builtin_frame_address(100000) :-)
1577 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1578 ins => [ "frame", "cnt", "tmp" ],
1580 latency => 4, # random number
1581 attr_type => "ia32_climbframe_attr_t",
1582 attr => "unsigned count",
1592 reg_req => { in => [ "gp" ],
1593 out => [ "in_r1" ] },
1594 emit => '. bswap%M %S0',
1602 # bswap16, use xchg here
1606 reg_req => { in => [ "eax ebx ecx edx" ],
1607 out => [ "in_r1" ] },
1608 emit => '. xchg %SB0, %SH0',
1620 reg_req => { in => [ "none" ], out => [ "none" ] },
1629 # Undefined Instruction on ALL x86 CPU's
1633 reg_req => { in => [ "none" ], out => [ "none" ] },
1636 emit => ". .value 0x0b0f",
1647 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1648 ins => [ "port", "value", "mem" ],
1649 emit => '. out%M %SS0, %SI1',
1653 modified_flags => $status_flags
1662 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1663 ins => [ "port", "mem" ],
1664 outs => [ "res", "M" ],
1665 emit => '. in%M %DS0, %SS0',
1669 modified_flags => $status_flags
1673 # Intel style prefetching
1677 state => "exc_pinned",
1678 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1679 ins => [ "base", "index", "mem" ],
1682 emit => ". prefetcht0 %AM",
1688 state => "exc_pinned",
1689 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1690 ins => [ "base", "index", "mem" ],
1693 emit => ". prefetcht1 %AM",
1699 state => "exc_pinned",
1700 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1701 ins => [ "base", "index", "mem" ],
1704 emit => ". prefetcht2 %AM",
1710 state => "exc_pinned",
1711 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1712 ins => [ "base", "index", "mem" ],
1715 emit => ". prefetchnta %AM",
1720 # 3DNow! prefetch instructions
1724 state => "exc_pinned",
1725 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1726 ins => [ "base", "index", "mem" ],
1729 emit => ". prefetch %AM",
1735 state => "exc_pinned",
1736 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1737 ins => [ "base", "index", "mem" ],
1740 emit => ". prefetchw %AM",
1744 #-----------------------------------------------------------------------------#
1745 # _____ _____ ______ __ _ _ _ #
1746 # / ____/ ____| ____| / _| | | | | | #
1747 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1748 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1749 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1750 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1751 #-----------------------------------------------------------------------------#
1756 reg_req => { out => [ "xmm" ] },
1757 emit => '. xorp%XSD %D0, %D0',
1765 reg_req => { out => [ "xmm" ] },
1766 emit => '. pxor %D0, %D0',
1772 # produces all 1 bits
1775 reg_req => { out => [ "xmm" ] },
1776 emit => '. pcmpeqb %D0, %D0',
1782 # integer shift left, dword
1785 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1786 emit => '. pslld %SI1, %D0',
1792 # integer shift left, qword
1795 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1796 emit => '. psllq %SI1, %D0',
1802 # integer shift right, dword
1805 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1806 emit => '. psrld %SI1, %D0',
1812 # mov from integer to SSE register
1815 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1816 emit => '. movd %S0, %D0',
1822 # commutative operations
1826 state => "exc_pinned",
1827 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1828 out => [ "in_r4 in_r5", "flags", "none" ] },
1829 ins => [ "base", "index", "mem", "left", "right" ],
1830 outs => [ "res", "flags", "M" ],
1831 am => "source,binary",
1832 emit => '. add%XXM %binop',
1840 state => "exc_pinned",
1841 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1842 out => [ "in_r4 in_r5", "flags", "none" ] },
1843 ins => [ "base", "index", "mem", "left", "right" ],
1844 outs => [ "res", "flags", "M" ],
1845 am => "source,binary",
1846 emit => '. mul%XXM %binop',
1854 state => "exc_pinned",
1855 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1856 out => [ "in_r4 in_r5", "flags", "none" ] },
1857 ins => [ "base", "index", "mem", "left", "right" ],
1858 outs => [ "res", "flags", "M" ],
1859 am => "source,binary",
1860 emit => '. max%XXM %binop',
1868 state => "exc_pinned",
1869 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1870 out => [ "in_r4 in_r5", "flags", "none" ] },
1871 ins => [ "base", "index", "mem", "left", "right" ],
1872 outs => [ "res", "flags", "M" ],
1873 am => "source,binary",
1874 emit => '. min%XXM %binop',
1882 state => "exc_pinned",
1883 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1884 out => [ "in_r4 in_r5", "flags", "none" ] },
1885 ins => [ "base", "index", "mem", "left", "right" ],
1886 outs => [ "res", "flags", "M" ],
1887 am => "source,binary",
1888 emit => '. andp%XSD %binop',
1896 state => "exc_pinned",
1897 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1898 out => [ "in_r4 in_r5", "flags", "none" ] },
1899 ins => [ "base", "index", "mem", "left", "right" ],
1900 outs => [ "res", "flags", "M" ],
1901 am => "source,binary",
1902 emit => '. orp%XSD %binop',
1910 state => "exc_pinned",
1911 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1912 out => [ "in_r4 in_r5", "flags", "none" ] },
1913 ins => [ "base", "index", "mem", "left", "right" ],
1914 outs => [ "res", "flags", "M" ],
1915 am => "source,binary",
1916 emit => '. xorp%XSD %binop',
1922 # not commutative operations
1926 state => "exc_pinned",
1927 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1928 out => [ "in_r4 !in_r5", "flags", "none" ] },
1929 ins => [ "base", "index", "mem", "left", "right" ],
1930 outs => [ "res", "flags", "M" ],
1931 am => "source,binary",
1932 emit => '. andnp%XSD %binop',
1940 state => "exc_pinned",
1941 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1942 out => [ "in_r4", "flags", "none" ] },
1943 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1944 outs => [ "res", "flags", "M" ],
1945 am => "source,binary",
1946 emit => '. sub%XXM %binop',
1954 state => "exc_pinned",
1955 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1956 out => [ "in_r4 !in_r5", "flags", "none" ] },
1957 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1958 outs => [ "res", "flags", "M" ],
1959 am => "source,binary",
1960 emit => '. div%XXM %binop',
1969 state => "exc_pinned",
1970 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1971 out => [ "eflags" ] },
1972 ins => [ "base", "index", "mem", "left", "right" ],
1973 outs => [ "flags" ],
1974 am => "source,binary",
1975 attr => "int ins_permuted",
1976 init_attr => "attr->data.ins_permuted = ins_permuted;",
1977 emit => ' .ucomi%XXM %binop',
1980 mode => $mode_flags,
1981 modified_flags => 1,
1988 state => "exc_pinned",
1989 reg_req => { in => [ "gp", "gp", "none" ],
1990 out => [ "xmm", "none", "none", "none" ] },
1991 ins => [ "base", "index", "mem" ],
1992 outs => [ "res", "unused", "M", "X_exc" ],
1993 emit => '. mov%XXM %AM, %D0',
1994 attr => "ir_mode *load_mode",
1995 init_attr => "attr->ls_mode = load_mode;",
2002 state => "exc_pinned",
2003 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
2004 ins => [ "base", "index", "mem", "val" ],
2005 outs => [ "M", "X_exc" ],
2006 emit => '. mov%XXM %S3, %AM',
2014 state => "exc_pinned",
2015 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none" ] },
2016 ins => [ "base", "index", "mem", "val" ],
2018 emit => '. mov%XXM %S3, %AM',
2026 state => "exc_pinned",
2027 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2028 ins => [ "base", "index", "mem", "val" ],
2029 am => "source,unary",
2030 emit => '. cvtsi2ss %unop3, %D0',
2038 state => "exc_pinned",
2039 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2040 ins => [ "base", "index", "mem", "val" ],
2041 am => "source,unary",
2042 emit => '. cvtsi2sd %unop3, %D0',
2051 cmp_attr => "return 1;",
2052 ins => [ "val_high", "val_low" ],
2053 reg_req => { in => [ "none", "none" ], out => [ "none" ] }
2058 cmp_attr => "return 1;",
2060 outs => [ "res_high", "res_low" ],
2061 reg_req => { in => [ "none" ], out => [ "none", "none" ] }
2069 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2070 outs => [ "DST", "SRC", "CNT", "M" ],
2071 attr_type => "ia32_copyb_attr_t",
2072 attr => "unsigned size",
2075 # we don't care about this flag, so no need to mark this node
2076 # modified_flags => [ "DF" ]
2082 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2083 outs => [ "DST", "SRC", "M" ],
2084 attr_type => "ia32_copyb_attr_t",
2085 attr => "unsigned size",
2088 # we don't care about this flag, so no need to mark this node
2089 # modified_flags => [ "DF" ]
2095 state => "exc_pinned",
2096 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2106 state => "exc_pinned",
2107 reg_req => { in => [ "gp", "gp", "none", "gp" ],
2108 out => [ "gp", "none", "none" ] },
2109 ins => [ "base", "index", "mem", "val" ],
2110 outs => [ "res", "flags", "M" ],
2111 am => "source,unary",
2114 attr => "ir_mode *smaller_mode",
2115 init_attr => "attr->ls_mode = smaller_mode;",
2120 state => "exc_pinned",
2121 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2122 out => [ "gp", "none", "none" ] },
2123 ins => [ "base", "index", "mem", "val" ],
2124 outs => [ "res", "flags", "M" ],
2125 am => "source,unary",
2128 attr => "ir_mode *smaller_mode",
2129 init_attr => "attr->ls_mode = smaller_mode;",
2134 state => "exc_pinned",
2135 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2136 ins => [ "base", "index", "mem", "val" ],
2137 am => "source,unary",
2144 state => "exc_pinned",
2145 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2146 ins => [ "base", "index", "mem", "val" ],
2147 am => "source,unary",
2154 state => "exc_pinned",
2155 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2156 ins => [ "base", "index", "mem", "val" ],
2157 am => "source,unary",
2163 #----------------------------------------------------------#
2165 # (_) | | | | / _| | | | #
2166 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
2167 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
2168 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
2169 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
2171 # _ __ ___ __| | ___ ___ #
2172 # | '_ \ / _ \ / _` |/ _ \/ __| #
2173 # | | | | (_) | (_| | __/\__ \ #
2174 # |_| |_|\___/ \__,_|\___||___/ #
2175 #----------------------------------------------------------#
2177 # rematerialisation disabled for all float nodes for now, because the fpcw
2178 # handler runs before spilling and we might end up with wrong fpcw then
2182 state => "exc_pinned",
2183 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2184 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2185 am => "source,binary",
2189 attr_type => "ia32_x87_attr_t",
2194 state => "exc_pinned",
2195 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2196 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2197 am => "source,binary",
2201 attr_type => "ia32_x87_attr_t",
2206 state => "exc_pinned",
2207 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2208 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2209 am => "source,binary",
2213 attr_type => "ia32_x87_attr_t",
2217 state => "exc_pinned",
2218 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
2219 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2220 am => "source,binary",
2221 outs => [ "res", "M" ],
2224 attr_type => "ia32_x87_attr_t",
2228 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2229 ins => [ "left", "right", "fpcw" ],
2233 attr_type => "ia32_x87_attr_t",
2238 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2243 attr_type => "ia32_x87_attr_t",
2248 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2253 attr_type => "ia32_x87_attr_t",
2256 # virtual Load and Store
2261 state => "exc_pinned",
2262 reg_req => { in => [ "gp", "gp", "none" ],
2263 out => [ "vfp", "none", "none", "none" ] },
2264 ins => [ "base", "index", "mem" ],
2265 outs => [ "res", "unused", "M", "X_exc" ],
2266 attr => "ir_mode *load_mode",
2267 init_attr => "attr->attr.ls_mode = load_mode;",
2270 attr_type => "ia32_x87_attr_t",
2276 state => "exc_pinned",
2277 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2278 out => [ "none", "none" ] },
2279 ins => [ "base", "index", "mem", "val" ],
2280 outs => [ "M", "X_exc" ],
2281 attr => "ir_mode *store_mode",
2282 init_attr => "attr->attr.ls_mode = store_mode;",
2286 attr_type => "ia32_x87_attr_t",
2292 state => "exc_pinned",
2293 reg_req => { in => [ "gp", "gp", "none" ],
2294 out => [ "vfp", "none", "none" ] },
2295 outs => [ "res", "unused", "M" ],
2296 ins => [ "base", "index", "mem" ],
2299 attr_type => "ia32_x87_attr_t",
2303 state => "exc_pinned",
2304 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ], out => [ "none" ] },
2305 ins => [ "base", "index", "mem", "val", "fpcw" ],
2310 attr_type => "ia32_x87_attr_t",
2313 # SSE3 fisttp instruction
2315 state => "exc_pinned",
2316 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2317 ins => [ "base", "index", "mem", "val" ],
2318 outs => [ "res", "M" ],
2321 attr_type => "ia32_x87_attr_t",
2329 reg_req => { out => [ "vfp" ] },
2334 attr_type => "ia32_x87_attr_t",
2339 reg_req => { out => [ "vfp" ] },
2344 attr_type => "ia32_x87_attr_t",
2349 reg_req => { out => [ "vfp" ] },
2354 attr_type => "ia32_x87_attr_t",
2359 reg_req => { out => [ "vfp" ] },
2364 attr_type => "ia32_x87_attr_t",
2369 reg_req => { out => [ "vfp" ] },
2374 attr_type => "ia32_x87_attr_t",
2379 reg_req => { out => [ "vfp" ] },
2384 attr_type => "ia32_x87_attr_t",
2389 reg_req => { out => [ "vfp" ] },
2394 attr_type => "ia32_x87_attr_t",
2400 # we can't allow to rematerialize this node so we don't have
2401 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2403 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2404 ins => [ "left", "right" ],
2405 outs => [ "flags" ],
2406 attr => "int ins_permuted",
2407 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2410 attr_type => "ia32_x87_attr_t",
2416 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2417 ins => [ "left", "right" ],
2418 outs => [ "flags" ],
2419 attr => "int ins_permuted",
2420 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2423 attr_type => "ia32_x87_attr_t",
2429 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2431 outs => [ "flags" ],
2432 attr => "int ins_permuted",
2433 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2436 attr_type => "ia32_x87_attr_t",
2442 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2444 outs => [ "flags" ],
2448 mode => $mode_flags,
2451 #------------------------------------------------------------------------#
2452 # ___ _____ __ _ _ _ #
2453 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2454 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2455 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2456 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2457 #------------------------------------------------------------------------#
2459 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2460 # are swapped, we work this around in the emitter...
2463 state => "exc_pinned",
2464 rd_constructor => "NONE",
2466 emit => '. fadd%XM %x87_binop',
2468 attr_type => "ia32_x87_attr_t",
2472 state => "exc_pinned",
2473 rd_constructor => "NONE",
2475 emit => '. faddp%XM %x87_binop',
2477 attr_type => "ia32_x87_attr_t",
2481 state => "exc_pinned",
2482 rd_constructor => "NONE",
2484 emit => '. fmul%XM %x87_binop',
2486 attr_type => "ia32_x87_attr_t",
2490 state => "exc_pinned",
2491 rd_constructor => "NONE",
2493 emit => '. fmulp%XM %x87_binop',,
2495 attr_type => "ia32_x87_attr_t",
2499 state => "exc_pinned",
2500 rd_constructor => "NONE",
2502 emit => '. fsub%XM %x87_binop',
2504 attr_type => "ia32_x87_attr_t",
2508 state => "exc_pinned",
2509 rd_constructor => "NONE",
2511 # see note about gas bugs
2512 emit => '. fsubrp%XM %x87_binop',
2514 attr_type => "ia32_x87_attr_t",
2518 state => "exc_pinned",
2519 rd_constructor => "NONE",
2522 emit => '. fsubr%XM %x87_binop',
2524 attr_type => "ia32_x87_attr_t",
2528 state => "exc_pinned",
2529 rd_constructor => "NONE",
2532 # see note about gas bugs
2533 emit => '. fsubp%XM %x87_binop',
2535 attr_type => "ia32_x87_attr_t",
2539 rd_constructor => "NONE",
2543 attr_type => "ia32_x87_attr_t",
2546 # this node is just here, to keep the simulator running
2547 # we can omit this when a fprem simulation function exists
2549 rd_constructor => "NONE",
2551 emit => '. fprem1\n'.
2554 attr_type => "ia32_x87_attr_t",
2558 state => "exc_pinned",
2559 rd_constructor => "NONE",
2561 emit => '. fdiv%XM %x87_binop',
2563 attr_type => "ia32_x87_attr_t",
2567 state => "exc_pinned",
2568 rd_constructor => "NONE",
2570 # see note about gas bugs
2571 emit => '. fdivrp%XM %x87_binop',
2573 attr_type => "ia32_x87_attr_t",
2577 state => "exc_pinned",
2578 rd_constructor => "NONE",
2580 emit => '. fdivr%XM %x87_binop',
2582 attr_type => "ia32_x87_attr_t",
2586 state => "exc_pinned",
2587 rd_constructor => "NONE",
2589 # see note about gas bugs
2590 emit => '. fdivp%XM %x87_binop',
2592 attr_type => "ia32_x87_attr_t",
2596 rd_constructor => "NONE",
2600 attr_type => "ia32_x87_attr_t",
2605 rd_constructor => "NONE",
2609 attr_type => "ia32_x87_attr_t",
2612 # x87 Load and Store
2615 rd_constructor => "NONE",
2616 op_flags => "R|L|F",
2617 state => "exc_pinned",
2619 emit => '. fld%XM %AM',
2620 attr_type => "ia32_x87_attr_t",
2625 rd_constructor => "NONE",
2626 op_flags => "R|L|F",
2627 state => "exc_pinned",
2629 emit => '. fst%XM %AM',
2631 attr_type => "ia32_x87_attr_t",
2636 rd_constructor => "NONE",
2637 op_flags => "R|L|F",
2638 state => "exc_pinned",
2640 emit => '. fstp%XM %AM',
2642 attr_type => "ia32_x87_attr_t",
2649 state => "exc_pinned",
2650 rd_constructor => "NONE",
2652 emit => '. fild%XM %AM',
2653 attr_type => "ia32_x87_attr_t",
2658 state => "exc_pinned",
2659 rd_constructor => "NONE",
2661 emit => '. fist%XM %AM',
2663 attr_type => "ia32_x87_attr_t",
2668 state => "exc_pinned",
2669 rd_constructor => "NONE",
2671 emit => '. fistp%XM %AM',
2673 attr_type => "ia32_x87_attr_t",
2677 # SSE3 fisttp instruction
2679 state => "exc_pinned",
2680 rd_constructor => "NONE",
2682 emit => '. fisttp%XM %AM',
2684 attr_type => "ia32_x87_attr_t",
2691 op_flags => "R|c|K",
2693 reg_req => { out => [ "vfp" ] },
2695 attr_type => "ia32_x87_attr_t",
2700 op_flags => "R|c|K",
2702 reg_req => { out => [ "vfp" ] },
2704 attr_type => "ia32_x87_attr_t",
2709 op_flags => "R|c|K",
2711 reg_req => { out => [ "vfp" ] },
2713 attr_type => "ia32_x87_attr_t",
2718 op_flags => "R|c|K",
2720 reg_req => { out => [ "vfp" ] },
2722 attr_type => "ia32_x87_attr_t",
2727 op_flags => "R|c|K",
2729 reg_req => { out => [ "vfp" ] },
2731 attr_type => "ia32_x87_attr_t",
2736 op_flags => "R|c|K",
2738 reg_req => { out => [ "vfp" ] },
2739 emit => '. fldll2t',
2740 attr_type => "ia32_x87_attr_t",
2745 op_flags => "R|c|K",
2747 reg_req => { out => [ "vfp" ] },
2749 attr_type => "ia32_x87_attr_t",
2754 # Note that it is NEVER allowed to do CSE on these nodes
2755 # Moreover, note the virtual register requierements!
2759 reg_req => { out => [ "none" ] },
2760 cmp_attr => "return 1;",
2761 emit => '. fxch %X0',
2762 attr_type => "ia32_x87_attr_t",
2769 reg_req => { out => [ "none" ] },
2770 cmp_attr => "return 1;",
2771 emit => '. fld %X0',
2772 attr_type => "ia32_x87_attr_t",
2778 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2779 cmp_attr => "return 1;",
2780 emit => '. fld %X0',
2781 attr_type => "ia32_x87_attr_t",
2787 reg_req => { out => [ "none" ] },
2788 cmp_attr => "return 1;",
2789 emit => '. fstp %X0',
2790 attr_type => "ia32_x87_attr_t",
2797 reg_req => { out => [ "none" ] },
2798 cmp_attr => "return 1;",
2799 emit => '. ffreep %X0',
2800 attr_type => "ia32_x87_attr_t",
2807 reg_req => { out => [ "none" ] },
2808 cmp_attr => "return 1;",
2810 attr_type => "ia32_x87_attr_t",
2817 reg_req => { out => [ "none" ] },
2818 cmp_attr => "return 1;",
2820 attr_type => "ia32_x87_attr_t",
2829 emit => ". fucom %X1\n".
2831 attr_type => "ia32_x87_attr_t",
2837 emit => ". fucomp %X1\n".
2839 attr_type => "ia32_x87_attr_t",
2845 emit => ". fucompp\n".
2847 attr_type => "ia32_x87_attr_t",
2853 emit => '. fucomi %X1',
2854 attr_type => "ia32_x87_attr_t",
2860 emit => '. fucompi %X1',
2861 attr_type => "ia32_x87_attr_t",
2869 attr_type => "ia32_x87_attr_t",
2874 # -------------------------------------------------------------------------------- #
2875 # ____ ____ _____ _ _ #
2876 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2877 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2878 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2879 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2881 # -------------------------------------------------------------------------------- #
2884 # Spilling and reloading of SSE registers, hardcoded, not generated #
2888 state => "exc_pinned",
2889 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2890 emit => '. movdqu %D0, %AM',
2891 outs => [ "res", "M" ],
2898 state => "exc_pinned",
2899 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2900 ins => [ "base", "index", "mem", "val" ],
2901 emit => '. movdqu %binop',
2909 # Include the generated SIMD node specification written by the SIMD optimization
2910 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2911 unless ($return = do $my_script_name) {
2912 warn "couldn't parse $my_script_name: $@" if $@;
2913 warn "couldn't do $my_script_name: $!" unless defined $return;
2914 warn "couldn't run $my_script_name" unless $return;
2917 # Transform some attributes
2918 foreach my $op (keys(%nodes)) {
2919 my $node = $nodes{$op};
2920 my $op_attr_init = $node->{op_attr_init};
2922 if(defined($op_attr_init)) {
2923 $op_attr_init .= "\n\t";
2928 if(!defined($node->{latency})) {
2930 $node->{latency} = 0;
2932 die("Latency missing for op $op");
2935 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2937 $node->{op_attr_init} = $op_attr_init;