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, 3);",
223 unop4 => "${arch}_emit_unop(node, 4);",
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;
278 ia32_attr_t => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
280 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
281 "\tinit_ia32_x87_attributes(res);",
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
284 "\tinit_ia32_x87_attributes(res);".
285 "\tinit_ia32_asm_attributes(res);",
286 ia32_immediate_attr_t =>
287 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
288 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
290 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
291 "\tinit_ia32_copyb_attributes(res, size);",
292 ia32_condcode_attr_t =>
293 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
294 "\tinit_ia32_condcode_attributes(res, pnc);",
298 ia32_attr_t => "ia32_compare_nodes_attr",
299 ia32_x87_attr_t => "ia32_compare_x87_attr",
300 ia32_asm_attr_t => "ia32_compare_asm_attr",
301 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
302 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
303 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
309 $mode_xmm = "mode_E";
310 $mode_gp = "mode_Iu";
311 $mode_flags = "mode_Iu";
312 $mode_fpcw = "mode_fpcw";
313 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
314 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
315 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
323 reg_req => { out => [ "gp_NOREG" ] },
324 attr => "ir_entity *symconst, int symconst_sign, long offset",
325 attr_type => "ia32_immediate_attr_t",
326 hash_func => "ia32_hash_Immediate",
334 out_arity => "variable",
335 attr_type => "ia32_asm_attr_t",
336 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
337 init_attr => "attr->asm_text = asm_text;\n".
338 "\tattr->register_map = register_map;\n",
343 # "allocates" a free register
347 reg_req => { out => [ "gp" ] },
352 cmp_attr => "return 1;",
355 #-----------------------------------------------------------------#
358 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
359 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
360 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
361 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
364 #-----------------------------------------------------------------#
366 # commutative operations
370 state => "exc_pinned",
371 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
372 out => [ "in_r4 in_r5", "flags", "none" ] },
373 ins => [ "base", "index", "mem", "left", "right" ],
374 outs => [ "res", "flags", "M" ],
375 emit => '. add%M %binop',
376 am => "source,binary",
380 modified_flags => $status_flags
385 state => "exc_pinned",
386 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
387 ins => [ "base", "index", "mem", "val" ],
388 emit => ". add%M %SI3, %AM",
392 modified_flags => $status_flags
397 state => "exc_pinned",
398 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
399 ins => [ "base", "index", "mem", "val" ],
400 emit => ". add%M %SB3, %AM",
404 modified_flags => $status_flags
408 state => "exc_pinned",
409 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
410 out => [ "in_r4 in_r5", "flags", "none" ] },
411 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
412 outs => [ "res", "flags", "M" ],
413 emit => '. adc%M %binop',
414 am => "source,binary",
418 modified_flags => $status_flags
423 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
424 ins => [ "left", "right" ],
428 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
429 ins => [ "left", "right", "eflags" ],
433 # we should not rematrialize this node. It produces 2 results and has
434 # very strict constrains
435 state => "exc_pinned",
436 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
437 out => [ "eax", "edx", "none" ] },
438 ins => [ "base", "index", "mem", "val_high", "val_low" ],
439 emit => '. mul%M %unop4',
440 outs => [ "res_low", "res_high", "M" ],
441 am => "source,binary",
444 modified_flags => $status_flags
448 # we should not rematrialize this node. It produces 2 results and has
449 # very strict constrains
451 cmp_attr => "return 1;",
452 outs => [ "EAX", "EDX", "M" ],
458 state => "exc_pinned",
459 # TODO: adjust out requirements for the 3 operand form
460 # (no need for should_be_same then)
461 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
462 out => [ "in_r4 in_r5", "flags", "none" ] },
463 ins => [ "base", "index", "mem", "left", "right" ],
464 outs => [ "res", "flags", "M" ],
465 am => "source,binary",
469 modified_flags => $status_flags
474 state => "exc_pinned",
475 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
476 out => [ "eax", "edx", "none" ] },
477 ins => [ "base", "index", "mem", "val_high", "val_low" ],
478 emit => '. imul%M %unop4',
479 outs => [ "res_low", "res_high", "M" ],
480 am => "source,binary",
483 modified_flags => $status_flags
488 cmp_attr => "return 1;",
489 outs => [ "res_low", "res_high", "M" ],
495 state => "exc_pinned",
496 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
497 out => [ "in_r4 in_r5", "flags", "none" ] },
498 ins => [ "base", "index", "mem", "left", "right" ],
499 outs => [ "res", "flags", "M" ],
500 op_modes => "commutative | am | immediate | mode_neutral",
501 am => "source,binary",
502 emit => '. and%M %binop',
506 modified_flags => $status_flags
511 state => "exc_pinned",
512 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
513 ins => [ "base", "index", "mem", "val" ],
514 emit => '. and%M %SI3, %AM',
518 modified_flags => $status_flags
523 state => "exc_pinned",
524 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
525 ins => [ "base", "index", "mem", "val" ],
526 emit => '. and%M %SB3, %AM',
530 modified_flags => $status_flags
535 state => "exc_pinned",
536 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
537 out => [ "in_r4 in_r5", "flags", "none" ] },
538 ins => [ "base", "index", "mem", "left", "right" ],
539 outs => [ "res", "flags", "M" ],
540 am => "source,binary",
541 emit => '. or%M %binop',
545 modified_flags => $status_flags
550 state => "exc_pinned",
551 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
552 ins => [ "base", "index", "mem", "val" ],
553 emit => '. or%M %SI3, %AM',
557 modified_flags => $status_flags
562 state => "exc_pinned",
563 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
564 ins => [ "base", "index", "mem", "val" ],
565 emit => '. or%M %SB3, %AM',
569 modified_flags => $status_flags
574 state => "exc_pinned",
575 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
576 out => [ "in_r4 in_r5", "flags", "none" ] },
577 ins => [ "base", "index", "mem", "left", "right" ],
578 outs => [ "res", "flags", "M" ],
579 am => "source,binary",
580 emit => '. xor%M %binop',
584 modified_flags => $status_flags
589 state => "exc_pinned",
590 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
591 ins => [ "base", "index", "mem", "val" ],
592 emit => '. xor%M %SI3, %AM',
596 modified_flags => $status_flags
601 state => "exc_pinned",
602 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
603 ins => [ "base", "index", "mem", "val" ],
604 emit => '. xor%M %SB3, %AM',
608 modified_flags => $status_flags
611 # not commutative operations
615 state => "exc_pinned",
616 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
617 out => [ "in_r4", "flags", "none" ] },
618 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
619 outs => [ "res", "flags", "M" ],
620 am => "source,binary",
621 emit => '. sub%M %binop',
625 modified_flags => $status_flags
630 state => "exc_pinned",
631 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
632 ins => [ "base", "index", "mem", "subtrahend" ],
633 emit => '. sub%M %SI3, %AM',
637 modified_flags => $status_flags
642 state => "exc_pinned",
643 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
644 ins => [ "base", "index", "mem", "subtrahend" ],
645 emit => '. sub%M %SB3, %AM',
649 modified_flags => $status_flags
653 state => "exc_pinned",
654 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
655 out => [ "in_r4 !in_r5", "flags", "none" ] },
656 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
657 outs => [ "res", "flags", "M" ],
658 am => "source,binary",
659 emit => '. sbb%M %binop',
663 modified_flags => $status_flags
667 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
668 ins => [ "minuend", "subtrahend" ],
672 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
673 ins => [ "minuend", "subtrahend", "eflags" ],
678 state => "exc_pinned",
679 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
680 out => [ "eax", "flags", "none", "edx", "none" ] },
681 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
682 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
683 am => "source,ternary",
684 emit => ". idiv%M %unop3",
687 modified_flags => $status_flags
692 state => "exc_pinned",
693 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
694 out => [ "eax", "flags", "none", "edx", "none" ] },
695 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
696 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
697 am => "source,ternary",
698 emit => ". div%M %unop3",
701 modified_flags => $status_flags
706 reg_req => { in => [ "gp", "ecx" ],
707 out => [ "in_r1 !in_r2", "flags" ] },
708 ins => [ "val", "count" ],
709 outs => [ "res", "flags" ],
710 emit => '. shl %SB1, %S0',
714 modified_flags => $status_flags
719 state => "exc_pinned",
720 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
721 ins => [ "base", "index", "mem", "count" ],
722 emit => '. shl%M %SB3, %AM',
726 modified_flags => $status_flags
730 cmp_attr => "return 1;",
731 ins => [ "val", "count", "dep" ],
737 reg_req => { in => [ "gp", "gp", "ecx" ],
738 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
739 ins => [ "val_high", "val_low", "count" ],
740 outs => [ "res", "flags" ],
741 emit => ". shld%M %SB2, %S1, %D0",
745 modified_flags => $status_flags
749 cmp_attr => "return 1;",
750 ins => [ "val_high", "val_low", "count" ],
756 reg_req => { in => [ "gp", "ecx" ],
757 out => [ "in_r1 !in_r2", "flags" ] },
758 ins => [ "val", "count" ],
759 outs => [ "res", "flags" ],
760 emit => '. shr %SB1, %S0',
764 modified_flags => $status_flags
769 state => "exc_pinned",
770 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
771 ins => [ "base", "index", "mem", "count" ],
772 emit => '. shr%M %SB3, %AM',
776 modified_flags => $status_flags
780 cmp_attr => "return 1;",
781 ins => [ "val", "count", "dep" ],
787 reg_req => { in => [ "gp", "gp", "ecx" ],
788 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
789 ins => [ "val_high", "val_low", "count" ],
790 outs => [ "res", "flags" ],
791 emit => ". shrd%M %SB2, %S1, %D0",
795 modified_flags => $status_flags
799 cmp_attr => "return 1;",
801 ins => [ "val_high", "val_low", "count" ],
806 reg_req => { in => [ "gp", "ecx" ],
807 out => [ "in_r1 !in_r2", "flags" ] },
808 ins => [ "val", "count" ],
809 outs => [ "res", "flags" ],
810 emit => '. sar %SB1, %S0',
814 modified_flags => $status_flags
819 state => "exc_pinned",
820 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
821 ins => [ "base", "index", "mem", "count" ],
822 emit => '. sar%M %SB3, %AM',
826 modified_flags => $status_flags
830 cmp_attr => "return 1;",
831 ins => [ "val", "count", "dep" ],
837 reg_req => { in => [ "gp", "ecx" ],
838 out => [ "in_r1 !in_r2", "flags" ] },
839 ins => [ "val", "count" ],
840 outs => [ "res", "flags" ],
841 emit => '. ror %SB1, %S0',
845 modified_flags => $status_flags
850 state => "exc_pinned",
851 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
852 ins => [ "base", "index", "mem", "count" ],
853 emit => '. ror%M %SB3, %AM',
857 modified_flags => $status_flags
862 reg_req => { in => [ "gp", "ecx" ],
863 out => [ "in_r1 !in_r2", "flags" ] },
864 ins => [ "val", "count" ],
865 outs => [ "res", "flags" ],
866 emit => '. rol %SB1, %S0',
870 modified_flags => $status_flags
875 state => "exc_pinned",
876 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
877 ins => [ "base", "index", "mem", "count" ],
878 emit => '. rol%M %SB3, %AM',
882 modified_flags => $status_flags
889 reg_req => { in => [ "gp" ],
890 out => [ "in_r1", "flags" ] },
893 outs => [ "res", "flags" ],
897 modified_flags => $status_flags
902 state => "exc_pinned",
903 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
904 ins => [ "base", "index", "mem" ],
905 emit => '. neg%M %AM',
909 modified_flags => $status_flags
914 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
915 outs => [ "low_res", "high_res" ],
918 modified_flags => $status_flags
924 reg_req => { in => [ "gp" ],
925 out => [ "in_r1", "flags" ] },
927 outs => [ "res", "flags" ],
932 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
937 state => "exc_pinned",
938 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
939 ins => [ "base", "index", "mem" ],
940 emit => '. inc%M %AM',
944 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
949 reg_req => { in => [ "gp" ],
950 out => [ "in_r1", "flags" ] },
952 outs => [ "res", "flags" ],
957 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
962 state => "exc_pinned",
963 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
964 ins => [ "base", "index", "mem" ],
965 emit => '. dec%M %AM',
969 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
974 reg_req => { in => [ "gp" ],
975 out => [ "in_r1", "flags" ] },
977 outs => [ "res", "flags" ],
987 state => "exc_pinned",
988 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
989 ins => [ "base", "index", "mem" ],
990 emit => '. not%M %AM',
998 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1002 mode => $mode_flags,
1003 modified_flags => $status_flags
1007 reg_req => { out => [ "flags" ] },
1011 mode => $mode_flags,
1012 modified_flags => $status_flags
1019 state => "exc_pinned",
1020 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1021 out => [ "flags", "none", "none" ] },
1022 ins => [ "base", "index", "mem", "left", "right" ],
1023 outs => [ "eflags", "unused", "M" ],
1024 am => "source,binary",
1025 emit => '. cmp%M %binop',
1026 attr => "int ins_permuted, int cmp_unsigned",
1027 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1028 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1031 mode => $mode_flags,
1032 modified_flags => $status_flags
1037 state => "exc_pinned",
1038 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1039 ins => [ "base", "index", "mem", "left", "right" ],
1040 outs => [ "eflags" ],
1041 am => "source,binary",
1042 emit => '. cmpb %binop',
1043 attr => "int ins_permuted, int cmp_unsigned",
1044 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1045 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1048 mode => $mode_flags,
1049 modified_flags => $status_flags
1054 state => "exc_pinned",
1055 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1056 ins => [ "base", "index", "mem", "left", "right" ],
1057 outs => [ "eflags" ],
1058 am => "source,binary",
1059 emit => '. test%M %binop',
1060 attr => "int ins_permuted, int cmp_unsigned",
1061 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1062 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1065 mode => $mode_flags,
1066 modified_flags => $status_flags
1071 state => "exc_pinned",
1072 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1073 ins => [ "base", "index", "mem", "left", "right" ],
1074 outs => [ "eflags" ],
1075 am => "source,binary",
1076 emit => '. testb %binop',
1077 attr => "int ins_permuted, int cmp_unsigned",
1078 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1079 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1082 mode => $mode_flags,
1083 modified_flags => $status_flags
1088 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1089 ins => [ "eflags" ],
1090 attr_type => "ia32_condcode_attr_t",
1091 attr => "pn_Cmp pnc, int ins_permuted",
1092 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1093 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1094 emit => '. set%CMP0 %DB0',
1102 state => "exc_pinned",
1103 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1104 ins => [ "base", "index", "mem","eflags" ],
1105 attr_type => "ia32_condcode_attr_t",
1106 attr => "pn_Cmp pnc, int ins_permuted",
1107 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1108 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1109 emit => '. set%CMP3 %AM',
1117 # (note: leave the false,true order intact to make it compatible with other
1119 state => "exc_pinned",
1120 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1121 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1122 am => "source,binary",
1123 attr_type => "ia32_condcode_attr_t",
1124 attr => "int ins_permuted, pn_Cmp pnc",
1125 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1133 op_flags => "L|X|Y",
1134 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1135 ins => [ "eflags" ],
1136 outs => [ "false", "true" ],
1137 attr_type => "ia32_condcode_attr_t",
1138 attr => "pn_Cmp pnc",
1140 units => [ "BRANCH" ],
1145 op_flags => "L|X|Y",
1146 reg_req => { in => [ "gp" ], out => [ "none" ] },
1148 attr_type => "ia32_condcode_attr_t",
1151 units => [ "BRANCH" ],
1152 modified_flags => $status_flags,
1158 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1159 ins => [ "base", "index", "mem", "target" ],
1160 am => "source,unary",
1161 emit => '. jmp *%unop3',
1163 units => [ "BRANCH" ],
1170 reg_req => { out => [ "gp" ] },
1172 attr => "ir_entity *symconst, int symconst_sign, long offset",
1173 attr_type => "ia32_immediate_attr_t",
1180 reg_req => { out => [ "gp" ] },
1184 modified_flags => $status_flags,
1191 reg_req => { out => [ "gp_UKNWN" ] },
1202 reg_req => { out => [ "vfp_UKNWN" ] },
1207 attr_type => "ia32_x87_attr_t",
1214 reg_req => { out => [ "xmm_UKNWN" ] },
1223 op_flags => "c|NB|NI",
1225 reg_req => { out => [ "gp_NOREG" ] },
1234 op_flags => "c|NB|NI",
1236 reg_req => { out => [ "vfp_NOREG" ] },
1241 attr_type => "ia32_x87_attr_t",
1246 op_flags => "c|NB|NI",
1248 reg_req => { out => [ "xmm_NOREG" ] },
1259 reg_req => { out => [ "fp_cw" ] },
1263 modified_flags => $fpcw_flags
1269 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1270 ins => [ "base", "index", "mem" ],
1272 emit => ". fldcw %AM",
1275 modified_flags => $fpcw_flags
1281 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1282 ins => [ "base", "index", "mem", "fpcw" ],
1284 emit => ". fnstcw %AM",
1292 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1300 # we should not rematrialize this node. It has very strict constraints.
1301 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1302 ins => [ "val", "clobbered" ],
1311 # Note that we add additional latency values depending on address mode, so a
1312 # lateny of 0 for load is correct
1316 state => "exc_pinned",
1317 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1318 ins => [ "base", "index", "mem" ],
1319 outs => [ "res", "M", "X_exc" ],
1321 emit => ". mov%SE%ME%.l %AM, %D0",
1327 cmp_attr => "return 1;",
1328 outs => [ "res", "M" ],
1334 cmp_attr => "return 1;",
1335 state => "exc_pinned",
1342 state => "exc_pinned",
1343 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1344 ins => [ "base", "index", "mem", "val" ],
1345 outs => [ "M", "X_exc" ],
1346 emit => '. mov%M %SI3, %AM',
1354 state => "exc_pinned",
1355 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1356 ins => [ "base", "index", "mem", "val" ],
1357 outs => [ "M", "X_exc" ],
1358 emit => '. mov%M %SB3, %AM',
1366 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1367 ins => [ "base", "index" ],
1368 emit => '. leal %AM, %D0',
1372 # lea doesn't modify the flags, but setting this seems advantageous since it
1373 # increases chances that the Lea is transformed back to an Add
1374 modified_flags => 1,
1378 state => "exc_pinned",
1379 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp", "none" ] },
1380 ins => [ "base", "index", "mem", "val", "stack" ],
1381 emit => '. push%M %unop3',
1382 outs => [ "stack:I|S", "M" ],
1383 am => "source,binary",
1389 state => "exc_pinned",
1390 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp" ] },
1391 ins => [ "mem", "stack" ],
1392 outs => [ "res", "M", "unused", "stack:I|S" ],
1393 emit => '. pop%M %D0',
1394 latency => 3, # Pop is more expensive than Push on Athlon
1399 state => "exc_pinned",
1400 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp" ] },
1401 ins => [ "base", "index", "mem", "stack" ],
1402 outs => [ "unused0", "M", "unused1", "stack:I|S" ],
1403 emit => '. pop%M %AM',
1404 latency => 3, # Pop is more expensive than Push on Athlon
1409 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1411 outs => [ "frame:I", "stack:I|S", "M" ],
1417 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1419 outs => [ "frame:I", "stack:I|S" ],
1427 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1428 ins => [ "base", "index", "mem", "stack", "size" ],
1429 am => "source,binary",
1430 emit => '. addl %binop',
1432 outs => [ "stack:I|S", "M" ],
1434 modified_flags => $status_flags
1440 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1441 ins => [ "base", "index", "mem", "stack", "size" ],
1442 am => "source,binary",
1443 emit => ". subl %binop\n".
1444 ". movl %%esp, %D1",
1446 outs => [ "stack:I|S", "addr", "M" ],
1448 modified_flags => $status_flags
1461 reg_req => { out => [ "gp" ] },
1468 state => "exc_pinned",
1469 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1470 ins => [ "left", "right" ],
1471 emit => '. bt%M %S1, %S0',
1474 mode => $mode_flags,
1475 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1478 #-----------------------------------------------------------------------------#
1479 # _____ _____ ______ __ _ _ _ #
1480 # / ____/ ____| ____| / _| | | | | | #
1481 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1482 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1483 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1484 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1485 #-----------------------------------------------------------------------------#
1490 reg_req => { out => [ "xmm" ] },
1491 emit => '. xorp%XSD %D0, %D0',
1499 reg_req => { out => [ "xmm" ] },
1500 emit => '. pxor %D0, %D0',
1506 # produces all 1 bits
1509 reg_req => { out => [ "xmm" ] },
1510 emit => '. pcmpeqb %D0, %D0',
1516 # integer shift left, dword
1519 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1520 emit => '. pslld %SI1, %D0',
1526 # integer shift left, qword
1529 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1530 emit => '. psllq %SI1, %D0',
1536 # integer shift right, dword
1539 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1540 emit => '. psrld %SI1, %D0',
1546 # mov from integer to SSE register
1549 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1550 emit => '. movd %S0, %D0',
1556 # commutative operations
1560 state => "exc_pinned",
1561 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1562 ins => [ "base", "index", "mem", "left", "right" ],
1563 am => "source,binary",
1564 emit => '. add%XXM %binop',
1572 state => "exc_pinned",
1573 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1574 ins => [ "base", "index", "mem", "left", "right" ],
1575 am => "source,binary",
1576 emit => '. mul%XXM %binop',
1584 state => "exc_pinned",
1585 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1586 ins => [ "base", "index", "mem", "left", "right" ],
1587 am => "source,binary",
1588 emit => '. max%XXM %binop',
1596 state => "exc_pinned",
1597 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1598 ins => [ "base", "index", "mem", "left", "right" ],
1599 am => "source,binary",
1600 emit => '. min%XXM %binop',
1608 state => "exc_pinned",
1609 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1610 ins => [ "base", "index", "mem", "left", "right" ],
1611 am => "source,binary",
1612 emit => '. andp%XSD %binop',
1620 state => "exc_pinned",
1621 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1622 ins => [ "base", "index", "mem", "left", "right" ],
1623 am => "source,binary",
1624 emit => '. orp%XSD %binop',
1632 state => "exc_pinned",
1633 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1634 ins => [ "base", "index", "mem", "left", "right" ],
1635 am => "source,binary",
1636 emit => '. xorp%XSD %binop',
1642 # not commutative operations
1646 state => "exc_pinned",
1647 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1648 ins => [ "base", "index", "mem", "left", "right" ],
1649 am => "source,binary",
1650 emit => '. andnp%XSD %binop',
1658 state => "exc_pinned",
1659 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1660 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1661 am => "source,binary",
1662 emit => '. sub%XXM %binop',
1670 state => "exc_pinned",
1671 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1672 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1673 am => "source,binary",
1674 outs => [ "res", "M" ],
1675 emit => '. div%XXM %binop',
1684 state => "exc_pinned",
1685 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1686 ins => [ "base", "index", "mem", "left", "right" ],
1687 outs => [ "flags" ],
1688 am => "source,binary",
1689 attr => "int ins_permuted",
1690 init_attr => "attr->data.ins_permuted = ins_permuted;",
1691 emit => ' .ucomi%XXM %binop',
1694 mode => $mode_flags,
1695 modified_flags => 1,
1702 state => "exc_pinned",
1703 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1704 ins => [ "base", "index", "mem" ],
1705 outs => [ "res", "M", "X_exc" ],
1706 emit => '. mov%XXM %AM, %D0',
1707 attr => "ir_mode *load_mode",
1708 init_attr => "attr->ls_mode = load_mode;",
1715 state => "exc_pinned",
1716 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1717 ins => [ "base", "index", "mem", "val" ],
1718 outs => [ "M", "X_exc" ],
1719 emit => '. mov%XXM %S3, %AM',
1727 state => "exc_pinned",
1728 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1729 ins => [ "base", "index", "mem", "val" ],
1730 emit => '. mov%XXM %S3, %AM',
1738 state => "exc_pinned",
1739 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1740 ins => [ "base", "index", "mem", "val" ],
1741 am => "source,unary",
1742 emit => '. cvtsi2ss %unop3, %D0',
1750 state => "exc_pinned",
1751 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1752 ins => [ "base", "index", "mem", "val" ],
1753 am => "source,unary",
1754 emit => '. cvtsi2sd %unop3, %D0',
1763 cmp_attr => "return 1;",
1764 ins => [ "val_high", "val_low" ],
1769 cmp_attr => "return 1;",
1771 outs => [ "res_high", "res_low" ],
1779 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1780 outs => [ "DST", "SRC", "CNT", "M" ],
1781 attr_type => "ia32_copyb_attr_t",
1782 attr => "unsigned size",
1785 # we don't care about this flag, so no need to mark this node
1786 # modified_flags => [ "DF" ]
1792 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1793 outs => [ "DST", "SRC", "M" ],
1794 attr_type => "ia32_copyb_attr_t",
1795 attr => "unsigned size",
1798 # we don't care about this flag, so no need to mark this node
1799 # modified_flags => [ "DF" ]
1805 state => "exc_pinned",
1806 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1807 ins => [ "base", "index", "mem", "val" ],
1808 am => "source,unary",
1811 attr => "ir_mode *smaller_mode",
1812 init_attr => "attr->ls_mode = smaller_mode;",
1817 state => "exc_pinned",
1818 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1819 ins => [ "base", "index", "mem", "val" ],
1820 am => "source,unary",
1823 attr => "ir_mode *smaller_mode",
1824 init_attr => "attr->ls_mode = smaller_mode;",
1829 state => "exc_pinned",
1830 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1831 ins => [ "base", "index", "mem", "val" ],
1832 am => "source,unary",
1839 state => "exc_pinned",
1840 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1841 ins => [ "base", "index", "mem", "val" ],
1842 am => "source,unary",
1849 state => "exc_pinned",
1850 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1851 ins => [ "base", "index", "mem", "val" ],
1852 am => "source,unary",
1858 #----------------------------------------------------------#
1860 # (_) | | | | / _| | | | #
1861 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1862 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1863 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1864 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1866 # _ __ ___ __| | ___ ___ #
1867 # | '_ \ / _ \ / _` |/ _ \/ __| #
1868 # | | | | (_) | (_| | __/\__ \ #
1869 # |_| |_|\___/ \__,_|\___||___/ #
1870 #----------------------------------------------------------#
1872 # rematerialisation disabled for all float nodes for now, because the fpcw
1873 # handler runs before spilling and we might end up with wrong fpcw then
1877 state => "exc_pinned",
1878 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1879 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1880 am => "source,binary",
1884 attr_type => "ia32_x87_attr_t",
1889 state => "exc_pinned",
1890 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1891 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
1892 am => "source,binary",
1896 attr_type => "ia32_x87_attr_t",
1901 state => "exc_pinned",
1902 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1903 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
1904 am => "source,binary",
1908 attr_type => "ia32_x87_attr_t",
1912 state => "exc_pinned",
1913 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1914 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
1915 am => "source,binary",
1916 outs => [ "res", "M" ],
1919 attr_type => "ia32_x87_attr_t",
1923 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1924 ins => [ "left", "right", "fpcw" ],
1928 attr_type => "ia32_x87_attr_t",
1933 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1938 attr_type => "ia32_x87_attr_t",
1943 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1948 attr_type => "ia32_x87_attr_t",
1951 # virtual Load and Store
1956 state => "exc_pinned",
1957 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
1958 ins => [ "base", "index", "mem" ],
1959 outs => [ "res", "M", "X_exc" ],
1960 attr => "ir_mode *load_mode",
1961 init_attr => "attr->attr.ls_mode = load_mode;",
1964 attr_type => "ia32_x87_attr_t",
1970 state => "exc_pinned",
1971 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
1972 ins => [ "base", "index", "mem", "val" ],
1973 outs => [ "M", "X_exc" ],
1974 attr => "ir_mode *store_mode",
1975 init_attr => "attr->attr.ls_mode = store_mode;",
1979 attr_type => "ia32_x87_attr_t",
1985 state => "exc_pinned",
1986 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1987 outs => [ "res", "M" ],
1988 ins => [ "base", "index", "mem" ],
1991 attr_type => "ia32_x87_attr_t",
1995 cmp_attr => "return 1;",
1996 outs => [ "res", "M" ],
2001 state => "exc_pinned",
2002 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2003 ins => [ "base", "index", "mem", "val", "fpcw" ],
2007 attr_type => "ia32_x87_attr_t",
2010 # SSE3 fisttp instruction
2012 state => "exc_pinned",
2013 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2014 ins => [ "base", "index", "mem", "val" ],
2015 outs => [ "res", "M" ],
2018 attr_type => "ia32_x87_attr_t",
2022 cmp_attr => "return 1;",
2023 state => "exc_pinned",
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",
2069 reg_req => { out => [ "vfp" ] },
2073 attr_type => "ia32_x87_attr_t",
2078 reg_req => { out => [ "vfp" ] },
2082 attr_type => "ia32_x87_attr_t",
2087 reg_req => { out => [ "vfp" ] },
2091 attr_type => "ia32_x87_attr_t",
2097 # we can't allow to rematerialize this node so we don't have
2098 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2100 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2101 ins => [ "left", "right" ],
2102 outs => [ "flags" ],
2103 attr => "int ins_permuted",
2104 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2107 attr_type => "ia32_x87_attr_t",
2113 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2114 ins => [ "left", "right" ],
2115 outs => [ "flags" ],
2116 attr => "int ins_permuted",
2117 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2120 attr_type => "ia32_x87_attr_t",
2126 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2128 outs => [ "flags" ],
2129 attr => "int ins_permuted",
2130 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2133 attr_type => "ia32_x87_attr_t",
2139 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2141 outs => [ "flags" ],
2145 mode => $mode_flags,
2148 #------------------------------------------------------------------------#
2149 # ___ _____ __ _ _ _ #
2150 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2151 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2152 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2153 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2154 #------------------------------------------------------------------------#
2156 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2157 # are swapped, we work this around in the emitter...
2160 state => "exc_pinned",
2161 rd_constructor => "NONE",
2163 emit => '. fadd%XM %x87_binop',
2165 attr_type => "ia32_x87_attr_t",
2169 state => "exc_pinned",
2170 rd_constructor => "NONE",
2172 emit => '. faddp%XM %x87_binop',
2174 attr_type => "ia32_x87_attr_t",
2178 state => "exc_pinned",
2179 rd_constructor => "NONE",
2181 emit => '. fmul%XM %x87_binop',
2183 attr_type => "ia32_x87_attr_t",
2187 state => "exc_pinned",
2188 rd_constructor => "NONE",
2190 emit => '. fmulp%XM %x87_binop',,
2192 attr_type => "ia32_x87_attr_t",
2196 state => "exc_pinned",
2197 rd_constructor => "NONE",
2199 emit => '. fsub%XM %x87_binop',
2201 attr_type => "ia32_x87_attr_t",
2205 state => "exc_pinned",
2206 rd_constructor => "NONE",
2208 # see note about gas bugs
2209 emit => '. fsubrp%XM %x87_binop',
2211 attr_type => "ia32_x87_attr_t",
2215 state => "exc_pinned",
2216 rd_constructor => "NONE",
2219 emit => '. fsubr%XM %x87_binop',
2221 attr_type => "ia32_x87_attr_t",
2225 state => "exc_pinned",
2226 rd_constructor => "NONE",
2229 # see note about gas bugs
2230 emit => '. fsubp%XM %x87_binop',
2232 attr_type => "ia32_x87_attr_t",
2236 rd_constructor => "NONE",
2240 attr_type => "ia32_x87_attr_t",
2243 # this node is just here, to keep the simulator running
2244 # we can omit this when a fprem simulation function exists
2246 rd_constructor => "NONE",
2248 emit => '. fprem1\n'.
2251 attr_type => "ia32_x87_attr_t",
2255 state => "exc_pinned",
2256 rd_constructor => "NONE",
2258 emit => '. fdiv%XM %x87_binop',
2260 attr_type => "ia32_x87_attr_t",
2264 state => "exc_pinned",
2265 rd_constructor => "NONE",
2267 # see note about gas bugs
2268 emit => '. fdivrp%XM %x87_binop',
2270 attr_type => "ia32_x87_attr_t",
2274 state => "exc_pinned",
2275 rd_constructor => "NONE",
2277 emit => '. fdivr%XM %x87_binop',
2279 attr_type => "ia32_x87_attr_t",
2283 state => "exc_pinned",
2284 rd_constructor => "NONE",
2286 # see note about gas bugs
2287 emit => '. fdivp%XM %x87_binop',
2289 attr_type => "ia32_x87_attr_t",
2293 rd_constructor => "NONE",
2297 attr_type => "ia32_x87_attr_t",
2302 rd_constructor => "NONE",
2306 attr_type => "ia32_x87_attr_t",
2309 # x87 Load and Store
2312 rd_constructor => "NONE",
2313 op_flags => "R|L|F",
2314 state => "exc_pinned",
2316 emit => '. fld%XM %AM',
2317 attr_type => "ia32_x87_attr_t",
2322 rd_constructor => "NONE",
2323 op_flags => "R|L|F",
2324 state => "exc_pinned",
2326 emit => '. fst%XM %AM',
2328 attr_type => "ia32_x87_attr_t",
2333 rd_constructor => "NONE",
2334 op_flags => "R|L|F",
2335 state => "exc_pinned",
2337 emit => '. fstp%XM %AM',
2339 attr_type => "ia32_x87_attr_t",
2346 state => "exc_pinned",
2347 rd_constructor => "NONE",
2349 emit => '. fild%M %AM',
2350 attr_type => "ia32_x87_attr_t",
2355 state => "exc_pinned",
2356 rd_constructor => "NONE",
2358 emit => '. fist%M %AM',
2360 attr_type => "ia32_x87_attr_t",
2365 state => "exc_pinned",
2366 rd_constructor => "NONE",
2368 emit => '. fistp%M %AM',
2370 attr_type => "ia32_x87_attr_t",
2374 # SSE3 firsttp instruction
2376 state => "exc_pinned",
2377 rd_constructor => "NONE",
2379 emit => '. fisttp%M %AM',
2381 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" ] },
2410 attr_type => "ia32_x87_attr_t",
2415 op_flags => "R|c|K",
2417 reg_req => { out => [ "vfp" ] },
2419 attr_type => "ia32_x87_attr_t",
2424 op_flags => "R|c|K",
2426 reg_req => { out => [ "vfp" ] },
2428 attr_type => "ia32_x87_attr_t",
2433 op_flags => "R|c|K",
2435 reg_req => { out => [ "vfp" ] },
2436 emit => '. fldll2t',
2437 attr_type => "ia32_x87_attr_t",
2442 op_flags => "R|c|K",
2444 reg_req => { out => [ "vfp" ] },
2446 attr_type => "ia32_x87_attr_t",
2451 # Note that it is NEVER allowed to do CSE on these nodes
2452 # Moreover, note the virtual register requierements!
2457 cmp_attr => "return 1;",
2458 emit => '. fxch %X0',
2459 attr_type => "ia32_x87_attr_t",
2467 cmp_attr => "return 1;",
2468 emit => '. fld %X0',
2469 attr_type => "ia32_x87_attr_t",
2475 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2476 cmp_attr => "return 1;",
2477 emit => '. fld %X0',
2478 attr_type => "ia32_x87_attr_t",
2485 cmp_attr => "return 1;",
2486 emit => '. fstp %X0',
2487 attr_type => "ia32_x87_attr_t",
2495 cmp_attr => "return 1;",
2496 emit => '. ffreep %X0',
2497 attr_type => "ia32_x87_attr_t",
2505 cmp_attr => "return 1;",
2507 attr_type => "ia32_x87_attr_t",
2515 cmp_attr => "return 1;",
2517 attr_type => "ia32_x87_attr_t",
2526 emit => ". fucom %X1\n".
2528 attr_type => "ia32_x87_attr_t",
2534 emit => ". fucomp %X1\n".
2536 attr_type => "ia32_x87_attr_t",
2542 emit => ". fucompp\n".
2544 attr_type => "ia32_x87_attr_t",
2550 emit => '. fucomi %X1',
2551 attr_type => "ia32_x87_attr_t",
2557 emit => '. fucompi %X1',
2558 attr_type => "ia32_x87_attr_t",
2566 attr_type => "ia32_x87_attr_t",
2571 # -------------------------------------------------------------------------------- #
2572 # ____ ____ _____ _ _ #
2573 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2574 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2575 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2576 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2578 # -------------------------------------------------------------------------------- #
2581 # Spilling and reloading of SSE registers, hardcoded, not generated #
2585 state => "exc_pinned",
2586 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2587 emit => '. movdqu %D0, %AM',
2588 outs => [ "res", "M" ],
2595 state => "exc_pinned",
2596 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2597 ins => [ "base", "index", "mem", "val" ],
2598 emit => '. movdqu %binop',
2606 # Include the generated SIMD node specification written by the SIMD optimization
2607 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2608 unless ($return = do $my_script_name) {
2609 warn "couldn't parse $my_script_name: $@" if $@;
2610 warn "couldn't do $my_script_name: $!" unless defined $return;
2611 warn "couldn't run $my_script_name" unless $return;
2614 # Transform some attributes
2615 foreach my $op (keys(%nodes)) {
2616 my $node = $nodes{$op};
2617 my $op_attr_init = $node->{op_attr_init};
2619 if(defined($op_attr_init)) {
2620 $op_attr_init .= "\n\t";
2625 if(!defined($node->{latency})) {
2627 $node->{latency} = 0;
2629 die("Latency missing for op $op");
2632 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2634 $node->{op_attr_init} = $op_attr_init;