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_Source, ia32_am_unary);";
257 } elsif($am eq "source,binary") {
258 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
259 } elsif($am eq "source,ternary") {
260 $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
261 } elsif($am eq "none") {
264 die("Invalid address mode '$am' specified on op $name");
267 if($node->{state} ne "exc_pinned"
268 and $node->{state} ne "pinned") {
269 die("AM nodes must have pinned or AM pinned state ($name)");
275 $custom_init_attr_func = \&ia32_custom_init_attr;
279 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
280 "\tinit_ia32_x87_attributes(res);".
281 "\tinit_ia32_asm_attributes(res);",
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
284 ia32_condcode_attr_t =>
285 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
286 "\tinit_ia32_condcode_attributes(res, pnc);",
288 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
289 "\tinit_ia32_copyb_attributes(res, size);",
290 ia32_immediate_attr_t =>
291 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
292 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_x87_attributes(res);",
299 ia32_asm_attr_t => "ia32_compare_asm_attr",
300 ia32_attr_t => "ia32_compare_nodes_attr",
301 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
302 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
303 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
304 ia32_x87_attr_t => "ia32_compare_x87_attr",
310 $mode_xmm = "mode_E";
311 $mode_gp = "mode_Iu";
312 $mode_flags = "mode_Iu";
313 $mode_fpcw = "mode_fpcw";
314 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
315 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
316 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
324 reg_req => { out => [ "gp_NOREG" ] },
325 attr => "ir_entity *symconst, int symconst_sign, long offset",
326 attr_type => "ia32_immediate_attr_t",
327 hash_func => "ia32_hash_Immediate",
335 out_arity => "variable",
336 attr_type => "ia32_asm_attr_t",
337 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
338 init_attr => "attr->asm_text = asm_text;\n".
339 "\tattr->register_map = register_map;\n",
344 # "allocates" a free register
348 reg_req => { out => [ "gp" ] },
353 cmp_attr => "return 1;",
356 #-----------------------------------------------------------------#
359 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
360 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
361 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
362 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
365 #-----------------------------------------------------------------#
367 # commutative operations
371 state => "exc_pinned",
372 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
373 out => [ "in_r4 in_r5", "flags", "none" ] },
374 ins => [ "base", "index", "mem", "left", "right" ],
375 outs => [ "res", "flags", "M" ],
376 emit => '. add%M %binop',
377 am => "source,binary",
381 modified_flags => $status_flags
386 state => "exc_pinned",
387 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
388 ins => [ "base", "index", "mem", "val" ],
389 emit => ". add%M %SI3, %AM",
393 modified_flags => $status_flags
398 state => "exc_pinned",
399 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
400 ins => [ "base", "index", "mem", "val" ],
401 emit => ". add%M %SB3, %AM",
405 modified_flags => $status_flags
409 state => "exc_pinned",
410 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
411 out => [ "in_r4 in_r5", "flags", "none" ] },
412 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
413 outs => [ "res", "flags", "M" ],
414 emit => '. adc%M %binop',
415 am => "source,binary",
419 modified_flags => $status_flags
424 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
425 ins => [ "left", "right" ],
429 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
430 ins => [ "left", "right", "eflags" ],
434 # we should not rematrialize this node. It produces 2 results and has
435 # very strict constraints
436 state => "exc_pinned",
437 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
438 out => [ "eax", "edx", "none" ] },
439 ins => [ "base", "index", "mem", "left", "right" ],
440 emit => '. mul%M %unop4',
441 outs => [ "res_low", "res_high", "M" ],
442 am => "source,binary",
445 modified_flags => $status_flags
449 # we should not rematrialize this node. It produces 2 results and has
450 # very strict constraints
452 cmp_attr => "return 1;",
453 outs => [ "EAX", "EDX", "M" ],
459 state => "exc_pinned",
460 # TODO: adjust out requirements for the 3 operand form
461 # (no need for should_be_same then)
462 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
463 out => [ "in_r4 in_r5", "flags", "none" ] },
464 ins => [ "base", "index", "mem", "left", "right" ],
465 outs => [ "res", "flags", "M" ],
466 am => "source,binary",
470 modified_flags => $status_flags
475 state => "exc_pinned",
476 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
477 out => [ "eax", "edx", "none" ] },
478 ins => [ "base", "index", "mem", "left", "right" ],
479 emit => '. imul%M %unop4',
480 outs => [ "res_low", "res_high", "M" ],
481 am => "source,binary",
484 modified_flags => $status_flags
489 cmp_attr => "return 1;",
490 outs => [ "res_low", "res_high", "M" ],
496 state => "exc_pinned",
497 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
498 out => [ "in_r4 in_r5", "flags", "none" ] },
499 ins => [ "base", "index", "mem", "left", "right" ],
500 outs => [ "res", "flags", "M" ],
501 op_modes => "commutative | am | immediate | mode_neutral",
502 am => "source,binary",
503 emit => '. and%M %binop',
507 modified_flags => $status_flags
512 state => "exc_pinned",
513 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
514 ins => [ "base", "index", "mem", "val" ],
515 emit => '. and%M %SI3, %AM',
519 modified_flags => $status_flags
524 state => "exc_pinned",
525 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
526 ins => [ "base", "index", "mem", "val" ],
527 emit => '. and%M %SB3, %AM',
531 modified_flags => $status_flags
536 state => "exc_pinned",
537 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
538 out => [ "in_r4 in_r5", "flags", "none" ] },
539 ins => [ "base", "index", "mem", "left", "right" ],
540 outs => [ "res", "flags", "M" ],
541 am => "source,binary",
542 emit => '. or%M %binop',
546 modified_flags => $status_flags
551 state => "exc_pinned",
552 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
553 ins => [ "base", "index", "mem", "val" ],
554 emit => '. or%M %SI3, %AM',
558 modified_flags => $status_flags
563 state => "exc_pinned",
564 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
565 ins => [ "base", "index", "mem", "val" ],
566 emit => '. or%M %SB3, %AM',
570 modified_flags => $status_flags
575 state => "exc_pinned",
576 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
577 out => [ "in_r4 in_r5", "flags", "none" ] },
578 ins => [ "base", "index", "mem", "left", "right" ],
579 outs => [ "res", "flags", "M" ],
580 am => "source,binary",
581 emit => '. xor%M %binop',
585 modified_flags => $status_flags
590 state => "exc_pinned",
591 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
592 ins => [ "base", "index", "mem", "val" ],
593 emit => '. xor%M %SI3, %AM',
597 modified_flags => $status_flags
602 state => "exc_pinned",
603 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
604 ins => [ "base", "index", "mem", "val" ],
605 emit => '. xor%M %SB3, %AM',
609 modified_flags => $status_flags
612 # not commutative operations
616 state => "exc_pinned",
617 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
618 out => [ "in_r4", "flags", "none" ] },
619 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
620 outs => [ "res", "flags", "M" ],
621 am => "source,binary",
622 emit => '. sub%M %binop',
626 modified_flags => $status_flags
631 state => "exc_pinned",
632 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
633 ins => [ "base", "index", "mem", "subtrahend" ],
634 emit => '. sub%M %SI3, %AM',
638 modified_flags => $status_flags
643 state => "exc_pinned",
644 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
645 ins => [ "base", "index", "mem", "subtrahend" ],
646 emit => '. sub%M %SB3, %AM',
650 modified_flags => $status_flags
654 state => "exc_pinned",
655 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
656 out => [ "in_r4 !in_r5", "flags", "none" ] },
657 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
658 outs => [ "res", "flags", "M" ],
659 am => "source,binary",
660 emit => '. sbb%M %binop',
664 modified_flags => $status_flags
668 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
669 ins => [ "minuend", "subtrahend" ],
673 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
674 ins => [ "minuend", "subtrahend", "eflags" ],
679 state => "exc_pinned",
680 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
681 out => [ "eax", "flags", "none", "edx", "none" ] },
682 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
683 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
684 am => "source,ternary",
685 emit => ". idiv%M %unop3",
688 modified_flags => $status_flags
693 state => "exc_pinned",
694 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
695 out => [ "eax", "flags", "none", "edx", "none" ] },
696 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
697 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
698 am => "source,ternary",
699 emit => ". div%M %unop3",
702 modified_flags => $status_flags
707 reg_req => { in => [ "gp", "ecx" ],
708 out => [ "in_r1 !in_r2", "flags" ] },
709 ins => [ "val", "count" ],
710 outs => [ "res", "flags" ],
711 emit => '. shl %SB1, %S0',
715 modified_flags => $status_flags
720 state => "exc_pinned",
721 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
722 ins => [ "base", "index", "mem", "count" ],
723 emit => '. shl%M %SB3, %AM',
727 modified_flags => $status_flags
731 cmp_attr => "return 1;",
732 ins => [ "val", "count", "dep" ],
738 reg_req => { in => [ "gp", "gp", "ecx" ],
739 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
740 ins => [ "val_high", "val_low", "count" ],
741 outs => [ "res", "flags" ],
742 emit => ". shld%M %SB2, %S1, %D0",
746 modified_flags => $status_flags
750 cmp_attr => "return 1;",
751 ins => [ "val_high", "val_low", "count" ],
757 reg_req => { in => [ "gp", "ecx" ],
758 out => [ "in_r1 !in_r2", "flags" ] },
759 ins => [ "val", "count" ],
760 outs => [ "res", "flags" ],
761 emit => '. shr %SB1, %S0',
765 modified_flags => $status_flags
770 state => "exc_pinned",
771 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
772 ins => [ "base", "index", "mem", "count" ],
773 emit => '. shr%M %SB3, %AM',
777 modified_flags => $status_flags
781 cmp_attr => "return 1;",
782 ins => [ "val", "count", "dep" ],
788 reg_req => { in => [ "gp", "gp", "ecx" ],
789 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
790 ins => [ "val_high", "val_low", "count" ],
791 outs => [ "res", "flags" ],
792 emit => ". shrd%M %SB2, %S1, %D0",
796 modified_flags => $status_flags
800 cmp_attr => "return 1;",
802 ins => [ "val_high", "val_low", "count" ],
807 reg_req => { in => [ "gp", "ecx" ],
808 out => [ "in_r1 !in_r2", "flags" ] },
809 ins => [ "val", "count" ],
810 outs => [ "res", "flags" ],
811 emit => '. sar %SB1, %S0',
815 modified_flags => $status_flags
820 state => "exc_pinned",
821 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
822 ins => [ "base", "index", "mem", "count" ],
823 emit => '. sar%M %SB3, %AM',
827 modified_flags => $status_flags
831 cmp_attr => "return 1;",
832 ins => [ "val", "count", "dep" ],
838 reg_req => { in => [ "gp", "ecx" ],
839 out => [ "in_r1 !in_r2", "flags" ] },
840 ins => [ "val", "count" ],
841 outs => [ "res", "flags" ],
842 emit => '. ror %SB1, %S0',
846 modified_flags => $status_flags
851 state => "exc_pinned",
852 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
853 ins => [ "base", "index", "mem", "count" ],
854 emit => '. ror%M %SB3, %AM',
858 modified_flags => $status_flags
863 reg_req => { in => [ "gp", "ecx" ],
864 out => [ "in_r1 !in_r2", "flags" ] },
865 ins => [ "val", "count" ],
866 outs => [ "res", "flags" ],
867 emit => '. rol %SB1, %S0',
871 modified_flags => $status_flags
876 state => "exc_pinned",
877 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
878 ins => [ "base", "index", "mem", "count" ],
879 emit => '. rol%M %SB3, %AM',
883 modified_flags => $status_flags
890 reg_req => { in => [ "gp" ],
891 out => [ "in_r1", "flags" ] },
894 outs => [ "res", "flags" ],
898 modified_flags => $status_flags
903 state => "exc_pinned",
904 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
905 ins => [ "base", "index", "mem" ],
906 emit => '. neg%M %AM',
910 modified_flags => $status_flags
915 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
916 outs => [ "low_res", "high_res" ],
919 modified_flags => $status_flags
925 reg_req => { in => [ "gp" ],
926 out => [ "in_r1", "flags" ] },
928 outs => [ "res", "flags" ],
933 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
938 state => "exc_pinned",
939 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
940 ins => [ "base", "index", "mem" ],
941 emit => '. inc%M %AM',
945 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
950 reg_req => { in => [ "gp" ],
951 out => [ "in_r1", "flags" ] },
953 outs => [ "res", "flags" ],
958 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
963 state => "exc_pinned",
964 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
965 ins => [ "base", "index", "mem" ],
966 emit => '. dec%M %AM',
970 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
975 reg_req => { in => [ "gp" ],
976 out => [ "in_r1", "flags" ] },
978 outs => [ "res", "flags" ],
988 state => "exc_pinned",
989 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
990 ins => [ "base", "index", "mem" ],
991 emit => '. not%M %AM',
999 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1003 mode => $mode_flags,
1004 modified_flags => $status_flags
1008 reg_req => { out => [ "flags" ] },
1012 mode => $mode_flags,
1013 modified_flags => $status_flags
1020 state => "exc_pinned",
1021 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1022 out => [ "flags", "none", "none" ] },
1023 ins => [ "base", "index", "mem", "left", "right" ],
1024 outs => [ "eflags", "unused", "M" ],
1025 am => "source,binary",
1026 emit => '. cmp%M %binop',
1027 attr => "int ins_permuted, int cmp_unsigned",
1028 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1029 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1032 mode => $mode_flags,
1033 modified_flags => $status_flags
1038 state => "exc_pinned",
1039 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1040 ins => [ "base", "index", "mem", "left", "right" ],
1041 outs => [ "eflags" ],
1042 am => "source,binary",
1043 emit => '. cmpb %binop',
1044 attr => "int ins_permuted, int cmp_unsigned",
1045 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1046 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1049 mode => $mode_flags,
1050 modified_flags => $status_flags
1055 state => "exc_pinned",
1056 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1057 ins => [ "base", "index", "mem", "left", "right" ],
1058 outs => [ "eflags" ],
1059 am => "source,binary",
1060 emit => '. test%M %binop',
1061 attr => "int ins_permuted, int cmp_unsigned",
1062 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1063 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1066 mode => $mode_flags,
1067 modified_flags => $status_flags
1072 state => "exc_pinned",
1073 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1074 ins => [ "base", "index", "mem", "left", "right" ],
1075 outs => [ "eflags" ],
1076 am => "source,binary",
1077 emit => '. testb %binop',
1078 attr => "int ins_permuted, int cmp_unsigned",
1079 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1080 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1083 mode => $mode_flags,
1084 modified_flags => $status_flags
1089 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1090 ins => [ "eflags" ],
1091 attr_type => "ia32_condcode_attr_t",
1092 attr => "pn_Cmp pnc, int ins_permuted",
1093 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1094 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1095 emit => '. set%CMP0 %DB0',
1103 state => "exc_pinned",
1104 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1105 ins => [ "base", "index", "mem","eflags" ],
1106 attr_type => "ia32_condcode_attr_t",
1107 attr => "pn_Cmp pnc, int ins_permuted",
1108 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1109 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1110 emit => '. set%CMP3 %AM',
1118 # (note: leave the false,true order intact to make it compatible with other
1120 state => "exc_pinned",
1121 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1122 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1123 am => "source,binary",
1124 attr_type => "ia32_condcode_attr_t",
1125 attr => "int ins_permuted, pn_Cmp pnc",
1126 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1134 op_flags => "L|X|Y",
1135 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1136 ins => [ "eflags" ],
1137 outs => [ "false", "true" ],
1138 attr_type => "ia32_condcode_attr_t",
1139 attr => "pn_Cmp pnc",
1141 units => [ "BRANCH" ],
1146 op_flags => "L|X|Y",
1147 reg_req => { in => [ "gp" ], out => [ "none" ] },
1149 attr_type => "ia32_condcode_attr_t",
1152 units => [ "BRANCH" ],
1153 modified_flags => $status_flags,
1159 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1160 ins => [ "base", "index", "mem", "target" ],
1161 am => "source,unary",
1162 emit => '. jmp *%unop3',
1164 units => [ "BRANCH" ],
1171 reg_req => { out => [ "gp" ] },
1173 attr => "ir_entity *symconst, int symconst_sign, long offset",
1174 attr_type => "ia32_immediate_attr_t",
1181 reg_req => { out => [ "gp" ] },
1185 modified_flags => $status_flags,
1192 reg_req => { out => [ "gp_UKNWN" ] },
1203 reg_req => { out => [ "vfp_UKNWN" ] },
1208 attr_type => "ia32_x87_attr_t",
1215 reg_req => { out => [ "xmm_UKNWN" ] },
1224 op_flags => "c|NB|NI",
1226 reg_req => { out => [ "gp_NOREG" ] },
1235 op_flags => "c|NB|NI",
1237 reg_req => { out => [ "vfp_NOREG" ] },
1242 attr_type => "ia32_x87_attr_t",
1247 op_flags => "c|NB|NI",
1249 reg_req => { out => [ "xmm_NOREG" ] },
1260 reg_req => { out => [ "fp_cw" ] },
1264 modified_flags => $fpcw_flags
1270 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1271 ins => [ "base", "index", "mem" ],
1273 emit => ". fldcw %AM",
1276 modified_flags => $fpcw_flags
1282 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1283 ins => [ "base", "index", "mem", "fpcw" ],
1285 emit => ". fnstcw %AM",
1293 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1301 # we should not rematrialize this node. It has very strict constraints.
1302 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1303 ins => [ "val", "clobbered" ],
1312 # Note that we add additional latency values depending on address mode, so a
1313 # lateny of 0 for load is correct
1317 state => "exc_pinned",
1318 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1319 ins => [ "base", "index", "mem" ],
1320 outs => [ "res", "M", "X_exc" ],
1322 emit => ". mov%SE%ME%.l %AM, %D0",
1328 state => "exc_pinned",
1329 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1330 ins => [ "base", "index", "mem", "val" ],
1331 outs => [ "M", "X_exc" ],
1332 emit => '. mov%M %SI3, %AM',
1340 state => "exc_pinned",
1341 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1342 ins => [ "base", "index", "mem", "val" ],
1343 outs => [ "M", "X_exc" ],
1344 emit => '. mov%M %SB3, %AM',
1352 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1353 ins => [ "base", "index" ],
1354 emit => '. leal %AM, %D0',
1358 # lea doesn't modify the flags, but setting this seems advantageous since it
1359 # increases chances that the Lea is transformed back to an Add
1360 modified_flags => 1,
1364 state => "exc_pinned",
1365 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1366 ins => [ "base", "index", "mem", "val", "stack" ],
1367 emit => '. push%M %unop3',
1368 outs => [ "stack:I|S", "M" ],
1369 am => "source,unary",
1375 state => "exc_pinned",
1376 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1377 ins => [ "mem", "stack" ],
1378 outs => [ "res", "M", "unused", "stack:I|S" ],
1379 emit => '. pop%M %D0',
1380 latency => 3, # Pop is more expensive than Push on Athlon
1385 state => "exc_pinned",
1386 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1387 ins => [ "base", "index", "mem", "stack" ],
1388 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1389 emit => '. pop%M %AM',
1390 latency => 3, # Pop is more expensive than Push on Athlon
1395 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1397 outs => [ "frame:I", "stack:I|S", "M" ],
1403 reg_req => { in => [ "ebp" ], out => [ "ebp", "esp" ] },
1405 outs => [ "frame:I", "stack:I|S" ],
1413 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1414 ins => [ "base", "index", "mem", "stack", "size" ],
1415 am => "source,binary",
1416 emit => '. addl %binop',
1418 outs => [ "stack:I|S", "M" ],
1420 modified_flags => $status_flags
1426 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1427 ins => [ "base", "index", "mem", "stack", "size" ],
1428 am => "source,binary",
1429 emit => ". subl %binop\n".
1430 ". movl %%esp, %D1",
1432 outs => [ "stack:I|S", "addr", "M" ],
1434 modified_flags => $status_flags
1447 reg_req => { out => [ "gp" ] },
1454 state => "exc_pinned",
1455 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1456 ins => [ "left", "right" ],
1457 emit => '. bt%M %S1, %S0',
1460 mode => $mode_flags,
1461 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1464 #-----------------------------------------------------------------------------#
1465 # _____ _____ ______ __ _ _ _ #
1466 # / ____/ ____| ____| / _| | | | | | #
1467 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1468 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1469 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1470 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1471 #-----------------------------------------------------------------------------#
1476 reg_req => { out => [ "xmm" ] },
1477 emit => '. xorp%XSD %D0, %D0',
1485 reg_req => { out => [ "xmm" ] },
1486 emit => '. pxor %D0, %D0',
1492 # produces all 1 bits
1495 reg_req => { out => [ "xmm" ] },
1496 emit => '. pcmpeqb %D0, %D0',
1502 # integer shift left, dword
1505 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1506 emit => '. pslld %SI1, %D0',
1512 # integer shift left, qword
1515 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1516 emit => '. psllq %SI1, %D0',
1522 # integer shift right, dword
1525 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1526 emit => '. psrld %SI1, %D0',
1532 # mov from integer to SSE register
1535 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1536 emit => '. movd %S0, %D0',
1542 # commutative operations
1546 state => "exc_pinned",
1547 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1548 ins => [ "base", "index", "mem", "left", "right" ],
1549 am => "source,binary",
1550 emit => '. add%XXM %binop',
1558 state => "exc_pinned",
1559 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1560 ins => [ "base", "index", "mem", "left", "right" ],
1561 am => "source,binary",
1562 emit => '. mul%XXM %binop',
1570 state => "exc_pinned",
1571 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1572 ins => [ "base", "index", "mem", "left", "right" ],
1573 am => "source,binary",
1574 emit => '. max%XXM %binop',
1582 state => "exc_pinned",
1583 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1584 ins => [ "base", "index", "mem", "left", "right" ],
1585 am => "source,binary",
1586 emit => '. min%XXM %binop',
1594 state => "exc_pinned",
1595 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1596 ins => [ "base", "index", "mem", "left", "right" ],
1597 am => "source,binary",
1598 emit => '. andp%XSD %binop',
1606 state => "exc_pinned",
1607 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1608 ins => [ "base", "index", "mem", "left", "right" ],
1609 am => "source,binary",
1610 emit => '. orp%XSD %binop',
1618 state => "exc_pinned",
1619 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1620 ins => [ "base", "index", "mem", "left", "right" ],
1621 am => "source,binary",
1622 emit => '. xorp%XSD %binop',
1628 # not commutative operations
1632 state => "exc_pinned",
1633 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1634 ins => [ "base", "index", "mem", "left", "right" ],
1635 am => "source,binary",
1636 emit => '. andnp%XSD %binop',
1644 state => "exc_pinned",
1645 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1646 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1647 am => "source,binary",
1648 emit => '. sub%XXM %binop',
1656 state => "exc_pinned",
1657 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1658 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1659 am => "source,binary",
1660 outs => [ "res", "M" ],
1661 emit => '. div%XXM %binop',
1670 state => "exc_pinned",
1671 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1672 ins => [ "base", "index", "mem", "left", "right" ],
1673 outs => [ "flags" ],
1674 am => "source,binary",
1675 attr => "int ins_permuted",
1676 init_attr => "attr->data.ins_permuted = ins_permuted;",
1677 emit => ' .ucomi%XXM %binop',
1680 mode => $mode_flags,
1681 modified_flags => 1,
1688 state => "exc_pinned",
1689 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1690 ins => [ "base", "index", "mem" ],
1691 outs => [ "res", "M", "X_exc" ],
1692 emit => '. mov%XXM %AM, %D0',
1693 attr => "ir_mode *load_mode",
1694 init_attr => "attr->ls_mode = load_mode;",
1701 state => "exc_pinned",
1702 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1703 ins => [ "base", "index", "mem", "val" ],
1704 outs => [ "M", "X_exc" ],
1705 emit => '. mov%XXM %S3, %AM',
1713 state => "exc_pinned",
1714 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1715 ins => [ "base", "index", "mem", "val" ],
1716 emit => '. mov%XXM %S3, %AM',
1724 state => "exc_pinned",
1725 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1726 ins => [ "base", "index", "mem", "val" ],
1727 am => "source,unary",
1728 emit => '. cvtsi2ss %unop3, %D0',
1736 state => "exc_pinned",
1737 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1738 ins => [ "base", "index", "mem", "val" ],
1739 am => "source,unary",
1740 emit => '. cvtsi2sd %unop3, %D0',
1749 cmp_attr => "return 1;",
1750 ins => [ "val_high", "val_low" ],
1755 cmp_attr => "return 1;",
1757 outs => [ "res_high", "res_low" ],
1765 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1766 outs => [ "DST", "SRC", "CNT", "M" ],
1767 attr_type => "ia32_copyb_attr_t",
1768 attr => "unsigned size",
1771 # we don't care about this flag, so no need to mark this node
1772 # modified_flags => [ "DF" ]
1778 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1779 outs => [ "DST", "SRC", "M" ],
1780 attr_type => "ia32_copyb_attr_t",
1781 attr => "unsigned size",
1784 # we don't care about this flag, so no need to mark this node
1785 # modified_flags => [ "DF" ]
1791 state => "exc_pinned",
1792 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1793 ins => [ "base", "index", "mem", "val" ],
1794 am => "source,unary",
1797 attr => "ir_mode *smaller_mode",
1798 init_attr => "attr->ls_mode = smaller_mode;",
1803 state => "exc_pinned",
1804 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1805 ins => [ "base", "index", "mem", "val" ],
1806 am => "source,unary",
1809 attr => "ir_mode *smaller_mode",
1810 init_attr => "attr->ls_mode = smaller_mode;",
1815 state => "exc_pinned",
1816 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1817 ins => [ "base", "index", "mem", "val" ],
1818 am => "source,unary",
1825 state => "exc_pinned",
1826 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1827 ins => [ "base", "index", "mem", "val" ],
1828 am => "source,unary",
1835 state => "exc_pinned",
1836 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1837 ins => [ "base", "index", "mem", "val" ],
1838 am => "source,unary",
1844 #----------------------------------------------------------#
1846 # (_) | | | | / _| | | | #
1847 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1848 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1849 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1850 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1852 # _ __ ___ __| | ___ ___ #
1853 # | '_ \ / _ \ / _` |/ _ \/ __| #
1854 # | | | | (_) | (_| | __/\__ \ #
1855 # |_| |_|\___/ \__,_|\___||___/ #
1856 #----------------------------------------------------------#
1858 # rematerialisation disabled for all float nodes for now, because the fpcw
1859 # handler runs before spilling and we might end up with wrong fpcw then
1863 state => "exc_pinned",
1864 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1865 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1866 am => "source,binary",
1870 attr_type => "ia32_x87_attr_t",
1875 state => "exc_pinned",
1876 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1877 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1878 am => "source,binary",
1882 attr_type => "ia32_x87_attr_t",
1887 state => "exc_pinned",
1888 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1889 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1890 am => "source,binary",
1894 attr_type => "ia32_x87_attr_t",
1898 state => "exc_pinned",
1899 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1900 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1901 am => "source,binary",
1902 outs => [ "res", "M" ],
1905 attr_type => "ia32_x87_attr_t",
1909 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1910 ins => [ "left", "right", "fpcw" ],
1914 attr_type => "ia32_x87_attr_t",
1919 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1924 attr_type => "ia32_x87_attr_t",
1929 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1934 attr_type => "ia32_x87_attr_t",
1937 # virtual Load and Store
1942 state => "exc_pinned",
1943 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1944 ins => [ "base", "index", "mem" ],
1945 outs => [ "res", "M", "X_exc" ],
1946 attr => "ir_mode *load_mode",
1947 init_attr => "attr->attr.ls_mode = load_mode;",
1950 attr_type => "ia32_x87_attr_t",
1956 state => "exc_pinned",
1957 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1958 ins => [ "base", "index", "mem", "val" ],
1959 outs => [ "M", "X_exc" ],
1960 attr => "ir_mode *store_mode",
1961 init_attr => "attr->attr.ls_mode = store_mode;",
1965 attr_type => "ia32_x87_attr_t",
1971 state => "exc_pinned",
1972 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1973 outs => [ "res", "M" ],
1974 ins => [ "base", "index", "mem" ],
1977 attr_type => "ia32_x87_attr_t",
1981 state => "exc_pinned",
1982 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1983 ins => [ "base", "index", "mem", "val", "fpcw" ],
1987 attr_type => "ia32_x87_attr_t",
1990 # SSE3 fisttp instruction
1992 state => "exc_pinned",
1993 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
1994 ins => [ "base", "index", "mem", "val" ],
1995 outs => [ "res", "M" ],
1998 attr_type => "ia32_x87_attr_t",
2006 reg_req => { out => [ "vfp" ] },
2010 attr_type => "ia32_x87_attr_t",
2015 reg_req => { out => [ "vfp" ] },
2019 attr_type => "ia32_x87_attr_t",
2024 reg_req => { out => [ "vfp" ] },
2028 attr_type => "ia32_x87_attr_t",
2033 reg_req => { out => [ "vfp" ] },
2037 attr_type => "ia32_x87_attr_t",
2042 reg_req => { out => [ "vfp" ] },
2046 attr_type => "ia32_x87_attr_t",
2051 reg_req => { out => [ "vfp" ] },
2055 attr_type => "ia32_x87_attr_t",
2060 reg_req => { out => [ "vfp" ] },
2064 attr_type => "ia32_x87_attr_t",
2070 # we can't allow to rematerialize this node so we don't have
2071 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2073 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2074 ins => [ "left", "right" ],
2075 outs => [ "flags" ],
2076 attr => "int ins_permuted",
2077 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2080 attr_type => "ia32_x87_attr_t",
2086 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2087 ins => [ "left", "right" ],
2088 outs => [ "flags" ],
2089 attr => "int ins_permuted",
2090 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2093 attr_type => "ia32_x87_attr_t",
2099 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2101 outs => [ "flags" ],
2102 attr => "int ins_permuted",
2103 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2106 attr_type => "ia32_x87_attr_t",
2112 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2114 outs => [ "flags" ],
2118 mode => $mode_flags,
2121 #------------------------------------------------------------------------#
2122 # ___ _____ __ _ _ _ #
2123 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2124 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2125 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2126 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2127 #------------------------------------------------------------------------#
2129 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2130 # are swapped, we work this around in the emitter...
2133 state => "exc_pinned",
2134 rd_constructor => "NONE",
2136 emit => '. fadd%XM %x87_binop',
2138 attr_type => "ia32_x87_attr_t",
2142 state => "exc_pinned",
2143 rd_constructor => "NONE",
2145 emit => '. faddp%XM %x87_binop',
2147 attr_type => "ia32_x87_attr_t",
2151 state => "exc_pinned",
2152 rd_constructor => "NONE",
2154 emit => '. fmul%XM %x87_binop',
2156 attr_type => "ia32_x87_attr_t",
2160 state => "exc_pinned",
2161 rd_constructor => "NONE",
2163 emit => '. fmulp%XM %x87_binop',,
2165 attr_type => "ia32_x87_attr_t",
2169 state => "exc_pinned",
2170 rd_constructor => "NONE",
2172 emit => '. fsub%XM %x87_binop',
2174 attr_type => "ia32_x87_attr_t",
2178 state => "exc_pinned",
2179 rd_constructor => "NONE",
2181 # see note about gas bugs
2182 emit => '. fsubrp%XM %x87_binop',
2184 attr_type => "ia32_x87_attr_t",
2188 state => "exc_pinned",
2189 rd_constructor => "NONE",
2192 emit => '. fsubr%XM %x87_binop',
2194 attr_type => "ia32_x87_attr_t",
2198 state => "exc_pinned",
2199 rd_constructor => "NONE",
2202 # see note about gas bugs
2203 emit => '. fsubp%XM %x87_binop',
2205 attr_type => "ia32_x87_attr_t",
2209 rd_constructor => "NONE",
2213 attr_type => "ia32_x87_attr_t",
2216 # this node is just here, to keep the simulator running
2217 # we can omit this when a fprem simulation function exists
2219 rd_constructor => "NONE",
2221 emit => '. fprem1\n'.
2224 attr_type => "ia32_x87_attr_t",
2228 state => "exc_pinned",
2229 rd_constructor => "NONE",
2231 emit => '. fdiv%XM %x87_binop',
2233 attr_type => "ia32_x87_attr_t",
2237 state => "exc_pinned",
2238 rd_constructor => "NONE",
2240 # see note about gas bugs
2241 emit => '. fdivrp%XM %x87_binop',
2243 attr_type => "ia32_x87_attr_t",
2247 state => "exc_pinned",
2248 rd_constructor => "NONE",
2250 emit => '. fdivr%XM %x87_binop',
2252 attr_type => "ia32_x87_attr_t",
2256 state => "exc_pinned",
2257 rd_constructor => "NONE",
2259 # see note about gas bugs
2260 emit => '. fdivp%XM %x87_binop',
2262 attr_type => "ia32_x87_attr_t",
2266 rd_constructor => "NONE",
2270 attr_type => "ia32_x87_attr_t",
2275 rd_constructor => "NONE",
2279 attr_type => "ia32_x87_attr_t",
2282 # x87 Load and Store
2285 rd_constructor => "NONE",
2286 op_flags => "R|L|F",
2287 state => "exc_pinned",
2289 emit => '. fld%XM %AM',
2290 attr_type => "ia32_x87_attr_t",
2295 rd_constructor => "NONE",
2296 op_flags => "R|L|F",
2297 state => "exc_pinned",
2299 emit => '. fst%XM %AM',
2301 attr_type => "ia32_x87_attr_t",
2306 rd_constructor => "NONE",
2307 op_flags => "R|L|F",
2308 state => "exc_pinned",
2310 emit => '. fstp%XM %AM',
2312 attr_type => "ia32_x87_attr_t",
2319 state => "exc_pinned",
2320 rd_constructor => "NONE",
2322 emit => '. fild%M %AM',
2323 attr_type => "ia32_x87_attr_t",
2328 state => "exc_pinned",
2329 rd_constructor => "NONE",
2331 emit => '. fist%M %AM',
2333 attr_type => "ia32_x87_attr_t",
2338 state => "exc_pinned",
2339 rd_constructor => "NONE",
2341 emit => '. fistp%M %AM',
2343 attr_type => "ia32_x87_attr_t",
2347 # SSE3 firsttp instruction
2349 state => "exc_pinned",
2350 rd_constructor => "NONE",
2352 emit => '. fisttp%M %AM',
2354 attr_type => "ia32_x87_attr_t",
2361 op_flags => "R|c|K",
2363 reg_req => { out => [ "vfp" ] },
2365 attr_type => "ia32_x87_attr_t",
2370 op_flags => "R|c|K",
2372 reg_req => { out => [ "vfp" ] },
2374 attr_type => "ia32_x87_attr_t",
2379 op_flags => "R|c|K",
2381 reg_req => { out => [ "vfp" ] },
2383 attr_type => "ia32_x87_attr_t",
2388 op_flags => "R|c|K",
2390 reg_req => { out => [ "vfp" ] },
2392 attr_type => "ia32_x87_attr_t",
2397 op_flags => "R|c|K",
2399 reg_req => { out => [ "vfp" ] },
2401 attr_type => "ia32_x87_attr_t",
2406 op_flags => "R|c|K",
2408 reg_req => { out => [ "vfp" ] },
2409 emit => '. fldll2t',
2410 attr_type => "ia32_x87_attr_t",
2415 op_flags => "R|c|K",
2417 reg_req => { out => [ "vfp" ] },
2419 attr_type => "ia32_x87_attr_t",
2424 # Note that it is NEVER allowed to do CSE on these nodes
2425 # Moreover, note the virtual register requierements!
2430 cmp_attr => "return 1;",
2431 emit => '. fxch %X0',
2432 attr_type => "ia32_x87_attr_t",
2440 cmp_attr => "return 1;",
2441 emit => '. fld %X0',
2442 attr_type => "ia32_x87_attr_t",
2448 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2449 cmp_attr => "return 1;",
2450 emit => '. fld %X0',
2451 attr_type => "ia32_x87_attr_t",
2458 cmp_attr => "return 1;",
2459 emit => '. fstp %X0',
2460 attr_type => "ia32_x87_attr_t",
2468 cmp_attr => "return 1;",
2469 emit => '. ffreep %X0',
2470 attr_type => "ia32_x87_attr_t",
2478 cmp_attr => "return 1;",
2480 attr_type => "ia32_x87_attr_t",
2488 cmp_attr => "return 1;",
2490 attr_type => "ia32_x87_attr_t",
2499 emit => ". fucom %X1\n".
2501 attr_type => "ia32_x87_attr_t",
2507 emit => ". fucomp %X1\n".
2509 attr_type => "ia32_x87_attr_t",
2515 emit => ". fucompp\n".
2517 attr_type => "ia32_x87_attr_t",
2523 emit => '. fucomi %X1',
2524 attr_type => "ia32_x87_attr_t",
2530 emit => '. fucompi %X1',
2531 attr_type => "ia32_x87_attr_t",
2539 attr_type => "ia32_x87_attr_t",
2544 # -------------------------------------------------------------------------------- #
2545 # ____ ____ _____ _ _ #
2546 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2547 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2548 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2549 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2551 # -------------------------------------------------------------------------------- #
2554 # Spilling and reloading of SSE registers, hardcoded, not generated #
2558 state => "exc_pinned",
2559 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2560 emit => '. movdqu %D0, %AM',
2561 outs => [ "res", "M" ],
2568 state => "exc_pinned",
2569 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2570 ins => [ "base", "index", "mem", "val" ],
2571 emit => '. movdqu %binop',
2579 # Include the generated SIMD node specification written by the SIMD optimization
2580 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2581 unless ($return = do $my_script_name) {
2582 warn "couldn't parse $my_script_name: $@" if $@;
2583 warn "couldn't do $my_script_name: $!" unless defined $return;
2584 warn "couldn't run $my_script_name" unless $return;
2587 # Transform some attributes
2588 foreach my $op (keys(%nodes)) {
2589 my $node = $nodes{$op};
2590 my $op_attr_init = $node->{op_attr_init};
2592 if(defined($op_attr_init)) {
2593 $op_attr_init .= "\n\t";
2598 if(!defined($node->{latency})) {
2600 $node->{latency} = 0;
2602 die("Latency missing for op $op");
2605 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2607 $node->{op_attr_init} = $op_attr_init;