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 => "attitional 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 # "allocates" a free register
346 reg_req => { out => [ "gp" ] },
351 cmp_attr => "return 1;",
354 #-----------------------------------------------------------------#
357 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
358 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
359 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
360 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
363 #-----------------------------------------------------------------#
365 # commutative operations
369 state => "exc_pinned",
370 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
371 out => [ "in_r4 in_r5", "flags", "none" ] },
372 ins => [ "base", "index", "mem", "left", "right" ],
373 outs => [ "res", "flags", "M" ],
374 emit => '. add%M %binop',
375 am => "source,binary",
379 modified_flags => $status_flags
384 state => "exc_pinned",
385 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
386 ins => [ "base", "index", "mem", "val" ],
387 emit => ". add%M %SI3, %AM",
391 modified_flags => $status_flags
396 state => "exc_pinned",
397 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
398 ins => [ "base", "index", "mem", "val" ],
399 emit => ". add%M %SB3, %AM",
403 modified_flags => $status_flags
407 state => "exc_pinned",
408 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
409 out => [ "in_r4 in_r5", "flags", "none" ] },
410 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
411 outs => [ "res", "flags", "M" ],
412 emit => '. adc%M %binop',
413 am => "source,binary",
417 modified_flags => $status_flags
422 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
423 ins => [ "left", "right" ],
427 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
428 ins => [ "left", "right", "eflags" ],
432 # we should not rematrialize this node. It produces 2 results and has
433 # very strict constraints
434 state => "exc_pinned",
435 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
436 out => [ "eax", "flags", "edx", "none" ] },
437 ins => [ "base", "index", "mem", "left", "right" ],
438 emit => '. mul%M %unop4',
439 outs => [ "res_low", "flags", "res_high", "M" ],
440 am => "source,binary",
443 modified_flags => $status_flags
447 # we should not rematrialize this node. It produces 2 results and has
448 # very strict constraints
450 cmp_attr => "return 1;",
451 outs => [ "EAX", "flags", "EDX", "M" ],
457 state => "exc_pinned",
458 # TODO: adjust out requirements for the 3 operand form
459 # (no need for should_be_same then)
460 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
461 out => [ "in_r4 in_r5", "flags", "none" ] },
462 ins => [ "base", "index", "mem", "left", "right" ],
463 outs => [ "res", "flags", "M" ],
464 am => "source,binary",
468 modified_flags => $status_flags
473 state => "exc_pinned",
474 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
475 out => [ "eax", "flags", "edx", "none" ] },
476 ins => [ "base", "index", "mem", "left", "right" ],
477 emit => '. imul%M %unop4',
478 outs => [ "res_low", "flags", "res_high", "M" ],
479 am => "source,binary",
482 modified_flags => $status_flags
487 cmp_attr => "return 1;",
488 outs => [ "res_low", "res_high", "M" ],
494 state => "exc_pinned",
495 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
496 out => [ "in_r4 in_r5", "flags", "none" ] },
497 ins => [ "base", "index", "mem", "left", "right" ],
498 outs => [ "res", "flags", "M" ],
499 op_modes => "commutative | am | immediate | mode_neutral",
500 am => "source,binary",
501 emit => '. and%M %binop',
505 modified_flags => $status_flags
510 state => "exc_pinned",
511 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
512 ins => [ "base", "index", "mem", "val" ],
513 emit => '. and%M %SI3, %AM',
517 modified_flags => $status_flags
522 state => "exc_pinned",
523 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
524 ins => [ "base", "index", "mem", "val" ],
525 emit => '. and%M %SB3, %AM',
529 modified_flags => $status_flags
534 state => "exc_pinned",
535 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
536 out => [ "in_r4 in_r5", "flags", "none" ] },
537 ins => [ "base", "index", "mem", "left", "right" ],
538 outs => [ "res", "flags", "M" ],
539 am => "source,binary",
540 emit => '. or%M %binop',
544 modified_flags => $status_flags
549 state => "exc_pinned",
550 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
551 ins => [ "base", "index", "mem", "val" ],
552 emit => '. or%M %SI3, %AM',
556 modified_flags => $status_flags
561 state => "exc_pinned",
562 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
563 ins => [ "base", "index", "mem", "val" ],
564 emit => '. or%M %SB3, %AM',
568 modified_flags => $status_flags
573 state => "exc_pinned",
574 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
575 out => [ "in_r4 in_r5", "flags", "none" ] },
576 ins => [ "base", "index", "mem", "left", "right" ],
577 outs => [ "res", "flags", "M" ],
578 am => "source,binary",
579 emit => '. xor%M %binop',
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
666 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
667 ins => [ "minuend", "subtrahend" ],
671 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
672 ins => [ "minuend", "subtrahend", "eflags" ],
677 state => "exc_pinned",
678 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
679 out => [ "eax", "flags", "none", "edx", "none" ] },
680 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
681 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
682 am => "source,unary",
683 emit => ". idiv%M %unop3",
686 modified_flags => $status_flags
691 state => "exc_pinned",
692 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
693 out => [ "eax", "flags", "none", "edx", "none" ] },
694 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
695 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
696 am => "source,unary",
697 emit => ". div%M %unop3",
700 modified_flags => $status_flags
705 reg_req => { in => [ "gp", "ecx" ],
706 out => [ "in_r1 !in_r2", "flags" ] },
707 ins => [ "val", "count" ],
708 outs => [ "res", "flags" ],
709 emit => '. shl %SB1, %S0',
713 modified_flags => $status_flags
718 state => "exc_pinned",
719 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
720 ins => [ "base", "index", "mem", "count" ],
721 emit => '. shl%M %SB3, %AM',
725 modified_flags => $status_flags
729 cmp_attr => "return 1;",
730 ins => [ "val", "count", "dep" ],
736 reg_req => { in => [ "gp", "gp", "ecx" ],
737 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
738 ins => [ "val_high", "val_low", "count" ],
739 outs => [ "res", "flags" ],
740 emit => ". shld%M %SB2, %S1, %D0",
744 modified_flags => $status_flags
748 cmp_attr => "return 1;",
749 ins => [ "val_high", "val_low", "count" ],
755 reg_req => { in => [ "gp", "ecx" ],
756 out => [ "in_r1 !in_r2", "flags" ] },
757 ins => [ "val", "count" ],
758 outs => [ "res", "flags" ],
759 emit => '. shr %SB1, %S0',
763 modified_flags => $status_flags
768 state => "exc_pinned",
769 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
770 ins => [ "base", "index", "mem", "count" ],
771 emit => '. shr%M %SB3, %AM',
775 modified_flags => $status_flags
779 cmp_attr => "return 1;",
780 ins => [ "val", "count", "dep" ],
786 reg_req => { in => [ "gp", "gp", "ecx" ],
787 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
788 ins => [ "val_high", "val_low", "count" ],
789 outs => [ "res", "flags" ],
790 emit => ". shrd%M %SB2, %S1, %D0",
794 modified_flags => $status_flags
798 cmp_attr => "return 1;",
800 ins => [ "val_high", "val_low", "count" ],
805 reg_req => { in => [ "gp", "ecx" ],
806 out => [ "in_r1 !in_r2", "flags" ] },
807 ins => [ "val", "count" ],
808 outs => [ "res", "flags" ],
809 emit => '. sar %SB1, %S0',
813 modified_flags => $status_flags
818 state => "exc_pinned",
819 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
820 ins => [ "base", "index", "mem", "count" ],
821 emit => '. sar%M %SB3, %AM',
825 modified_flags => $status_flags
829 cmp_attr => "return 1;",
830 ins => [ "val", "count", "dep" ],
836 reg_req => { in => [ "gp", "ecx" ],
837 out => [ "in_r1 !in_r2", "flags" ] },
838 ins => [ "val", "count" ],
839 outs => [ "res", "flags" ],
840 emit => '. ror %SB1, %S0',
844 modified_flags => $status_flags
849 state => "exc_pinned",
850 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
851 ins => [ "base", "index", "mem", "count" ],
852 emit => '. ror%M %SB3, %AM',
856 modified_flags => $status_flags
861 reg_req => { in => [ "gp", "ecx" ],
862 out => [ "in_r1 !in_r2", "flags" ] },
863 ins => [ "val", "count" ],
864 outs => [ "res", "flags" ],
865 emit => '. rol %SB1, %S0',
869 modified_flags => $status_flags
874 state => "exc_pinned",
875 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
876 ins => [ "base", "index", "mem", "count" ],
877 emit => '. rol%M %SB3, %AM',
881 modified_flags => $status_flags
888 reg_req => { in => [ "gp" ],
889 out => [ "in_r1", "flags" ] },
892 outs => [ "res", "flags" ],
896 modified_flags => $status_flags
901 state => "exc_pinned",
902 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
903 ins => [ "base", "index", "mem" ],
904 emit => '. neg%M %AM',
908 modified_flags => $status_flags
913 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
914 outs => [ "low_res", "high_res" ],
917 modified_flags => $status_flags
923 reg_req => { in => [ "gp" ],
924 out => [ "in_r1", "flags" ] },
926 outs => [ "res", "flags" ],
931 modified_flags => $status_flags_wo_cf
936 state => "exc_pinned",
937 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
938 ins => [ "base", "index", "mem" ],
939 emit => '. inc%M %AM',
943 modified_flags => $status_flags_wo_cf
948 reg_req => { in => [ "gp" ],
949 out => [ "in_r1", "flags" ] },
951 outs => [ "res", "flags" ],
956 modified_flags => $status_flags_wo_cf
961 state => "exc_pinned",
962 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
963 ins => [ "base", "index", "mem" ],
964 emit => '. dec%M %AM',
968 modified_flags => $status_flags_wo_cf
973 reg_req => { in => [ "gp" ],
974 out => [ "in_r1", "flags" ] },
976 outs => [ "res", "flags" ],
986 state => "exc_pinned",
987 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
988 ins => [ "base", "index", "mem" ],
989 emit => '. not%M %AM',
997 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1001 mode => $mode_flags,
1002 modified_flags => $status_flags
1006 reg_req => { out => [ "flags" ] },
1010 mode => $mode_flags,
1011 modified_flags => $status_flags
1018 state => "exc_pinned",
1019 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1020 out => [ "flags", "none", "none" ] },
1021 ins => [ "base", "index", "mem", "left", "right" ],
1022 outs => [ "eflags", "unused", "M" ],
1023 am => "source,binary",
1024 emit => '. cmp%M %binop',
1025 attr => "int ins_permuted, int cmp_unsigned",
1026 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1027 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1030 mode => $mode_flags,
1031 modified_flags => $status_flags
1036 state => "exc_pinned",
1037 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1038 ins => [ "base", "index", "mem", "left", "right" ],
1039 outs => [ "eflags" ],
1040 am => "source,binary",
1041 emit => '. cmpb %binop',
1042 attr => "int ins_permuted, int cmp_unsigned",
1043 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1044 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1047 mode => $mode_flags,
1048 modified_flags => $status_flags
1053 state => "exc_pinned",
1054 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1055 ins => [ "base", "index", "mem", "left", "right" ],
1056 outs => [ "eflags" ],
1057 am => "source,binary",
1058 emit => '. test%M %binop',
1059 attr => "int ins_permuted, int cmp_unsigned",
1060 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1061 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1064 mode => $mode_flags,
1065 modified_flags => $status_flags
1070 state => "exc_pinned",
1071 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1072 ins => [ "base", "index", "mem", "left", "right" ],
1073 outs => [ "eflags" ],
1074 am => "source,binary",
1075 emit => '. testb %binop',
1076 attr => "int ins_permuted, int cmp_unsigned",
1077 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1078 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1081 mode => $mode_flags,
1082 modified_flags => $status_flags
1087 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1088 ins => [ "eflags" ],
1089 attr_type => "ia32_condcode_attr_t",
1090 attr => "pn_Cmp pnc, int ins_permuted",
1091 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1092 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1093 emit => '. set%CMP0 %DB0',
1101 state => "exc_pinned",
1102 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1103 ins => [ "base", "index", "mem","eflags" ],
1104 attr_type => "ia32_condcode_attr_t",
1105 attr => "pn_Cmp pnc, int ins_permuted",
1106 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1107 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1108 emit => '. set%CMP3 %AM',
1116 # (note: leave the false,true order intact to make it compatible with other
1118 state => "exc_pinned",
1119 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1120 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1121 am => "source,binary",
1122 attr_type => "ia32_condcode_attr_t",
1123 attr => "int ins_permuted, pn_Cmp pnc",
1124 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1132 op_flags => "L|X|Y",
1133 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1134 ins => [ "eflags" ],
1135 outs => [ "false", "true" ],
1136 attr_type => "ia32_condcode_attr_t",
1137 attr => "pn_Cmp pnc",
1139 units => [ "BRANCH" ],
1144 op_flags => "L|X|Y",
1145 reg_req => { in => [ "gp" ], out => [ "none" ] },
1147 attr_type => "ia32_condcode_attr_t",
1150 units => [ "BRANCH" ],
1151 modified_flags => $status_flags,
1157 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1158 ins => [ "base", "index", "mem", "target" ],
1159 am => "source,unary",
1160 emit => '. jmp *%unop3',
1162 units => [ "BRANCH" ],
1169 reg_req => { out => [ "gp" ] },
1171 attr => "ir_entity *symconst, int symconst_sign, long offset",
1172 attr_type => "ia32_immediate_attr_t",
1179 reg_req => { out => [ "gp" ] },
1183 modified_flags => $status_flags,
1189 reg_req => { out => [ "gp_UKNWN:I" ] },
1199 reg_req => { out => [ "vfp_UKNWN:I" ] },
1204 attr_type => "ia32_x87_attr_t",
1210 reg_req => { out => [ "xmm_UKNWN:I" ] },
1219 op_flags => "c|NB|NI",
1220 reg_req => { out => [ "gp_NOREG:I" ] },
1229 op_flags => "c|NB|NI",
1230 reg_req => { out => [ "vfp_NOREG:I" ] },
1235 attr_type => "ia32_x87_attr_t",
1240 op_flags => "c|NB|NI",
1241 reg_req => { out => [ "xmm_NOREG:I" ] },
1251 reg_req => { out => [ "fpcw:I" ] },
1255 modified_flags => $fpcw_flags
1261 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1262 ins => [ "base", "index", "mem" ],
1264 emit => ". fldcw %AM",
1267 modified_flags => $fpcw_flags
1273 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1274 ins => [ "base", "index", "mem", "fpcw" ],
1276 emit => ". fnstcw %AM",
1284 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1292 # we should not rematrialize this node. It has very strict constraints.
1293 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1294 ins => [ "val", "clobbered" ],
1303 # Note that we add additional latency values depending on address mode, so a
1304 # lateny of 0 for load is correct
1308 state => "exc_pinned",
1309 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1310 ins => [ "base", "index", "mem" ],
1311 outs => [ "res", "M", "X_exc" ],
1313 emit => ". mov%SE%ME%.l %AM, %D0",
1319 state => "exc_pinned",
1320 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1321 ins => [ "base", "index", "mem", "val" ],
1322 outs => [ "M", "X_exc" ],
1323 emit => '. mov%M %SI3, %AM',
1331 state => "exc_pinned",
1332 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1333 ins => [ "base", "index", "mem", "val" ],
1334 outs => [ "M", "X_exc" ],
1335 emit => '. mov%M %SB3, %AM',
1343 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1344 ins => [ "base", "index" ],
1345 emit => '. leal %AM, %D0',
1349 # lea doesn't modify the flags, but setting this seems advantageous since it
1350 # increases chances that the Lea is transformed back to an Add
1351 modified_flags => 1,
1355 state => "exc_pinned",
1356 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1357 ins => [ "base", "index", "mem", "val", "stack" ],
1358 emit => '. push%M %unop3',
1359 outs => [ "stack", "M" ],
1360 am => "source,unary",
1366 state => "exc_pinned",
1367 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1368 ins => [ "mem", "stack" ],
1369 outs => [ "res", "M", "unused", "stack" ],
1370 emit => '. pop%M %D0',
1371 latency => 3, # Pop is more expensive than Push on Athlon
1376 state => "exc_pinned",
1377 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1378 ins => [ "mem", "stack" ],
1379 outs => [ "res", "M", "unused", "stack" ],
1380 emit => '. pop%M %D0',
1381 latency => 3, # Pop is more expensive than Push on Athlon
1386 state => "exc_pinned",
1387 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1388 ins => [ "base", "index", "mem", "stack" ],
1389 outs => [ "unused0", "M", "unused1", "stack" ],
1390 emit => '. pop%M %AM',
1391 latency => 3, # Pop is more expensive than Push on Athlon
1396 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1398 outs => [ "frame", "stack", "M" ],
1404 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1406 outs => [ "frame", "stack" ],
1413 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1414 ins => [ "base", "index", "mem", "stack", "size" ],
1415 am => "source,binary",
1416 emit => '. addl %binop',
1418 outs => [ "stack", "M" ],
1420 modified_flags => $status_flags
1425 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1426 ins => [ "base", "index", "mem", "stack", "size" ],
1427 am => "source,binary",
1428 emit => ". subl %binop\n".
1429 ". movl %%esp, %D1",
1431 outs => [ "stack", "addr", "M" ],
1433 modified_flags => $status_flags
1446 reg_req => { out => [ "gp" ] },
1453 state => "exc_pinned",
1454 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1455 ins => [ "left", "right" ],
1456 emit => '. bt%M %S1, %S0',
1459 mode => $mode_flags,
1460 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1464 state => "exc_pinned",
1466 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1467 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" ]
1469 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1470 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1471 attr_type => "ia32_call_attr_t",
1472 attr => "unsigned pop, ir_type *call_tp",
1473 am => "source,unary",
1474 units => [ "BRANCH" ],
1475 latency => 4, # random number
1476 modified_flags => $status_flags
1479 #-----------------------------------------------------------------------------#
1480 # _____ _____ ______ __ _ _ _ #
1481 # / ____/ ____| ____| / _| | | | | | #
1482 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1483 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1484 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1485 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1486 #-----------------------------------------------------------------------------#
1491 reg_req => { out => [ "xmm" ] },
1492 emit => '. xorp%XSD %D0, %D0',
1500 reg_req => { out => [ "xmm" ] },
1501 emit => '. pxor %D0, %D0',
1507 # produces all 1 bits
1510 reg_req => { out => [ "xmm" ] },
1511 emit => '. pcmpeqb %D0, %D0',
1517 # integer shift left, dword
1520 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1521 emit => '. pslld %SI1, %D0',
1527 # integer shift left, qword
1530 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1531 emit => '. psllq %SI1, %D0',
1537 # integer shift right, dword
1540 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1541 emit => '. psrld %SI1, %D0',
1547 # mov from integer to SSE register
1550 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1551 emit => '. movd %S0, %D0',
1557 # commutative operations
1561 state => "exc_pinned",
1562 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1563 ins => [ "base", "index", "mem", "left", "right" ],
1564 am => "source,binary",
1565 emit => '. add%XXM %binop',
1573 state => "exc_pinned",
1574 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1575 ins => [ "base", "index", "mem", "left", "right" ],
1576 am => "source,binary",
1577 emit => '. mul%XXM %binop',
1585 state => "exc_pinned",
1586 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1587 ins => [ "base", "index", "mem", "left", "right" ],
1588 am => "source,binary",
1589 emit => '. max%XXM %binop',
1597 state => "exc_pinned",
1598 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1599 ins => [ "base", "index", "mem", "left", "right" ],
1600 am => "source,binary",
1601 emit => '. min%XXM %binop',
1609 state => "exc_pinned",
1610 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1611 ins => [ "base", "index", "mem", "left", "right" ],
1612 am => "source,binary",
1613 emit => '. andp%XSD %binop',
1621 state => "exc_pinned",
1622 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1623 ins => [ "base", "index", "mem", "left", "right" ],
1624 am => "source,binary",
1625 emit => '. orp%XSD %binop',
1633 state => "exc_pinned",
1634 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1635 ins => [ "base", "index", "mem", "left", "right" ],
1636 am => "source,binary",
1637 emit => '. xorp%XSD %binop',
1643 # not commutative operations
1647 state => "exc_pinned",
1648 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1649 ins => [ "base", "index", "mem", "left", "right" ],
1650 am => "source,binary",
1651 emit => '. andnp%XSD %binop',
1659 state => "exc_pinned",
1660 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1661 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1662 am => "source,binary",
1663 emit => '. sub%XXM %binop',
1671 state => "exc_pinned",
1672 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1673 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1674 am => "source,binary",
1675 outs => [ "res", "M" ],
1676 emit => '. div%XXM %binop',
1685 state => "exc_pinned",
1686 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1687 ins => [ "base", "index", "mem", "left", "right" ],
1688 outs => [ "flags" ],
1689 am => "source,binary",
1690 attr => "int ins_permuted",
1691 init_attr => "attr->data.ins_permuted = ins_permuted;",
1692 emit => ' .ucomi%XXM %binop',
1695 mode => $mode_flags,
1696 modified_flags => 1,
1703 state => "exc_pinned",
1704 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1705 ins => [ "base", "index", "mem" ],
1706 outs => [ "res", "M", "X_exc" ],
1707 emit => '. mov%XXM %AM, %D0',
1708 attr => "ir_mode *load_mode",
1709 init_attr => "attr->ls_mode = load_mode;",
1716 state => "exc_pinned",
1717 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1718 ins => [ "base", "index", "mem", "val" ],
1719 outs => [ "M", "X_exc" ],
1720 emit => '. mov%XXM %S3, %AM',
1728 state => "exc_pinned",
1729 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1730 ins => [ "base", "index", "mem", "val" ],
1731 emit => '. mov%XXM %S3, %AM',
1739 state => "exc_pinned",
1740 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1741 ins => [ "base", "index", "mem", "val" ],
1742 am => "source,unary",
1743 emit => '. cvtsi2ss %unop3, %D0',
1751 state => "exc_pinned",
1752 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1753 ins => [ "base", "index", "mem", "val" ],
1754 am => "source,unary",
1755 emit => '. cvtsi2sd %unop3, %D0',
1764 cmp_attr => "return 1;",
1765 ins => [ "val_high", "val_low" ],
1770 cmp_attr => "return 1;",
1772 outs => [ "res_high", "res_low" ],
1780 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1781 outs => [ "DST", "SRC", "CNT", "M" ],
1782 attr_type => "ia32_copyb_attr_t",
1783 attr => "unsigned size",
1786 # we don't care about this flag, so no need to mark this node
1787 # modified_flags => [ "DF" ]
1793 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1794 outs => [ "DST", "SRC", "M" ],
1795 attr_type => "ia32_copyb_attr_t",
1796 attr => "unsigned size",
1799 # we don't care about this flag, so no need to mark this node
1800 # modified_flags => [ "DF" ]
1806 state => "exc_pinned",
1807 reg_req => { in => [ "eax" ], out => [ "eax" ] },
1817 state => "exc_pinned",
1818 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1819 ins => [ "base", "index", "mem", "val" ],
1820 outs => [ "res", "M" ],
1821 am => "source,unary",
1824 attr => "ir_mode *smaller_mode",
1825 init_attr => "attr->ls_mode = smaller_mode;",
1830 state => "exc_pinned",
1831 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1832 ins => [ "base", "index", "mem", "val" ],
1833 am => "source,unary",
1836 attr => "ir_mode *smaller_mode",
1837 init_attr => "attr->ls_mode = smaller_mode;",
1842 state => "exc_pinned",
1843 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1844 ins => [ "base", "index", "mem", "val" ],
1845 am => "source,unary",
1852 state => "exc_pinned",
1853 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1854 ins => [ "base", "index", "mem", "val" ],
1855 am => "source,unary",
1862 state => "exc_pinned",
1863 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1864 ins => [ "base", "index", "mem", "val" ],
1865 am => "source,unary",
1871 #----------------------------------------------------------#
1873 # (_) | | | | / _| | | | #
1874 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1875 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1876 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1877 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1879 # _ __ ___ __| | ___ ___ #
1880 # | '_ \ / _ \ / _` |/ _ \/ __| #
1881 # | | | | (_) | (_| | __/\__ \ #
1882 # |_| |_|\___/ \__,_|\___||___/ #
1883 #----------------------------------------------------------#
1885 # rematerialisation disabled for all float nodes for now, because the fpcw
1886 # handler runs before spilling and we might end up with wrong fpcw then
1890 state => "exc_pinned",
1891 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1892 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1893 am => "source,binary",
1897 attr_type => "ia32_x87_attr_t",
1902 state => "exc_pinned",
1903 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1904 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1905 am => "source,binary",
1909 attr_type => "ia32_x87_attr_t",
1914 state => "exc_pinned",
1915 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1916 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1917 am => "source,binary",
1921 attr_type => "ia32_x87_attr_t",
1925 state => "exc_pinned",
1926 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1927 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1928 am => "source,binary",
1929 outs => [ "res", "M" ],
1932 attr_type => "ia32_x87_attr_t",
1936 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1937 ins => [ "left", "right", "fpcw" ],
1941 attr_type => "ia32_x87_attr_t",
1946 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1951 attr_type => "ia32_x87_attr_t",
1956 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1961 attr_type => "ia32_x87_attr_t",
1964 # virtual Load and Store
1969 state => "exc_pinned",
1970 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1971 ins => [ "base", "index", "mem" ],
1972 outs => [ "res", "M", "X_exc" ],
1973 attr => "ir_mode *load_mode",
1974 init_attr => "attr->attr.ls_mode = load_mode;",
1977 attr_type => "ia32_x87_attr_t",
1983 state => "exc_pinned",
1984 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1985 ins => [ "base", "index", "mem", "val" ],
1986 outs => [ "M", "X_exc" ],
1987 attr => "ir_mode *store_mode",
1988 init_attr => "attr->attr.ls_mode = store_mode;",
1992 attr_type => "ia32_x87_attr_t",
1998 state => "exc_pinned",
1999 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
2000 outs => [ "res", "M" ],
2001 ins => [ "base", "index", "mem" ],
2004 attr_type => "ia32_x87_attr_t",
2008 state => "exc_pinned",
2009 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2010 ins => [ "base", "index", "mem", "val", "fpcw" ],
2014 attr_type => "ia32_x87_attr_t",
2017 # SSE3 fisttp instruction
2019 state => "exc_pinned",
2020 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2021 ins => [ "base", "index", "mem", "val" ],
2022 outs => [ "res", "M" ],
2025 attr_type => "ia32_x87_attr_t",
2033 reg_req => { out => [ "vfp" ] },
2038 attr_type => "ia32_x87_attr_t",
2043 reg_req => { out => [ "vfp" ] },
2048 attr_type => "ia32_x87_attr_t",
2053 reg_req => { out => [ "vfp" ] },
2058 attr_type => "ia32_x87_attr_t",
2063 reg_req => { out => [ "vfp" ] },
2068 attr_type => "ia32_x87_attr_t",
2073 reg_req => { out => [ "vfp" ] },
2078 attr_type => "ia32_x87_attr_t",
2083 reg_req => { out => [ "vfp" ] },
2088 attr_type => "ia32_x87_attr_t",
2093 reg_req => { out => [ "vfp" ] },
2098 attr_type => "ia32_x87_attr_t",
2104 # we can't allow to rematerialize this node so we don't have
2105 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2107 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2108 ins => [ "left", "right" ],
2109 outs => [ "flags" ],
2110 attr => "int ins_permuted",
2111 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2114 attr_type => "ia32_x87_attr_t",
2120 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2121 ins => [ "left", "right" ],
2122 outs => [ "flags" ],
2123 attr => "int ins_permuted",
2124 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2127 attr_type => "ia32_x87_attr_t",
2133 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2135 outs => [ "flags" ],
2136 attr => "int ins_permuted",
2137 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2140 attr_type => "ia32_x87_attr_t",
2146 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2148 outs => [ "flags" ],
2152 mode => $mode_flags,
2155 #------------------------------------------------------------------------#
2156 # ___ _____ __ _ _ _ #
2157 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2158 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2159 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2160 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2161 #------------------------------------------------------------------------#
2163 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2164 # are swapped, we work this around in the emitter...
2167 state => "exc_pinned",
2168 rd_constructor => "NONE",
2170 emit => '. fadd%XM %x87_binop',
2172 attr_type => "ia32_x87_attr_t",
2176 state => "exc_pinned",
2177 rd_constructor => "NONE",
2179 emit => '. faddp%XM %x87_binop',
2181 attr_type => "ia32_x87_attr_t",
2185 state => "exc_pinned",
2186 rd_constructor => "NONE",
2188 emit => '. fmul%XM %x87_binop',
2190 attr_type => "ia32_x87_attr_t",
2194 state => "exc_pinned",
2195 rd_constructor => "NONE",
2197 emit => '. fmulp%XM %x87_binop',,
2199 attr_type => "ia32_x87_attr_t",
2203 state => "exc_pinned",
2204 rd_constructor => "NONE",
2206 emit => '. fsub%XM %x87_binop',
2208 attr_type => "ia32_x87_attr_t",
2212 state => "exc_pinned",
2213 rd_constructor => "NONE",
2215 # see note about gas bugs
2216 emit => '. fsubrp%XM %x87_binop',
2218 attr_type => "ia32_x87_attr_t",
2222 state => "exc_pinned",
2223 rd_constructor => "NONE",
2226 emit => '. fsubr%XM %x87_binop',
2228 attr_type => "ia32_x87_attr_t",
2232 state => "exc_pinned",
2233 rd_constructor => "NONE",
2236 # see note about gas bugs
2237 emit => '. fsubp%XM %x87_binop',
2239 attr_type => "ia32_x87_attr_t",
2243 rd_constructor => "NONE",
2247 attr_type => "ia32_x87_attr_t",
2250 # this node is just here, to keep the simulator running
2251 # we can omit this when a fprem simulation function exists
2253 rd_constructor => "NONE",
2255 emit => '. fprem1\n'.
2258 attr_type => "ia32_x87_attr_t",
2262 state => "exc_pinned",
2263 rd_constructor => "NONE",
2265 emit => '. fdiv%XM %x87_binop',
2267 attr_type => "ia32_x87_attr_t",
2271 state => "exc_pinned",
2272 rd_constructor => "NONE",
2274 # see note about gas bugs
2275 emit => '. fdivrp%XM %x87_binop',
2277 attr_type => "ia32_x87_attr_t",
2281 state => "exc_pinned",
2282 rd_constructor => "NONE",
2284 emit => '. fdivr%XM %x87_binop',
2286 attr_type => "ia32_x87_attr_t",
2290 state => "exc_pinned",
2291 rd_constructor => "NONE",
2293 # see note about gas bugs
2294 emit => '. fdivp%XM %x87_binop',
2296 attr_type => "ia32_x87_attr_t",
2300 rd_constructor => "NONE",
2304 attr_type => "ia32_x87_attr_t",
2309 rd_constructor => "NONE",
2313 attr_type => "ia32_x87_attr_t",
2316 # x87 Load and Store
2319 rd_constructor => "NONE",
2320 op_flags => "R|L|F",
2321 state => "exc_pinned",
2323 emit => '. fld%XM %AM',
2324 attr_type => "ia32_x87_attr_t",
2329 rd_constructor => "NONE",
2330 op_flags => "R|L|F",
2331 state => "exc_pinned",
2333 emit => '. fst%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 => '. fstp%XM %AM',
2346 attr_type => "ia32_x87_attr_t",
2353 state => "exc_pinned",
2354 rd_constructor => "NONE",
2356 emit => '. fild%XM %AM',
2357 attr_type => "ia32_x87_attr_t",
2362 state => "exc_pinned",
2363 rd_constructor => "NONE",
2365 emit => '. fist%XM %AM',
2367 attr_type => "ia32_x87_attr_t",
2372 state => "exc_pinned",
2373 rd_constructor => "NONE",
2375 emit => '. fistp%XM %AM',
2377 attr_type => "ia32_x87_attr_t",
2381 # SSE3 firsttp instruction
2383 state => "exc_pinned",
2384 rd_constructor => "NONE",
2386 emit => '. fisttp%XM %AM',
2388 attr_type => "ia32_x87_attr_t",
2395 op_flags => "R|c|K",
2397 reg_req => { out => [ "vfp" ] },
2399 attr_type => "ia32_x87_attr_t",
2404 op_flags => "R|c|K",
2406 reg_req => { out => [ "vfp" ] },
2408 attr_type => "ia32_x87_attr_t",
2413 op_flags => "R|c|K",
2415 reg_req => { out => [ "vfp" ] },
2417 attr_type => "ia32_x87_attr_t",
2422 op_flags => "R|c|K",
2424 reg_req => { out => [ "vfp" ] },
2426 attr_type => "ia32_x87_attr_t",
2431 op_flags => "R|c|K",
2433 reg_req => { out => [ "vfp" ] },
2435 attr_type => "ia32_x87_attr_t",
2440 op_flags => "R|c|K",
2442 reg_req => { out => [ "vfp" ] },
2443 emit => '. fldll2t',
2444 attr_type => "ia32_x87_attr_t",
2449 op_flags => "R|c|K",
2451 reg_req => { out => [ "vfp" ] },
2453 attr_type => "ia32_x87_attr_t",
2458 # Note that it is NEVER allowed to do CSE on these nodes
2459 # Moreover, note the virtual register requierements!
2464 cmp_attr => "return 1;",
2465 emit => '. fxch %X0',
2466 attr_type => "ia32_x87_attr_t",
2474 cmp_attr => "return 1;",
2475 emit => '. fld %X0',
2476 attr_type => "ia32_x87_attr_t",
2482 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2483 cmp_attr => "return 1;",
2484 emit => '. fld %X0',
2485 attr_type => "ia32_x87_attr_t",
2492 cmp_attr => "return 1;",
2493 emit => '. fstp %X0',
2494 attr_type => "ia32_x87_attr_t",
2502 cmp_attr => "return 1;",
2503 emit => '. ffreep %X0',
2504 attr_type => "ia32_x87_attr_t",
2512 cmp_attr => "return 1;",
2514 attr_type => "ia32_x87_attr_t",
2522 cmp_attr => "return 1;",
2524 attr_type => "ia32_x87_attr_t",
2533 emit => ". fucom %X1\n".
2535 attr_type => "ia32_x87_attr_t",
2541 emit => ". fucomp %X1\n".
2543 attr_type => "ia32_x87_attr_t",
2549 emit => ". fucompp\n".
2551 attr_type => "ia32_x87_attr_t",
2557 emit => '. fucomi %X1',
2558 attr_type => "ia32_x87_attr_t",
2564 emit => '. fucompi %X1',
2565 attr_type => "ia32_x87_attr_t",
2573 attr_type => "ia32_x87_attr_t",
2578 # -------------------------------------------------------------------------------- #
2579 # ____ ____ _____ _ _ #
2580 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2581 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2582 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2583 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2585 # -------------------------------------------------------------------------------- #
2588 # Spilling and reloading of SSE registers, hardcoded, not generated #
2592 state => "exc_pinned",
2593 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2594 emit => '. movdqu %D0, %AM',
2595 outs => [ "res", "M" ],
2602 state => "exc_pinned",
2603 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2604 ins => [ "base", "index", "mem", "val" ],
2605 emit => '. movdqu %binop',
2613 # Include the generated SIMD node specification written by the SIMD optimization
2614 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2615 unless ($return = do $my_script_name) {
2616 warn "couldn't parse $my_script_name: $@" if $@;
2617 warn "couldn't do $my_script_name: $!" unless defined $return;
2618 warn "couldn't run $my_script_name" unless $return;
2621 # Transform some attributes
2622 foreach my $op (keys(%nodes)) {
2623 my $node = $nodes{$op};
2624 my $op_attr_init = $node->{op_attr_init};
2626 if(defined($op_attr_init)) {
2627 $op_attr_init .= "\n\t";
2632 if(!defined($node->{latency})) {
2634 $node->{latency} = 0;
2636 die("Latency missing for op $op");
2639 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2641 $node->{op_attr_init} = $op_attr_init;