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",
20 # irn_flags => "R|N|I|S"
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",
43 # ... # (all nodes you need to describe)
45 # ); # close the %nodes initializer
47 # op_flags: flags for the operation, OPTIONAL (default is "N")
48 # the op_flags correspond to the firm irop_flags:
51 # C irop_flag_commutative
52 # X irop_flag_cfopcode
53 # I irop_flag_ip_cfopcode
56 # H irop_flag_highlevel
57 # c irop_flag_constlike
59 # NB irop_flag_dump_noblock
60 # NI irop_flag_dump_noinput
62 # irn_flags: special node flags, OPTIONAL (default is 0)
63 # following irn_flags are supported:
66 # I ignore for register allocation
67 # S modifies stack pointer
69 # state: state of the operation, OPTIONAL (default is "floats")
71 # arity: arity of the operation, MUST NOT BE OMITTED
73 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
74 # are always the first 3 arguments and are always autmatically
76 # If this key is missing the following arguments will be created:
77 # for i = 1 .. arity: ir_node *op_i
80 # outs: if a node defines more than one output, the names of the projections
81 # nodes having outs having automatically the mode mode_T
82 # One can also annotate some flags for each out, additional to irn_flags.
83 # They are separated from name with a colon ':', and concatenated by pipe '|'
84 # Only I and S are available at the moment (same meaning as in irn_flags).
85 # example: [ "frame:I", "stack:I|S", "M" ]
87 # comment: OPTIONAL comment for the node constructor
89 # rd_constructor: for every operation there will be a
90 # new_rd_<arch>_<op-name> function with the arguments from above
91 # which creates the ir_node corresponding to the defined operation
92 # you can either put the complete source code of this function here
94 # This key is OPTIONAL. If omitted, the following constructor will
96 # if (!op_<arch>_<op-name>) assert(0);
100 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
103 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
107 # 0 - no special type
108 # 1 - caller save (register must be saved by the caller of a function)
109 # 2 - callee save (register must be saved by the called function)
110 # 4 - ignore (do not assign this register)
111 # 8 - emitter can choose an arbitrary register of this class
112 # 16 - the register is a virtual one
113 # 32 - register represents a state
114 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
117 { name => "edx", type => 1 },
118 { name => "ecx", type => 1 },
119 { name => "eax", type => 1 },
120 { name => "ebx", type => 2 },
121 { name => "esi", type => 2 },
122 { name => "edi", type => 2 },
123 { name => "ebp", type => 2 },
124 { name => "esp", type => 4 },
125 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
126 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
127 { mode => "mode_Iu" }
130 { name => "mm0", type => 4 },
131 { name => "mm1", type => 4 },
132 { name => "mm2", type => 4 },
133 { name => "mm3", type => 4 },
134 { name => "mm4", type => 4 },
135 { name => "mm5", type => 4 },
136 { name => "mm6", type => 4 },
137 { name => "mm7", type => 4 },
138 { mode => "mode_E", flags => "manual_ra" }
141 { name => "xmm0", type => 1 },
142 { name => "xmm1", type => 1 },
143 { name => "xmm2", type => 1 },
144 { name => "xmm3", type => 1 },
145 { name => "xmm4", type => 1 },
146 { name => "xmm5", type => 1 },
147 { name => "xmm6", type => 1 },
148 { name => "xmm7", type => 1 },
149 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
150 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
154 { name => "vf0", type => 1 },
155 { name => "vf1", type => 1 },
156 { name => "vf2", type => 1 },
157 { name => "vf3", type => 1 },
158 { name => "vf4", type => 1 },
159 { name => "vf5", type => 1 },
160 { name => "vf6", type => 1 },
161 { name => "vf7", type => 1 },
162 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
163 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
167 { name => "st0", realname => "st", type => 4 },
168 { name => "st1", realname => "st(1)", type => 4 },
169 { name => "st2", realname => "st(2)", type => 4 },
170 { name => "st3", realname => "st(3)", type => 4 },
171 { name => "st4", realname => "st(4)", type => 4 },
172 { name => "st5", realname => "st(5)", type => 4 },
173 { name => "st6", realname => "st(6)", type => 4 },
174 { name => "st7", realname => "st(7)", type => 4 },
175 { mode => "mode_E", flags => "manual_ra" }
177 fp_cw => [ # the floating point control word
178 { name => "fpcw", type => 4|32 },
179 { mode => "mode_fpcw", flags => "manual_ra|state" }
182 { name => "eflags", type => 0 },
183 { mode => "mode_Iu", flags => "manual_ra" }
188 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
189 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
190 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
191 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
196 bundels_per_cycle => 1
200 S0 => "${arch}_emit_source_register(node, 0);",
201 S1 => "${arch}_emit_source_register(node, 1);",
202 S2 => "${arch}_emit_source_register(node, 2);",
203 S3 => "${arch}_emit_source_register(node, 3);",
204 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
205 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
206 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
207 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
208 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
209 D0 => "${arch}_emit_dest_register(node, 0);",
210 D1 => "${arch}_emit_dest_register(node, 1);",
211 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
212 X0 => "${arch}_emit_x87_register(node, 0);",
213 X1 => "${arch}_emit_x87_register(node, 1);",
214 SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
215 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
216 ia32_emit_mode_suffix(node);",
217 M => "${arch}_emit_mode_suffix(node);",
218 XM => "${arch}_emit_x87_mode_suffix(node);",
219 XXM => "${arch}_emit_xmm_mode_suffix(node);",
220 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
221 AM => "${arch}_emit_am(node);",
222 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
223 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
224 binop => "${arch}_emit_binop(node);",
225 x87_binop => "${arch}_emit_x87_binop(node);",
226 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
227 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
230 #--------------------------------------------------#
233 # _ __ _____ __ _ _ __ ___ _ __ ___ #
234 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
235 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
236 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
239 #--------------------------------------------------#
241 $default_op_attr_type = "ia32_op_attr_t";
242 $default_attr_type = "ia32_attr_t";
243 $default_copy_attr = "ia32_copy_attr";
245 sub ia32_custom_init_attr {
250 if(defined($node->{modified_flags})) {
251 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
253 if(defined($node->{am})) {
254 my $am = $node->{am};
255 if($am eq "source,unary") {
256 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
257 } elsif($am eq "source,binary") {
258 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
259 } elsif($am eq "none") {
262 die("Invalid address mode '$am' specified on op $name");
265 if($node->{state} ne "exc_pinned"
266 and $node->{state} ne "pinned") {
267 die("AM nodes must have pinned or AM pinned state ($name)");
273 $custom_init_attr_func = \&ia32_custom_init_attr;
277 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
278 "\tinit_ia32_x87_attributes(res);".
279 "\tinit_ia32_asm_attributes(res);",
281 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
282 ia32_condcode_attr_t =>
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
284 "\tinit_ia32_condcode_attributes(res, pnc);",
286 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
287 "\tinit_ia32_copyb_attributes(res, size);",
288 ia32_immediate_attr_t =>
289 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
290 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
292 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
293 "\tinit_ia32_x87_attributes(res);",
297 ia32_asm_attr_t => "ia32_compare_asm_attr",
298 ia32_attr_t => "ia32_compare_nodes_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" ];
323 reg_req => { out => [ "gp_NOREG" ] },
324 attr => "ir_entity *symconst, int symconst_sign, long offset",
325 attr_type => "ia32_immediate_attr_t",
326 hash_func => "ia32_hash_Immediate",
334 out_arity => "variable",
335 attr_type => "ia32_asm_attr_t",
336 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
337 init_attr => "attr->asm_text = asm_text;\n".
338 "\tattr->register_map = register_map;\n",
343 # "allocates" a free register
347 reg_req => { out => [ "gp" ] },
352 cmp_attr => "return 1;",
355 #-----------------------------------------------------------------#
358 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
359 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
360 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
361 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
364 #-----------------------------------------------------------------#
366 # commutative operations
370 state => "exc_pinned",
371 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
372 out => [ "in_r4 in_r5", "flags", "none" ] },
373 ins => [ "base", "index", "mem", "left", "right" ],
374 outs => [ "res", "flags", "M" ],
375 emit => '. add%M %binop',
376 am => "source,binary",
380 modified_flags => $status_flags
385 state => "exc_pinned",
386 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
387 ins => [ "base", "index", "mem", "val" ],
388 emit => ". add%M %SI3, %AM",
392 modified_flags => $status_flags
397 state => "exc_pinned",
398 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
399 ins => [ "base", "index", "mem", "val" ],
400 emit => ". add%M %SB3, %AM",
404 modified_flags => $status_flags
408 state => "exc_pinned",
409 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
410 out => [ "in_r4 in_r5", "flags", "none" ] },
411 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
412 outs => [ "res", "flags", "M" ],
413 emit => '. adc%M %binop',
414 am => "source,binary",
418 modified_flags => $status_flags
423 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
424 ins => [ "left", "right" ],
428 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
429 ins => [ "left", "right", "eflags" ],
433 # we should not rematrialize this node. It produces 2 results and has
434 # very strict constraints
435 state => "exc_pinned",
436 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
437 out => [ "eax", "flags", "edx", "none" ] },
438 ins => [ "base", "index", "mem", "left", "right" ],
439 emit => '. mul%M %unop4',
440 outs => [ "res_low", "flags", "res_high", "M" ],
441 am => "source,binary",
444 modified_flags => $status_flags
448 # we should not rematrialize this node. It produces 2 results and has
449 # very strict constraints
451 cmp_attr => "return 1;",
452 outs => [ "EAX", "flags", "EDX", "M" ],
458 state => "exc_pinned",
459 # TODO: adjust out requirements for the 3 operand form
460 # (no need for should_be_same then)
461 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
462 out => [ "in_r4 in_r5", "flags", "none" ] },
463 ins => [ "base", "index", "mem", "left", "right" ],
464 outs => [ "res", "flags", "M" ],
465 am => "source,binary",
469 modified_flags => $status_flags
474 state => "exc_pinned",
475 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
476 out => [ "eax", "edx", "none" ] },
477 ins => [ "base", "index", "mem", "left", "right" ],
478 emit => '. imul%M %unop4',
479 outs => [ "res_low", "res_high", "M" ],
480 am => "source,binary",
483 modified_flags => $status_flags
488 cmp_attr => "return 1;",
489 outs => [ "res_low", "res_high", "M" ],
495 state => "exc_pinned",
496 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
497 out => [ "in_r4 in_r5", "flags", "none" ] },
498 ins => [ "base", "index", "mem", "left", "right" ],
499 outs => [ "res", "flags", "M" ],
500 op_modes => "commutative | am | immediate | mode_neutral",
501 am => "source,binary",
502 emit => '. and%M %binop',
506 modified_flags => $status_flags
511 state => "exc_pinned",
512 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
513 ins => [ "base", "index", "mem", "val" ],
514 emit => '. and%M %SI3, %AM',
518 modified_flags => $status_flags
523 state => "exc_pinned",
524 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
525 ins => [ "base", "index", "mem", "val" ],
526 emit => '. and%M %SB3, %AM',
530 modified_flags => $status_flags
535 state => "exc_pinned",
536 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
537 out => [ "in_r4 in_r5", "flags", "none" ] },
538 ins => [ "base", "index", "mem", "left", "right" ],
539 outs => [ "res", "flags", "M" ],
540 am => "source,binary",
541 emit => '. or%M %binop',
545 modified_flags => $status_flags
550 state => "exc_pinned",
551 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
552 ins => [ "base", "index", "mem", "val" ],
553 emit => '. or%M %SI3, %AM',
557 modified_flags => $status_flags
562 state => "exc_pinned",
563 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
564 ins => [ "base", "index", "mem", "val" ],
565 emit => '. or%M %SB3, %AM',
569 modified_flags => $status_flags
574 state => "exc_pinned",
575 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
576 out => [ "in_r4 in_r5", "flags", "none" ] },
577 ins => [ "base", "index", "mem", "left", "right" ],
578 outs => [ "res", "flags", "M" ],
579 am => "source,binary",
580 emit => '. xor%M %binop',
584 modified_flags => $status_flags
589 state => "exc_pinned",
590 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
591 ins => [ "base", "index", "mem", "val" ],
592 emit => '. xor%M %SI3, %AM',
596 modified_flags => $status_flags
601 state => "exc_pinned",
602 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
603 ins => [ "base", "index", "mem", "val" ],
604 emit => '. xor%M %SB3, %AM',
608 modified_flags => $status_flags
611 # not commutative operations
615 state => "exc_pinned",
616 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
617 out => [ "in_r4", "flags", "none" ] },
618 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
619 outs => [ "res", "flags", "M" ],
620 am => "source,binary",
621 emit => '. sub%M %binop',
625 modified_flags => $status_flags
630 state => "exc_pinned",
631 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
632 ins => [ "base", "index", "mem", "subtrahend" ],
633 emit => '. sub%M %SI3, %AM',
637 modified_flags => $status_flags
642 state => "exc_pinned",
643 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
644 ins => [ "base", "index", "mem", "subtrahend" ],
645 emit => '. sub%M %SB3, %AM',
649 modified_flags => $status_flags
653 state => "exc_pinned",
654 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
655 out => [ "in_r4 !in_r5", "flags", "none" ] },
656 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
657 outs => [ "res", "flags", "M" ],
658 am => "source,binary",
659 emit => '. sbb%M %binop',
663 modified_flags => $status_flags
667 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
668 ins => [ "minuend", "subtrahend" ],
672 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
673 ins => [ "minuend", "subtrahend", "eflags" ],
678 state => "exc_pinned",
679 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
680 out => [ "eax", "flags", "none", "edx", "none" ] },
681 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
682 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
683 am => "source,unary",
684 emit => ". idiv%M %unop3",
687 modified_flags => $status_flags
692 state => "exc_pinned",
693 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
694 out => [ "eax", "flags", "none", "edx", "none" ] },
695 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
696 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
697 am => "source,unary",
698 emit => ". div%M %unop3",
701 modified_flags => $status_flags
706 reg_req => { in => [ "gp", "ecx" ],
707 out => [ "in_r1 !in_r2", "flags" ] },
708 ins => [ "val", "count" ],
709 outs => [ "res", "flags" ],
710 emit => '. shl %SB1, %S0',
714 modified_flags => $status_flags
719 state => "exc_pinned",
720 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
721 ins => [ "base", "index", "mem", "count" ],
722 emit => '. shl%M %SB3, %AM',
726 modified_flags => $status_flags
730 cmp_attr => "return 1;",
731 ins => [ "val", "count", "dep" ],
737 reg_req => { in => [ "gp", "gp", "ecx" ],
738 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
739 ins => [ "val_high", "val_low", "count" ],
740 outs => [ "res", "flags" ],
741 emit => ". shld%M %SB2, %S1, %D0",
745 modified_flags => $status_flags
749 cmp_attr => "return 1;",
750 ins => [ "val_high", "val_low", "count" ],
756 reg_req => { in => [ "gp", "ecx" ],
757 out => [ "in_r1 !in_r2", "flags" ] },
758 ins => [ "val", "count" ],
759 outs => [ "res", "flags" ],
760 emit => '. shr %SB1, %S0',
764 modified_flags => $status_flags
769 state => "exc_pinned",
770 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
771 ins => [ "base", "index", "mem", "count" ],
772 emit => '. shr%M %SB3, %AM',
776 modified_flags => $status_flags
780 cmp_attr => "return 1;",
781 ins => [ "val", "count", "dep" ],
787 reg_req => { in => [ "gp", "gp", "ecx" ],
788 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
789 ins => [ "val_high", "val_low", "count" ],
790 outs => [ "res", "flags" ],
791 emit => ". shrd%M %SB2, %S1, %D0",
795 modified_flags => $status_flags
799 cmp_attr => "return 1;",
801 ins => [ "val_high", "val_low", "count" ],
806 reg_req => { in => [ "gp", "ecx" ],
807 out => [ "in_r1 !in_r2", "flags" ] },
808 ins => [ "val", "count" ],
809 outs => [ "res", "flags" ],
810 emit => '. sar %SB1, %S0',
814 modified_flags => $status_flags
819 state => "exc_pinned",
820 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
821 ins => [ "base", "index", "mem", "count" ],
822 emit => '. sar%M %SB3, %AM',
826 modified_flags => $status_flags
830 cmp_attr => "return 1;",
831 ins => [ "val", "count", "dep" ],
837 reg_req => { in => [ "gp", "ecx" ],
838 out => [ "in_r1 !in_r2", "flags" ] },
839 ins => [ "val", "count" ],
840 outs => [ "res", "flags" ],
841 emit => '. ror %SB1, %S0',
845 modified_flags => $status_flags
850 state => "exc_pinned",
851 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
852 ins => [ "base", "index", "mem", "count" ],
853 emit => '. ror%M %SB3, %AM',
857 modified_flags => $status_flags
862 reg_req => { in => [ "gp", "ecx" ],
863 out => [ "in_r1 !in_r2", "flags" ] },
864 ins => [ "val", "count" ],
865 outs => [ "res", "flags" ],
866 emit => '. rol %SB1, %S0',
870 modified_flags => $status_flags
875 state => "exc_pinned",
876 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
877 ins => [ "base", "index", "mem", "count" ],
878 emit => '. rol%M %SB3, %AM',
882 modified_flags => $status_flags
889 reg_req => { in => [ "gp" ],
890 out => [ "in_r1", "flags" ] },
893 outs => [ "res", "flags" ],
897 modified_flags => $status_flags
902 state => "exc_pinned",
903 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
904 ins => [ "base", "index", "mem" ],
905 emit => '. neg%M %AM',
909 modified_flags => $status_flags
914 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
915 outs => [ "low_res", "high_res" ],
918 modified_flags => $status_flags
924 reg_req => { in => [ "gp" ],
925 out => [ "in_r1", "flags" ] },
927 outs => [ "res", "flags" ],
932 modified_flags => $status_flags_wo_cf
937 state => "exc_pinned",
938 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
939 ins => [ "base", "index", "mem" ],
940 emit => '. inc%M %AM',
944 modified_flags => $status_flags_wo_cf
949 reg_req => { in => [ "gp" ],
950 out => [ "in_r1", "flags" ] },
952 outs => [ "res", "flags" ],
957 modified_flags => $status_flags_wo_cf
962 state => "exc_pinned",
963 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
964 ins => [ "base", "index", "mem" ],
965 emit => '. dec%M %AM',
969 modified_flags => $status_flags_wo_cf
974 reg_req => { in => [ "gp" ],
975 out => [ "in_r1", "flags" ] },
977 outs => [ "res", "flags" ],
987 state => "exc_pinned",
988 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
989 ins => [ "base", "index", "mem" ],
990 emit => '. not%M %AM',
998 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1002 mode => $mode_flags,
1003 modified_flags => $status_flags
1007 reg_req => { out => [ "flags" ] },
1011 mode => $mode_flags,
1012 modified_flags => $status_flags
1019 state => "exc_pinned",
1020 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1021 out => [ "flags", "none", "none" ] },
1022 ins => [ "base", "index", "mem", "left", "right" ],
1023 outs => [ "eflags", "unused", "M" ],
1024 am => "source,binary",
1025 emit => '. cmp%M %binop',
1026 attr => "int ins_permuted, int cmp_unsigned",
1027 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1028 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1031 mode => $mode_flags,
1032 modified_flags => $status_flags
1037 state => "exc_pinned",
1038 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1039 ins => [ "base", "index", "mem", "left", "right" ],
1040 outs => [ "eflags" ],
1041 am => "source,binary",
1042 emit => '. cmpb %binop',
1043 attr => "int ins_permuted, int cmp_unsigned",
1044 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1045 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1048 mode => $mode_flags,
1049 modified_flags => $status_flags
1054 state => "exc_pinned",
1055 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1056 ins => [ "base", "index", "mem", "left", "right" ],
1057 outs => [ "eflags" ],
1058 am => "source,binary",
1059 emit => '. test%M %binop',
1060 attr => "int ins_permuted, int cmp_unsigned",
1061 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1062 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1065 mode => $mode_flags,
1066 modified_flags => $status_flags
1071 state => "exc_pinned",
1072 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1073 ins => [ "base", "index", "mem", "left", "right" ],
1074 outs => [ "eflags" ],
1075 am => "source,binary",
1076 emit => '. testb %binop',
1077 attr => "int ins_permuted, int cmp_unsigned",
1078 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1079 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1082 mode => $mode_flags,
1083 modified_flags => $status_flags
1088 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1089 ins => [ "eflags" ],
1090 attr_type => "ia32_condcode_attr_t",
1091 attr => "pn_Cmp pnc, int ins_permuted",
1092 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1093 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1094 emit => '. set%CMP0 %DB0',
1102 state => "exc_pinned",
1103 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1104 ins => [ "base", "index", "mem","eflags" ],
1105 attr_type => "ia32_condcode_attr_t",
1106 attr => "pn_Cmp pnc, int ins_permuted",
1107 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1108 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1109 emit => '. set%CMP3 %AM',
1117 # (note: leave the false,true order intact to make it compatible with other
1119 state => "exc_pinned",
1120 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1121 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1122 am => "source,binary",
1123 attr_type => "ia32_condcode_attr_t",
1124 attr => "int ins_permuted, pn_Cmp pnc",
1125 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1133 op_flags => "L|X|Y",
1134 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1135 ins => [ "eflags" ],
1136 outs => [ "false", "true" ],
1137 attr_type => "ia32_condcode_attr_t",
1138 attr => "pn_Cmp pnc",
1140 units => [ "BRANCH" ],
1145 op_flags => "L|X|Y",
1146 reg_req => { in => [ "gp" ], out => [ "none" ] },
1148 attr_type => "ia32_condcode_attr_t",
1151 units => [ "BRANCH" ],
1152 modified_flags => $status_flags,
1158 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1159 ins => [ "base", "index", "mem", "target" ],
1160 am => "source,unary",
1161 emit => '. jmp *%unop3',
1163 units => [ "BRANCH" ],
1170 reg_req => { out => [ "gp" ] },
1172 attr => "ir_entity *symconst, int symconst_sign, long offset",
1173 attr_type => "ia32_immediate_attr_t",
1180 reg_req => { out => [ "gp" ] },
1184 modified_flags => $status_flags,
1191 reg_req => { out => [ "gp_UKNWN" ] },
1202 reg_req => { out => [ "vfp_UKNWN" ] },
1207 attr_type => "ia32_x87_attr_t",
1214 reg_req => { out => [ "xmm_UKNWN" ] },
1223 op_flags => "c|NB|NI",
1225 reg_req => { out => [ "gp_NOREG" ] },
1234 op_flags => "c|NB|NI",
1236 reg_req => { out => [ "vfp_NOREG" ] },
1241 attr_type => "ia32_x87_attr_t",
1246 op_flags => "c|NB|NI",
1248 reg_req => { out => [ "xmm_NOREG" ] },
1259 reg_req => { out => [ "fp_cw" ] },
1263 modified_flags => $fpcw_flags
1269 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1270 ins => [ "base", "index", "mem" ],
1272 emit => ". fldcw %AM",
1275 modified_flags => $fpcw_flags
1281 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1282 ins => [ "base", "index", "mem", "fpcw" ],
1284 emit => ". fnstcw %AM",
1292 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1300 # we should not rematrialize this node. It has very strict constraints.
1301 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1302 ins => [ "val", "clobbered" ],
1311 # Note that we add additional latency values depending on address mode, so a
1312 # lateny of 0 for load is correct
1316 state => "exc_pinned",
1317 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1318 ins => [ "base", "index", "mem" ],
1319 outs => [ "res", "M", "X_exc" ],
1321 emit => ". mov%SE%ME%.l %AM, %D0",
1327 state => "exc_pinned",
1328 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1329 ins => [ "base", "index", "mem", "val" ],
1330 outs => [ "M", "X_exc" ],
1331 emit => '. mov%M %SI3, %AM',
1339 state => "exc_pinned",
1340 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1341 ins => [ "base", "index", "mem", "val" ],
1342 outs => [ "M", "X_exc" ],
1343 emit => '. mov%M %SB3, %AM',
1351 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1352 ins => [ "base", "index" ],
1353 emit => '. leal %AM, %D0',
1357 # lea doesn't modify the flags, but setting this seems advantageous since it
1358 # increases chances that the Lea is transformed back to an Add
1359 modified_flags => 1,
1363 state => "exc_pinned",
1364 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1365 ins => [ "base", "index", "mem", "val", "stack" ],
1366 emit => '. push%M %unop3',
1367 outs => [ "stack:I|S", "M" ],
1368 am => "source,unary",
1374 state => "exc_pinned",
1375 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1376 ins => [ "mem", "stack" ],
1377 outs => [ "res", "M", "unused", "stack:I|S" ],
1378 emit => '. pop%M %D0',
1379 latency => 3, # Pop is more expensive than Push on Athlon
1384 state => "exc_pinned",
1385 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1386 ins => [ "base", "index", "mem", "stack" ],
1387 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1388 emit => '. pop%M %AM',
1389 latency => 3, # Pop is more expensive than Push on Athlon
1394 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1396 outs => [ "frame:I", "stack:I|S", "M" ],
1402 reg_req => { in => [ "ebp" ], out => [ "ebp", "esp" ] },
1404 outs => [ "frame:I", "stack:I|S" ],
1412 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1413 ins => [ "base", "index", "mem", "stack", "size" ],
1414 am => "source,binary",
1415 emit => '. addl %binop',
1417 outs => [ "stack:I|S", "M" ],
1419 modified_flags => $status_flags
1425 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "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:I|S", "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
1463 #-----------------------------------------------------------------------------#
1464 # _____ _____ ______ __ _ _ _ #
1465 # / ____/ ____| ____| / _| | | | | | #
1466 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1467 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1468 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1469 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1470 #-----------------------------------------------------------------------------#
1475 reg_req => { out => [ "xmm" ] },
1476 emit => '. xorp%XSD %D0, %D0',
1484 reg_req => { out => [ "xmm" ] },
1485 emit => '. pxor %D0, %D0',
1491 # produces all 1 bits
1494 reg_req => { out => [ "xmm" ] },
1495 emit => '. pcmpeqb %D0, %D0',
1501 # integer shift left, dword
1504 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1505 emit => '. pslld %SI1, %D0',
1511 # integer shift left, qword
1514 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1515 emit => '. psllq %SI1, %D0',
1521 # integer shift right, dword
1524 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1525 emit => '. psrld %SI1, %D0',
1531 # mov from integer to SSE register
1534 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1535 emit => '. movd %S0, %D0',
1541 # commutative operations
1545 state => "exc_pinned",
1546 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1547 ins => [ "base", "index", "mem", "left", "right" ],
1548 am => "source,binary",
1549 emit => '. add%XXM %binop',
1557 state => "exc_pinned",
1558 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1559 ins => [ "base", "index", "mem", "left", "right" ],
1560 am => "source,binary",
1561 emit => '. mul%XXM %binop',
1569 state => "exc_pinned",
1570 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1571 ins => [ "base", "index", "mem", "left", "right" ],
1572 am => "source,binary",
1573 emit => '. max%XXM %binop',
1581 state => "exc_pinned",
1582 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1583 ins => [ "base", "index", "mem", "left", "right" ],
1584 am => "source,binary",
1585 emit => '. min%XXM %binop',
1593 state => "exc_pinned",
1594 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1595 ins => [ "base", "index", "mem", "left", "right" ],
1596 am => "source,binary",
1597 emit => '. andp%XSD %binop',
1605 state => "exc_pinned",
1606 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1607 ins => [ "base", "index", "mem", "left", "right" ],
1608 am => "source,binary",
1609 emit => '. orp%XSD %binop',
1617 state => "exc_pinned",
1618 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1619 ins => [ "base", "index", "mem", "left", "right" ],
1620 am => "source,binary",
1621 emit => '. xorp%XSD %binop',
1627 # not commutative operations
1631 state => "exc_pinned",
1632 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1633 ins => [ "base", "index", "mem", "left", "right" ],
1634 am => "source,binary",
1635 emit => '. andnp%XSD %binop',
1643 state => "exc_pinned",
1644 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1645 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1646 am => "source,binary",
1647 emit => '. sub%XXM %binop',
1655 state => "exc_pinned",
1656 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1657 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1658 am => "source,binary",
1659 outs => [ "res", "M" ],
1660 emit => '. div%XXM %binop',
1669 state => "exc_pinned",
1670 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1671 ins => [ "base", "index", "mem", "left", "right" ],
1672 outs => [ "flags" ],
1673 am => "source,binary",
1674 attr => "int ins_permuted",
1675 init_attr => "attr->data.ins_permuted = ins_permuted;",
1676 emit => ' .ucomi%XXM %binop',
1679 mode => $mode_flags,
1680 modified_flags => 1,
1687 state => "exc_pinned",
1688 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1689 ins => [ "base", "index", "mem" ],
1690 outs => [ "res", "M", "X_exc" ],
1691 emit => '. mov%XXM %AM, %D0',
1692 attr => "ir_mode *load_mode",
1693 init_attr => "attr->ls_mode = load_mode;",
1700 state => "exc_pinned",
1701 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1702 ins => [ "base", "index", "mem", "val" ],
1703 outs => [ "M", "X_exc" ],
1704 emit => '. mov%XXM %S3, %AM',
1712 state => "exc_pinned",
1713 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1714 ins => [ "base", "index", "mem", "val" ],
1715 emit => '. mov%XXM %S3, %AM',
1723 state => "exc_pinned",
1724 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1725 ins => [ "base", "index", "mem", "val" ],
1726 am => "source,unary",
1727 emit => '. cvtsi2ss %unop3, %D0',
1735 state => "exc_pinned",
1736 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1737 ins => [ "base", "index", "mem", "val" ],
1738 am => "source,unary",
1739 emit => '. cvtsi2sd %unop3, %D0',
1748 cmp_attr => "return 1;",
1749 ins => [ "val_high", "val_low" ],
1754 cmp_attr => "return 1;",
1756 outs => [ "res_high", "res_low" ],
1764 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1765 outs => [ "DST", "SRC", "CNT", "M" ],
1766 attr_type => "ia32_copyb_attr_t",
1767 attr => "unsigned size",
1770 # we don't care about this flag, so no need to mark this node
1771 # modified_flags => [ "DF" ]
1777 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1778 outs => [ "DST", "SRC", "M" ],
1779 attr_type => "ia32_copyb_attr_t",
1780 attr => "unsigned size",
1783 # we don't care about this flag, so no need to mark this node
1784 # modified_flags => [ "DF" ]
1790 state => "exc_pinned",
1791 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1792 ins => [ "base", "index", "mem", "val" ],
1793 am => "source,unary",
1796 attr => "ir_mode *smaller_mode",
1797 init_attr => "attr->ls_mode = smaller_mode;",
1802 state => "exc_pinned",
1803 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1804 ins => [ "base", "index", "mem", "val" ],
1805 am => "source,unary",
1808 attr => "ir_mode *smaller_mode",
1809 init_attr => "attr->ls_mode = smaller_mode;",
1814 state => "exc_pinned",
1815 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1816 ins => [ "base", "index", "mem", "val" ],
1817 am => "source,unary",
1824 state => "exc_pinned",
1825 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1826 ins => [ "base", "index", "mem", "val" ],
1827 am => "source,unary",
1834 state => "exc_pinned",
1835 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1836 ins => [ "base", "index", "mem", "val" ],
1837 am => "source,unary",
1843 #----------------------------------------------------------#
1845 # (_) | | | | / _| | | | #
1846 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1847 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1848 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1849 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1851 # _ __ ___ __| | ___ ___ #
1852 # | '_ \ / _ \ / _` |/ _ \/ __| #
1853 # | | | | (_) | (_| | __/\__ \ #
1854 # |_| |_|\___/ \__,_|\___||___/ #
1855 #----------------------------------------------------------#
1857 # rematerialisation disabled for all float nodes for now, because the fpcw
1858 # handler runs before spilling and we might end up with wrong fpcw then
1862 state => "exc_pinned",
1863 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1864 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1865 am => "source,binary",
1869 attr_type => "ia32_x87_attr_t",
1874 state => "exc_pinned",
1875 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1876 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1877 am => "source,binary",
1881 attr_type => "ia32_x87_attr_t",
1886 state => "exc_pinned",
1887 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1888 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1889 am => "source,binary",
1893 attr_type => "ia32_x87_attr_t",
1897 state => "exc_pinned",
1898 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1899 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1900 am => "source,binary",
1901 outs => [ "res", "M" ],
1904 attr_type => "ia32_x87_attr_t",
1908 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1909 ins => [ "left", "right", "fpcw" ],
1913 attr_type => "ia32_x87_attr_t",
1918 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1923 attr_type => "ia32_x87_attr_t",
1928 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1933 attr_type => "ia32_x87_attr_t",
1936 # virtual Load and Store
1941 state => "exc_pinned",
1942 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1943 ins => [ "base", "index", "mem" ],
1944 outs => [ "res", "M", "X_exc" ],
1945 attr => "ir_mode *load_mode",
1946 init_attr => "attr->attr.ls_mode = load_mode;",
1949 attr_type => "ia32_x87_attr_t",
1955 state => "exc_pinned",
1956 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1957 ins => [ "base", "index", "mem", "val" ],
1958 outs => [ "M", "X_exc" ],
1959 attr => "ir_mode *store_mode",
1960 init_attr => "attr->attr.ls_mode = store_mode;",
1964 attr_type => "ia32_x87_attr_t",
1970 state => "exc_pinned",
1971 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1972 outs => [ "res", "M" ],
1973 ins => [ "base", "index", "mem" ],
1976 attr_type => "ia32_x87_attr_t",
1980 state => "exc_pinned",
1981 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1982 ins => [ "base", "index", "mem", "val", "fpcw" ],
1986 attr_type => "ia32_x87_attr_t",
1989 # SSE3 fisttp instruction
1991 state => "exc_pinned",
1992 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
1993 ins => [ "base", "index", "mem", "val" ],
1994 outs => [ "res", "M" ],
1997 attr_type => "ia32_x87_attr_t",
2005 reg_req => { out => [ "vfp" ] },
2009 attr_type => "ia32_x87_attr_t",
2014 reg_req => { out => [ "vfp" ] },
2018 attr_type => "ia32_x87_attr_t",
2023 reg_req => { out => [ "vfp" ] },
2027 attr_type => "ia32_x87_attr_t",
2032 reg_req => { out => [ "vfp" ] },
2036 attr_type => "ia32_x87_attr_t",
2041 reg_req => { out => [ "vfp" ] },
2045 attr_type => "ia32_x87_attr_t",
2050 reg_req => { out => [ "vfp" ] },
2054 attr_type => "ia32_x87_attr_t",
2059 reg_req => { out => [ "vfp" ] },
2063 attr_type => "ia32_x87_attr_t",
2069 # we can't allow to rematerialize this node so we don't have
2070 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2072 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2073 ins => [ "left", "right" ],
2074 outs => [ "flags" ],
2075 attr => "int ins_permuted",
2076 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2079 attr_type => "ia32_x87_attr_t",
2085 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2086 ins => [ "left", "right" ],
2087 outs => [ "flags" ],
2088 attr => "int ins_permuted",
2089 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2092 attr_type => "ia32_x87_attr_t",
2098 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2100 outs => [ "flags" ],
2101 attr => "int ins_permuted",
2102 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2105 attr_type => "ia32_x87_attr_t",
2111 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2113 outs => [ "flags" ],
2117 mode => $mode_flags,
2120 #------------------------------------------------------------------------#
2121 # ___ _____ __ _ _ _ #
2122 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2123 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2124 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2125 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2126 #------------------------------------------------------------------------#
2128 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2129 # are swapped, we work this around in the emitter...
2132 state => "exc_pinned",
2133 rd_constructor => "NONE",
2135 emit => '. fadd%XM %x87_binop',
2137 attr_type => "ia32_x87_attr_t",
2141 state => "exc_pinned",
2142 rd_constructor => "NONE",
2144 emit => '. faddp%XM %x87_binop',
2146 attr_type => "ia32_x87_attr_t",
2150 state => "exc_pinned",
2151 rd_constructor => "NONE",
2153 emit => '. fmul%XM %x87_binop',
2155 attr_type => "ia32_x87_attr_t",
2159 state => "exc_pinned",
2160 rd_constructor => "NONE",
2162 emit => '. fmulp%XM %x87_binop',,
2164 attr_type => "ia32_x87_attr_t",
2168 state => "exc_pinned",
2169 rd_constructor => "NONE",
2171 emit => '. fsub%XM %x87_binop',
2173 attr_type => "ia32_x87_attr_t",
2177 state => "exc_pinned",
2178 rd_constructor => "NONE",
2180 # see note about gas bugs
2181 emit => '. fsubrp%XM %x87_binop',
2183 attr_type => "ia32_x87_attr_t",
2187 state => "exc_pinned",
2188 rd_constructor => "NONE",
2191 emit => '. fsubr%XM %x87_binop',
2193 attr_type => "ia32_x87_attr_t",
2197 state => "exc_pinned",
2198 rd_constructor => "NONE",
2201 # see note about gas bugs
2202 emit => '. fsubp%XM %x87_binop',
2204 attr_type => "ia32_x87_attr_t",
2208 rd_constructor => "NONE",
2212 attr_type => "ia32_x87_attr_t",
2215 # this node is just here, to keep the simulator running
2216 # we can omit this when a fprem simulation function exists
2218 rd_constructor => "NONE",
2220 emit => '. fprem1\n'.
2223 attr_type => "ia32_x87_attr_t",
2227 state => "exc_pinned",
2228 rd_constructor => "NONE",
2230 emit => '. fdiv%XM %x87_binop',
2232 attr_type => "ia32_x87_attr_t",
2236 state => "exc_pinned",
2237 rd_constructor => "NONE",
2239 # see note about gas bugs
2240 emit => '. fdivrp%XM %x87_binop',
2242 attr_type => "ia32_x87_attr_t",
2246 state => "exc_pinned",
2247 rd_constructor => "NONE",
2249 emit => '. fdivr%XM %x87_binop',
2251 attr_type => "ia32_x87_attr_t",
2255 state => "exc_pinned",
2256 rd_constructor => "NONE",
2258 # see note about gas bugs
2259 emit => '. fdivp%XM %x87_binop',
2261 attr_type => "ia32_x87_attr_t",
2265 rd_constructor => "NONE",
2269 attr_type => "ia32_x87_attr_t",
2274 rd_constructor => "NONE",
2278 attr_type => "ia32_x87_attr_t",
2281 # x87 Load and Store
2284 rd_constructor => "NONE",
2285 op_flags => "R|L|F",
2286 state => "exc_pinned",
2288 emit => '. fld%XM %AM',
2289 attr_type => "ia32_x87_attr_t",
2294 rd_constructor => "NONE",
2295 op_flags => "R|L|F",
2296 state => "exc_pinned",
2298 emit => '. fst%XM %AM',
2300 attr_type => "ia32_x87_attr_t",
2305 rd_constructor => "NONE",
2306 op_flags => "R|L|F",
2307 state => "exc_pinned",
2309 emit => '. fstp%XM %AM',
2311 attr_type => "ia32_x87_attr_t",
2318 state => "exc_pinned",
2319 rd_constructor => "NONE",
2321 emit => '. fild%XM %AM',
2322 attr_type => "ia32_x87_attr_t",
2327 state => "exc_pinned",
2328 rd_constructor => "NONE",
2330 emit => '. fist%XM %AM',
2332 attr_type => "ia32_x87_attr_t",
2337 state => "exc_pinned",
2338 rd_constructor => "NONE",
2340 emit => '. fistp%XM %AM',
2342 attr_type => "ia32_x87_attr_t",
2346 # SSE3 firsttp instruction
2348 state => "exc_pinned",
2349 rd_constructor => "NONE",
2351 emit => '. fisttp%XM %AM',
2353 attr_type => "ia32_x87_attr_t",
2360 op_flags => "R|c|K",
2362 reg_req => { out => [ "vfp" ] },
2364 attr_type => "ia32_x87_attr_t",
2369 op_flags => "R|c|K",
2371 reg_req => { out => [ "vfp" ] },
2373 attr_type => "ia32_x87_attr_t",
2378 op_flags => "R|c|K",
2380 reg_req => { out => [ "vfp" ] },
2382 attr_type => "ia32_x87_attr_t",
2387 op_flags => "R|c|K",
2389 reg_req => { out => [ "vfp" ] },
2391 attr_type => "ia32_x87_attr_t",
2396 op_flags => "R|c|K",
2398 reg_req => { out => [ "vfp" ] },
2400 attr_type => "ia32_x87_attr_t",
2405 op_flags => "R|c|K",
2407 reg_req => { out => [ "vfp" ] },
2408 emit => '. fldll2t',
2409 attr_type => "ia32_x87_attr_t",
2414 op_flags => "R|c|K",
2416 reg_req => { out => [ "vfp" ] },
2418 attr_type => "ia32_x87_attr_t",
2423 # Note that it is NEVER allowed to do CSE on these nodes
2424 # Moreover, note the virtual register requierements!
2429 cmp_attr => "return 1;",
2430 emit => '. fxch %X0',
2431 attr_type => "ia32_x87_attr_t",
2439 cmp_attr => "return 1;",
2440 emit => '. fld %X0',
2441 attr_type => "ia32_x87_attr_t",
2447 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2448 cmp_attr => "return 1;",
2449 emit => '. fld %X0',
2450 attr_type => "ia32_x87_attr_t",
2457 cmp_attr => "return 1;",
2458 emit => '. fstp %X0',
2459 attr_type => "ia32_x87_attr_t",
2467 cmp_attr => "return 1;",
2468 emit => '. ffreep %X0',
2469 attr_type => "ia32_x87_attr_t",
2477 cmp_attr => "return 1;",
2479 attr_type => "ia32_x87_attr_t",
2487 cmp_attr => "return 1;",
2489 attr_type => "ia32_x87_attr_t",
2498 emit => ". fucom %X1\n".
2500 attr_type => "ia32_x87_attr_t",
2506 emit => ". fucomp %X1\n".
2508 attr_type => "ia32_x87_attr_t",
2514 emit => ". fucompp\n".
2516 attr_type => "ia32_x87_attr_t",
2522 emit => '. fucomi %X1',
2523 attr_type => "ia32_x87_attr_t",
2529 emit => '. fucompi %X1',
2530 attr_type => "ia32_x87_attr_t",
2538 attr_type => "ia32_x87_attr_t",
2543 # -------------------------------------------------------------------------------- #
2544 # ____ ____ _____ _ _ #
2545 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2546 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2547 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2548 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2550 # -------------------------------------------------------------------------------- #
2553 # Spilling and reloading of SSE registers, hardcoded, not generated #
2557 state => "exc_pinned",
2558 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2559 emit => '. movdqu %D0, %AM',
2560 outs => [ "res", "M" ],
2567 state => "exc_pinned",
2568 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2569 ins => [ "base", "index", "mem", "val" ],
2570 emit => '. movdqu %binop',
2578 # Include the generated SIMD node specification written by the SIMD optimization
2579 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2580 unless ($return = do $my_script_name) {
2581 warn "couldn't parse $my_script_name: $@" if $@;
2582 warn "couldn't do $my_script_name: $!" unless defined $return;
2583 warn "couldn't run $my_script_name" unless $return;
2586 # Transform some attributes
2587 foreach my $op (keys(%nodes)) {
2588 my $node = $nodes{$op};
2589 my $op_attr_init = $node->{op_attr_init};
2591 if(defined($op_attr_init)) {
2592 $op_attr_init .= "\n\t";
2597 if(!defined($node->{latency})) {
2599 $node->{latency} = 0;
2601 die("Latency missing for op $op");
2604 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2606 $node->{op_attr_init} = $op_attr_init;