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 | 16 },
155 { name => "vf1", type => 1 | 16 },
156 { name => "vf2", type => 1 | 16 },
157 { name => "vf3", type => 1 | 16 },
158 { name => "vf4", type => 1 | 16 },
159 { name => "vf5", type => 1 | 16 },
160 { name => "vf6", type => 1 | 16 },
161 { name => "vf7", type => 1 | 16 },
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", "gp" ] },
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 cmp_attr => "return 1;",
1329 outs => [ "res", "M" ],
1335 cmp_attr => "return 1;",
1336 state => "exc_pinned",
1343 state => "exc_pinned",
1344 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1345 ins => [ "base", "index", "mem", "val" ],
1346 outs => [ "M", "X_exc" ],
1347 emit => '. mov%M %SI3, %AM',
1355 state => "exc_pinned",
1356 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1357 ins => [ "base", "index", "mem", "val" ],
1358 outs => [ "M", "X_exc" ],
1359 emit => '. mov%M %SB3, %AM',
1367 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1368 ins => [ "base", "index" ],
1369 emit => '. leal %AM, %D0',
1373 # lea doesn't modify the flags, but setting this seems advantageous since it
1374 # increases chances that the Lea is transformed back to an Add
1375 modified_flags => 1,
1379 state => "exc_pinned",
1380 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1381 ins => [ "base", "index", "mem", "val", "stack" ],
1382 emit => '. push%M %unop3',
1383 outs => [ "stack:I|S", "M" ],
1384 am => "source,unary",
1390 state => "exc_pinned",
1391 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1392 ins => [ "mem", "stack" ],
1393 outs => [ "res", "M", "unused", "stack:I|S" ],
1394 emit => '. pop%M %D0',
1395 latency => 3, # Pop is more expensive than Push on Athlon
1400 state => "exc_pinned",
1401 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1402 ins => [ "base", "index", "mem", "stack" ],
1403 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1404 emit => '. pop%M %AM',
1405 latency => 3, # Pop is more expensive than Push on Athlon
1410 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1412 outs => [ "frame:I", "stack:I|S", "M" ],
1418 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1420 outs => [ "frame:I", "stack:I|S" ],
1428 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1429 ins => [ "base", "index", "mem", "stack", "size" ],
1430 am => "source,binary",
1431 emit => '. addl %binop',
1433 outs => [ "stack:I|S", "M" ],
1435 modified_flags => $status_flags
1441 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1442 ins => [ "base", "index", "mem", "stack", "size" ],
1443 am => "source,binary",
1444 emit => ". subl %binop\n".
1445 ". movl %%esp, %D1",
1447 outs => [ "stack:I|S", "addr", "M" ],
1449 modified_flags => $status_flags
1462 reg_req => { out => [ "gp" ] },
1469 state => "exc_pinned",
1470 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1471 ins => [ "left", "right" ],
1472 emit => '. bt%M %S1, %S0',
1475 mode => $mode_flags,
1476 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1479 #-----------------------------------------------------------------------------#
1480 # _____ _____ ______ __ _ _ _ #
1481 # / ____/ ____| ____| / _| | | | | | #
1482 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1483 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1484 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1485 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1486 #-----------------------------------------------------------------------------#
1491 reg_req => { out => [ "xmm" ] },
1492 emit => '. xorp%XSD %D0, %D0',
1500 reg_req => { out => [ "xmm" ] },
1501 emit => '. pxor %D0, %D0',
1507 # produces all 1 bits
1510 reg_req => { out => [ "xmm" ] },
1511 emit => '. pcmpeqb %D0, %D0',
1517 # integer shift left, dword
1520 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1521 emit => '. pslld %SI1, %D0',
1527 # integer shift left, qword
1530 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1531 emit => '. psllq %SI1, %D0',
1537 # integer shift right, dword
1540 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1541 emit => '. psrld %SI1, %D0',
1547 # mov from integer to SSE register
1550 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1551 emit => '. movd %S0, %D0',
1557 # commutative operations
1561 state => "exc_pinned",
1562 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1563 ins => [ "base", "index", "mem", "left", "right" ],
1564 am => "source,binary",
1565 emit => '. add%XXM %binop',
1573 state => "exc_pinned",
1574 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1575 ins => [ "base", "index", "mem", "left", "right" ],
1576 am => "source,binary",
1577 emit => '. mul%XXM %binop',
1585 state => "exc_pinned",
1586 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1587 ins => [ "base", "index", "mem", "left", "right" ],
1588 am => "source,binary",
1589 emit => '. max%XXM %binop',
1597 state => "exc_pinned",
1598 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1599 ins => [ "base", "index", "mem", "left", "right" ],
1600 am => "source,binary",
1601 emit => '. min%XXM %binop',
1609 state => "exc_pinned",
1610 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1611 ins => [ "base", "index", "mem", "left", "right" ],
1612 am => "source,binary",
1613 emit => '. andp%XSD %binop',
1621 state => "exc_pinned",
1622 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1623 ins => [ "base", "index", "mem", "left", "right" ],
1624 am => "source,binary",
1625 emit => '. orp%XSD %binop',
1633 state => "exc_pinned",
1634 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1635 ins => [ "base", "index", "mem", "left", "right" ],
1636 am => "source,binary",
1637 emit => '. xorp%XSD %binop',
1643 # not commutative operations
1647 state => "exc_pinned",
1648 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1649 ins => [ "base", "index", "mem", "left", "right" ],
1650 am => "source,binary",
1651 emit => '. andnp%XSD %binop',
1659 state => "exc_pinned",
1660 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1661 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1662 am => "source,binary",
1663 emit => '. sub%XXM %binop',
1671 state => "exc_pinned",
1672 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1673 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1674 am => "source,binary",
1675 outs => [ "res", "M" ],
1676 emit => '. div%XXM %binop',
1685 state => "exc_pinned",
1686 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1687 ins => [ "base", "index", "mem", "left", "right" ],
1688 outs => [ "flags" ],
1689 am => "source,binary",
1690 attr => "int ins_permuted",
1691 init_attr => "attr->data.ins_permuted = ins_permuted;",
1692 emit => ' .ucomi%XXM %binop',
1695 mode => $mode_flags,
1696 modified_flags => 1,
1703 state => "exc_pinned",
1704 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1705 ins => [ "base", "index", "mem" ],
1706 outs => [ "res", "M", "X_exc" ],
1707 emit => '. mov%XXM %AM, %D0',
1708 attr => "ir_mode *load_mode",
1709 init_attr => "attr->ls_mode = load_mode;",
1716 state => "exc_pinned",
1717 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1718 ins => [ "base", "index", "mem", "val" ],
1719 outs => [ "M", "X_exc" ],
1720 emit => '. mov%XXM %S3, %AM',
1728 state => "exc_pinned",
1729 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1730 ins => [ "base", "index", "mem", "val" ],
1731 emit => '. mov%XXM %S3, %AM',
1739 state => "exc_pinned",
1740 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1741 ins => [ "base", "index", "mem", "val" ],
1742 am => "source,unary",
1743 emit => '. cvtsi2ss %unop3, %D0',
1751 state => "exc_pinned",
1752 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1753 ins => [ "base", "index", "mem", "val" ],
1754 am => "source,unary",
1755 emit => '. cvtsi2sd %unop3, %D0',
1764 cmp_attr => "return 1;",
1765 ins => [ "val_high", "val_low" ],
1770 cmp_attr => "return 1;",
1772 outs => [ "res_high", "res_low" ],
1780 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1781 outs => [ "DST", "SRC", "CNT", "M" ],
1782 attr_type => "ia32_copyb_attr_t",
1783 attr => "unsigned size",
1786 # we don't care about this flag, so no need to mark this node
1787 # modified_flags => [ "DF" ]
1793 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1794 outs => [ "DST", "SRC", "M" ],
1795 attr_type => "ia32_copyb_attr_t",
1796 attr => "unsigned size",
1799 # we don't care about this flag, so no need to mark this node
1800 # modified_flags => [ "DF" ]
1806 state => "exc_pinned",
1807 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1808 ins => [ "base", "index", "mem", "val" ],
1809 am => "source,unary",
1812 attr => "ir_mode *smaller_mode",
1813 init_attr => "attr->ls_mode = smaller_mode;",
1818 state => "exc_pinned",
1819 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1820 ins => [ "base", "index", "mem", "val" ],
1821 am => "source,unary",
1824 attr => "ir_mode *smaller_mode",
1825 init_attr => "attr->ls_mode = smaller_mode;",
1830 state => "exc_pinned",
1831 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1832 ins => [ "base", "index", "mem", "val" ],
1833 am => "source,unary",
1840 state => "exc_pinned",
1841 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1842 ins => [ "base", "index", "mem", "val" ],
1843 am => "source,unary",
1850 state => "exc_pinned",
1851 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1852 ins => [ "base", "index", "mem", "val" ],
1853 am => "source,unary",
1859 #----------------------------------------------------------#
1861 # (_) | | | | / _| | | | #
1862 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1863 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1864 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1865 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1867 # _ __ ___ __| | ___ ___ #
1868 # | '_ \ / _ \ / _` |/ _ \/ __| #
1869 # | | | | (_) | (_| | __/\__ \ #
1870 # |_| |_|\___/ \__,_|\___||___/ #
1871 #----------------------------------------------------------#
1873 # rematerialisation disabled for all float nodes for now, because the fpcw
1874 # handler runs before spilling and we might end up with wrong fpcw then
1878 state => "exc_pinned",
1879 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1880 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1881 am => "source,binary",
1885 attr_type => "ia32_x87_attr_t",
1890 state => "exc_pinned",
1891 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1892 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1893 am => "source,binary",
1897 attr_type => "ia32_x87_attr_t",
1902 state => "exc_pinned",
1903 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1904 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1905 am => "source,binary",
1909 attr_type => "ia32_x87_attr_t",
1913 state => "exc_pinned",
1914 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1915 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1916 am => "source,binary",
1917 outs => [ "res", "M" ],
1920 attr_type => "ia32_x87_attr_t",
1924 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1925 ins => [ "left", "right", "fpcw" ],
1929 attr_type => "ia32_x87_attr_t",
1934 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1939 attr_type => "ia32_x87_attr_t",
1944 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1949 attr_type => "ia32_x87_attr_t",
1952 # virtual Load and Store
1957 state => "exc_pinned",
1958 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1959 ins => [ "base", "index", "mem" ],
1960 outs => [ "res", "M", "X_exc" ],
1961 attr => "ir_mode *load_mode",
1962 init_attr => "attr->attr.ls_mode = load_mode;",
1965 attr_type => "ia32_x87_attr_t",
1971 state => "exc_pinned",
1972 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1973 ins => [ "base", "index", "mem", "val" ],
1974 outs => [ "M", "X_exc" ],
1975 attr => "ir_mode *store_mode",
1976 init_attr => "attr->attr.ls_mode = store_mode;",
1980 attr_type => "ia32_x87_attr_t",
1986 state => "exc_pinned",
1987 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1988 outs => [ "res", "M" ],
1989 ins => [ "base", "index", "mem" ],
1992 attr_type => "ia32_x87_attr_t",
1996 cmp_attr => "return 1;",
1997 outs => [ "res", "M" ],
2002 state => "exc_pinned",
2003 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2004 ins => [ "base", "index", "mem", "val", "fpcw" ],
2008 attr_type => "ia32_x87_attr_t",
2011 # SSE3 fisttp instruction
2013 state => "exc_pinned",
2014 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2015 ins => [ "base", "index", "mem", "val" ],
2016 outs => [ "res", "M" ],
2019 attr_type => "ia32_x87_attr_t",
2023 cmp_attr => "return 1;",
2024 state => "exc_pinned",
2034 reg_req => { out => [ "vfp" ] },
2038 attr_type => "ia32_x87_attr_t",
2043 reg_req => { out => [ "vfp" ] },
2047 attr_type => "ia32_x87_attr_t",
2052 reg_req => { out => [ "vfp" ] },
2056 attr_type => "ia32_x87_attr_t",
2061 reg_req => { out => [ "vfp" ] },
2065 attr_type => "ia32_x87_attr_t",
2070 reg_req => { out => [ "vfp" ] },
2074 attr_type => "ia32_x87_attr_t",
2079 reg_req => { out => [ "vfp" ] },
2083 attr_type => "ia32_x87_attr_t",
2088 reg_req => { out => [ "vfp" ] },
2092 attr_type => "ia32_x87_attr_t",
2098 # we can't allow to rematerialize this node so we don't have
2099 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2101 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2102 ins => [ "left", "right" ],
2103 outs => [ "flags" ],
2104 attr => "int ins_permuted",
2105 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2108 attr_type => "ia32_x87_attr_t",
2114 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2115 ins => [ "left", "right" ],
2116 outs => [ "flags" ],
2117 attr => "int ins_permuted",
2118 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2121 attr_type => "ia32_x87_attr_t",
2127 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2129 outs => [ "flags" ],
2130 attr => "int ins_permuted",
2131 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2134 attr_type => "ia32_x87_attr_t",
2140 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2142 outs => [ "flags" ],
2146 mode => $mode_flags,
2149 #------------------------------------------------------------------------#
2150 # ___ _____ __ _ _ _ #
2151 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2152 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2153 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2154 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2155 #------------------------------------------------------------------------#
2157 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2158 # are swapped, we work this around in the emitter...
2161 state => "exc_pinned",
2162 rd_constructor => "NONE",
2164 emit => '. fadd%XM %x87_binop',
2166 attr_type => "ia32_x87_attr_t",
2170 state => "exc_pinned",
2171 rd_constructor => "NONE",
2173 emit => '. faddp%XM %x87_binop',
2175 attr_type => "ia32_x87_attr_t",
2179 state => "exc_pinned",
2180 rd_constructor => "NONE",
2182 emit => '. fmul%XM %x87_binop',
2184 attr_type => "ia32_x87_attr_t",
2188 state => "exc_pinned",
2189 rd_constructor => "NONE",
2191 emit => '. fmulp%XM %x87_binop',,
2193 attr_type => "ia32_x87_attr_t",
2197 state => "exc_pinned",
2198 rd_constructor => "NONE",
2200 emit => '. fsub%XM %x87_binop',
2202 attr_type => "ia32_x87_attr_t",
2206 state => "exc_pinned",
2207 rd_constructor => "NONE",
2209 # see note about gas bugs
2210 emit => '. fsubrp%XM %x87_binop',
2212 attr_type => "ia32_x87_attr_t",
2216 state => "exc_pinned",
2217 rd_constructor => "NONE",
2220 emit => '. fsubr%XM %x87_binop',
2222 attr_type => "ia32_x87_attr_t",
2226 state => "exc_pinned",
2227 rd_constructor => "NONE",
2230 # see note about gas bugs
2231 emit => '. fsubp%XM %x87_binop',
2233 attr_type => "ia32_x87_attr_t",
2237 rd_constructor => "NONE",
2241 attr_type => "ia32_x87_attr_t",
2244 # this node is just here, to keep the simulator running
2245 # we can omit this when a fprem simulation function exists
2247 rd_constructor => "NONE",
2249 emit => '. fprem1\n'.
2252 attr_type => "ia32_x87_attr_t",
2256 state => "exc_pinned",
2257 rd_constructor => "NONE",
2259 emit => '. fdiv%XM %x87_binop',
2261 attr_type => "ia32_x87_attr_t",
2265 state => "exc_pinned",
2266 rd_constructor => "NONE",
2268 # see note about gas bugs
2269 emit => '. fdivrp%XM %x87_binop',
2271 attr_type => "ia32_x87_attr_t",
2275 state => "exc_pinned",
2276 rd_constructor => "NONE",
2278 emit => '. fdivr%XM %x87_binop',
2280 attr_type => "ia32_x87_attr_t",
2284 state => "exc_pinned",
2285 rd_constructor => "NONE",
2287 # see note about gas bugs
2288 emit => '. fdivp%XM %x87_binop',
2290 attr_type => "ia32_x87_attr_t",
2294 rd_constructor => "NONE",
2298 attr_type => "ia32_x87_attr_t",
2303 rd_constructor => "NONE",
2307 attr_type => "ia32_x87_attr_t",
2310 # x87 Load and Store
2313 rd_constructor => "NONE",
2314 op_flags => "R|L|F",
2315 state => "exc_pinned",
2317 emit => '. fld%XM %AM',
2318 attr_type => "ia32_x87_attr_t",
2323 rd_constructor => "NONE",
2324 op_flags => "R|L|F",
2325 state => "exc_pinned",
2327 emit => '. fst%XM %AM',
2329 attr_type => "ia32_x87_attr_t",
2334 rd_constructor => "NONE",
2335 op_flags => "R|L|F",
2336 state => "exc_pinned",
2338 emit => '. fstp%XM %AM',
2340 attr_type => "ia32_x87_attr_t",
2347 state => "exc_pinned",
2348 rd_constructor => "NONE",
2350 emit => '. fild%M %AM',
2351 attr_type => "ia32_x87_attr_t",
2356 state => "exc_pinned",
2357 rd_constructor => "NONE",
2359 emit => '. fist%M %AM',
2361 attr_type => "ia32_x87_attr_t",
2366 state => "exc_pinned",
2367 rd_constructor => "NONE",
2369 emit => '. fistp%M %AM',
2371 attr_type => "ia32_x87_attr_t",
2375 # SSE3 firsttp instruction
2377 state => "exc_pinned",
2378 rd_constructor => "NONE",
2380 emit => '. fisttp%M %AM',
2382 attr_type => "ia32_x87_attr_t",
2389 op_flags => "R|c|K",
2391 reg_req => { out => [ "vfp" ] },
2393 attr_type => "ia32_x87_attr_t",
2398 op_flags => "R|c|K",
2400 reg_req => { out => [ "vfp" ] },
2402 attr_type => "ia32_x87_attr_t",
2407 op_flags => "R|c|K",
2409 reg_req => { out => [ "vfp" ] },
2411 attr_type => "ia32_x87_attr_t",
2416 op_flags => "R|c|K",
2418 reg_req => { out => [ "vfp" ] },
2420 attr_type => "ia32_x87_attr_t",
2425 op_flags => "R|c|K",
2427 reg_req => { out => [ "vfp" ] },
2429 attr_type => "ia32_x87_attr_t",
2434 op_flags => "R|c|K",
2436 reg_req => { out => [ "vfp" ] },
2437 emit => '. fldll2t',
2438 attr_type => "ia32_x87_attr_t",
2443 op_flags => "R|c|K",
2445 reg_req => { out => [ "vfp" ] },
2447 attr_type => "ia32_x87_attr_t",
2452 # Note that it is NEVER allowed to do CSE on these nodes
2453 # Moreover, note the virtual register requierements!
2458 cmp_attr => "return 1;",
2459 emit => '. fxch %X0',
2460 attr_type => "ia32_x87_attr_t",
2468 cmp_attr => "return 1;",
2469 emit => '. fld %X0',
2470 attr_type => "ia32_x87_attr_t",
2476 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2477 cmp_attr => "return 1;",
2478 emit => '. fld %X0',
2479 attr_type => "ia32_x87_attr_t",
2486 cmp_attr => "return 1;",
2487 emit => '. fstp %X0',
2488 attr_type => "ia32_x87_attr_t",
2496 cmp_attr => "return 1;",
2497 emit => '. ffreep %X0',
2498 attr_type => "ia32_x87_attr_t",
2506 cmp_attr => "return 1;",
2508 attr_type => "ia32_x87_attr_t",
2516 cmp_attr => "return 1;",
2518 attr_type => "ia32_x87_attr_t",
2527 emit => ". fucom %X1\n".
2529 attr_type => "ia32_x87_attr_t",
2535 emit => ". fucomp %X1\n".
2537 attr_type => "ia32_x87_attr_t",
2543 emit => ". fucompp\n".
2545 attr_type => "ia32_x87_attr_t",
2551 emit => '. fucomi %X1',
2552 attr_type => "ia32_x87_attr_t",
2558 emit => '. fucompi %X1',
2559 attr_type => "ia32_x87_attr_t",
2567 attr_type => "ia32_x87_attr_t",
2572 # -------------------------------------------------------------------------------- #
2573 # ____ ____ _____ _ _ #
2574 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2575 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2576 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2577 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2579 # -------------------------------------------------------------------------------- #
2582 # Spilling and reloading of SSE registers, hardcoded, not generated #
2586 state => "exc_pinned",
2587 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2588 emit => '. movdqu %D0, %AM',
2589 outs => [ "res", "M" ],
2596 state => "exc_pinned",
2597 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2598 ins => [ "base", "index", "mem", "val" ],
2599 emit => '. movdqu %binop',
2607 # Include the generated SIMD node specification written by the SIMD optimization
2608 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2609 unless ($return = do $my_script_name) {
2610 warn "couldn't parse $my_script_name: $@" if $@;
2611 warn "couldn't do $my_script_name: $!" unless defined $return;
2612 warn "couldn't run $my_script_name" unless $return;
2615 # Transform some attributes
2616 foreach my $op (keys(%nodes)) {
2617 my $node = $nodes{$op};
2618 my $op_attr_init = $node->{op_attr_init};
2620 if(defined($op_attr_init)) {
2621 $op_attr_init .= "\n\t";
2626 if(!defined($node->{latency})) {
2628 $node->{latency} = 0;
2630 die("Latency missing for op $op");
2633 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2635 $node->{op_attr_init} = $op_attr_init;