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 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
201 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
202 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
203 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
204 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
205 D0 => "${arch}_emit_dest_register(node, 0);",
206 D1 => "${arch}_emit_dest_register(node, 1);",
207 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
208 X0 => "${arch}_emit_x87_register(node, 0);",
209 X1 => "${arch}_emit_x87_register(node, 1);",
210 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
211 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
212 ia32_emit_mode_suffix(node);",
213 M => "${arch}_emit_mode_suffix(node);",
214 XM => "${arch}_emit_x87_mode_suffix(node);",
215 XXM => "${arch}_emit_xmm_mode_suffix(node);",
216 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
217 AM => "${arch}_emit_am(node);",
218 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
219 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
220 binop => "${arch}_emit_binop(node);",
221 x87_binop => "${arch}_emit_x87_binop(node);",
222 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
223 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
226 #--------------------------------------------------#
229 # _ __ _____ __ _ _ __ ___ _ __ ___ #
230 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
231 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
232 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
235 #--------------------------------------------------#
237 $default_op_attr_type = "ia32_op_attr_t";
238 $default_attr_type = "ia32_attr_t";
239 $default_copy_attr = "ia32_copy_attr";
241 sub ia32_custom_init_attr {
246 if(defined($node->{modified_flags})) {
247 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
249 if(defined($node->{am})) {
250 my $am = $node->{am};
251 if($am eq "source,unary") {
252 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
253 } elsif($am eq "source,binary") {
254 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
255 } elsif($am eq "none") {
258 die("Invalid address mode '$am' specified on op $name");
261 if($node->{state} ne "exc_pinned"
262 and $node->{state} ne "pinned") {
263 die("AM nodes must have pinned or AM pinned state ($name)");
269 $custom_init_attr_func = \&ia32_custom_init_attr;
273 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
274 "\tinit_ia32_x87_attributes(res);".
275 "\tinit_ia32_asm_attributes(res);",
277 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
279 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
280 "\tinit_ia32_call_attributes(res, pop, call_tp);",
281 ia32_condcode_attr_t =>
282 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
283 "\tinit_ia32_condcode_attributes(res, pnc);",
285 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_copyb_attributes(res, size);",
287 ia32_immediate_attr_t =>
288 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
289 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
291 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_x87_attributes(res);",
296 ia32_asm_attr_t => "ia32_compare_asm_attr",
297 ia32_attr_t => "ia32_compare_nodes_attr",
298 ia32_call_attr_t => "ia32_compare_call_attr",
299 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
300 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
301 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
302 ia32_x87_attr_t => "ia32_compare_x87_attr",
308 $mode_xmm = "mode_E";
309 $mode_gp = "mode_Iu";
310 $mode_flags = "mode_Iu";
311 $mode_fpcw = "mode_fpcw";
312 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
313 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
314 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
315 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
322 reg_req => { out => [ "gp_NOREG:I" ] },
323 attr => "ir_entity *symconst, int symconst_sign, long offset",
324 attr_type => "ia32_immediate_attr_t",
325 hash_func => "ia32_hash_Immediate",
333 out_arity => "variable",
334 attr_type => "ia32_asm_attr_t",
335 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
336 init_attr => "attr->asm_text = asm_text;\n".
337 "\tattr->register_map = register_map;\n",
339 modified_flags => $status_flags,
342 #-----------------------------------------------------------------#
345 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
346 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
347 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
348 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
351 #-----------------------------------------------------------------#
353 # commutative operations
357 state => "exc_pinned",
358 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
359 out => [ "in_r4 in_r5", "flags", "none" ] },
360 ins => [ "base", "index", "mem", "left", "right" ],
361 outs => [ "res", "flags", "M" ],
362 emit => '. add%M %binop',
363 am => "source,binary",
367 modified_flags => $status_flags
372 state => "exc_pinned",
373 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
374 ins => [ "base", "index", "mem", "val" ],
375 emit => ". add%M %SI3, %AM",
379 modified_flags => $status_flags
384 state => "exc_pinned",
385 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
386 ins => [ "base", "index", "mem", "val" ],
387 emit => ". add%M %SB3, %AM",
391 modified_flags => $status_flags
395 state => "exc_pinned",
396 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
397 out => [ "in_r4 in_r5", "flags", "none" ] },
398 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
399 outs => [ "res", "flags", "M" ],
400 emit => '. adc%M %binop',
401 am => "source,binary",
405 modified_flags => $status_flags
410 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
411 ins => [ "left", "right" ],
415 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
416 ins => [ "left", "right", "eflags" ],
420 # we should not rematrialize this node. It produces 2 results and has
421 # very strict constraints
422 state => "exc_pinned",
423 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
424 out => [ "eax", "flags", "edx", "none" ] },
425 ins => [ "base", "index", "mem", "left", "right" ],
426 emit => '. mul%M %unop4',
427 outs => [ "res_low", "flags", "res_high", "M" ],
428 am => "source,binary",
431 modified_flags => $status_flags
435 # we should not rematrialize this node. It produces 2 results and has
436 # very strict constraints
438 cmp_attr => "return 1;",
439 outs => [ "EAX", "flags", "EDX", "M" ],
445 state => "exc_pinned",
446 # TODO: adjust out requirements for the 3 operand form
447 # (no need for should_be_same then)
448 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
449 out => [ "in_r4 in_r5", "flags", "none" ] },
450 ins => [ "base", "index", "mem", "left", "right" ],
451 outs => [ "res", "flags", "M" ],
452 am => "source,binary",
456 modified_flags => $status_flags
461 state => "exc_pinned",
462 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
463 out => [ "eax", "flags", "edx", "none" ] },
464 ins => [ "base", "index", "mem", "left", "right" ],
465 emit => '. imul%M %unop4',
466 outs => [ "res_low", "flags", "res_high", "M" ],
467 am => "source,binary",
470 modified_flags => $status_flags
475 cmp_attr => "return 1;",
476 outs => [ "res_low", "res_high", "M" ],
482 state => "exc_pinned",
483 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
484 out => [ "in_r4 in_r5", "flags", "none" ] },
485 ins => [ "base", "index", "mem", "left", "right" ],
486 outs => [ "res", "flags", "M" ],
487 op_modes => "commutative | am | immediate | mode_neutral",
488 am => "source,binary",
489 emit => '. and%M %binop',
493 modified_flags => $status_flags
498 state => "exc_pinned",
499 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
500 ins => [ "base", "index", "mem", "val" ],
501 emit => '. and%M %SI3, %AM',
505 modified_flags => $status_flags
510 state => "exc_pinned",
511 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
512 ins => [ "base", "index", "mem", "val" ],
513 emit => '. and%M %SB3, %AM',
517 modified_flags => $status_flags
522 state => "exc_pinned",
523 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
524 out => [ "in_r4 in_r5", "flags", "none" ] },
525 ins => [ "base", "index", "mem", "left", "right" ],
526 outs => [ "res", "flags", "M" ],
527 am => "source,binary",
528 emit => '. or%M %binop',
532 modified_flags => $status_flags
537 state => "exc_pinned",
538 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
539 ins => [ "base", "index", "mem", "val" ],
540 emit => '. or%M %SI3, %AM',
544 modified_flags => $status_flags
549 state => "exc_pinned",
550 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
551 ins => [ "base", "index", "mem", "val" ],
552 emit => '. or%M %SB3, %AM',
556 modified_flags => $status_flags
561 state => "exc_pinned",
562 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
563 out => [ "in_r4 in_r5", "flags", "none" ] },
564 ins => [ "base", "index", "mem", "left", "right" ],
565 outs => [ "res", "flags", "M" ],
566 am => "source,binary",
567 emit => '. xor%M %binop',
571 modified_flags => $status_flags
577 reg_req => { out => [ "gp", "flags" ] },
578 outs => [ "res", "flags" ],
579 emit => ". xor%M %D0, %D0",
583 modified_flags => $status_flags
588 state => "exc_pinned",
589 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
590 ins => [ "base", "index", "mem", "val" ],
591 emit => '. xor%M %SI3, %AM',
595 modified_flags => $status_flags
600 state => "exc_pinned",
601 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
602 ins => [ "base", "index", "mem", "val" ],
603 emit => '. xor%M %SB3, %AM',
607 modified_flags => $status_flags
610 # not commutative operations
614 state => "exc_pinned",
615 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
616 out => [ "in_r4", "flags", "none" ] },
617 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
618 outs => [ "res", "flags", "M" ],
619 am => "source,binary",
620 emit => '. sub%M %binop',
624 modified_flags => $status_flags
629 state => "exc_pinned",
630 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
631 ins => [ "base", "index", "mem", "subtrahend" ],
632 emit => '. sub%M %SI3, %AM',
636 modified_flags => $status_flags
641 state => "exc_pinned",
642 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
643 ins => [ "base", "index", "mem", "subtrahend" ],
644 emit => '. sub%M %SB3, %AM',
648 modified_flags => $status_flags
652 state => "exc_pinned",
653 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
654 out => [ "in_r4 !in_r5", "flags", "none" ] },
655 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
656 outs => [ "res", "flags", "M" ],
657 am => "source,binary",
658 emit => '. sbb%M %binop',
662 modified_flags => $status_flags
667 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
668 outs => [ "res", "flags" ],
669 emit => ". sbb%M %D0, %D0",
673 modified_flags => $status_flags
677 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
678 ins => [ "minuend", "subtrahend" ],
682 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
683 ins => [ "minuend", "subtrahend", "eflags" ],
688 state => "exc_pinned",
689 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
690 out => [ "eax", "flags", "none", "edx", "none" ] },
691 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
692 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
693 am => "source,unary",
694 emit => ". idiv%M %unop3",
697 modified_flags => $status_flags
702 state => "exc_pinned",
703 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
704 out => [ "eax", "flags", "none", "edx", "none" ] },
705 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
706 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
707 am => "source,unary",
708 emit => ". div%M %unop3",
711 modified_flags => $status_flags
716 reg_req => { in => [ "gp", "ecx" ],
717 out => [ "in_r1 !in_r2", "flags" ] },
718 ins => [ "val", "count" ],
719 outs => [ "res", "flags" ],
720 emit => '. shl%M %SB1, %S0',
724 modified_flags => $status_flags
729 state => "exc_pinned",
730 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
731 ins => [ "base", "index", "mem", "count" ],
732 emit => '. shl%M %SB3, %AM',
736 modified_flags => $status_flags
740 cmp_attr => "return 1;",
741 ins => [ "val", "count", "dep" ],
747 reg_req => { in => [ "gp", "gp", "ecx" ],
748 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
749 ins => [ "val_high", "val_low", "count" ],
750 outs => [ "res", "flags" ],
751 emit => ". shld%M %SB2, %S1, %D0",
755 modified_flags => $status_flags
759 cmp_attr => "return 1;",
760 ins => [ "val_high", "val_low", "count" ],
766 reg_req => { in => [ "gp", "ecx" ],
767 out => [ "in_r1 !in_r2", "flags" ] },
768 ins => [ "val", "count" ],
769 outs => [ "res", "flags" ],
770 emit => '. shr%M %SB1, %S0',
774 modified_flags => $status_flags
779 state => "exc_pinned",
780 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
781 ins => [ "base", "index", "mem", "count" ],
782 emit => '. shr%M %SB3, %AM',
786 modified_flags => $status_flags
790 cmp_attr => "return 1;",
791 ins => [ "val", "count", "dep" ],
797 reg_req => { in => [ "gp", "gp", "ecx" ],
798 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
799 ins => [ "val_high", "val_low", "count" ],
800 outs => [ "res", "flags" ],
801 emit => ". shrd%M %SB2, %S1, %D0",
805 modified_flags => $status_flags
809 cmp_attr => "return 1;",
811 ins => [ "val_high", "val_low", "count" ],
816 reg_req => { in => [ "gp", "ecx" ],
817 out => [ "in_r1 !in_r2", "flags" ] },
818 ins => [ "val", "count" ],
819 outs => [ "res", "flags" ],
820 emit => '. sar%M %SB1, %S0',
824 modified_flags => $status_flags
829 state => "exc_pinned",
830 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
831 ins => [ "base", "index", "mem", "count" ],
832 emit => '. sar%M %SB3, %AM',
836 modified_flags => $status_flags
840 cmp_attr => "return 1;",
841 ins => [ "val", "count", "dep" ],
847 reg_req => { in => [ "gp", "ecx" ],
848 out => [ "in_r1 !in_r2", "flags" ] },
849 ins => [ "val", "count" ],
850 outs => [ "res", "flags" ],
851 emit => '. ror%M %SB1, %S0',
855 modified_flags => $status_flags
860 state => "exc_pinned",
861 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
862 ins => [ "base", "index", "mem", "count" ],
863 emit => '. ror%M %SB3, %AM',
867 modified_flags => $status_flags
872 reg_req => { in => [ "gp", "ecx" ],
873 out => [ "in_r1 !in_r2", "flags" ] },
874 ins => [ "val", "count" ],
875 outs => [ "res", "flags" ],
876 emit => '. rol%M %SB1, %S0',
880 modified_flags => $status_flags
885 state => "exc_pinned",
886 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
887 ins => [ "base", "index", "mem", "count" ],
888 emit => '. rol%M %SB3, %AM',
892 modified_flags => $status_flags
899 reg_req => { in => [ "gp" ],
900 out => [ "in_r1", "flags" ] },
901 emit => '. neg%M %S0',
903 outs => [ "res", "flags" ],
907 modified_flags => $status_flags
912 state => "exc_pinned",
913 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
914 ins => [ "base", "index", "mem" ],
915 emit => '. neg%M %AM',
919 modified_flags => $status_flags
924 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
925 outs => [ "low_res", "high_res" ],
928 modified_flags => $status_flags
934 reg_req => { in => [ "gp" ],
935 out => [ "in_r1", "flags" ] },
937 outs => [ "res", "flags" ],
938 emit => '. inc%M %S0',
942 modified_flags => $status_flags_wo_cf
947 state => "exc_pinned",
948 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
949 ins => [ "base", "index", "mem" ],
950 emit => '. inc%M %AM',
954 modified_flags => $status_flags_wo_cf
959 reg_req => { in => [ "gp" ],
960 out => [ "in_r1", "flags" ] },
962 outs => [ "res", "flags" ],
963 emit => '. dec%M %S0',
967 modified_flags => $status_flags_wo_cf
972 state => "exc_pinned",
973 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
974 ins => [ "base", "index", "mem" ],
975 emit => '. dec%M %AM',
979 modified_flags => $status_flags_wo_cf
984 reg_req => { in => [ "gp" ],
985 out => [ "in_r1", "flags" ] },
987 outs => [ "res", "flags" ],
988 emit => '. not%M %S0',
997 state => "exc_pinned",
998 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
999 ins => [ "base", "index", "mem" ],
1000 emit => '. not%M %AM',
1008 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1012 mode => $mode_flags,
1013 modified_flags => $status_flags
1017 reg_req => { out => [ "flags" ] },
1021 mode => $mode_flags,
1022 modified_flags => $status_flags
1029 state => "exc_pinned",
1030 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1031 out => [ "flags", "none", "none" ] },
1032 ins => [ "base", "index", "mem", "left", "right" ],
1033 outs => [ "eflags", "unused", "M" ],
1034 am => "source,binary",
1035 emit => '. cmp%M %binop',
1036 attr => "int ins_permuted, int cmp_unsigned",
1037 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1038 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1041 mode => $mode_flags,
1042 modified_flags => $status_flags
1047 state => "exc_pinned",
1048 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1049 ins => [ "base", "index", "mem", "left", "right" ],
1050 outs => [ "eflags" ],
1051 am => "source,binary",
1052 emit => '. cmpb %binop',
1053 attr => "int ins_permuted, int cmp_unsigned",
1054 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1055 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1058 mode => $mode_flags,
1059 modified_flags => $status_flags
1064 state => "exc_pinned",
1065 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1066 ins => [ "base", "index", "mem", "left", "right" ],
1067 outs => [ "eflags" ],
1068 am => "source,binary",
1069 emit => '. test%M %binop',
1070 attr => "int ins_permuted, int cmp_unsigned",
1071 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1072 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1075 mode => $mode_flags,
1076 modified_flags => $status_flags
1081 state => "exc_pinned",
1082 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1083 ins => [ "base", "index", "mem", "left", "right" ],
1084 outs => [ "eflags" ],
1085 am => "source,binary",
1086 emit => '. testb %binop',
1087 attr => "int ins_permuted, int cmp_unsigned",
1088 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1089 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1092 mode => $mode_flags,
1093 modified_flags => $status_flags
1098 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1099 ins => [ "eflags" ],
1100 attr_type => "ia32_condcode_attr_t",
1101 attr => "pn_Cmp pnc, int ins_permuted",
1102 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1103 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1104 emit => '. set%CMP0 %DB0',
1112 state => "exc_pinned",
1113 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1114 ins => [ "base", "index", "mem","eflags" ],
1115 attr_type => "ia32_condcode_attr_t",
1116 attr => "pn_Cmp pnc, int ins_permuted",
1117 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1118 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1119 emit => '. set%CMP3 %AM',
1127 # (note: leave the false,true order intact to make it compatible with other
1129 state => "exc_pinned",
1130 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1131 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1132 am => "source,binary",
1133 attr_type => "ia32_condcode_attr_t",
1134 attr => "int ins_permuted, pn_Cmp pnc",
1135 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1143 op_flags => "L|X|Y",
1144 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1145 ins => [ "eflags" ],
1146 outs => [ "false", "true" ],
1147 attr_type => "ia32_condcode_attr_t",
1148 attr => "pn_Cmp pnc",
1150 units => [ "BRANCH" ],
1155 op_flags => "L|X|Y",
1156 reg_req => { in => [ "gp" ], out => [ "none" ] },
1158 attr_type => "ia32_condcode_attr_t",
1161 units => [ "BRANCH" ],
1162 modified_flags => $status_flags,
1168 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1169 ins => [ "base", "index", "mem", "target" ],
1170 am => "source,unary",
1171 emit => '. jmp *%unop3',
1173 units => [ "BRANCH" ],
1180 reg_req => { out => [ "gp" ] },
1182 attr => "ir_entity *symconst, int symconst_sign, long offset",
1183 attr_type => "ia32_immediate_attr_t",
1190 reg_req => { out => [ "gp" ] },
1194 modified_flags => $status_flags,
1200 reg_req => { out => [ "gp_UKNWN:I" ] },
1210 reg_req => { out => [ "vfp_UKNWN:I" ] },
1215 attr_type => "ia32_x87_attr_t",
1221 reg_req => { out => [ "xmm_UKNWN:I" ] },
1230 op_flags => "c|NB|NI",
1231 reg_req => { out => [ "gp_NOREG:I" ] },
1240 op_flags => "c|NB|NI",
1241 reg_req => { out => [ "vfp_NOREG:I" ] },
1246 attr_type => "ia32_x87_attr_t",
1251 op_flags => "c|NB|NI",
1252 reg_req => { out => [ "xmm_NOREG:I" ] },
1262 reg_req => { out => [ "fpcw:I" ] },
1266 modified_flags => $fpcw_flags
1272 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1273 ins => [ "base", "index", "mem" ],
1275 emit => ". fldcw %AM",
1278 modified_flags => $fpcw_flags
1284 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1285 ins => [ "base", "index", "mem", "fpcw" ],
1287 emit => ". fnstcw %AM",
1295 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1303 # we should not rematrialize this node. It has very strict constraints.
1304 reg_req => { in => [ "eax" ], out => [ "edx" ] },
1314 # Note that we add additional latency values depending on address mode, so a
1315 # lateny of 0 for load is correct
1319 state => "exc_pinned",
1320 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1321 ins => [ "base", "index", "mem" ],
1322 outs => [ "res", "M", "X_exc" ],
1324 emit => ". mov%SE%ME%.l %AM, %D0",
1330 state => "exc_pinned",
1331 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1332 ins => [ "base", "index", "mem", "val" ],
1333 outs => [ "M", "X_exc" ],
1334 emit => '. mov%M %SI3, %AM',
1342 state => "exc_pinned",
1343 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1344 ins => [ "base", "index", "mem", "val" ],
1345 outs => [ "M", "X_exc" ],
1346 emit => '. mov%M %SB3, %AM',
1354 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1355 ins => [ "base", "index" ],
1356 emit => '. leal %AM, %D0',
1360 # lea doesn't modify the flags, but setting this seems advantageous since it
1361 # increases chances that the Lea is transformed back to an Add
1362 modified_flags => 1,
1366 state => "exc_pinned",
1367 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1368 ins => [ "base", "index", "mem", "val", "stack" ],
1369 emit => '. push%M %unop3',
1370 outs => [ "stack", "M" ],
1371 am => "source,unary",
1377 state => "exc_pinned",
1378 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1379 ins => [ "mem", "stack" ],
1380 outs => [ "res", "M", "unused", "stack" ],
1381 emit => '. pop%M %D0',
1382 latency => 3, # Pop is more expensive than Push on Athlon
1387 state => "exc_pinned",
1388 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1389 ins => [ "mem", "stack" ],
1390 outs => [ "res", "M", "unused", "stack" ],
1391 emit => '. pop%M %D0',
1392 latency => 3, # Pop is more expensive than Push on Athlon
1397 state => "exc_pinned",
1398 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1399 ins => [ "base", "index", "mem", "stack" ],
1400 outs => [ "unused0", "M", "unused1", "stack" ],
1401 emit => '. pop%M %AM',
1402 latency => 3, # Pop is more expensive than Push on Athlon
1407 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1409 outs => [ "frame", "stack", "M" ],
1415 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1417 outs => [ "frame", "stack" ],
1424 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1425 ins => [ "base", "index", "mem", "stack", "size" ],
1426 am => "source,binary",
1427 emit => '. addl %binop',
1429 outs => [ "stack", "M" ],
1431 modified_flags => $status_flags
1436 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1437 ins => [ "base", "index", "mem", "stack", "size" ],
1438 am => "source,binary",
1439 emit => ". subl %binop\n".
1440 ". movl %%esp, %D1",
1442 outs => [ "stack", "addr", "M" ],
1444 modified_flags => $status_flags
1457 reg_req => { out => [ "gp" ] },
1464 state => "exc_pinned",
1465 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1466 ins => [ "left", "right" ],
1467 emit => '. bt%M %S1, %S0',
1470 mode => $mode_flags,
1471 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1475 state => "exc_pinned",
1477 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1478 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" ]
1480 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1481 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1482 attr_type => "ia32_call_attr_t",
1483 attr => "unsigned pop, ir_type *call_tp",
1484 am => "source,unary",
1485 units => [ "BRANCH" ],
1486 latency => 4, # random number
1487 modified_flags => $status_flags
1490 #-----------------------------------------------------------------------------#
1491 # _____ _____ ______ __ _ _ _ #
1492 # / ____/ ____| ____| / _| | | | | | #
1493 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1494 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1495 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1496 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1497 #-----------------------------------------------------------------------------#
1502 reg_req => { out => [ "xmm" ] },
1503 emit => '. xorp%XSD %D0, %D0',
1511 reg_req => { out => [ "xmm" ] },
1512 emit => '. pxor %D0, %D0',
1518 # produces all 1 bits
1521 reg_req => { out => [ "xmm" ] },
1522 emit => '. pcmpeqb %D0, %D0',
1528 # integer shift left, dword
1531 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1532 emit => '. pslld %SI1, %D0',
1538 # integer shift left, qword
1541 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1542 emit => '. psllq %SI1, %D0',
1548 # integer shift right, dword
1551 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1552 emit => '. psrld %SI1, %D0',
1558 # mov from integer to SSE register
1561 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1562 emit => '. movd %S0, %D0',
1568 # commutative operations
1572 state => "exc_pinned",
1573 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1574 ins => [ "base", "index", "mem", "left", "right" ],
1575 am => "source,binary",
1576 emit => '. add%XXM %binop',
1584 state => "exc_pinned",
1585 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1586 ins => [ "base", "index", "mem", "left", "right" ],
1587 am => "source,binary",
1588 emit => '. mul%XXM %binop',
1596 state => "exc_pinned",
1597 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1598 ins => [ "base", "index", "mem", "left", "right" ],
1599 am => "source,binary",
1600 emit => '. max%XXM %binop',
1608 state => "exc_pinned",
1609 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1610 ins => [ "base", "index", "mem", "left", "right" ],
1611 am => "source,binary",
1612 emit => '. min%XXM %binop',
1620 state => "exc_pinned",
1621 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1622 ins => [ "base", "index", "mem", "left", "right" ],
1623 am => "source,binary",
1624 emit => '. andp%XSD %binop',
1632 state => "exc_pinned",
1633 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1634 ins => [ "base", "index", "mem", "left", "right" ],
1635 am => "source,binary",
1636 emit => '. orp%XSD %binop',
1644 state => "exc_pinned",
1645 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1646 ins => [ "base", "index", "mem", "left", "right" ],
1647 am => "source,binary",
1648 emit => '. xorp%XSD %binop',
1654 # not commutative operations
1658 state => "exc_pinned",
1659 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1660 ins => [ "base", "index", "mem", "left", "right" ],
1661 am => "source,binary",
1662 emit => '. andnp%XSD %binop',
1670 state => "exc_pinned",
1671 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1672 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1673 am => "source,binary",
1674 emit => '. sub%XXM %binop',
1682 state => "exc_pinned",
1683 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1684 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1685 am => "source,binary",
1686 outs => [ "res", "M" ],
1687 emit => '. div%XXM %binop',
1696 state => "exc_pinned",
1697 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1698 ins => [ "base", "index", "mem", "left", "right" ],
1699 outs => [ "flags" ],
1700 am => "source,binary",
1701 attr => "int ins_permuted",
1702 init_attr => "attr->data.ins_permuted = ins_permuted;",
1703 emit => ' .ucomi%XXM %binop',
1706 mode => $mode_flags,
1707 modified_flags => 1,
1714 state => "exc_pinned",
1715 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1716 ins => [ "base", "index", "mem" ],
1717 outs => [ "res", "M", "X_exc" ],
1718 emit => '. mov%XXM %AM, %D0',
1719 attr => "ir_mode *load_mode",
1720 init_attr => "attr->ls_mode = load_mode;",
1727 state => "exc_pinned",
1728 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1729 ins => [ "base", "index", "mem", "val" ],
1730 outs => [ "M", "X_exc" ],
1731 emit => '. mov%XXM %S3, %AM',
1739 state => "exc_pinned",
1740 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1741 ins => [ "base", "index", "mem", "val" ],
1742 emit => '. mov%XXM %S3, %AM',
1750 state => "exc_pinned",
1751 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1752 ins => [ "base", "index", "mem", "val" ],
1753 am => "source,unary",
1754 emit => '. cvtsi2ss %unop3, %D0',
1762 state => "exc_pinned",
1763 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1764 ins => [ "base", "index", "mem", "val" ],
1765 am => "source,unary",
1766 emit => '. cvtsi2sd %unop3, %D0',
1775 cmp_attr => "return 1;",
1776 ins => [ "val_high", "val_low" ],
1781 cmp_attr => "return 1;",
1783 outs => [ "res_high", "res_low" ],
1791 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1792 outs => [ "DST", "SRC", "CNT", "M" ],
1793 attr_type => "ia32_copyb_attr_t",
1794 attr => "unsigned size",
1797 # we don't care about this flag, so no need to mark this node
1798 # modified_flags => [ "DF" ]
1804 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1805 outs => [ "DST", "SRC", "M" ],
1806 attr_type => "ia32_copyb_attr_t",
1807 attr => "unsigned size",
1810 # we don't care about this flag, so no need to mark this node
1811 # modified_flags => [ "DF" ]
1817 state => "exc_pinned",
1818 reg_req => { in => [ "eax" ], out => [ "eax" ] },
1828 state => "exc_pinned",
1829 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1830 ins => [ "base", "index", "mem", "val" ],
1831 outs => [ "res", "M" ],
1832 am => "source,unary",
1835 attr => "ir_mode *smaller_mode",
1836 init_attr => "attr->ls_mode = smaller_mode;",
1841 state => "exc_pinned",
1842 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1843 ins => [ "base", "index", "mem", "val" ],
1844 am => "source,unary",
1847 attr => "ir_mode *smaller_mode",
1848 init_attr => "attr->ls_mode = smaller_mode;",
1853 state => "exc_pinned",
1854 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1855 ins => [ "base", "index", "mem", "val" ],
1856 am => "source,unary",
1863 state => "exc_pinned",
1864 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1865 ins => [ "base", "index", "mem", "val" ],
1866 am => "source,unary",
1873 state => "exc_pinned",
1874 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1875 ins => [ "base", "index", "mem", "val" ],
1876 am => "source,unary",
1882 #----------------------------------------------------------#
1884 # (_) | | | | / _| | | | #
1885 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1886 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1887 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1888 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1890 # _ __ ___ __| | ___ ___ #
1891 # | '_ \ / _ \ / _` |/ _ \/ __| #
1892 # | | | | (_) | (_| | __/\__ \ #
1893 # |_| |_|\___/ \__,_|\___||___/ #
1894 #----------------------------------------------------------#
1896 # rematerialisation disabled for all float nodes for now, because the fpcw
1897 # handler runs before spilling and we might end up with wrong fpcw then
1901 state => "exc_pinned",
1902 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1903 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1904 am => "source,binary",
1908 attr_type => "ia32_x87_attr_t",
1913 state => "exc_pinned",
1914 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1915 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1916 am => "source,binary",
1920 attr_type => "ia32_x87_attr_t",
1925 state => "exc_pinned",
1926 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1927 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1928 am => "source,binary",
1932 attr_type => "ia32_x87_attr_t",
1936 state => "exc_pinned",
1937 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1938 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1939 am => "source,binary",
1940 outs => [ "res", "M" ],
1943 attr_type => "ia32_x87_attr_t",
1947 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1948 ins => [ "left", "right", "fpcw" ],
1952 attr_type => "ia32_x87_attr_t",
1957 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1962 attr_type => "ia32_x87_attr_t",
1967 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1972 attr_type => "ia32_x87_attr_t",
1975 # virtual Load and Store
1980 state => "exc_pinned",
1981 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1982 ins => [ "base", "index", "mem" ],
1983 outs => [ "res", "M", "X_exc" ],
1984 attr => "ir_mode *load_mode",
1985 init_attr => "attr->attr.ls_mode = load_mode;",
1988 attr_type => "ia32_x87_attr_t",
1994 state => "exc_pinned",
1995 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1996 ins => [ "base", "index", "mem", "val" ],
1997 outs => [ "M", "X_exc" ],
1998 attr => "ir_mode *store_mode",
1999 init_attr => "attr->attr.ls_mode = store_mode;",
2003 attr_type => "ia32_x87_attr_t",
2009 state => "exc_pinned",
2010 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
2011 outs => [ "res", "M" ],
2012 ins => [ "base", "index", "mem" ],
2015 attr_type => "ia32_x87_attr_t",
2019 state => "exc_pinned",
2020 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2021 ins => [ "base", "index", "mem", "val", "fpcw" ],
2025 attr_type => "ia32_x87_attr_t",
2028 # SSE3 fisttp instruction
2030 state => "exc_pinned",
2031 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2032 ins => [ "base", "index", "mem", "val" ],
2033 outs => [ "res", "M" ],
2036 attr_type => "ia32_x87_attr_t",
2044 reg_req => { out => [ "vfp" ] },
2049 attr_type => "ia32_x87_attr_t",
2054 reg_req => { out => [ "vfp" ] },
2059 attr_type => "ia32_x87_attr_t",
2064 reg_req => { out => [ "vfp" ] },
2069 attr_type => "ia32_x87_attr_t",
2074 reg_req => { out => [ "vfp" ] },
2079 attr_type => "ia32_x87_attr_t",
2084 reg_req => { out => [ "vfp" ] },
2089 attr_type => "ia32_x87_attr_t",
2094 reg_req => { out => [ "vfp" ] },
2099 attr_type => "ia32_x87_attr_t",
2104 reg_req => { out => [ "vfp" ] },
2109 attr_type => "ia32_x87_attr_t",
2115 # we can't allow to rematerialize this node so we don't have
2116 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2118 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2119 ins => [ "left", "right" ],
2120 outs => [ "flags" ],
2121 attr => "int ins_permuted",
2122 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2125 attr_type => "ia32_x87_attr_t",
2131 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2132 ins => [ "left", "right" ],
2133 outs => [ "flags" ],
2134 attr => "int ins_permuted",
2135 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2138 attr_type => "ia32_x87_attr_t",
2144 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2146 outs => [ "flags" ],
2147 attr => "int ins_permuted",
2148 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2151 attr_type => "ia32_x87_attr_t",
2157 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2159 outs => [ "flags" ],
2163 mode => $mode_flags,
2166 #------------------------------------------------------------------------#
2167 # ___ _____ __ _ _ _ #
2168 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2169 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2170 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2171 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2172 #------------------------------------------------------------------------#
2174 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2175 # are swapped, we work this around in the emitter...
2178 state => "exc_pinned",
2179 rd_constructor => "NONE",
2181 emit => '. fadd%XM %x87_binop',
2183 attr_type => "ia32_x87_attr_t",
2187 state => "exc_pinned",
2188 rd_constructor => "NONE",
2190 emit => '. faddp%XM %x87_binop',
2192 attr_type => "ia32_x87_attr_t",
2196 state => "exc_pinned",
2197 rd_constructor => "NONE",
2199 emit => '. fmul%XM %x87_binop',
2201 attr_type => "ia32_x87_attr_t",
2205 state => "exc_pinned",
2206 rd_constructor => "NONE",
2208 emit => '. fmulp%XM %x87_binop',,
2210 attr_type => "ia32_x87_attr_t",
2214 state => "exc_pinned",
2215 rd_constructor => "NONE",
2217 emit => '. fsub%XM %x87_binop',
2219 attr_type => "ia32_x87_attr_t",
2223 state => "exc_pinned",
2224 rd_constructor => "NONE",
2226 # see note about gas bugs
2227 emit => '. fsubrp%XM %x87_binop',
2229 attr_type => "ia32_x87_attr_t",
2233 state => "exc_pinned",
2234 rd_constructor => "NONE",
2237 emit => '. fsubr%XM %x87_binop',
2239 attr_type => "ia32_x87_attr_t",
2243 state => "exc_pinned",
2244 rd_constructor => "NONE",
2247 # see note about gas bugs
2248 emit => '. fsubp%XM %x87_binop',
2250 attr_type => "ia32_x87_attr_t",
2254 rd_constructor => "NONE",
2258 attr_type => "ia32_x87_attr_t",
2261 # this node is just here, to keep the simulator running
2262 # we can omit this when a fprem simulation function exists
2264 rd_constructor => "NONE",
2266 emit => '. fprem1\n'.
2269 attr_type => "ia32_x87_attr_t",
2273 state => "exc_pinned",
2274 rd_constructor => "NONE",
2276 emit => '. fdiv%XM %x87_binop',
2278 attr_type => "ia32_x87_attr_t",
2282 state => "exc_pinned",
2283 rd_constructor => "NONE",
2285 # see note about gas bugs
2286 emit => '. fdivrp%XM %x87_binop',
2288 attr_type => "ia32_x87_attr_t",
2292 state => "exc_pinned",
2293 rd_constructor => "NONE",
2295 emit => '. fdivr%XM %x87_binop',
2297 attr_type => "ia32_x87_attr_t",
2301 state => "exc_pinned",
2302 rd_constructor => "NONE",
2304 # see note about gas bugs
2305 emit => '. fdivp%XM %x87_binop',
2307 attr_type => "ia32_x87_attr_t",
2311 rd_constructor => "NONE",
2315 attr_type => "ia32_x87_attr_t",
2320 rd_constructor => "NONE",
2324 attr_type => "ia32_x87_attr_t",
2327 # x87 Load and Store
2330 rd_constructor => "NONE",
2331 op_flags => "R|L|F",
2332 state => "exc_pinned",
2334 emit => '. fld%XM %AM',
2335 attr_type => "ia32_x87_attr_t",
2340 rd_constructor => "NONE",
2341 op_flags => "R|L|F",
2342 state => "exc_pinned",
2344 emit => '. fst%XM %AM',
2346 attr_type => "ia32_x87_attr_t",
2351 rd_constructor => "NONE",
2352 op_flags => "R|L|F",
2353 state => "exc_pinned",
2355 emit => '. fstp%XM %AM',
2357 attr_type => "ia32_x87_attr_t",
2364 state => "exc_pinned",
2365 rd_constructor => "NONE",
2367 emit => '. fild%XM %AM',
2368 attr_type => "ia32_x87_attr_t",
2373 state => "exc_pinned",
2374 rd_constructor => "NONE",
2376 emit => '. fist%XM %AM',
2378 attr_type => "ia32_x87_attr_t",
2383 state => "exc_pinned",
2384 rd_constructor => "NONE",
2386 emit => '. fistp%XM %AM',
2388 attr_type => "ia32_x87_attr_t",
2392 # SSE3 firsttp instruction
2394 state => "exc_pinned",
2395 rd_constructor => "NONE",
2397 emit => '. fisttp%XM %AM',
2399 attr_type => "ia32_x87_attr_t",
2406 op_flags => "R|c|K",
2408 reg_req => { out => [ "vfp" ] },
2410 attr_type => "ia32_x87_attr_t",
2415 op_flags => "R|c|K",
2417 reg_req => { out => [ "vfp" ] },
2419 attr_type => "ia32_x87_attr_t",
2424 op_flags => "R|c|K",
2426 reg_req => { out => [ "vfp" ] },
2428 attr_type => "ia32_x87_attr_t",
2433 op_flags => "R|c|K",
2435 reg_req => { out => [ "vfp" ] },
2437 attr_type => "ia32_x87_attr_t",
2442 op_flags => "R|c|K",
2444 reg_req => { out => [ "vfp" ] },
2446 attr_type => "ia32_x87_attr_t",
2451 op_flags => "R|c|K",
2453 reg_req => { out => [ "vfp" ] },
2454 emit => '. fldll2t',
2455 attr_type => "ia32_x87_attr_t",
2460 op_flags => "R|c|K",
2462 reg_req => { out => [ "vfp" ] },
2464 attr_type => "ia32_x87_attr_t",
2469 # Note that it is NEVER allowed to do CSE on these nodes
2470 # Moreover, note the virtual register requierements!
2475 cmp_attr => "return 1;",
2476 emit => '. fxch %X0',
2477 attr_type => "ia32_x87_attr_t",
2485 cmp_attr => "return 1;",
2486 emit => '. fld %X0',
2487 attr_type => "ia32_x87_attr_t",
2493 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2494 cmp_attr => "return 1;",
2495 emit => '. fld %X0',
2496 attr_type => "ia32_x87_attr_t",
2503 cmp_attr => "return 1;",
2504 emit => '. fstp %X0',
2505 attr_type => "ia32_x87_attr_t",
2513 cmp_attr => "return 1;",
2514 emit => '. ffreep %X0',
2515 attr_type => "ia32_x87_attr_t",
2523 cmp_attr => "return 1;",
2525 attr_type => "ia32_x87_attr_t",
2533 cmp_attr => "return 1;",
2535 attr_type => "ia32_x87_attr_t",
2544 emit => ". fucom %X1\n".
2546 attr_type => "ia32_x87_attr_t",
2552 emit => ". fucomp %X1\n".
2554 attr_type => "ia32_x87_attr_t",
2560 emit => ". fucompp\n".
2562 attr_type => "ia32_x87_attr_t",
2568 emit => '. fucomi %X1',
2569 attr_type => "ia32_x87_attr_t",
2575 emit => '. fucompi %X1',
2576 attr_type => "ia32_x87_attr_t",
2584 attr_type => "ia32_x87_attr_t",
2589 # -------------------------------------------------------------------------------- #
2590 # ____ ____ _____ _ _ #
2591 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2592 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2593 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2594 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2596 # -------------------------------------------------------------------------------- #
2599 # Spilling and reloading of SSE registers, hardcoded, not generated #
2603 state => "exc_pinned",
2604 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2605 emit => '. movdqu %D0, %AM',
2606 outs => [ "res", "M" ],
2613 state => "exc_pinned",
2614 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2615 ins => [ "base", "index", "mem", "val" ],
2616 emit => '. movdqu %binop',
2624 # Include the generated SIMD node specification written by the SIMD optimization
2625 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2626 unless ($return = do $my_script_name) {
2627 warn "couldn't parse $my_script_name: $@" if $@;
2628 warn "couldn't do $my_script_name: $!" unless defined $return;
2629 warn "couldn't run $my_script_name" unless $return;
2632 # Transform some attributes
2633 foreach my $op (keys(%nodes)) {
2634 my $node = $nodes{$op};
2635 my $op_attr_init = $node->{op_attr_init};
2637 if(defined($op_attr_init)) {
2638 $op_attr_init .= "\n\t";
2643 if(!defined($node->{latency})) {
2645 $node->{latency} = 0;
2647 die("Latency missing for op $op");
2650 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2652 $node->{op_attr_init} = $op_attr_init;