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 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, out_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, out_reqs, exec_units, n_res);",
282 "\tinit_ia32_attributes(res, flags, in_reqs, out_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, out_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_condcode_attributes(res, pnc);",
288 "\tinit_ia32_attributes(res, flags, in_reqs, out_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, out_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_x87_attributes(res);",
296 ia32_climbframe_attr_t =>
297 "\tinit_ia32_attributes(res, flags, in_reqs, out_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, 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", "edx", "none" ] },
444 ins => [ "base", "index", "mem", "left", "right" ],
445 emit => '. mul%M %unop4',
446 outs => [ "res_low", "flags", "res_high", "M" ],
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 outs => [ "EAX", "flags", "EDX", "M" ],
464 state => "exc_pinned",
465 # TODO: adjust out requirements for the 3 operand form
466 # (no need for should_be_same then)
467 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
468 out => [ "in_r4 in_r5", "flags", "none" ] },
469 ins => [ "base", "index", "mem", "left", "right" ],
470 outs => [ "res", "flags", "M" ],
471 am => "source,binary",
475 modified_flags => $status_flags
480 state => "exc_pinned",
481 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
482 out => [ "eax", "flags", "edx", "none" ] },
483 ins => [ "base", "index", "mem", "left", "right" ],
484 emit => '. imul%M %unop4',
485 outs => [ "res_low", "flags", "res_high", "M" ],
486 am => "source,binary",
489 modified_flags => $status_flags
494 cmp_attr => "return 1;",
495 outs => [ "res_low", "res_high", "M" ],
501 state => "exc_pinned",
502 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
503 out => [ "in_r4 in_r5", "flags", "none" ] },
504 ins => [ "base", "index", "mem", "left", "right" ],
505 outs => [ "res", "flags", "M" ],
506 op_modes => "commutative | am | immediate | mode_neutral",
507 am => "source,binary",
508 emit => '. and%M %binop',
512 modified_flags => $status_flags
517 state => "exc_pinned",
518 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
519 ins => [ "base", "index", "mem", "val" ],
520 emit => '. and%M %SI3, %AM',
524 modified_flags => $status_flags
529 state => "exc_pinned",
530 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
531 ins => [ "base", "index", "mem", "val" ],
532 emit => '. and%M %SB3, %AM',
536 modified_flags => $status_flags
541 state => "exc_pinned",
542 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
543 out => [ "in_r4 in_r5", "flags", "none" ] },
544 ins => [ "base", "index", "mem", "left", "right" ],
545 outs => [ "res", "flags", "M" ],
546 am => "source,binary",
547 emit => '. or%M %binop',
551 modified_flags => $status_flags
556 state => "exc_pinned",
557 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
558 ins => [ "base", "index", "mem", "val" ],
559 emit => '. or%M %SI3, %AM',
563 modified_flags => $status_flags
568 state => "exc_pinned",
569 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
570 ins => [ "base", "index", "mem", "val" ],
571 emit => '. or%M %SB3, %AM',
575 modified_flags => $status_flags
580 state => "exc_pinned",
581 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
582 out => [ "in_r4 in_r5", "flags", "none" ] },
583 ins => [ "base", "index", "mem", "left", "right" ],
584 outs => [ "res", "flags", "M" ],
585 am => "source,binary",
586 emit => '. xor%M %binop',
590 modified_flags => $status_flags
596 reg_req => { out => [ "gp", "flags" ] },
597 outs => [ "res", "flags" ],
598 emit => ". xor%M %D0, %D0",
602 modified_flags => $status_flags
607 state => "exc_pinned",
608 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
609 ins => [ "base", "index", "mem", "val" ],
610 emit => '. xor%M %SI3, %AM',
614 modified_flags => $status_flags
619 state => "exc_pinned",
620 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
621 ins => [ "base", "index", "mem", "val" ],
622 emit => '. xor%M %SB3, %AM',
626 modified_flags => $status_flags
629 # not commutative operations
633 state => "exc_pinned",
634 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
635 out => [ "in_r4", "flags", "none" ] },
636 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
637 outs => [ "res", "flags", "M" ],
638 am => "source,binary",
639 emit => '. sub%M %binop',
643 modified_flags => $status_flags
648 state => "exc_pinned",
649 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
650 ins => [ "base", "index", "mem", "subtrahend" ],
651 emit => '. sub%M %SI3, %AM',
655 modified_flags => $status_flags
660 state => "exc_pinned",
661 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
662 ins => [ "base", "index", "mem", "subtrahend" ],
663 emit => '. sub%M %SB3, %AM',
667 modified_flags => $status_flags
671 state => "exc_pinned",
672 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
673 out => [ "in_r4 !in_r5", "flags", "none" ] },
674 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
675 outs => [ "res", "flags", "M" ],
676 am => "source,binary",
677 emit => '. sbb%M %binop',
681 modified_flags => $status_flags
686 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
687 outs => [ "res", "flags" ],
688 emit => ". sbb%M %D0, %D0",
692 modified_flags => $status_flags
696 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
697 ins => [ "minuend", "subtrahend" ],
701 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
702 ins => [ "minuend", "subtrahend", "eflags" ],
707 state => "exc_pinned",
708 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
709 out => [ "eax", "flags", "none", "edx", "none" ] },
710 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
711 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
712 am => "source,unary",
713 emit => ". idiv%M %unop3",
716 modified_flags => $status_flags
721 state => "exc_pinned",
722 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
723 out => [ "eax", "flags", "none", "edx", "none" ] },
724 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
725 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
726 am => "source,unary",
727 emit => ". div%M %unop3",
730 modified_flags => $status_flags
735 reg_req => { in => [ "gp", "ecx" ],
736 out => [ "in_r1 !in_r2", "flags" ] },
737 ins => [ "val", "count" ],
738 outs => [ "res", "flags" ],
739 emit => '. shl%M %SB1, %S0',
743 modified_flags => $status_flags
748 state => "exc_pinned",
749 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
750 ins => [ "base", "index", "mem", "count" ],
751 emit => '. shl%M %SB3, %AM',
755 modified_flags => $status_flags
759 cmp_attr => "return 1;",
760 ins => [ "val", "count", "dep" ],
766 reg_req => { in => [ "gp", "gp", "ecx" ],
767 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
768 ins => [ "val_high", "val_low", "count" ],
769 outs => [ "res", "flags" ],
770 emit => ". shld%M %SB2, %S1, %D0",
774 modified_flags => $status_flags
778 cmp_attr => "return 1;",
779 ins => [ "val_high", "val_low", "count" ],
785 reg_req => { in => [ "gp", "ecx" ],
786 out => [ "in_r1 !in_r2", "flags" ] },
787 ins => [ "val", "count" ],
788 outs => [ "res", "flags" ],
789 emit => '. shr%M %SB1, %S0',
793 modified_flags => $status_flags
798 state => "exc_pinned",
799 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
800 ins => [ "base", "index", "mem", "count" ],
801 emit => '. shr%M %SB3, %AM',
805 modified_flags => $status_flags
809 cmp_attr => "return 1;",
810 ins => [ "val", "count", "dep" ],
816 reg_req => { in => [ "gp", "gp", "ecx" ],
817 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
818 ins => [ "val_high", "val_low", "count" ],
819 outs => [ "res", "flags" ],
820 emit => ". shrd%M %SB2, %S1, %D0",
824 modified_flags => $status_flags
828 cmp_attr => "return 1;",
830 ins => [ "val_high", "val_low", "count" ],
835 reg_req => { in => [ "gp", "ecx" ],
836 out => [ "in_r1 !in_r2", "flags" ] },
837 ins => [ "val", "count" ],
838 outs => [ "res", "flags" ],
839 emit => '. sar%M %SB1, %S0',
843 modified_flags => $status_flags
848 state => "exc_pinned",
849 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
850 ins => [ "base", "index", "mem", "count" ],
851 emit => '. sar%M %SB3, %AM',
855 modified_flags => $status_flags
859 cmp_attr => "return 1;",
860 ins => [ "val", "count", "dep" ],
866 reg_req => { in => [ "gp", "ecx" ],
867 out => [ "in_r1 !in_r2", "flags" ] },
868 ins => [ "val", "count" ],
869 outs => [ "res", "flags" ],
870 emit => '. ror%M %SB1, %S0',
874 modified_flags => $status_flags
879 state => "exc_pinned",
880 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
881 ins => [ "base", "index", "mem", "count" ],
882 emit => '. ror%M %SB3, %AM',
886 modified_flags => $status_flags
891 reg_req => { in => [ "gp", "ecx" ],
892 out => [ "in_r1 !in_r2", "flags" ] },
893 ins => [ "val", "count" ],
894 outs => [ "res", "flags" ],
895 emit => '. rol%M %SB1, %S0',
899 modified_flags => $status_flags
904 state => "exc_pinned",
905 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
906 ins => [ "base", "index", "mem", "count" ],
907 emit => '. rol%M %SB3, %AM',
911 modified_flags => $status_flags
918 reg_req => { in => [ "gp" ],
919 out => [ "in_r1", "flags" ] },
920 emit => '. neg%M %S0',
922 outs => [ "res", "flags" ],
926 modified_flags => $status_flags
931 state => "exc_pinned",
932 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
933 ins => [ "base", "index", "mem" ],
934 emit => '. neg%M %AM',
938 modified_flags => $status_flags
943 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
944 outs => [ "low_res", "high_res" ],
947 modified_flags => $status_flags
953 reg_req => { in => [ "gp" ],
954 out => [ "in_r1", "flags" ] },
956 outs => [ "res", "flags" ],
957 emit => '. inc%M %S0',
961 modified_flags => $status_flags_wo_cf
966 state => "exc_pinned",
967 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
968 ins => [ "base", "index", "mem" ],
969 emit => '. inc%M %AM',
973 modified_flags => $status_flags_wo_cf
978 reg_req => { in => [ "gp" ],
979 out => [ "in_r1", "flags" ] },
981 outs => [ "res", "flags" ],
982 emit => '. dec%M %S0',
986 modified_flags => $status_flags_wo_cf
991 state => "exc_pinned",
992 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
993 ins => [ "base", "index", "mem" ],
994 emit => '. dec%M %AM',
998 modified_flags => $status_flags_wo_cf
1003 reg_req => { in => [ "gp" ],
1004 out => [ "in_r1", "flags" ] },
1006 outs => [ "res", "flags" ],
1007 emit => '. not%M %S0',
1016 state => "exc_pinned",
1017 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1018 ins => [ "base", "index", "mem" ],
1019 emit => '. not%M %AM',
1027 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1031 mode => $mode_flags,
1032 modified_flags => $status_flags
1036 reg_req => { out => [ "flags" ] },
1040 mode => $mode_flags,
1041 modified_flags => $status_flags
1048 state => "exc_pinned",
1049 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1050 out => [ "flags", "none", "none" ] },
1051 ins => [ "base", "index", "mem", "left", "right" ],
1052 outs => [ "eflags", "unused", "M" ],
1053 am => "source,binary",
1054 emit => '. cmp%M %binop',
1055 attr => "int ins_permuted, int cmp_unsigned",
1056 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1057 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1060 mode => $mode_flags,
1061 modified_flags => $status_flags
1066 state => "exc_pinned",
1067 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1068 ins => [ "base", "index", "mem", "left", "right" ],
1069 outs => [ "eflags" ],
1070 am => "source,binary",
1071 emit => '. cmpb %binop',
1072 attr => "int ins_permuted, int cmp_unsigned",
1073 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1074 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1077 mode => $mode_flags,
1078 modified_flags => $status_flags
1083 state => "exc_pinned",
1084 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1085 ins => [ "base", "index", "mem", "left", "right" ],
1086 outs => [ "eflags" ],
1087 am => "source,binary",
1088 emit => '. test%M %binop',
1089 attr => "int ins_permuted, int cmp_unsigned",
1090 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1091 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1094 mode => $mode_flags,
1095 modified_flags => $status_flags
1100 state => "exc_pinned",
1101 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1102 ins => [ "base", "index", "mem", "left", "right" ],
1103 outs => [ "eflags" ],
1104 am => "source,binary",
1105 emit => '. testb %binop',
1106 attr => "int ins_permuted, int cmp_unsigned",
1107 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1108 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1111 mode => $mode_flags,
1112 modified_flags => $status_flags
1117 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1118 ins => [ "eflags" ],
1119 attr_type => "ia32_condcode_attr_t",
1120 attr => "pn_Cmp pnc, int ins_permuted",
1121 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1122 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1123 emit => '. set%CMP0 %DB0',
1131 state => "exc_pinned",
1132 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1133 ins => [ "base", "index", "mem","eflags" ],
1134 attr_type => "ia32_condcode_attr_t",
1135 attr => "pn_Cmp pnc, int ins_permuted",
1136 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1137 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1138 emit => '. set%CMP3 %AM',
1146 # (note: leave the false,true order intact to make it compatible with other
1148 state => "exc_pinned",
1149 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1150 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1151 am => "source,binary",
1152 attr_type => "ia32_condcode_attr_t",
1153 attr => "int ins_permuted, pn_Cmp pnc",
1154 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1162 op_flags => "L|X|Y",
1163 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1164 ins => [ "eflags" ],
1165 outs => [ "false", "true" ],
1166 attr_type => "ia32_condcode_attr_t",
1167 attr => "pn_Cmp pnc",
1169 units => [ "BRANCH" ],
1174 op_flags => "L|X|Y",
1175 reg_req => { in => [ "gp" ], out => [ "none" ] },
1177 attr_type => "ia32_condcode_attr_t",
1180 units => [ "BRANCH" ],
1181 modified_flags => $status_flags,
1187 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1188 ins => [ "base", "index", "mem", "target" ],
1189 am => "source,unary",
1190 emit => '. jmp *%unop3',
1192 units => [ "BRANCH" ],
1199 reg_req => { out => [ "gp" ] },
1201 attr => "ir_entity *symconst, int symconst_sign, long offset",
1202 attr_type => "ia32_immediate_attr_t",
1209 reg_req => { out => [ "gp" ] },
1213 modified_flags => $status_flags,
1219 reg_req => { out => [ "gp_UKNWN:I" ] },
1229 reg_req => { out => [ "vfp_UKNWN:I" ] },
1234 attr_type => "ia32_x87_attr_t",
1240 reg_req => { out => [ "xmm_UKNWN:I" ] },
1249 op_flags => "c|NB|NI",
1250 reg_req => { out => [ "gp_NOREG:I" ] },
1259 op_flags => "c|NB|NI",
1260 reg_req => { out => [ "vfp_NOREG:I" ] },
1265 attr_type => "ia32_x87_attr_t",
1270 op_flags => "c|NB|NI",
1271 reg_req => { out => [ "xmm_NOREG:I" ] },
1281 reg_req => { out => [ "fpcw:I" ] },
1285 modified_flags => $fpcw_flags
1291 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1292 ins => [ "base", "index", "mem" ],
1294 emit => ". fldcw %AM",
1297 modified_flags => $fpcw_flags
1303 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1304 ins => [ "base", "index", "mem", "fpcw" ],
1306 emit => ". fnstcw %AM",
1314 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1322 # we should not rematrialize this node. It has very strict constraints.
1323 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1324 ins => [ "val", "clobbered" ],
1333 # Note that we add additional latency values depending on address mode, so a
1334 # lateny of 0 for load is correct
1338 state => "exc_pinned",
1339 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1340 ins => [ "base", "index", "mem" ],
1341 outs => [ "res", "M", "X_exc" ],
1343 emit => ". mov%EX%.l %AM, %D0",
1349 state => "exc_pinned",
1350 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1351 ins => [ "base", "index", "mem", "val" ],
1352 outs => [ "M", "X_exc" ],
1353 emit => '. mov%M %SI3, %AM',
1361 state => "exc_pinned",
1362 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1363 ins => [ "base", "index", "mem", "val" ],
1364 outs => [ "M", "X_exc" ],
1365 emit => '. mov%M %SB3, %AM',
1373 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1374 ins => [ "base", "index" ],
1375 emit => '. leal %AM, %D0',
1379 # lea doesn't modify the flags, but setting this seems advantageous since it
1380 # increases chances that the Lea is transformed back to an Add
1381 modified_flags => 1,
1385 state => "exc_pinned",
1386 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1387 ins => [ "base", "index", "mem", "val", "stack" ],
1388 emit => '. push%M %unop3',
1389 outs => [ "stack", "M" ],
1390 am => "source,unary",
1396 state => "exc_pinned",
1397 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1398 ins => [ "mem", "stack" ],
1399 outs => [ "res", "M", "unused", "stack" ],
1400 emit => '. pop%M %D0',
1401 latency => 3, # Pop is more expensive than Push on Athlon
1406 state => "exc_pinned",
1407 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1408 ins => [ "mem", "stack" ],
1409 outs => [ "res", "M", "unused", "stack" ],
1410 emit => '. pop%M %D0',
1411 latency => 3, # Pop is more expensive than Push on Athlon
1416 state => "exc_pinned",
1417 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1418 ins => [ "base", "index", "mem", "stack" ],
1419 outs => [ "unused0", "M", "unused1", "stack" ],
1420 emit => '. pop%M %AM',
1421 latency => 3, # Pop is more expensive than Push on Athlon
1426 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1428 outs => [ "frame", "stack", "M" ],
1434 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1436 outs => [ "frame", "stack" ],
1443 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1444 ins => [ "base", "index", "mem", "stack", "size" ],
1445 am => "source,binary",
1446 emit => '. addl %binop',
1448 outs => [ "stack", "M" ],
1450 modified_flags => $status_flags
1455 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1456 ins => [ "base", "index", "mem", "stack", "size" ],
1457 am => "source,binary",
1458 emit => ". subl %binop\n".
1459 ". movl %%esp, %D1",
1461 outs => [ "stack", "addr", "M" ],
1463 modified_flags => $status_flags
1476 reg_req => { out => [ "gp" ] },
1482 # BT supports source address mode, but this is unused yet
1486 state => "exc_pinned",
1487 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1488 ins => [ "left", "right" ],
1489 emit => '. bt%M %S1, %S0',
1492 mode => $mode_flags,
1493 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1498 state => "exc_pinned",
1499 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1500 out => [ "gp", "flags", "none" ] },
1501 ins => [ "base", "index", "mem", "operand" ],
1502 outs => [ "res", "flags", "M" ],
1503 am => "source,binary",
1504 emit => '. bsf%M %unop3, %D0',
1508 modified_flags => $status_flags
1513 state => "exc_pinned",
1514 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1515 out => [ "gp", "flags", "none" ] },
1516 ins => [ "base", "index", "mem", "operand" ],
1517 outs => [ "res", "flags", "M" ],
1518 am => "source,binary",
1519 emit => '. bsr%M %unop3, %D0',
1523 modified_flags => $status_flags
1527 # SSE4.2 or SSE4a popcnt instruction
1531 state => "exc_pinned",
1532 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1533 out => [ "gp", "flags", "none" ] },
1534 ins => [ "base", "index", "mem", "operand" ],
1535 outs => [ "res", "flags", "M" ],
1536 am => "source,binary",
1537 emit => '. popcnt%M %unop3, %D0',
1541 modified_flags => $status_flags
1545 state => "exc_pinned",
1547 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1548 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" ]
1550 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1551 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1552 attr_type => "ia32_call_attr_t",
1553 attr => "unsigned pop, ir_type *call_tp",
1554 am => "source,unary",
1555 units => [ "BRANCH" ],
1556 latency => 4, # random number
1557 modified_flags => $status_flags
1561 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1563 # PS: try gcc __builtin_frame_address(100000) :-)
1566 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1567 ins => [ "frame", "cnt", "tmp" ],
1569 latency => 4, # random number
1570 attr_type => "ia32_climbframe_attr_t",
1571 attr => "unsigned count",
1581 reg_req => { in => [ "gp" ],
1582 out => [ "in_r1" ] },
1583 emit => '. bswap%M %S0',
1591 # bswap16, use xchg here
1595 reg_req => { in => [ "eax ebx ecx edx" ],
1596 out => [ "in_r1" ] },
1597 emit => '. xchg %SB0, %SH0',
1609 reg_req => { in => [ "none" ], out => [ "none" ] },
1618 # Undefined Instruction on ALL x86 CPU's
1622 reg_req => { in => [ "none" ], out => [ "none" ] },
1625 emit => ". .value 0x0b0f",
1636 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1637 ins => [ "port", "value", "mem" ],
1638 emit => '. out%M %SS0, %SI1',
1642 modified_flags => $status_flags
1651 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1652 ins => [ "port", "mem" ],
1653 outs => [ "res", "M" ],
1654 emit => '. in%M %DS0, %SS0',
1658 modified_flags => $status_flags
1662 # Intel style prefetching
1666 state => "exc_pinned",
1667 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1668 ins => [ "base", "index", "mem" ],
1671 emit => ". prefetcht0 %AM",
1677 state => "exc_pinned",
1678 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1679 ins => [ "base", "index", "mem" ],
1682 emit => ". prefetcht1 %AM",
1688 state => "exc_pinned",
1689 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1690 ins => [ "base", "index", "mem" ],
1693 emit => ". prefetcht2 %AM",
1699 state => "exc_pinned",
1700 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1701 ins => [ "base", "index", "mem" ],
1704 emit => ". prefetchnta %AM",
1709 # 3DNow! prefetch instructions
1713 state => "exc_pinned",
1714 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1715 ins => [ "base", "index", "mem" ],
1718 emit => ". prefetch %AM",
1724 state => "exc_pinned",
1725 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1726 ins => [ "base", "index", "mem" ],
1729 emit => ". prefetchw %AM",
1733 #-----------------------------------------------------------------------------#
1734 # _____ _____ ______ __ _ _ _ #
1735 # / ____/ ____| ____| / _| | | | | | #
1736 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1737 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1738 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1739 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1740 #-----------------------------------------------------------------------------#
1745 reg_req => { out => [ "xmm" ] },
1746 emit => '. xorp%XSD %D0, %D0',
1754 reg_req => { out => [ "xmm" ] },
1755 emit => '. pxor %D0, %D0',
1761 # produces all 1 bits
1764 reg_req => { out => [ "xmm" ] },
1765 emit => '. pcmpeqb %D0, %D0',
1771 # integer shift left, dword
1774 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1775 emit => '. pslld %SI1, %D0',
1781 # integer shift left, qword
1784 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1785 emit => '. psllq %SI1, %D0',
1791 # integer shift right, dword
1794 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1795 emit => '. psrld %SI1, %D0',
1801 # mov from integer to SSE register
1804 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1805 emit => '. movd %S0, %D0',
1811 # commutative operations
1815 state => "exc_pinned",
1816 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1817 ins => [ "base", "index", "mem", "left", "right" ],
1818 am => "source,binary",
1819 emit => '. add%XXM %binop',
1827 state => "exc_pinned",
1828 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1829 ins => [ "base", "index", "mem", "left", "right" ],
1830 am => "source,binary",
1831 emit => '. mul%XXM %binop',
1839 state => "exc_pinned",
1840 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1841 ins => [ "base", "index", "mem", "left", "right" ],
1842 am => "source,binary",
1843 emit => '. max%XXM %binop',
1851 state => "exc_pinned",
1852 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1853 ins => [ "base", "index", "mem", "left", "right" ],
1854 am => "source,binary",
1855 emit => '. min%XXM %binop',
1863 state => "exc_pinned",
1864 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1865 ins => [ "base", "index", "mem", "left", "right" ],
1866 am => "source,binary",
1867 emit => '. andp%XSD %binop',
1875 state => "exc_pinned",
1876 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1877 ins => [ "base", "index", "mem", "left", "right" ],
1878 am => "source,binary",
1879 emit => '. orp%XSD %binop',
1887 state => "exc_pinned",
1888 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1889 ins => [ "base", "index", "mem", "left", "right" ],
1890 am => "source,binary",
1891 emit => '. xorp%XSD %binop',
1897 # not commutative operations
1901 state => "exc_pinned",
1902 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1903 ins => [ "base", "index", "mem", "left", "right" ],
1904 am => "source,binary",
1905 emit => '. andnp%XSD %binop',
1913 state => "exc_pinned",
1914 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1915 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1916 am => "source,binary",
1917 emit => '. sub%XXM %binop',
1925 state => "exc_pinned",
1926 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1927 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1928 am => "source,binary",
1929 outs => [ "res", "M" ],
1930 emit => '. div%XXM %binop',
1939 state => "exc_pinned",
1940 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1941 ins => [ "base", "index", "mem", "left", "right" ],
1942 outs => [ "flags" ],
1943 am => "source,binary",
1944 attr => "int ins_permuted",
1945 init_attr => "attr->data.ins_permuted = ins_permuted;",
1946 emit => ' .ucomi%XXM %binop',
1949 mode => $mode_flags,
1950 modified_flags => 1,
1957 state => "exc_pinned",
1958 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1959 ins => [ "base", "index", "mem" ],
1960 outs => [ "res", "M", "X_exc" ],
1961 emit => '. mov%XXM %AM, %D0',
1962 attr => "ir_mode *load_mode",
1963 init_attr => "attr->ls_mode = load_mode;",
1970 state => "exc_pinned",
1971 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1972 ins => [ "base", "index", "mem", "val" ],
1973 outs => [ "M", "X_exc" ],
1974 emit => '. mov%XXM %S3, %AM',
1982 state => "exc_pinned",
1983 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1984 ins => [ "base", "index", "mem", "val" ],
1985 emit => '. mov%XXM %S3, %AM',
1993 state => "exc_pinned",
1994 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1995 ins => [ "base", "index", "mem", "val" ],
1996 am => "source,unary",
1997 emit => '. cvtsi2ss %unop3, %D0',
2005 state => "exc_pinned",
2006 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2007 ins => [ "base", "index", "mem", "val" ],
2008 am => "source,unary",
2009 emit => '. cvtsi2sd %unop3, %D0',
2018 cmp_attr => "return 1;",
2019 ins => [ "val_high", "val_low" ],
2024 cmp_attr => "return 1;",
2026 outs => [ "res_high", "res_low" ],
2034 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2035 outs => [ "DST", "SRC", "CNT", "M" ],
2036 attr_type => "ia32_copyb_attr_t",
2037 attr => "unsigned size",
2040 # we don't care about this flag, so no need to mark this node
2041 # modified_flags => [ "DF" ]
2047 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2048 outs => [ "DST", "SRC", "M" ],
2049 attr_type => "ia32_copyb_attr_t",
2050 attr => "unsigned size",
2053 # we don't care about this flag, so no need to mark this node
2054 # modified_flags => [ "DF" ]
2060 state => "exc_pinned",
2061 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2071 state => "exc_pinned",
2072 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
2073 ins => [ "base", "index", "mem", "val" ],
2074 outs => [ "res", "M" ],
2075 am => "source,unary",
2078 attr => "ir_mode *smaller_mode",
2079 init_attr => "attr->ls_mode = smaller_mode;",
2084 state => "exc_pinned",
2085 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
2086 ins => [ "base", "index", "mem", "val" ],
2087 am => "source,unary",
2090 attr => "ir_mode *smaller_mode",
2091 init_attr => "attr->ls_mode = smaller_mode;",
2096 state => "exc_pinned",
2097 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2098 ins => [ "base", "index", "mem", "val" ],
2099 am => "source,unary",
2106 state => "exc_pinned",
2107 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2108 ins => [ "base", "index", "mem", "val" ],
2109 am => "source,unary",
2116 state => "exc_pinned",
2117 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2118 ins => [ "base", "index", "mem", "val" ],
2119 am => "source,unary",
2125 #----------------------------------------------------------#
2127 # (_) | | | | / _| | | | #
2128 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
2129 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
2130 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
2131 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
2133 # _ __ ___ __| | ___ ___ #
2134 # | '_ \ / _ \ / _` |/ _ \/ __| #
2135 # | | | | (_) | (_| | __/\__ \ #
2136 # |_| |_|\___/ \__,_|\___||___/ #
2137 #----------------------------------------------------------#
2139 # rematerialisation disabled for all float nodes for now, because the fpcw
2140 # handler runs before spilling and we might end up with wrong fpcw then
2144 state => "exc_pinned",
2145 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2146 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2147 am => "source,binary",
2151 attr_type => "ia32_x87_attr_t",
2156 state => "exc_pinned",
2157 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2158 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2159 am => "source,binary",
2163 attr_type => "ia32_x87_attr_t",
2168 state => "exc_pinned",
2169 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2170 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2171 am => "source,binary",
2175 attr_type => "ia32_x87_attr_t",
2179 state => "exc_pinned",
2180 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
2181 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2182 am => "source,binary",
2183 outs => [ "res", "M" ],
2186 attr_type => "ia32_x87_attr_t",
2190 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2191 ins => [ "left", "right", "fpcw" ],
2195 attr_type => "ia32_x87_attr_t",
2200 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2205 attr_type => "ia32_x87_attr_t",
2210 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2215 attr_type => "ia32_x87_attr_t",
2218 # virtual Load and Store
2223 state => "exc_pinned",
2224 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
2225 ins => [ "base", "index", "mem" ],
2226 outs => [ "res", "M", "X_exc" ],
2227 attr => "ir_mode *load_mode",
2228 init_attr => "attr->attr.ls_mode = load_mode;",
2231 attr_type => "ia32_x87_attr_t",
2237 state => "exc_pinned",
2238 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
2239 ins => [ "base", "index", "mem", "val" ],
2240 outs => [ "M", "X_exc" ],
2241 attr => "ir_mode *store_mode",
2242 init_attr => "attr->attr.ls_mode = store_mode;",
2246 attr_type => "ia32_x87_attr_t",
2252 state => "exc_pinned",
2253 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
2254 outs => [ "res", "M" ],
2255 ins => [ "base", "index", "mem" ],
2258 attr_type => "ia32_x87_attr_t",
2262 state => "exc_pinned",
2263 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2264 ins => [ "base", "index", "mem", "val", "fpcw" ],
2268 attr_type => "ia32_x87_attr_t",
2271 # SSE3 fisttp instruction
2273 state => "exc_pinned",
2274 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2275 ins => [ "base", "index", "mem", "val" ],
2276 outs => [ "res", "M" ],
2279 attr_type => "ia32_x87_attr_t",
2287 reg_req => { out => [ "vfp" ] },
2292 attr_type => "ia32_x87_attr_t",
2297 reg_req => { out => [ "vfp" ] },
2302 attr_type => "ia32_x87_attr_t",
2307 reg_req => { out => [ "vfp" ] },
2312 attr_type => "ia32_x87_attr_t",
2317 reg_req => { out => [ "vfp" ] },
2322 attr_type => "ia32_x87_attr_t",
2327 reg_req => { out => [ "vfp" ] },
2332 attr_type => "ia32_x87_attr_t",
2337 reg_req => { out => [ "vfp" ] },
2342 attr_type => "ia32_x87_attr_t",
2347 reg_req => { out => [ "vfp" ] },
2352 attr_type => "ia32_x87_attr_t",
2358 # we can't allow to rematerialize this node so we don't have
2359 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2361 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2362 ins => [ "left", "right" ],
2363 outs => [ "flags" ],
2364 attr => "int ins_permuted",
2365 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2368 attr_type => "ia32_x87_attr_t",
2374 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2375 ins => [ "left", "right" ],
2376 outs => [ "flags" ],
2377 attr => "int ins_permuted",
2378 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2381 attr_type => "ia32_x87_attr_t",
2387 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2389 outs => [ "flags" ],
2390 attr => "int ins_permuted",
2391 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2394 attr_type => "ia32_x87_attr_t",
2400 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2402 outs => [ "flags" ],
2406 mode => $mode_flags,
2409 #------------------------------------------------------------------------#
2410 # ___ _____ __ _ _ _ #
2411 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2412 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2413 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2414 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2415 #------------------------------------------------------------------------#
2417 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2418 # are swapped, we work this around in the emitter...
2421 state => "exc_pinned",
2422 rd_constructor => "NONE",
2424 emit => '. fadd%XM %x87_binop',
2426 attr_type => "ia32_x87_attr_t",
2430 state => "exc_pinned",
2431 rd_constructor => "NONE",
2433 emit => '. faddp%XM %x87_binop',
2435 attr_type => "ia32_x87_attr_t",
2439 state => "exc_pinned",
2440 rd_constructor => "NONE",
2442 emit => '. fmul%XM %x87_binop',
2444 attr_type => "ia32_x87_attr_t",
2448 state => "exc_pinned",
2449 rd_constructor => "NONE",
2451 emit => '. fmulp%XM %x87_binop',,
2453 attr_type => "ia32_x87_attr_t",
2457 state => "exc_pinned",
2458 rd_constructor => "NONE",
2460 emit => '. fsub%XM %x87_binop',
2462 attr_type => "ia32_x87_attr_t",
2466 state => "exc_pinned",
2467 rd_constructor => "NONE",
2469 # see note about gas bugs
2470 emit => '. fsubrp%XM %x87_binop',
2472 attr_type => "ia32_x87_attr_t",
2476 state => "exc_pinned",
2477 rd_constructor => "NONE",
2480 emit => '. fsubr%XM %x87_binop',
2482 attr_type => "ia32_x87_attr_t",
2486 state => "exc_pinned",
2487 rd_constructor => "NONE",
2490 # see note about gas bugs
2491 emit => '. fsubp%XM %x87_binop',
2493 attr_type => "ia32_x87_attr_t",
2497 rd_constructor => "NONE",
2501 attr_type => "ia32_x87_attr_t",
2504 # this node is just here, to keep the simulator running
2505 # we can omit this when a fprem simulation function exists
2507 rd_constructor => "NONE",
2509 emit => '. fprem1\n'.
2512 attr_type => "ia32_x87_attr_t",
2516 state => "exc_pinned",
2517 rd_constructor => "NONE",
2519 emit => '. fdiv%XM %x87_binop',
2521 attr_type => "ia32_x87_attr_t",
2525 state => "exc_pinned",
2526 rd_constructor => "NONE",
2528 # see note about gas bugs
2529 emit => '. fdivrp%XM %x87_binop',
2531 attr_type => "ia32_x87_attr_t",
2535 state => "exc_pinned",
2536 rd_constructor => "NONE",
2538 emit => '. fdivr%XM %x87_binop',
2540 attr_type => "ia32_x87_attr_t",
2544 state => "exc_pinned",
2545 rd_constructor => "NONE",
2547 # see note about gas bugs
2548 emit => '. fdivp%XM %x87_binop',
2550 attr_type => "ia32_x87_attr_t",
2554 rd_constructor => "NONE",
2558 attr_type => "ia32_x87_attr_t",
2563 rd_constructor => "NONE",
2567 attr_type => "ia32_x87_attr_t",
2570 # x87 Load and Store
2573 rd_constructor => "NONE",
2574 op_flags => "R|L|F",
2575 state => "exc_pinned",
2577 emit => '. fld%XM %AM',
2578 attr_type => "ia32_x87_attr_t",
2583 rd_constructor => "NONE",
2584 op_flags => "R|L|F",
2585 state => "exc_pinned",
2587 emit => '. fst%XM %AM',
2589 attr_type => "ia32_x87_attr_t",
2594 rd_constructor => "NONE",
2595 op_flags => "R|L|F",
2596 state => "exc_pinned",
2598 emit => '. fstp%XM %AM',
2600 attr_type => "ia32_x87_attr_t",
2607 state => "exc_pinned",
2608 rd_constructor => "NONE",
2610 emit => '. fild%XM %AM',
2611 attr_type => "ia32_x87_attr_t",
2616 state => "exc_pinned",
2617 rd_constructor => "NONE",
2619 emit => '. fist%XM %AM',
2621 attr_type => "ia32_x87_attr_t",
2626 state => "exc_pinned",
2627 rd_constructor => "NONE",
2629 emit => '. fistp%XM %AM',
2631 attr_type => "ia32_x87_attr_t",
2635 # SSE3 firsttp instruction
2637 state => "exc_pinned",
2638 rd_constructor => "NONE",
2640 emit => '. fisttp%XM %AM',
2642 attr_type => "ia32_x87_attr_t",
2649 op_flags => "R|c|K",
2651 reg_req => { out => [ "vfp" ] },
2653 attr_type => "ia32_x87_attr_t",
2658 op_flags => "R|c|K",
2660 reg_req => { out => [ "vfp" ] },
2662 attr_type => "ia32_x87_attr_t",
2667 op_flags => "R|c|K",
2669 reg_req => { out => [ "vfp" ] },
2671 attr_type => "ia32_x87_attr_t",
2676 op_flags => "R|c|K",
2678 reg_req => { out => [ "vfp" ] },
2680 attr_type => "ia32_x87_attr_t",
2685 op_flags => "R|c|K",
2687 reg_req => { out => [ "vfp" ] },
2689 attr_type => "ia32_x87_attr_t",
2694 op_flags => "R|c|K",
2696 reg_req => { out => [ "vfp" ] },
2697 emit => '. fldll2t',
2698 attr_type => "ia32_x87_attr_t",
2703 op_flags => "R|c|K",
2705 reg_req => { out => [ "vfp" ] },
2707 attr_type => "ia32_x87_attr_t",
2712 # Note that it is NEVER allowed to do CSE on these nodes
2713 # Moreover, note the virtual register requierements!
2718 cmp_attr => "return 1;",
2719 emit => '. fxch %X0',
2720 attr_type => "ia32_x87_attr_t",
2728 cmp_attr => "return 1;",
2729 emit => '. fld %X0',
2730 attr_type => "ia32_x87_attr_t",
2736 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2737 cmp_attr => "return 1;",
2738 emit => '. fld %X0',
2739 attr_type => "ia32_x87_attr_t",
2746 cmp_attr => "return 1;",
2747 emit => '. fstp %X0',
2748 attr_type => "ia32_x87_attr_t",
2756 cmp_attr => "return 1;",
2757 emit => '. ffreep %X0',
2758 attr_type => "ia32_x87_attr_t",
2766 cmp_attr => "return 1;",
2768 attr_type => "ia32_x87_attr_t",
2776 cmp_attr => "return 1;",
2778 attr_type => "ia32_x87_attr_t",
2787 emit => ". fucom %X1\n".
2789 attr_type => "ia32_x87_attr_t",
2795 emit => ". fucomp %X1\n".
2797 attr_type => "ia32_x87_attr_t",
2803 emit => ". fucompp\n".
2805 attr_type => "ia32_x87_attr_t",
2811 emit => '. fucomi %X1',
2812 attr_type => "ia32_x87_attr_t",
2818 emit => '. fucompi %X1',
2819 attr_type => "ia32_x87_attr_t",
2827 attr_type => "ia32_x87_attr_t",
2832 # -------------------------------------------------------------------------------- #
2833 # ____ ____ _____ _ _ #
2834 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2835 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2836 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2837 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2839 # -------------------------------------------------------------------------------- #
2842 # Spilling and reloading of SSE registers, hardcoded, not generated #
2846 state => "exc_pinned",
2847 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2848 emit => '. movdqu %D0, %AM',
2849 outs => [ "res", "M" ],
2856 state => "exc_pinned",
2857 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2858 ins => [ "base", "index", "mem", "val" ],
2859 emit => '. movdqu %binop',
2867 # Include the generated SIMD node specification written by the SIMD optimization
2868 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2869 unless ($return = do $my_script_name) {
2870 warn "couldn't parse $my_script_name: $@" if $@;
2871 warn "couldn't do $my_script_name: $!" unless defined $return;
2872 warn "couldn't run $my_script_name" unless $return;
2875 # Transform some attributes
2876 foreach my $op (keys(%nodes)) {
2877 my $node = $nodes{$op};
2878 my $op_attr_init = $node->{op_attr_init};
2880 if(defined($op_attr_init)) {
2881 $op_attr_init .= "\n\t";
2886 if(!defined($node->{latency})) {
2888 $node->{latency} = 0;
2890 die("Latency missing for op $op");
2893 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2895 $node->{op_attr_init} = $op_attr_init;