3 # This is the specification for the ia32 assembler Firm-operations
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
13 # The node description is done as a perl hash initializer with the
14 # following structure:
19 # op_flags => "N|L|C|X|I|F|Y|H|c|K",
21 # arity => "0|1|2|3 ... |variable|dynamic|any",
22 # state => "floats|pinned|mem_pinned|exc_pinned",
24 # { type => "type 1", name => "name 1" },
25 # { type => "type 2", name => "name 2" },
28 # comment => "any comment for constructor",
29 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 # cmp_attr => "c source code for comparing node attributes",
31 # outs => { "out1", "out2" } # optional, creates pn_op_out1, ... consts
32 # ins => { "in1", "in2" } # optional, creates n_op_in1, ... consts
33 # mode => "mode_Iu" # optional, predefines the mode
34 # emit => "emit code with templates",
35 # attr => "additional attribute arguments for constructor",
36 # init_attr => "emit attribute initialization template",
37 # rd_constructor => "c source code which constructs an ir_node",
38 # hash_func => "name of the hash function for this operation",
39 # latency => "latency of this operation (can be float)"
40 # attr_type => "name of the attribute struct",
41 # modified_flags => [ "CF", ... ] # optional, list of modified flags
44 # ... # (all nodes you need to describe)
46 # ); # close the %nodes initializer
48 # op_flags: flags for the operation, OPTIONAL (default is "N")
49 # the op_flags correspond to the firm irop_flags:
52 # C irop_flag_commutative
53 # X irop_flag_cfopcode
54 # I irop_flag_ip_cfopcode
57 # H irop_flag_highlevel
58 # c irop_flag_constlike
60 # NB irop_flag_dump_noblock
61 # NI irop_flag_dump_noinput
63 # irn_flags: special node flags, OPTIONAL (default is 0)
64 # following irn_flags are supported:
68 # state: state of the operation, OPTIONAL (default is "floats")
70 # arity: arity of the operation, MUST NOT BE OMITTED
72 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
73 # are always the first 3 arguments and are always autmatically
75 # If this key is missing the following arguments will be created:
76 # for i = 1 .. arity: ir_node *op_i
79 # outs: if a node defines more than one output, the names of the projections
80 # nodes having outs having automatically the mode mode_T
81 # example: [ "frame", "stack", "M" ]
83 # comment: OPTIONAL comment for the node constructor
85 # rd_constructor: for every operation there will be a
86 # new_rd_<arch>_<op-name> function with the arguments from above
87 # which creates the ir_node corresponding to the defined operation
88 # you can either put the complete source code of this function here
90 # This key is OPTIONAL. If omitted, the following constructor will
92 # if (!op_<arch>_<op-name>) assert(0);
96 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
99 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
103 # 0 - no special type
104 # 1 - caller save (register must be saved by the caller of a function)
105 # 2 - callee save (register must be saved by the called function)
106 # 4 - ignore (do not assign this register)
107 # 8 - emitter can choose an arbitrary register of this class
108 # 16 - the register is a virtual one
109 # 32 - register represents a state
110 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
113 { name => "edx", type => 1 },
114 { name => "ecx", type => 1 },
115 { name => "eax", type => 1 },
116 { name => "ebx", type => 2 },
117 { name => "esi", type => 2 },
118 { name => "edi", type => 2 },
119 { name => "ebp", type => 2 },
120 { name => "esp", type => 4 },
121 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
122 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
123 { mode => "mode_Iu" }
126 { name => "mm0", type => 4 },
127 { name => "mm1", type => 4 },
128 { name => "mm2", type => 4 },
129 { name => "mm3", type => 4 },
130 { name => "mm4", type => 4 },
131 { name => "mm5", type => 4 },
132 { name => "mm6", type => 4 },
133 { name => "mm7", type => 4 },
134 { mode => "mode_E", flags => "manual_ra" }
137 { name => "xmm0", type => 1 },
138 { name => "xmm1", type => 1 },
139 { name => "xmm2", type => 1 },
140 { name => "xmm3", type => 1 },
141 { name => "xmm4", type => 1 },
142 { name => "xmm5", type => 1 },
143 { name => "xmm6", type => 1 },
144 { name => "xmm7", type => 1 },
145 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
146 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
150 { name => "vf0", type => 1 },
151 { name => "vf1", type => 1 },
152 { name => "vf2", type => 1 },
153 { name => "vf3", type => 1 },
154 { name => "vf4", type => 1 },
155 { name => "vf5", type => 1 },
156 { name => "vf6", type => 1 },
157 { name => "vf7", type => 1 },
158 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
159 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
163 { name => "st0", realname => "st", type => 4 },
164 { name => "st1", realname => "st(1)", type => 4 },
165 { name => "st2", realname => "st(2)", type => 4 },
166 { name => "st3", realname => "st(3)", type => 4 },
167 { name => "st4", realname => "st(4)", type => 4 },
168 { name => "st5", realname => "st(5)", type => 4 },
169 { name => "st6", realname => "st(6)", type => 4 },
170 { name => "st7", realname => "st(7)", type => 4 },
171 { mode => "mode_E", flags => "manual_ra" }
173 fp_cw => [ # the floating point control word
174 { name => "fpcw", type => 4|32 },
175 { mode => "mode_fpcw", flags => "manual_ra|state" }
178 { name => "eflags", type => 0 },
179 { mode => "mode_Iu", flags => "manual_ra" }
184 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
185 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
186 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
187 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
192 bundels_per_cycle => 1
196 S0 => "${arch}_emit_source_register(node, 0);",
197 S1 => "${arch}_emit_source_register(node, 1);",
198 S2 => "${arch}_emit_source_register(node, 2);",
199 S3 => "${arch}_emit_source_register(node, 3);",
200 SB0 => "${arch}_emit_8bit_source_register_or_immediate(node, 0);",
201 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
202 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
203 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
204 SH0 => "${arch}_emit_8bit_high_source_register(node, 0);",
205 SS0 => "${arch}_emit_16bit_source_register_or_immediate(node, 0);",
206 SI0 => "${arch}_emit_source_register_or_immediate(node, 0);",
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 DS0 => "${arch}_emit_dest_register_size(node, 0);",
212 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
213 X0 => "${arch}_emit_x87_register(node, 0);",
214 X1 => "${arch}_emit_x87_register(node, 1);",
215 EX => "${arch}_emit_extend_suffix(node);",
216 M => "${arch}_emit_mode_suffix(node);",
217 XM => "${arch}_emit_x87_mode_suffix(node);",
218 XXM => "${arch}_emit_xmm_mode_suffix(node);",
219 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
220 AM => "${arch}_emit_am(node);",
221 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
222 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
223 binop => "${arch}_emit_binop(node);",
224 x87_binop => "${arch}_emit_x87_binop(node);",
225 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
226 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
229 #--------------------------------------------------#
232 # _ __ _____ __ _ _ __ ___ _ __ ___ #
233 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
234 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
235 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
238 #--------------------------------------------------#
240 $default_op_attr_type = "ia32_op_attr_t";
241 $default_attr_type = "ia32_attr_t";
242 $default_copy_attr = "ia32_copy_attr";
244 sub ia32_custom_init_attr {
249 if(defined($node->{modified_flags})) {
250 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
252 if(defined($node->{am})) {
253 my $am = $node->{am};
254 if($am eq "source,unary") {
255 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
256 } elsif($am eq "source,binary") {
257 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
258 } elsif($am eq "none") {
261 die("Invalid address mode '$am' specified on op $name");
264 if($node->{state} ne "exc_pinned"
265 and $node->{state} ne "pinned") {
266 die("AM nodes must have pinned or AM pinned state ($name)");
272 $custom_init_attr_func = \&ia32_custom_init_attr;
276 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
277 "\tinit_ia32_x87_attributes(res);".
278 "\tinit_ia32_asm_attributes(res);",
280 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
282 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
283 "\tinit_ia32_call_attributes(res, pop, call_tp);",
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, no_pic_adjust, offset);",
294 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
295 "\tinit_ia32_x87_attributes(res);",
296 ia32_climbframe_attr_t =>
297 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
298 "\tinit_ia32_climbframe_attributes(res, count);",
302 ia32_asm_attr_t => "ia32_compare_asm_attr",
303 ia32_attr_t => "ia32_compare_nodes_attr",
304 ia32_call_attr_t => "ia32_compare_call_attr",
305 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
306 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
307 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
308 ia32_x87_attr_t => "ia32_compare_x87_attr",
309 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
315 $mode_xmm = "mode_E";
316 $mode_gp = "mode_Iu";
317 $mode_flags = "mode_Iu";
318 $mode_fpcw = "mode_fpcw";
319 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
320 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
321 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
322 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
329 reg_req => { out => [ "gp_NOREG:I" ] },
330 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
331 attr_type => "ia32_immediate_attr_t",
332 hash_func => "ia32_hash_Immediate",
340 out_arity => "variable",
341 attr_type => "ia32_asm_attr_t",
342 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
343 init_attr => "attr->asm_text = asm_text;\n".
344 "\tattr->register_map = register_map;\n",
346 modified_flags => $status_flags,
349 # "allocates" a free register
353 reg_req => { out => [ "gp" ] },
358 cmp_attr => "return 1;",
361 #-----------------------------------------------------------------#
364 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
365 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
366 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
367 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
370 #-----------------------------------------------------------------#
372 # commutative operations
376 state => "exc_pinned",
377 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
378 out => [ "in_r4 in_r5", "flags", "none" ] },
379 ins => [ "base", "index", "mem", "left", "right" ],
380 outs => [ "res", "flags", "M" ],
381 emit => '. add%M %binop',
382 am => "source,binary",
386 modified_flags => $status_flags
391 state => "exc_pinned",
392 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
393 ins => [ "base", "index", "mem", "val" ],
394 emit => ". add%M %SI3, %AM",
398 modified_flags => $status_flags
403 state => "exc_pinned",
404 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
405 ins => [ "base", "index", "mem", "val" ],
406 emit => ". add%M %SB3, %AM",
410 modified_flags => $status_flags
414 state => "exc_pinned",
415 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
416 out => [ "in_r4 in_r5", "flags", "none" ] },
417 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
418 outs => [ "res", "flags", "M" ],
419 emit => '. adc%M %binop',
420 am => "source,binary",
424 modified_flags => $status_flags
429 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
430 ins => [ "left", "right" ],
434 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
435 ins => [ "left", "right", "eflags" ],
439 # we should not rematrialize this node. It produces 2 results and has
440 # very strict constraints
441 state => "exc_pinned",
442 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
443 out => [ "eax", "flags", "none", "edx" ] },
444 ins => [ "base", "index", "mem", "left", "right" ],
445 emit => '. mul%M %unop4',
446 outs => [ "res_low", "flags", "M", "res_high" ],
447 am => "source,binary",
450 modified_flags => $status_flags
454 # we should not rematrialize this node. It produces 2 results and has
455 # very strict constraints
457 cmp_attr => "return 1;",
458 outs => [ "res_low", "flags", "M", "res_high" ],
464 state => "exc_pinned",
465 # TODO: adjust out requirements for the 3 operand form
466 # (no need for should_be_same then)
467 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
468 out => [ "in_r4 in_r5", "flags", "none" ] },
469 ins => [ "base", "index", "mem", "left", "right" ],
470 outs => [ "res", "flags", "M" ],
471 am => "source,binary",
475 modified_flags => $status_flags
480 state => "exc_pinned",
481 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
482 out => [ "eax", "flags", "none", "edx" ] },
483 ins => [ "base", "index", "mem", "left", "right" ],
484 emit => '. imul%M %unop4',
485 outs => [ "res_low", "flags", "M", "res_high" ],
486 am => "source,binary",
489 modified_flags => $status_flags
494 cmp_attr => "return 1;",
495 outs => [ "res_low", "flags", "M", "res_high" ],
501 state => "exc_pinned",
502 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
503 out => [ "in_r4 in_r5", "flags", "none" ] },
504 ins => [ "base", "index", "mem", "left", "right" ],
505 outs => [ "res", "flags", "M" ],
506 op_modes => "commutative | am | immediate | mode_neutral",
507 am => "source,binary",
508 emit => '. and%M %binop',
512 modified_flags => $status_flags
517 state => "exc_pinned",
518 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
519 ins => [ "base", "index", "mem", "val" ],
520 emit => '. and%M %SI3, %AM',
524 modified_flags => $status_flags
529 state => "exc_pinned",
530 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
531 ins => [ "base", "index", "mem", "val" ],
532 emit => '. and%M %SB3, %AM',
536 modified_flags => $status_flags
541 state => "exc_pinned",
542 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
543 out => [ "in_r4 in_r5", "flags", "none" ] },
544 ins => [ "base", "index", "mem", "left", "right" ],
545 outs => [ "res", "flags", "M" ],
546 am => "source,binary",
547 emit => '. or%M %binop',
551 modified_flags => $status_flags
556 state => "exc_pinned",
557 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
558 ins => [ "base", "index", "mem", "val" ],
559 emit => '. or%M %SI3, %AM',
563 modified_flags => $status_flags
568 state => "exc_pinned",
569 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
570 ins => [ "base", "index", "mem", "val" ],
571 emit => '. or%M %SB3, %AM',
575 modified_flags => $status_flags
580 state => "exc_pinned",
581 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
582 out => [ "in_r4 in_r5", "flags", "none" ] },
583 ins => [ "base", "index", "mem", "left", "right" ],
584 outs => [ "res", "flags", "M" ],
585 am => "source,binary",
586 emit => '. xor%M %binop',
590 modified_flags => $status_flags
596 reg_req => { out => [ "gp", "flags" ] },
597 outs => [ "res", "flags" ],
598 emit => ". xor%M %D0, %D0",
602 modified_flags => $status_flags
607 state => "exc_pinned",
608 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
609 ins => [ "base", "index", "mem", "val" ],
610 emit => '. xor%M %SI3, %AM',
614 modified_flags => $status_flags
619 state => "exc_pinned",
620 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
621 ins => [ "base", "index", "mem", "val" ],
622 emit => '. xor%M %SB3, %AM',
626 modified_flags => $status_flags
629 # not commutative operations
633 state => "exc_pinned",
634 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
635 out => [ "in_r4", "flags", "none" ] },
636 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
637 outs => [ "res", "flags", "M" ],
638 am => "source,binary",
639 emit => '. sub%M %binop',
643 modified_flags => $status_flags
648 state => "exc_pinned",
649 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
650 ins => [ "base", "index", "mem", "subtrahend" ],
651 emit => '. sub%M %SI3, %AM',
655 modified_flags => $status_flags
660 state => "exc_pinned",
661 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
662 ins => [ "base", "index", "mem", "subtrahend" ],
663 emit => '. sub%M %SB3, %AM',
667 modified_flags => $status_flags
671 state => "exc_pinned",
672 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
673 out => [ "in_r4 !in_r5", "flags", "none" ] },
674 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
675 outs => [ "res", "flags", "M" ],
676 am => "source,binary",
677 emit => '. sbb%M %binop',
681 modified_flags => $status_flags
686 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
687 outs => [ "res", "flags" ],
688 emit => ". sbb%M %D0, %D0",
692 modified_flags => $status_flags
696 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
697 ins => [ "minuend", "subtrahend" ],
701 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
702 ins => [ "minuend", "subtrahend", "eflags" ],
707 state => "exc_pinned",
708 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
709 out => [ "eax", "flags", "none", "edx", "none" ] },
710 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
711 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
712 am => "source,unary",
713 emit => ". idiv%M %unop3",
716 modified_flags => $status_flags
721 state => "exc_pinned",
722 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
723 out => [ "eax", "flags", "none", "edx", "none" ] },
724 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
725 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
726 am => "source,unary",
727 emit => ". div%M %unop3",
730 modified_flags => $status_flags
735 reg_req => { in => [ "gp", "ecx" ],
736 out => [ "in_r1 !in_r2", "flags" ] },
737 ins => [ "val", "count" ],
738 outs => [ "res", "flags" ],
739 emit => '. shl%M %SB1, %S0',
743 modified_flags => $status_flags
748 state => "exc_pinned",
749 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
750 ins => [ "base", "index", "mem", "count" ],
751 emit => '. shl%M %SB3, %AM',
755 modified_flags => $status_flags
759 cmp_attr => "return 1;",
760 ins => [ "val", "count", "dep" ],
766 reg_req => { in => [ "gp", "gp", "ecx" ],
767 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
768 ins => [ "val_high", "val_low", "count" ],
769 outs => [ "res", "flags" ],
770 emit => ". shld%M %SB2, %S1, %D0",
774 modified_flags => $status_flags
778 cmp_attr => "return 1;",
779 ins => [ "val_high", "val_low", "count" ],
785 reg_req => { in => [ "gp", "ecx" ],
786 out => [ "in_r1 !in_r2", "flags" ] },
787 ins => [ "val", "count" ],
788 outs => [ "res", "flags" ],
789 emit => '. shr%M %SB1, %S0',
793 modified_flags => $status_flags
798 state => "exc_pinned",
799 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
800 ins => [ "base", "index", "mem", "count" ],
801 emit => '. shr%M %SB3, %AM',
805 modified_flags => $status_flags
809 cmp_attr => "return 1;",
810 ins => [ "val", "count", "dep" ],
816 reg_req => { in => [ "gp", "gp", "ecx" ],
817 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
818 ins => [ "val_high", "val_low", "count" ],
819 outs => [ "res", "flags" ],
820 emit => ". shrd%M %SB2, %S1, %D0",
824 modified_flags => $status_flags
828 cmp_attr => "return 1;",
830 ins => [ "val_high", "val_low", "count" ],
835 reg_req => { in => [ "gp", "ecx" ],
836 out => [ "in_r1 !in_r2", "flags" ] },
837 ins => [ "val", "count" ],
838 outs => [ "res", "flags" ],
839 emit => '. sar%M %SB1, %S0',
843 modified_flags => $status_flags
848 state => "exc_pinned",
849 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
850 ins => [ "base", "index", "mem", "count" ],
851 emit => '. sar%M %SB3, %AM',
855 modified_flags => $status_flags
859 cmp_attr => "return 1;",
860 ins => [ "val", "count", "dep" ],
866 reg_req => { in => [ "gp", "ecx" ],
867 out => [ "in_r1 !in_r2", "flags" ] },
868 ins => [ "val", "count" ],
869 outs => [ "res", "flags" ],
870 emit => '. ror%M %SB1, %S0',
874 modified_flags => $status_flags
879 state => "exc_pinned",
880 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
881 ins => [ "base", "index", "mem", "count" ],
882 emit => '. ror%M %SB3, %AM',
886 modified_flags => $status_flags
891 reg_req => { in => [ "gp", "ecx" ],
892 out => [ "in_r1 !in_r2", "flags" ] },
893 ins => [ "val", "count" ],
894 outs => [ "res", "flags" ],
895 emit => '. rol%M %SB1, %S0',
899 modified_flags => $status_flags
904 state => "exc_pinned",
905 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
906 ins => [ "base", "index", "mem", "count" ],
907 emit => '. rol%M %SB3, %AM',
911 modified_flags => $status_flags
918 reg_req => { in => [ "gp" ],
919 out => [ "in_r1", "flags" ] },
920 emit => '. neg%M %S0',
922 outs => [ "res", "flags" ],
926 modified_flags => $status_flags
931 state => "exc_pinned",
932 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
933 ins => [ "base", "index", "mem" ],
934 emit => '. neg%M %AM',
938 modified_flags => $status_flags
943 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
944 outs => [ "low_res", "high_res" ],
947 modified_flags => $status_flags
953 reg_req => { in => [ "gp" ],
954 out => [ "in_r1", "flags" ] },
956 outs => [ "res", "flags" ],
957 emit => '. inc%M %S0',
961 modified_flags => $status_flags_wo_cf
966 state => "exc_pinned",
967 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
968 ins => [ "base", "index", "mem" ],
969 emit => '. inc%M %AM',
973 modified_flags => $status_flags_wo_cf
978 reg_req => { in => [ "gp" ],
979 out => [ "in_r1", "flags" ] },
981 outs => [ "res", "flags" ],
982 emit => '. dec%M %S0',
986 modified_flags => $status_flags_wo_cf
991 state => "exc_pinned",
992 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
993 ins => [ "base", "index", "mem" ],
994 emit => '. dec%M %AM',
998 modified_flags => $status_flags_wo_cf
1003 reg_req => { in => [ "gp" ],
1004 out => [ "in_r1", "flags" ] },
1006 outs => [ "res", "flags" ],
1007 emit => '. not%M %S0',
1016 state => "exc_pinned",
1017 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1018 ins => [ "base", "index", "mem" ],
1019 emit => '. not%M %AM',
1027 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1031 mode => $mode_flags,
1032 modified_flags => $status_flags
1036 reg_req => { out => [ "flags" ] },
1040 mode => $mode_flags,
1041 modified_flags => $status_flags
1048 state => "exc_pinned",
1049 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1050 out => [ "flags", "none", "none" ] },
1051 ins => [ "base", "index", "mem", "left", "right" ],
1052 outs => [ "eflags", "unused", "M" ],
1053 am => "source,binary",
1054 emit => '. cmp%M %binop',
1055 attr => "int ins_permuted, int cmp_unsigned",
1056 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1057 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1060 mode => $mode_flags,
1061 modified_flags => $status_flags
1066 state => "exc_pinned",
1067 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1068 out => [ "flags", "none", "none" ] },
1069 ins => [ "base", "index", "mem", "left", "right" ],
1070 outs => [ "eflags", "unused", "M" ],
1071 am => "source,binary",
1072 emit => '. cmpb %binop',
1073 attr => "int ins_permuted, int cmp_unsigned",
1074 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1075 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1078 mode => $mode_flags,
1079 modified_flags => $status_flags
1084 state => "exc_pinned",
1085 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] ,
1086 out => [ "flags", "none", "none" ] },
1087 ins => [ "base", "index", "mem", "left", "right" ],
1088 outs => [ "eflags", "unused", "M" ],
1089 am => "source,binary",
1090 emit => '. test%M %binop',
1091 attr => "int ins_permuted, int cmp_unsigned",
1092 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1093 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1096 mode => $mode_flags,
1097 modified_flags => $status_flags
1102 state => "exc_pinned",
1103 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] ,
1104 out => [ "flags", "none", "none" ] },
1105 ins => [ "base", "index", "mem", "left", "right" ],
1106 outs => [ "eflags", "unused", "M" ],
1107 am => "source,binary",
1108 emit => '. testb %binop',
1109 attr => "int ins_permuted, int cmp_unsigned",
1110 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1111 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1114 mode => $mode_flags,
1115 modified_flags => $status_flags
1120 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1121 ins => [ "eflags" ],
1122 attr_type => "ia32_condcode_attr_t",
1123 attr => "pn_Cmp pnc, int ins_permuted",
1124 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1125 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1126 emit => '. set%CMP0 %DB0',
1134 state => "exc_pinned",
1135 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1136 ins => [ "base", "index", "mem","eflags" ],
1137 attr_type => "ia32_condcode_attr_t",
1138 attr => "pn_Cmp pnc, int ins_permuted",
1139 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1140 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1141 emit => '. set%CMP3 %AM',
1149 # (note: leave the false,true order intact to make it compatible with other
1151 state => "exc_pinned",
1152 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
1153 out => [ "in_r4 in_r5", "flags", "none" ] },
1154 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1155 outs => [ "res", "flags", "M" ],
1156 am => "source,binary",
1157 attr_type => "ia32_condcode_attr_t",
1158 attr => "int ins_permuted, pn_Cmp pnc",
1159 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1167 op_flags => "L|X|Y",
1168 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1169 ins => [ "eflags" ],
1170 outs => [ "false", "true" ],
1171 attr_type => "ia32_condcode_attr_t",
1172 attr => "pn_Cmp pnc",
1174 units => [ "BRANCH" ],
1179 op_flags => "L|X|Y",
1180 reg_req => { in => [ "gp" ],
1183 attr_type => "ia32_condcode_attr_t",
1186 units => [ "BRANCH" ],
1187 modified_flags => $status_flags,
1193 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1194 ins => [ "base", "index", "mem", "target" ],
1195 am => "source,unary",
1196 emit => '. jmp *%unop3',
1198 units => [ "BRANCH" ],
1205 reg_req => { out => [ "gp" ] },
1207 attr => "ir_entity *symconst, int symconst_sign, int no_pic_adjust, long offset",
1208 attr_type => "ia32_immediate_attr_t",
1215 reg_req => { out => [ "gp" ] },
1219 modified_flags => $status_flags,
1225 reg_req => { out => [ "gp_UKNWN:I" ] },
1235 reg_req => { out => [ "vfp_UKNWN:I" ] },
1240 attr_type => "ia32_x87_attr_t",
1246 reg_req => { out => [ "xmm_UKNWN:I" ] },
1255 op_flags => "c|NB|NI",
1256 reg_req => { out => [ "gp_NOREG:I" ] },
1265 op_flags => "c|NB|NI",
1266 reg_req => { out => [ "vfp_NOREG:I" ] },
1271 attr_type => "ia32_x87_attr_t",
1276 op_flags => "c|NB|NI",
1277 reg_req => { out => [ "xmm_NOREG:I" ] },
1287 reg_req => { out => [ "fpcw:I" ] },
1291 modified_flags => $fpcw_flags
1297 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1298 ins => [ "base", "index", "mem" ],
1300 emit => ". fldcw %AM",
1303 modified_flags => $fpcw_flags
1309 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1310 ins => [ "base", "index", "mem", "fpcw" ],
1312 emit => ". fnstcw %AM",
1320 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1328 # we should not rematrialize this node. It has very strict constraints.
1329 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1330 ins => [ "val", "clobbered" ],
1339 # Note that we add additional latency values depending on address mode, so a
1340 # lateny of 0 for load is correct
1344 state => "exc_pinned",
1345 reg_req => { in => [ "gp", "gp", "none" ],
1346 out => [ "gp", "none", "none", "none" ] },
1347 ins => [ "base", "index", "mem" ],
1348 outs => [ "res", "unused", "M", "X_exc" ],
1350 emit => ". mov%EX%.l %AM, %D0",
1356 state => "exc_pinned",
1357 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1358 ins => [ "base", "index", "mem", "val" ],
1359 outs => [ "M", "X_exc" ],
1360 emit => '. mov%M %SI3, %AM',
1368 state => "exc_pinned",
1369 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1370 ins => [ "base", "index", "mem", "val" ],
1371 outs => [ "M", "X_exc" ],
1372 emit => '. mov%M %SB3, %AM',
1380 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1381 ins => [ "base", "index" ],
1382 emit => '. leal %AM, %D0',
1386 # lea doesn't modify the flags, but setting this seems advantageous since it
1387 # increases chances that the Lea is transformed back to an Add
1388 modified_flags => 1,
1392 state => "exc_pinned",
1393 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1394 ins => [ "base", "index", "mem", "val", "stack" ],
1395 emit => '. push%M %unop3',
1396 outs => [ "stack", "M" ],
1397 am => "source,unary",
1403 state => "exc_pinned",
1404 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1405 ins => [ "mem", "stack" ],
1406 outs => [ "res", "M", "unused", "stack" ],
1407 emit => '. pop%M %D0',
1408 latency => 3, # Pop is more expensive than Push on Athlon
1413 state => "exc_pinned",
1414 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1415 ins => [ "mem", "stack" ],
1416 outs => [ "res", "M", "unused", "stack" ],
1417 emit => '. pop%M %D0',
1418 latency => 3, # Pop is more expensive than Push on Athlon
1423 state => "exc_pinned",
1424 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1425 ins => [ "base", "index", "mem", "stack" ],
1426 outs => [ "unused0", "M", "unused1", "stack" ],
1427 emit => '. pop%M %AM',
1428 latency => 3, # Pop is more expensive than Push on Athlon
1433 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1435 outs => [ "frame", "stack", "M" ],
1441 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1443 outs => [ "frame", "stack" ],
1450 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1451 ins => [ "base", "index", "mem", "stack", "size" ],
1452 am => "source,binary",
1453 emit => '. addl %binop',
1455 outs => [ "stack", "M" ],
1457 modified_flags => $status_flags
1462 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1463 ins => [ "base", "index", "mem", "stack", "size" ],
1464 am => "source,binary",
1465 emit => ". subl %binop\n".
1466 ". movl %%esp, %D1",
1468 outs => [ "stack", "addr", "M" ],
1470 modified_flags => $status_flags
1483 reg_req => { out => [ "gp" ] },
1489 # BT supports source address mode, but this is unused yet
1493 state => "exc_pinned",
1494 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1495 ins => [ "left", "right" ],
1496 emit => '. bt%M %S1, %S0',
1499 mode => $mode_flags,
1500 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1505 state => "exc_pinned",
1506 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1507 out => [ "gp", "flags", "none" ] },
1508 ins => [ "base", "index", "mem", "operand" ],
1509 outs => [ "res", "flags", "M" ],
1510 am => "source,binary",
1511 emit => '. bsf%M %unop3, %D0',
1515 modified_flags => $status_flags
1520 state => "exc_pinned",
1521 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1522 out => [ "gp", "flags", "none" ] },
1523 ins => [ "base", "index", "mem", "operand" ],
1524 outs => [ "res", "flags", "M" ],
1525 am => "source,binary",
1526 emit => '. bsr%M %unop3, %D0',
1530 modified_flags => $status_flags
1534 # SSE4.2 or SSE4a popcnt instruction
1538 state => "exc_pinned",
1539 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1540 out => [ "gp", "flags", "none" ] },
1541 ins => [ "base", "index", "mem", "operand" ],
1542 outs => [ "res", "flags", "M" ],
1543 am => "source,binary",
1544 emit => '. popcnt%M %unop3, %D0',
1548 modified_flags => $status_flags
1552 state => "exc_pinned",
1554 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1555 out => [ "esp:I|S", "fpcw:I", "none", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ]
1557 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1558 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1559 attr_type => "ia32_call_attr_t",
1560 attr => "unsigned pop, ir_type *call_tp",
1561 am => "source,unary",
1562 units => [ "BRANCH" ],
1563 latency => 4, # random number
1564 modified_flags => $status_flags
1568 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1570 # PS: try gcc __builtin_frame_address(100000) :-)
1573 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1574 ins => [ "frame", "cnt", "tmp" ],
1576 latency => 4, # random number
1577 attr_type => "ia32_climbframe_attr_t",
1578 attr => "unsigned count",
1588 reg_req => { in => [ "gp" ],
1589 out => [ "in_r1" ] },
1590 emit => '. bswap%M %S0',
1598 # bswap16, use xchg here
1602 reg_req => { in => [ "eax ebx ecx edx" ],
1603 out => [ "in_r1" ] },
1604 emit => '. xchg %SB0, %SH0',
1616 reg_req => { in => [ "none" ], out => [ "none" ] },
1625 # Undefined Instruction on ALL x86 CPU's
1629 reg_req => { in => [ "none" ], out => [ "none" ] },
1632 emit => ". .value 0x0b0f",
1643 reg_req => { in => [ "edx", "eax", "none" ], out => [ "none" ] },
1644 ins => [ "port", "value", "mem" ],
1645 emit => '. out%M %SS0, %SI1',
1649 modified_flags => $status_flags
1658 reg_req => { in => [ "edx", "none" ], out => [ "eax", "none" ] },
1659 ins => [ "port", "mem" ],
1660 outs => [ "res", "M" ],
1661 emit => '. in%M %DS0, %SS0',
1665 modified_flags => $status_flags
1669 # Intel style prefetching
1673 state => "exc_pinned",
1674 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1675 ins => [ "base", "index", "mem" ],
1678 emit => ". prefetcht0 %AM",
1684 state => "exc_pinned",
1685 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1686 ins => [ "base", "index", "mem" ],
1689 emit => ". prefetcht1 %AM",
1695 state => "exc_pinned",
1696 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1697 ins => [ "base", "index", "mem" ],
1700 emit => ". prefetcht2 %AM",
1706 state => "exc_pinned",
1707 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1708 ins => [ "base", "index", "mem" ],
1711 emit => ". prefetchnta %AM",
1716 # 3DNow! prefetch instructions
1720 state => "exc_pinned",
1721 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1722 ins => [ "base", "index", "mem" ],
1725 emit => ". prefetch %AM",
1731 state => "exc_pinned",
1732 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1733 ins => [ "base", "index", "mem" ],
1736 emit => ". prefetchw %AM",
1740 #-----------------------------------------------------------------------------#
1741 # _____ _____ ______ __ _ _ _ #
1742 # / ____/ ____| ____| / _| | | | | | #
1743 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1744 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1745 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1746 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1747 #-----------------------------------------------------------------------------#
1752 reg_req => { out => [ "xmm" ] },
1753 emit => '. xorp%XSD %D0, %D0',
1761 reg_req => { out => [ "xmm" ] },
1762 emit => '. pxor %D0, %D0',
1768 # produces all 1 bits
1771 reg_req => { out => [ "xmm" ] },
1772 emit => '. pcmpeqb %D0, %D0',
1778 # integer shift left, dword
1781 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1782 emit => '. pslld %SI1, %D0',
1788 # integer shift left, qword
1791 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1792 emit => '. psllq %SI1, %D0',
1798 # integer shift right, dword
1801 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1802 emit => '. psrld %SI1, %D0',
1808 # mov from integer to SSE register
1811 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1812 emit => '. movd %S0, %D0',
1818 # commutative operations
1822 state => "exc_pinned",
1823 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1824 out => [ "in_r4 in_r5", "flags", "none" ] },
1825 ins => [ "base", "index", "mem", "left", "right" ],
1826 outs => [ "res", "flags", "M" ],
1827 am => "source,binary",
1828 emit => '. add%XXM %binop',
1836 state => "exc_pinned",
1837 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1838 out => [ "in_r4 in_r5", "flags", "none" ] },
1839 ins => [ "base", "index", "mem", "left", "right" ],
1840 outs => [ "res", "flags", "M" ],
1841 am => "source,binary",
1842 emit => '. mul%XXM %binop',
1850 state => "exc_pinned",
1851 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1852 out => [ "in_r4 in_r5", "flags", "none" ] },
1853 ins => [ "base", "index", "mem", "left", "right" ],
1854 outs => [ "res", "flags", "M" ],
1855 am => "source,binary",
1856 emit => '. max%XXM %binop',
1864 state => "exc_pinned",
1865 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1866 out => [ "in_r4 in_r5", "flags", "none" ] },
1867 ins => [ "base", "index", "mem", "left", "right" ],
1868 outs => [ "res", "flags", "M" ],
1869 am => "source,binary",
1870 emit => '. min%XXM %binop',
1878 state => "exc_pinned",
1879 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1880 out => [ "in_r4 in_r5", "flags", "none" ] },
1881 ins => [ "base", "index", "mem", "left", "right" ],
1882 outs => [ "res", "flags", "M" ],
1883 am => "source,binary",
1884 emit => '. andp%XSD %binop',
1892 state => "exc_pinned",
1893 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1894 out => [ "in_r4 in_r5", "flags", "none" ] },
1895 ins => [ "base", "index", "mem", "left", "right" ],
1896 outs => [ "res", "flags", "M" ],
1897 am => "source,binary",
1898 emit => '. orp%XSD %binop',
1906 state => "exc_pinned",
1907 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1908 out => [ "in_r4 in_r5", "flags", "none" ] },
1909 ins => [ "base", "index", "mem", "left", "right" ],
1910 outs => [ "res", "flags", "M" ],
1911 am => "source,binary",
1912 emit => '. xorp%XSD %binop',
1918 # not commutative operations
1922 state => "exc_pinned",
1923 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1924 out => [ "in_r4 !in_r5", "flags", "none" ] },
1925 ins => [ "base", "index", "mem", "left", "right" ],
1926 outs => [ "res", "flags", "M" ],
1927 am => "source,binary",
1928 emit => '. andnp%XSD %binop',
1936 state => "exc_pinned",
1937 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1938 out => [ "in_r4", "flags", "none" ] },
1939 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1940 outs => [ "res", "flags", "M" ],
1941 am => "source,binary",
1942 emit => '. sub%XXM %binop',
1950 state => "exc_pinned",
1951 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1952 out => [ "in_r4 !in_r5", "flags", "none" ] },
1953 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1954 outs => [ "res", "flags", "M" ],
1955 am => "source,binary",
1956 emit => '. div%XXM %binop',
1965 state => "exc_pinned",
1966 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ],
1967 out => [ "eflags" ] },
1968 ins => [ "base", "index", "mem", "left", "right" ],
1969 outs => [ "flags" ],
1970 am => "source,binary",
1971 attr => "int ins_permuted",
1972 init_attr => "attr->data.ins_permuted = ins_permuted;",
1973 emit => ' .ucomi%XXM %binop',
1976 mode => $mode_flags,
1977 modified_flags => 1,
1984 state => "exc_pinned",
1985 reg_req => { in => [ "gp", "gp", "none" ],
1986 out => [ "xmm", "none", "none", "none" ] },
1987 ins => [ "base", "index", "mem" ],
1988 outs => [ "res", "unused", "M", "X_exc" ],
1989 emit => '. mov%XXM %AM, %D0',
1990 attr => "ir_mode *load_mode",
1991 init_attr => "attr->ls_mode = load_mode;",
1998 state => "exc_pinned",
1999 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
2000 ins => [ "base", "index", "mem", "val" ],
2001 outs => [ "M", "X_exc" ],
2002 emit => '. mov%XXM %S3, %AM',
2010 state => "exc_pinned",
2011 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2012 ins => [ "base", "index", "mem", "val" ],
2013 emit => '. mov%XXM %S3, %AM',
2021 state => "exc_pinned",
2022 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2023 ins => [ "base", "index", "mem", "val" ],
2024 am => "source,unary",
2025 emit => '. cvtsi2ss %unop3, %D0',
2033 state => "exc_pinned",
2034 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
2035 ins => [ "base", "index", "mem", "val" ],
2036 am => "source,unary",
2037 emit => '. cvtsi2sd %unop3, %D0',
2046 cmp_attr => "return 1;",
2047 ins => [ "val_high", "val_low" ],
2052 cmp_attr => "return 1;",
2054 outs => [ "res_high", "res_low" ],
2062 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
2063 outs => [ "DST", "SRC", "CNT", "M" ],
2064 attr_type => "ia32_copyb_attr_t",
2065 attr => "unsigned size",
2068 # we don't care about this flag, so no need to mark this node
2069 # modified_flags => [ "DF" ]
2075 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
2076 outs => [ "DST", "SRC", "M" ],
2077 attr_type => "ia32_copyb_attr_t",
2078 attr => "unsigned size",
2081 # we don't care about this flag, so no need to mark this node
2082 # modified_flags => [ "DF" ]
2088 state => "exc_pinned",
2089 reg_req => { in => [ "eax" ], out => [ "eax" ] },
2099 state => "exc_pinned",
2100 reg_req => { in => [ "gp", "gp", "none", "gp" ],
2101 out => [ "gp", "none", "none" ] },
2102 ins => [ "base", "index", "mem", "val" ],
2103 outs => [ "res", "flags", "M" ],
2104 am => "source,unary",
2107 attr => "ir_mode *smaller_mode",
2108 init_attr => "attr->ls_mode = smaller_mode;",
2113 state => "exc_pinned",
2114 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ],
2115 out => [ "gp", "none", "none" ] },
2116 ins => [ "base", "index", "mem", "val" ],
2117 outs => [ "res", "flags", "M" ],
2118 am => "source,unary",
2121 attr => "ir_mode *smaller_mode",
2122 init_attr => "attr->ls_mode = smaller_mode;",
2127 state => "exc_pinned",
2128 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2129 ins => [ "base", "index", "mem", "val" ],
2130 am => "source,unary",
2137 state => "exc_pinned",
2138 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2139 ins => [ "base", "index", "mem", "val" ],
2140 am => "source,unary",
2147 state => "exc_pinned",
2148 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2149 ins => [ "base", "index", "mem", "val" ],
2150 am => "source,unary",
2156 #----------------------------------------------------------#
2158 # (_) | | | | / _| | | | #
2159 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
2160 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
2161 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
2162 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
2164 # _ __ ___ __| | ___ ___ #
2165 # | '_ \ / _ \ / _` |/ _ \/ __| #
2166 # | | | | (_) | (_| | __/\__ \ #
2167 # |_| |_|\___/ \__,_|\___||___/ #
2168 #----------------------------------------------------------#
2170 # rematerialisation disabled for all float nodes for now, because the fpcw
2171 # handler runs before spilling and we might end up with wrong fpcw then
2175 state => "exc_pinned",
2176 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2177 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2178 am => "source,binary",
2182 attr_type => "ia32_x87_attr_t",
2187 state => "exc_pinned",
2188 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2189 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2190 am => "source,binary",
2194 attr_type => "ia32_x87_attr_t",
2199 state => "exc_pinned",
2200 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2201 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2202 am => "source,binary",
2206 attr_type => "ia32_x87_attr_t",
2210 state => "exc_pinned",
2211 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
2212 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2213 am => "source,binary",
2214 outs => [ "res", "M" ],
2217 attr_type => "ia32_x87_attr_t",
2221 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2222 ins => [ "left", "right", "fpcw" ],
2226 attr_type => "ia32_x87_attr_t",
2231 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2236 attr_type => "ia32_x87_attr_t",
2241 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2246 attr_type => "ia32_x87_attr_t",
2249 # virtual Load and Store
2254 state => "exc_pinned",
2255 reg_req => { in => [ "gp", "gp", "none" ],
2256 out => [ "vfp", "none", "none", "none" ] },
2257 ins => [ "base", "index", "mem" ],
2258 outs => [ "res", "unused", "M", "X_exc" ],
2259 attr => "ir_mode *load_mode",
2260 init_attr => "attr->attr.ls_mode = load_mode;",
2263 attr_type => "ia32_x87_attr_t",
2269 state => "exc_pinned",
2270 reg_req => { in => [ "gp", "gp", "none", "vfp" ],
2271 out => [ "none", "none" ] },
2272 ins => [ "base", "index", "mem", "val" ],
2273 outs => [ "M", "X_exc" ],
2274 attr => "ir_mode *store_mode",
2275 init_attr => "attr->attr.ls_mode = store_mode;",
2279 attr_type => "ia32_x87_attr_t",
2285 state => "exc_pinned",
2286 reg_req => { in => [ "gp", "gp", "none" ],
2287 out => [ "vfp", "none", "none" ] },
2288 outs => [ "res", "unused", "M" ],
2289 ins => [ "base", "index", "mem" ],
2292 attr_type => "ia32_x87_attr_t",
2296 state => "exc_pinned",
2297 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2298 ins => [ "base", "index", "mem", "val", "fpcw" ],
2302 attr_type => "ia32_x87_attr_t",
2305 # SSE3 fisttp instruction
2307 state => "exc_pinned",
2308 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2309 ins => [ "base", "index", "mem", "val" ],
2310 outs => [ "res", "M" ],
2313 attr_type => "ia32_x87_attr_t",
2321 reg_req => { out => [ "vfp" ] },
2326 attr_type => "ia32_x87_attr_t",
2331 reg_req => { out => [ "vfp" ] },
2336 attr_type => "ia32_x87_attr_t",
2341 reg_req => { out => [ "vfp" ] },
2346 attr_type => "ia32_x87_attr_t",
2351 reg_req => { out => [ "vfp" ] },
2356 attr_type => "ia32_x87_attr_t",
2361 reg_req => { out => [ "vfp" ] },
2366 attr_type => "ia32_x87_attr_t",
2371 reg_req => { out => [ "vfp" ] },
2376 attr_type => "ia32_x87_attr_t",
2381 reg_req => { out => [ "vfp" ] },
2386 attr_type => "ia32_x87_attr_t",
2392 # we can't allow to rematerialize this node so we don't have
2393 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2395 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2396 ins => [ "left", "right" ],
2397 outs => [ "flags" ],
2398 attr => "int ins_permuted",
2399 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2402 attr_type => "ia32_x87_attr_t",
2408 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2409 ins => [ "left", "right" ],
2410 outs => [ "flags" ],
2411 attr => "int ins_permuted",
2412 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2415 attr_type => "ia32_x87_attr_t",
2421 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2423 outs => [ "flags" ],
2424 attr => "int ins_permuted",
2425 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2428 attr_type => "ia32_x87_attr_t",
2434 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2436 outs => [ "flags" ],
2440 mode => $mode_flags,
2443 #------------------------------------------------------------------------#
2444 # ___ _____ __ _ _ _ #
2445 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2446 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2447 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2448 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2449 #------------------------------------------------------------------------#
2451 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2452 # are swapped, we work this around in the emitter...
2455 state => "exc_pinned",
2456 rd_constructor => "NONE",
2458 emit => '. fadd%XM %x87_binop',
2460 attr_type => "ia32_x87_attr_t",
2464 state => "exc_pinned",
2465 rd_constructor => "NONE",
2467 emit => '. faddp%XM %x87_binop',
2469 attr_type => "ia32_x87_attr_t",
2473 state => "exc_pinned",
2474 rd_constructor => "NONE",
2476 emit => '. fmul%XM %x87_binop',
2478 attr_type => "ia32_x87_attr_t",
2482 state => "exc_pinned",
2483 rd_constructor => "NONE",
2485 emit => '. fmulp%XM %x87_binop',,
2487 attr_type => "ia32_x87_attr_t",
2491 state => "exc_pinned",
2492 rd_constructor => "NONE",
2494 emit => '. fsub%XM %x87_binop',
2496 attr_type => "ia32_x87_attr_t",
2500 state => "exc_pinned",
2501 rd_constructor => "NONE",
2503 # see note about gas bugs
2504 emit => '. fsubrp%XM %x87_binop',
2506 attr_type => "ia32_x87_attr_t",
2510 state => "exc_pinned",
2511 rd_constructor => "NONE",
2514 emit => '. fsubr%XM %x87_binop',
2516 attr_type => "ia32_x87_attr_t",
2520 state => "exc_pinned",
2521 rd_constructor => "NONE",
2524 # see note about gas bugs
2525 emit => '. fsubp%XM %x87_binop',
2527 attr_type => "ia32_x87_attr_t",
2531 rd_constructor => "NONE",
2535 attr_type => "ia32_x87_attr_t",
2538 # this node is just here, to keep the simulator running
2539 # we can omit this when a fprem simulation function exists
2541 rd_constructor => "NONE",
2543 emit => '. fprem1\n'.
2546 attr_type => "ia32_x87_attr_t",
2550 state => "exc_pinned",
2551 rd_constructor => "NONE",
2553 emit => '. fdiv%XM %x87_binop',
2555 attr_type => "ia32_x87_attr_t",
2559 state => "exc_pinned",
2560 rd_constructor => "NONE",
2562 # see note about gas bugs
2563 emit => '. fdivrp%XM %x87_binop',
2565 attr_type => "ia32_x87_attr_t",
2569 state => "exc_pinned",
2570 rd_constructor => "NONE",
2572 emit => '. fdivr%XM %x87_binop',
2574 attr_type => "ia32_x87_attr_t",
2578 state => "exc_pinned",
2579 rd_constructor => "NONE",
2581 # see note about gas bugs
2582 emit => '. fdivp%XM %x87_binop',
2584 attr_type => "ia32_x87_attr_t",
2588 rd_constructor => "NONE",
2592 attr_type => "ia32_x87_attr_t",
2597 rd_constructor => "NONE",
2601 attr_type => "ia32_x87_attr_t",
2604 # x87 Load and Store
2607 rd_constructor => "NONE",
2608 op_flags => "R|L|F",
2609 state => "exc_pinned",
2611 emit => '. fld%XM %AM',
2612 attr_type => "ia32_x87_attr_t",
2617 rd_constructor => "NONE",
2618 op_flags => "R|L|F",
2619 state => "exc_pinned",
2621 emit => '. fst%XM %AM',
2623 attr_type => "ia32_x87_attr_t",
2628 rd_constructor => "NONE",
2629 op_flags => "R|L|F",
2630 state => "exc_pinned",
2632 emit => '. fstp%XM %AM',
2634 attr_type => "ia32_x87_attr_t",
2641 state => "exc_pinned",
2642 rd_constructor => "NONE",
2644 emit => '. fild%XM %AM',
2645 attr_type => "ia32_x87_attr_t",
2650 state => "exc_pinned",
2651 rd_constructor => "NONE",
2653 emit => '. fist%XM %AM',
2655 attr_type => "ia32_x87_attr_t",
2660 state => "exc_pinned",
2661 rd_constructor => "NONE",
2663 emit => '. fistp%XM %AM',
2665 attr_type => "ia32_x87_attr_t",
2669 # SSE3 fisttp instruction
2671 state => "exc_pinned",
2672 rd_constructor => "NONE",
2674 emit => '. fisttp%XM %AM',
2676 attr_type => "ia32_x87_attr_t",
2683 op_flags => "R|c|K",
2685 reg_req => { out => [ "vfp" ] },
2687 attr_type => "ia32_x87_attr_t",
2692 op_flags => "R|c|K",
2694 reg_req => { out => [ "vfp" ] },
2696 attr_type => "ia32_x87_attr_t",
2701 op_flags => "R|c|K",
2703 reg_req => { out => [ "vfp" ] },
2705 attr_type => "ia32_x87_attr_t",
2710 op_flags => "R|c|K",
2712 reg_req => { out => [ "vfp" ] },
2714 attr_type => "ia32_x87_attr_t",
2719 op_flags => "R|c|K",
2721 reg_req => { out => [ "vfp" ] },
2723 attr_type => "ia32_x87_attr_t",
2728 op_flags => "R|c|K",
2730 reg_req => { out => [ "vfp" ] },
2731 emit => '. fldll2t',
2732 attr_type => "ia32_x87_attr_t",
2737 op_flags => "R|c|K",
2739 reg_req => { out => [ "vfp" ] },
2741 attr_type => "ia32_x87_attr_t",
2746 # Note that it is NEVER allowed to do CSE on these nodes
2747 # Moreover, note the virtual register requierements!
2752 cmp_attr => "return 1;",
2753 emit => '. fxch %X0',
2754 attr_type => "ia32_x87_attr_t",
2762 cmp_attr => "return 1;",
2763 emit => '. fld %X0',
2764 attr_type => "ia32_x87_attr_t",
2770 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2771 cmp_attr => "return 1;",
2772 emit => '. fld %X0',
2773 attr_type => "ia32_x87_attr_t",
2780 cmp_attr => "return 1;",
2781 emit => '. fstp %X0',
2782 attr_type => "ia32_x87_attr_t",
2790 cmp_attr => "return 1;",
2791 emit => '. ffreep %X0',
2792 attr_type => "ia32_x87_attr_t",
2800 cmp_attr => "return 1;",
2802 attr_type => "ia32_x87_attr_t",
2810 cmp_attr => "return 1;",
2812 attr_type => "ia32_x87_attr_t",
2821 emit => ". fucom %X1\n".
2823 attr_type => "ia32_x87_attr_t",
2829 emit => ". fucomp %X1\n".
2831 attr_type => "ia32_x87_attr_t",
2837 emit => ". fucompp\n".
2839 attr_type => "ia32_x87_attr_t",
2845 emit => '. fucomi %X1',
2846 attr_type => "ia32_x87_attr_t",
2852 emit => '. fucompi %X1',
2853 attr_type => "ia32_x87_attr_t",
2861 attr_type => "ia32_x87_attr_t",
2866 # -------------------------------------------------------------------------------- #
2867 # ____ ____ _____ _ _ #
2868 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2869 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2870 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2871 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2873 # -------------------------------------------------------------------------------- #
2876 # Spilling and reloading of SSE registers, hardcoded, not generated #
2880 state => "exc_pinned",
2881 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2882 emit => '. movdqu %D0, %AM',
2883 outs => [ "res", "M" ],
2890 state => "exc_pinned",
2891 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2892 ins => [ "base", "index", "mem", "val" ],
2893 emit => '. movdqu %binop',
2901 # Include the generated SIMD node specification written by the SIMD optimization
2902 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2903 unless ($return = do $my_script_name) {
2904 warn "couldn't parse $my_script_name: $@" if $@;
2905 warn "couldn't do $my_script_name: $!" unless defined $return;
2906 warn "couldn't run $my_script_name" unless $return;
2909 # Transform some attributes
2910 foreach my $op (keys(%nodes)) {
2911 my $node = $nodes{$op};
2912 my $op_attr_init = $node->{op_attr_init};
2914 if(defined($op_attr_init)) {
2915 $op_attr_init .= "\n\t";
2920 if(!defined($node->{latency})) {
2922 $node->{latency} = 0;
2924 die("Latency missing for op $op");
2927 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2929 $node->{op_attr_init} = $op_attr_init;