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 SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
201 SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
202 SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
203 SI1 => "${arch}_emit_source_register_or_immediate(node, 1);",
204 SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
205 D0 => "${arch}_emit_dest_register(node, 0);",
206 D1 => "${arch}_emit_dest_register(node, 1);",
207 DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
208 X0 => "${arch}_emit_x87_register(node, 0);",
209 X1 => "${arch}_emit_x87_register(node, 1);",
210 EX => "${arch}_emit_extend_suffix(node);",
211 M => "${arch}_emit_mode_suffix(node);",
212 XM => "${arch}_emit_x87_mode_suffix(node);",
213 XXM => "${arch}_emit_xmm_mode_suffix(node);",
214 XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
215 AM => "${arch}_emit_am(node);",
216 unop3 => "${arch}_emit_unop(node, n_ia32_unary_op);",
217 unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
218 binop => "${arch}_emit_binop(node);",
219 x87_binop => "${arch}_emit_x87_binop(node);",
220 CMP0 => "${arch}_emit_cmp_suffix_node(node, 0);",
221 CMP3 => "${arch}_emit_cmp_suffix_node(node, 3);",
224 #--------------------------------------------------#
227 # _ __ _____ __ _ _ __ ___ _ __ ___ #
228 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
229 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
230 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
233 #--------------------------------------------------#
235 $default_op_attr_type = "ia32_op_attr_t";
236 $default_attr_type = "ia32_attr_t";
237 $default_copy_attr = "ia32_copy_attr";
239 sub ia32_custom_init_attr {
244 if(defined($node->{modified_flags})) {
245 $res .= "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n";
247 if(defined($node->{am})) {
248 my $am = $node->{am};
249 if($am eq "source,unary") {
250 $res .= "\tset_ia32_am_support(res, ia32_am_unary);";
251 } elsif($am eq "source,binary") {
252 $res .= "\tset_ia32_am_support(res, ia32_am_binary);";
253 } elsif($am eq "none") {
256 die("Invalid address mode '$am' specified on op $name");
259 if($node->{state} ne "exc_pinned"
260 and $node->{state} ne "pinned") {
261 die("AM nodes must have pinned or AM pinned state ($name)");
267 $custom_init_attr_func = \&ia32_custom_init_attr;
271 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
272 "\tinit_ia32_x87_attributes(res);".
273 "\tinit_ia32_asm_attributes(res);",
275 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
277 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
278 "\tinit_ia32_call_attributes(res, pop, call_tp);",
279 ia32_condcode_attr_t =>
280 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
281 "\tinit_ia32_condcode_attributes(res, pnc);",
283 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
284 "\tinit_ia32_copyb_attributes(res, size);",
285 ia32_immediate_attr_t =>
286 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
287 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);",
289 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
290 "\tinit_ia32_x87_attributes(res);",
291 ia32_climbframe_attr_t =>
292 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);\n".
293 "\tinit_ia32_climbframe_attributes(res, count);",
297 ia32_asm_attr_t => "ia32_compare_asm_attr",
298 ia32_attr_t => "ia32_compare_nodes_attr",
299 ia32_call_attr_t => "ia32_compare_call_attr",
300 ia32_condcode_attr_t => "ia32_compare_condcode_attr",
301 ia32_copyb_attr_t => "ia32_compare_copyb_attr",
302 ia32_immediate_attr_t => "ia32_compare_immediate_attr",
303 ia32_x87_attr_t => "ia32_compare_x87_attr",
304 ia32_climbframe_attr_t => "ia32_compare_climbframe_attr",
310 $mode_xmm = "mode_E";
311 $mode_gp = "mode_Iu";
312 $mode_flags = "mode_Iu";
313 $mode_fpcw = "mode_fpcw";
314 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
315 $status_flags_wo_cf = [ "PF", "AF", "ZF", "SF", "OF" ];
316 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
317 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
324 reg_req => { out => [ "gp_NOREG:I" ] },
325 attr => "ir_entity *symconst, int symconst_sign, long offset",
326 attr_type => "ia32_immediate_attr_t",
327 hash_func => "ia32_hash_Immediate",
335 out_arity => "variable",
336 attr_type => "ia32_asm_attr_t",
337 attr => "ident *asm_text, const ia32_asm_reg_t *register_map",
338 init_attr => "attr->asm_text = asm_text;\n".
339 "\tattr->register_map = register_map;\n",
341 modified_flags => $status_flags,
344 # "allocates" a free register
348 reg_req => { out => [ "gp" ] },
353 cmp_attr => "return 1;",
356 #-----------------------------------------------------------------#
359 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
360 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
361 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
362 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
365 #-----------------------------------------------------------------#
367 # commutative operations
371 state => "exc_pinned",
372 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
373 out => [ "in_r4 in_r5", "flags", "none" ] },
374 ins => [ "base", "index", "mem", "left", "right" ],
375 outs => [ "res", "flags", "M" ],
376 emit => '. add%M %binop',
377 am => "source,binary",
381 modified_flags => $status_flags
386 state => "exc_pinned",
387 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
388 ins => [ "base", "index", "mem", "val" ],
389 emit => ". add%M %SI3, %AM",
393 modified_flags => $status_flags
398 state => "exc_pinned",
399 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
400 ins => [ "base", "index", "mem", "val" ],
401 emit => ". add%M %SB3, %AM",
405 modified_flags => $status_flags
409 state => "exc_pinned",
410 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
411 out => [ "in_r4 in_r5", "flags", "none" ] },
412 ins => [ "base", "index", "mem", "left", "right", "eflags" ],
413 outs => [ "res", "flags", "M" ],
414 emit => '. adc%M %binop',
415 am => "source,binary",
419 modified_flags => $status_flags
424 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
425 ins => [ "left", "right" ],
429 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
430 ins => [ "left", "right", "eflags" ],
434 # we should not rematrialize this node. It produces 2 results and has
435 # very strict constraints
436 state => "exc_pinned",
437 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
438 out => [ "eax", "flags", "edx", "none" ] },
439 ins => [ "base", "index", "mem", "left", "right" ],
440 emit => '. mul%M %unop4',
441 outs => [ "res_low", "flags", "res_high", "M" ],
442 am => "source,binary",
445 modified_flags => $status_flags
449 # we should not rematrialize this node. It produces 2 results and has
450 # very strict constraints
452 cmp_attr => "return 1;",
453 outs => [ "EAX", "flags", "EDX", "M" ],
459 state => "exc_pinned",
460 # TODO: adjust out requirements for the 3 operand form
461 # (no need for should_be_same then)
462 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
463 out => [ "in_r4 in_r5", "flags", "none" ] },
464 ins => [ "base", "index", "mem", "left", "right" ],
465 outs => [ "res", "flags", "M" ],
466 am => "source,binary",
470 modified_flags => $status_flags
475 state => "exc_pinned",
476 reg_req => { in => [ "gp", "gp", "none", "eax", "gp" ],
477 out => [ "eax", "flags", "edx", "none" ] },
478 ins => [ "base", "index", "mem", "left", "right" ],
479 emit => '. imul%M %unop4',
480 outs => [ "res_low", "flags", "res_high", "M" ],
481 am => "source,binary",
484 modified_flags => $status_flags
489 cmp_attr => "return 1;",
490 outs => [ "res_low", "res_high", "M" ],
496 state => "exc_pinned",
497 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
498 out => [ "in_r4 in_r5", "flags", "none" ] },
499 ins => [ "base", "index", "mem", "left", "right" ],
500 outs => [ "res", "flags", "M" ],
501 op_modes => "commutative | am | immediate | mode_neutral",
502 am => "source,binary",
503 emit => '. and%M %binop',
507 modified_flags => $status_flags
512 state => "exc_pinned",
513 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
514 ins => [ "base", "index", "mem", "val" ],
515 emit => '. and%M %SI3, %AM',
519 modified_flags => $status_flags
524 state => "exc_pinned",
525 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
526 ins => [ "base", "index", "mem", "val" ],
527 emit => '. and%M %SB3, %AM',
531 modified_flags => $status_flags
536 state => "exc_pinned",
537 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
538 out => [ "in_r4 in_r5", "flags", "none" ] },
539 ins => [ "base", "index", "mem", "left", "right" ],
540 outs => [ "res", "flags", "M" ],
541 am => "source,binary",
542 emit => '. or%M %binop',
546 modified_flags => $status_flags
551 state => "exc_pinned",
552 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
553 ins => [ "base", "index", "mem", "val" ],
554 emit => '. or%M %SI3, %AM',
558 modified_flags => $status_flags
563 state => "exc_pinned",
564 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
565 ins => [ "base", "index", "mem", "val" ],
566 emit => '. or%M %SB3, %AM',
570 modified_flags => $status_flags
575 state => "exc_pinned",
576 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
577 out => [ "in_r4 in_r5", "flags", "none" ] },
578 ins => [ "base", "index", "mem", "left", "right" ],
579 outs => [ "res", "flags", "M" ],
580 am => "source,binary",
581 emit => '. xor%M %binop',
585 modified_flags => $status_flags
591 reg_req => { out => [ "gp", "flags" ] },
592 outs => [ "res", "flags" ],
593 emit => ". xor%M %D0, %D0",
597 modified_flags => $status_flags
602 state => "exc_pinned",
603 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
604 ins => [ "base", "index", "mem", "val" ],
605 emit => '. xor%M %SI3, %AM',
609 modified_flags => $status_flags
614 state => "exc_pinned",
615 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
616 ins => [ "base", "index", "mem", "val" ],
617 emit => '. xor%M %SB3, %AM',
621 modified_flags => $status_flags
624 # not commutative operations
628 state => "exc_pinned",
629 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
630 out => [ "in_r4", "flags", "none" ] },
631 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
632 outs => [ "res", "flags", "M" ],
633 am => "source,binary",
634 emit => '. sub%M %binop',
638 modified_flags => $status_flags
643 state => "exc_pinned",
644 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
645 ins => [ "base", "index", "mem", "subtrahend" ],
646 emit => '. sub%M %SI3, %AM',
650 modified_flags => $status_flags
655 state => "exc_pinned",
656 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
657 ins => [ "base", "index", "mem", "subtrahend" ],
658 emit => '. sub%M %SB3, %AM',
662 modified_flags => $status_flags
666 state => "exc_pinned",
667 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ],
668 out => [ "in_r4 !in_r5", "flags", "none" ] },
669 ins => [ "base", "index", "mem", "minuend", "subtrahend", "eflags" ],
670 outs => [ "res", "flags", "M" ],
671 am => "source,binary",
672 emit => '. sbb%M %binop',
676 modified_flags => $status_flags
681 reg_req => { in => [ "flags" ], out => [ "gp", "flags" ] },
682 outs => [ "res", "flags" ],
683 emit => ". sbb%M %D0, %D0",
687 modified_flags => $status_flags
691 reg_req => { in => [ "none", "none" ], out => [ "none" ] },
692 ins => [ "minuend", "subtrahend" ],
696 reg_req => { in => [ "none", "none", "none" ], out => [ "none" ] },
697 ins => [ "minuend", "subtrahend", "eflags" ],
702 state => "exc_pinned",
703 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
704 out => [ "eax", "flags", "none", "edx", "none" ] },
705 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
706 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
707 am => "source,unary",
708 emit => ". idiv%M %unop3",
711 modified_flags => $status_flags
716 state => "exc_pinned",
717 reg_req => { in => [ "gp", "gp", "none", "gp", "eax", "edx" ],
718 out => [ "eax", "flags", "none", "edx", "none" ] },
719 ins => [ "base", "index", "mem", "divisor", "dividend_low", "dividend_high" ],
720 outs => [ "div_res", "flags", "M", "mod_res", "X_exc" ],
721 am => "source,unary",
722 emit => ". div%M %unop3",
725 modified_flags => $status_flags
730 reg_req => { in => [ "gp", "ecx" ],
731 out => [ "in_r1 !in_r2", "flags" ] },
732 ins => [ "val", "count" ],
733 outs => [ "res", "flags" ],
734 emit => '. shl%M %SB1, %S0',
738 modified_flags => $status_flags
743 state => "exc_pinned",
744 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
745 ins => [ "base", "index", "mem", "count" ],
746 emit => '. shl%M %SB3, %AM',
750 modified_flags => $status_flags
754 cmp_attr => "return 1;",
755 ins => [ "val", "count", "dep" ],
761 reg_req => { in => [ "gp", "gp", "ecx" ],
762 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
763 ins => [ "val_high", "val_low", "count" ],
764 outs => [ "res", "flags" ],
765 emit => ". shld%M %SB2, %S1, %D0",
769 modified_flags => $status_flags
773 cmp_attr => "return 1;",
774 ins => [ "val_high", "val_low", "count" ],
780 reg_req => { in => [ "gp", "ecx" ],
781 out => [ "in_r1 !in_r2", "flags" ] },
782 ins => [ "val", "count" ],
783 outs => [ "res", "flags" ],
784 emit => '. shr%M %SB1, %S0',
788 modified_flags => $status_flags
793 state => "exc_pinned",
794 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
795 ins => [ "base", "index", "mem", "count" ],
796 emit => '. shr%M %SB3, %AM',
800 modified_flags => $status_flags
804 cmp_attr => "return 1;",
805 ins => [ "val", "count", "dep" ],
811 reg_req => { in => [ "gp", "gp", "ecx" ],
812 out => [ "in_r1 !in_r2 !in_r3", "flags" ] },
813 ins => [ "val_high", "val_low", "count" ],
814 outs => [ "res", "flags" ],
815 emit => ". shrd%M %SB2, %S1, %D0",
819 modified_flags => $status_flags
823 cmp_attr => "return 1;",
825 ins => [ "val_high", "val_low", "count" ],
830 reg_req => { in => [ "gp", "ecx" ],
831 out => [ "in_r1 !in_r2", "flags" ] },
832 ins => [ "val", "count" ],
833 outs => [ "res", "flags" ],
834 emit => '. sar%M %SB1, %S0',
838 modified_flags => $status_flags
843 state => "exc_pinned",
844 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
845 ins => [ "base", "index", "mem", "count" ],
846 emit => '. sar%M %SB3, %AM',
850 modified_flags => $status_flags
854 cmp_attr => "return 1;",
855 ins => [ "val", "count", "dep" ],
861 reg_req => { in => [ "gp", "ecx" ],
862 out => [ "in_r1 !in_r2", "flags" ] },
863 ins => [ "val", "count" ],
864 outs => [ "res", "flags" ],
865 emit => '. ror%M %SB1, %S0',
869 modified_flags => $status_flags
874 state => "exc_pinned",
875 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
876 ins => [ "base", "index", "mem", "count" ],
877 emit => '. ror%M %SB3, %AM',
881 modified_flags => $status_flags
886 reg_req => { in => [ "gp", "ecx" ],
887 out => [ "in_r1 !in_r2", "flags" ] },
888 ins => [ "val", "count" ],
889 outs => [ "res", "flags" ],
890 emit => '. rol%M %SB1, %S0',
894 modified_flags => $status_flags
899 state => "exc_pinned",
900 reg_req => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
901 ins => [ "base", "index", "mem", "count" ],
902 emit => '. rol%M %SB3, %AM',
906 modified_flags => $status_flags
913 reg_req => { in => [ "gp" ],
914 out => [ "in_r1", "flags" ] },
915 emit => '. neg%M %S0',
917 outs => [ "res", "flags" ],
921 modified_flags => $status_flags
926 state => "exc_pinned",
927 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
928 ins => [ "base", "index", "mem" ],
929 emit => '. neg%M %AM',
933 modified_flags => $status_flags
938 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1", "in_r2" ] },
939 outs => [ "low_res", "high_res" ],
942 modified_flags => $status_flags
948 reg_req => { in => [ "gp" ],
949 out => [ "in_r1", "flags" ] },
951 outs => [ "res", "flags" ],
952 emit => '. inc%M %S0',
956 modified_flags => $status_flags_wo_cf
961 state => "exc_pinned",
962 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
963 ins => [ "base", "index", "mem" ],
964 emit => '. inc%M %AM',
968 modified_flags => $status_flags_wo_cf
973 reg_req => { in => [ "gp" ],
974 out => [ "in_r1", "flags" ] },
976 outs => [ "res", "flags" ],
977 emit => '. dec%M %S0',
981 modified_flags => $status_flags_wo_cf
986 state => "exc_pinned",
987 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
988 ins => [ "base", "index", "mem" ],
989 emit => '. dec%M %AM',
993 modified_flags => $status_flags_wo_cf
998 reg_req => { in => [ "gp" ],
999 out => [ "in_r1", "flags" ] },
1001 outs => [ "res", "flags" ],
1002 emit => '. not%M %S0',
1011 state => "exc_pinned",
1012 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1013 ins => [ "base", "index", "mem" ],
1014 emit => '. not%M %AM',
1022 reg_req => { in => [ "flags" ], out => [ "flags" ] },
1026 mode => $mode_flags,
1027 modified_flags => $status_flags
1031 reg_req => { out => [ "flags" ] },
1035 mode => $mode_flags,
1036 modified_flags => $status_flags
1043 state => "exc_pinned",
1044 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ],
1045 out => [ "flags", "none", "none" ] },
1046 ins => [ "base", "index", "mem", "left", "right" ],
1047 outs => [ "eflags", "unused", "M" ],
1048 am => "source,binary",
1049 emit => '. cmp%M %binop',
1050 attr => "int ins_permuted, int cmp_unsigned",
1051 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1052 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1055 mode => $mode_flags,
1056 modified_flags => $status_flags
1061 state => "exc_pinned",
1062 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1063 ins => [ "base", "index", "mem", "left", "right" ],
1064 outs => [ "eflags" ],
1065 am => "source,binary",
1066 emit => '. cmpb %binop',
1067 attr => "int ins_permuted, int cmp_unsigned",
1068 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1069 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1072 mode => $mode_flags,
1073 modified_flags => $status_flags
1078 state => "exc_pinned",
1079 reg_req => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
1080 ins => [ "base", "index", "mem", "left", "right" ],
1081 outs => [ "eflags" ],
1082 am => "source,binary",
1083 emit => '. test%M %binop',
1084 attr => "int ins_permuted, int cmp_unsigned",
1085 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1086 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1089 mode => $mode_flags,
1090 modified_flags => $status_flags
1095 state => "exc_pinned",
1096 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
1097 ins => [ "base", "index", "mem", "left", "right" ],
1098 outs => [ "eflags" ],
1099 am => "source,binary",
1100 emit => '. testb %binop',
1101 attr => "int ins_permuted, int cmp_unsigned",
1102 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
1103 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
1106 mode => $mode_flags,
1107 modified_flags => $status_flags
1112 reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
1113 ins => [ "eflags" ],
1114 attr_type => "ia32_condcode_attr_t",
1115 attr => "pn_Cmp pnc, int ins_permuted",
1116 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1117 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1118 emit => '. set%CMP0 %DB0',
1126 state => "exc_pinned",
1127 reg_req => { in => [ "gp", "gp", "none", "eflags" ], out => [ "none" ] },
1128 ins => [ "base", "index", "mem","eflags" ],
1129 attr_type => "ia32_condcode_attr_t",
1130 attr => "pn_Cmp pnc, int ins_permuted",
1131 init_attr => "attr->attr.data.ins_permuted = ins_permuted;\n".
1132 "\tset_ia32_ls_mode(res, mode_Bu);\n",
1133 emit => '. set%CMP3 %AM',
1141 # (note: leave the false,true order intact to make it compatible with other
1143 state => "exc_pinned",
1144 reg_req => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
1145 ins => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
1146 am => "source,binary",
1147 attr_type => "ia32_condcode_attr_t",
1148 attr => "int ins_permuted, pn_Cmp pnc",
1149 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1157 op_flags => "L|X|Y",
1158 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
1159 ins => [ "eflags" ],
1160 outs => [ "false", "true" ],
1161 attr_type => "ia32_condcode_attr_t",
1162 attr => "pn_Cmp pnc",
1164 units => [ "BRANCH" ],
1169 op_flags => "L|X|Y",
1170 reg_req => { in => [ "gp" ], out => [ "none" ] },
1172 attr_type => "ia32_condcode_attr_t",
1175 units => [ "BRANCH" ],
1176 modified_flags => $status_flags,
1182 reg_req => { in => [ "gp", "gp", "none", "gp" ] },
1183 ins => [ "base", "index", "mem", "target" ],
1184 am => "source,unary",
1185 emit => '. jmp *%unop3',
1187 units => [ "BRANCH" ],
1194 reg_req => { out => [ "gp" ] },
1196 attr => "ir_entity *symconst, int symconst_sign, long offset",
1197 attr_type => "ia32_immediate_attr_t",
1204 reg_req => { out => [ "gp" ] },
1208 modified_flags => $status_flags,
1214 reg_req => { out => [ "gp_UKNWN:I" ] },
1224 reg_req => { out => [ "vfp_UKNWN:I" ] },
1229 attr_type => "ia32_x87_attr_t",
1235 reg_req => { out => [ "xmm_UKNWN:I" ] },
1244 op_flags => "c|NB|NI",
1245 reg_req => { out => [ "gp_NOREG:I" ] },
1254 op_flags => "c|NB|NI",
1255 reg_req => { out => [ "vfp_NOREG:I" ] },
1260 attr_type => "ia32_x87_attr_t",
1265 op_flags => "c|NB|NI",
1266 reg_req => { out => [ "xmm_NOREG:I" ] },
1276 reg_req => { out => [ "fpcw:I" ] },
1280 modified_flags => $fpcw_flags
1286 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fpcw:I" ] },
1287 ins => [ "base", "index", "mem" ],
1289 emit => ". fldcw %AM",
1292 modified_flags => $fpcw_flags
1298 reg_req => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1299 ins => [ "base", "index", "mem", "fpcw" ],
1301 emit => ". fnstcw %AM",
1309 reg_req => { in => [ "fp_cw" ], out => [ "none" ] },
1317 # we should not rematrialize this node. It has very strict constraints.
1318 reg_req => { in => [ "eax", "edx" ], out => [ "edx" ] },
1319 ins => [ "val", "clobbered" ],
1328 # Note that we add additional latency values depending on address mode, so a
1329 # lateny of 0 for load is correct
1333 state => "exc_pinned",
1334 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none", "none" ] },
1335 ins => [ "base", "index", "mem" ],
1336 outs => [ "res", "M", "X_exc" ],
1338 emit => ". mov%EX%.l %AM, %D0",
1344 state => "exc_pinned",
1345 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "none", "none" ] },
1346 ins => [ "base", "index", "mem", "val" ],
1347 outs => [ "M", "X_exc" ],
1348 emit => '. mov%M %SI3, %AM',
1356 state => "exc_pinned",
1357 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none", "none" ] },
1358 ins => [ "base", "index", "mem", "val" ],
1359 outs => [ "M", "X_exc" ],
1360 emit => '. mov%M %SB3, %AM',
1368 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
1369 ins => [ "base", "index" ],
1370 emit => '. leal %AM, %D0',
1374 # lea doesn't modify the flags, but setting this seems advantageous since it
1375 # increases chances that the Lea is transformed back to an Add
1376 modified_flags => 1,
1380 state => "exc_pinned",
1381 reg_req => { in => [ "gp", "gp", "none", "gp", "esp" ], out => [ "esp:I|S", "none" ] },
1382 ins => [ "base", "index", "mem", "val", "stack" ],
1383 emit => '. push%M %unop3',
1384 outs => [ "stack", "M" ],
1385 am => "source,unary",
1391 state => "exc_pinned",
1392 reg_req => { in => [ "none", "esp" ], out => [ "gp", "none", "none", "esp:I|S" ] },
1393 ins => [ "mem", "stack" ],
1394 outs => [ "res", "M", "unused", "stack" ],
1395 emit => '. pop%M %D0',
1396 latency => 3, # Pop is more expensive than Push on Athlon
1401 state => "exc_pinned",
1402 reg_req => { in => [ "none", "esp" ], out => [ "ebp:I", "none", "none", "esp:I|S" ] },
1403 ins => [ "mem", "stack" ],
1404 outs => [ "res", "M", "unused", "stack" ],
1405 emit => '. pop%M %D0',
1406 latency => 3, # Pop is more expensive than Push on Athlon
1411 state => "exc_pinned",
1412 reg_req => { in => [ "gp", "gp", "none", "esp" ], out => [ "none", "none", "none", "esp:I|S" ] },
1413 ins => [ "base", "index", "mem", "stack" ],
1414 outs => [ "unused0", "M", "unused1", "stack" ],
1415 emit => '. pop%M %AM',
1416 latency => 3, # Pop is more expensive than Push on Athlon
1421 reg_req => { in => [ "esp" ], out => [ "ebp", "esp:I|S", "none" ] },
1423 outs => [ "frame", "stack", "M" ],
1429 reg_req => { in => [ "ebp" ], out => [ "ebp:I", "esp:I|S" ] },
1431 outs => [ "frame", "stack" ],
1438 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "none" ] },
1439 ins => [ "base", "index", "mem", "stack", "size" ],
1440 am => "source,binary",
1441 emit => '. addl %binop',
1443 outs => [ "stack", "M" ],
1445 modified_flags => $status_flags
1450 reg_req => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp:I|S", "gp", "none" ] },
1451 ins => [ "base", "index", "mem", "stack", "size" ],
1452 am => "source,binary",
1453 emit => ". subl %binop\n".
1454 ". movl %%esp, %D1",
1456 outs => [ "stack", "addr", "M" ],
1458 modified_flags => $status_flags
1471 reg_req => { out => [ "gp" ] },
1477 # BT supports source address mode, but this is unused yet
1481 state => "exc_pinned",
1482 reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] },
1483 ins => [ "left", "right" ],
1484 emit => '. bt%M %S1, %S0',
1487 mode => $mode_flags,
1488 modified_flags => $status_flags # only CF is set, but the other flags are undefined
1493 state => "exc_pinned",
1494 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1495 out => [ "gp", "flags", "none" ] },
1496 ins => [ "base", "index", "mem", "operand" ],
1497 outs => [ "res", "flags", "M" ],
1498 am => "source,binary",
1499 emit => '. bsf%M %unop3, %D0',
1503 modified_flags => $status_flags
1508 state => "exc_pinned",
1509 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1510 out => [ "gp", "flags", "none" ] },
1511 ins => [ "base", "index", "mem", "operand" ],
1512 outs => [ "res", "flags", "M" ],
1513 am => "source,binary",
1514 emit => '. bsr%M %unop3, %D0',
1518 modified_flags => $status_flags
1522 # SSE4.2 or SSE4a popcnt instruction
1526 state => "exc_pinned",
1527 reg_req => { in => [ "gp", "gp", "none", "gp" ],
1528 out => [ "gp", "flags", "none" ] },
1529 ins => [ "base", "index", "mem", "operand" ],
1530 outs => [ "res", "flags", "M" ],
1531 am => "source,binary",
1532 emit => '. popcnt%M %unop3, %D0',
1536 modified_flags => $status_flags
1540 state => "exc_pinned",
1542 in => [ "gp", "gp", "none", "gp", "esp", "fpcw", "eax", "ecx", "edx" ],
1543 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" ]
1545 ins => [ "base", "index", "mem", "addr", "stack", "fpcw", "eax", "ecx", "edx" ],
1546 outs => [ "stack", "fpcw", "M", "eax", "ecx", "edx", "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" ],
1547 attr_type => "ia32_call_attr_t",
1548 attr => "unsigned pop, ir_type *call_tp",
1549 am => "source,unary",
1550 units => [ "BRANCH" ],
1551 latency => 4, # random number
1552 modified_flags => $status_flags
1556 # a Helper node for frame-climbing, needed for __builtin_(frame|return)_address
1558 # PS: try gcc __builtin_frame_address(100000) :-)
1561 reg_req => { in => [ "gp", "gp", "gp"], out => [ "in_r3" ] },
1562 ins => [ "frame", "cnt", "tmp" ],
1564 latency => 4, # random number
1565 attr_type => "ia32_climbframe_attr_t",
1566 attr => "unsigned count",
1572 # Intel style prefetching
1576 state => "exc_pinned",
1577 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1578 ins => [ "base", "index", "mem" ],
1581 emit => ". prefetcht0 %AM",
1587 state => "exc_pinned",
1588 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1589 ins => [ "base", "index", "mem" ],
1592 emit => ". prefetcht1 %AM",
1598 state => "exc_pinned",
1599 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1600 ins => [ "base", "index", "mem" ],
1603 emit => ". prefetcht2 %AM",
1609 state => "exc_pinned",
1610 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1611 ins => [ "base", "index", "mem" ],
1614 emit => ". prefetchnta %AM",
1619 # 3DNow! prefetch instructions
1623 state => "exc_pinned",
1624 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1625 ins => [ "base", "index", "mem" ],
1628 emit => ". prefetch %AM",
1634 state => "exc_pinned",
1635 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
1636 ins => [ "base", "index", "mem" ],
1639 emit => ". prefetchw %AM",
1643 #-----------------------------------------------------------------------------#
1644 # _____ _____ ______ __ _ _ _ #
1645 # / ____/ ____| ____| / _| | | | | | #
1646 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1647 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1648 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1649 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1650 #-----------------------------------------------------------------------------#
1655 reg_req => { out => [ "xmm" ] },
1656 emit => '. xorp%XSD %D0, %D0',
1664 reg_req => { out => [ "xmm" ] },
1665 emit => '. pxor %D0, %D0',
1671 # produces all 1 bits
1674 reg_req => { out => [ "xmm" ] },
1675 emit => '. pcmpeqb %D0, %D0',
1681 # integer shift left, dword
1684 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1685 emit => '. pslld %SI1, %D0',
1691 # integer shift left, qword
1694 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1695 emit => '. psllq %SI1, %D0',
1701 # integer shift right, dword
1704 reg_req => { in => [ "xmm", "xmm" ], out => [ "in_r1 !in_r2" ] },
1705 emit => '. psrld %SI1, %D0',
1711 # mov from integer to SSE register
1714 reg_req => { in => [ "gp" ], out => [ "xmm" ] },
1715 emit => '. movd %S0, %D0',
1721 # commutative operations
1725 state => "exc_pinned",
1726 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1727 ins => [ "base", "index", "mem", "left", "right" ],
1728 am => "source,binary",
1729 emit => '. add%XXM %binop',
1737 state => "exc_pinned",
1738 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1739 ins => [ "base", "index", "mem", "left", "right" ],
1740 am => "source,binary",
1741 emit => '. mul%XXM %binop',
1749 state => "exc_pinned",
1750 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1751 ins => [ "base", "index", "mem", "left", "right" ],
1752 am => "source,binary",
1753 emit => '. max%XXM %binop',
1761 state => "exc_pinned",
1762 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1763 ins => [ "base", "index", "mem", "left", "right" ],
1764 am => "source,binary",
1765 emit => '. min%XXM %binop',
1773 state => "exc_pinned",
1774 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1775 ins => [ "base", "index", "mem", "left", "right" ],
1776 am => "source,binary",
1777 emit => '. andp%XSD %binop',
1785 state => "exc_pinned",
1786 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1787 ins => [ "base", "index", "mem", "left", "right" ],
1788 am => "source,binary",
1789 emit => '. orp%XSD %binop',
1797 state => "exc_pinned",
1798 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1799 ins => [ "base", "index", "mem", "left", "right" ],
1800 am => "source,binary",
1801 emit => '. xorp%XSD %binop',
1807 # not commutative operations
1811 state => "exc_pinned",
1812 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1813 ins => [ "base", "index", "mem", "left", "right" ],
1814 am => "source,binary",
1815 emit => '. andnp%XSD %binop',
1823 state => "exc_pinned",
1824 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1825 ins => [ "base", "index", "mem", "minuend", "subtrahend" ],
1826 am => "source,binary",
1827 emit => '. sub%XXM %binop',
1835 state => "exc_pinned",
1836 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1837 ins => [ "base", "index", "mem", "dividend", "divisor" ],
1838 am => "source,binary",
1839 outs => [ "res", "M" ],
1840 emit => '. div%XXM %binop',
1849 state => "exc_pinned",
1850 reg_req => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1851 ins => [ "base", "index", "mem", "left", "right" ],
1852 outs => [ "flags" ],
1853 am => "source,binary",
1854 attr => "int ins_permuted",
1855 init_attr => "attr->data.ins_permuted = ins_permuted;",
1856 emit => ' .ucomi%XXM %binop',
1859 mode => $mode_flags,
1860 modified_flags => 1,
1867 state => "exc_pinned",
1868 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none", "none" ] },
1869 ins => [ "base", "index", "mem" ],
1870 outs => [ "res", "M", "X_exc" ],
1871 emit => '. mov%XXM %AM, %D0',
1872 attr => "ir_mode *load_mode",
1873 init_attr => "attr->ls_mode = load_mode;",
1880 state => "exc_pinned",
1881 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "none", "none" ] },
1882 ins => [ "base", "index", "mem", "val" ],
1883 outs => [ "M", "X_exc" ],
1884 emit => '. mov%XXM %S3, %AM',
1892 state => "exc_pinned",
1893 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
1894 ins => [ "base", "index", "mem", "val" ],
1895 emit => '. mov%XXM %S3, %AM',
1903 state => "exc_pinned",
1904 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1905 ins => [ "base", "index", "mem", "val" ],
1906 am => "source,unary",
1907 emit => '. cvtsi2ss %unop3, %D0',
1915 state => "exc_pinned",
1916 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1917 ins => [ "base", "index", "mem", "val" ],
1918 am => "source,unary",
1919 emit => '. cvtsi2sd %unop3, %D0',
1928 cmp_attr => "return 1;",
1929 ins => [ "val_high", "val_low" ],
1934 cmp_attr => "return 1;",
1936 outs => [ "res_high", "res_low" ],
1944 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1945 outs => [ "DST", "SRC", "CNT", "M" ],
1946 attr_type => "ia32_copyb_attr_t",
1947 attr => "unsigned size",
1950 # we don't care about this flag, so no need to mark this node
1951 # modified_flags => [ "DF" ]
1957 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1958 outs => [ "DST", "SRC", "M" ],
1959 attr_type => "ia32_copyb_attr_t",
1960 attr => "unsigned size",
1963 # we don't care about this flag, so no need to mark this node
1964 # modified_flags => [ "DF" ]
1970 state => "exc_pinned",
1971 reg_req => { in => [ "eax" ], out => [ "eax" ] },
1981 state => "exc_pinned",
1982 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1983 ins => [ "base", "index", "mem", "val" ],
1984 outs => [ "res", "M" ],
1985 am => "source,unary",
1988 attr => "ir_mode *smaller_mode",
1989 init_attr => "attr->ls_mode = smaller_mode;",
1994 state => "exc_pinned",
1995 reg_req => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1996 ins => [ "base", "index", "mem", "val" ],
1997 am => "source,unary",
2000 attr => "ir_mode *smaller_mode",
2001 init_attr => "attr->ls_mode = smaller_mode;",
2006 state => "exc_pinned",
2007 reg_req => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
2008 ins => [ "base", "index", "mem", "val" ],
2009 am => "source,unary",
2016 state => "exc_pinned",
2017 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
2018 ins => [ "base", "index", "mem", "val" ],
2019 am => "source,unary",
2026 state => "exc_pinned",
2027 reg_req => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
2028 ins => [ "base", "index", "mem", "val" ],
2029 am => "source,unary",
2035 #----------------------------------------------------------#
2037 # (_) | | | | / _| | | | #
2038 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
2039 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
2040 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
2041 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
2043 # _ __ ___ __| | ___ ___ #
2044 # | '_ \ / _ \ / _` |/ _ \/ __| #
2045 # | | | | (_) | (_| | __/\__ \ #
2046 # |_| |_|\___/ \__,_|\___||___/ #
2047 #----------------------------------------------------------#
2049 # rematerialisation disabled for all float nodes for now, because the fpcw
2050 # handler runs before spilling and we might end up with wrong fpcw then
2054 state => "exc_pinned",
2055 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2056 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2057 am => "source,binary",
2061 attr_type => "ia32_x87_attr_t",
2066 state => "exc_pinned",
2067 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2068 ins => [ "base", "index", "mem", "left", "right", "fpcw" ],
2069 am => "source,binary",
2073 attr_type => "ia32_x87_attr_t",
2078 state => "exc_pinned",
2079 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2080 ins => [ "base", "index", "mem", "minuend", "subtrahend", "fpcw" ],
2081 am => "source,binary",
2085 attr_type => "ia32_x87_attr_t",
2089 state => "exc_pinned",
2090 reg_req => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
2091 ins => [ "base", "index", "mem", "dividend", "divisor", "fpcw" ],
2092 am => "source,binary",
2093 outs => [ "res", "M" ],
2096 attr_type => "ia32_x87_attr_t",
2100 reg_req => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
2101 ins => [ "left", "right", "fpcw" ],
2105 attr_type => "ia32_x87_attr_t",
2110 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2115 attr_type => "ia32_x87_attr_t",
2120 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2125 attr_type => "ia32_x87_attr_t",
2128 # virtual Load and Store
2133 state => "exc_pinned",
2134 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none", "none" ] },
2135 ins => [ "base", "index", "mem" ],
2136 outs => [ "res", "M", "X_exc" ],
2137 attr => "ir_mode *load_mode",
2138 init_attr => "attr->attr.ls_mode = load_mode;",
2141 attr_type => "ia32_x87_attr_t",
2147 state => "exc_pinned",
2148 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "none", "none" ] },
2149 ins => [ "base", "index", "mem", "val" ],
2150 outs => [ "M", "X_exc" ],
2151 attr => "ir_mode *store_mode",
2152 init_attr => "attr->attr.ls_mode = store_mode;",
2156 attr_type => "ia32_x87_attr_t",
2162 state => "exc_pinned",
2163 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
2164 outs => [ "res", "M" ],
2165 ins => [ "base", "index", "mem" ],
2168 attr_type => "ia32_x87_attr_t",
2172 state => "exc_pinned",
2173 reg_req => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
2174 ins => [ "base", "index", "mem", "val", "fpcw" ],
2178 attr_type => "ia32_x87_attr_t",
2181 # SSE3 fisttp instruction
2183 state => "exc_pinned",
2184 reg_req => { in => [ "gp", "gp", "none", "vfp" ], out => [ "in_r4", "none" ]},
2185 ins => [ "base", "index", "mem", "val" ],
2186 outs => [ "res", "M" ],
2189 attr_type => "ia32_x87_attr_t",
2197 reg_req => { out => [ "vfp" ] },
2202 attr_type => "ia32_x87_attr_t",
2207 reg_req => { out => [ "vfp" ] },
2212 attr_type => "ia32_x87_attr_t",
2217 reg_req => { out => [ "vfp" ] },
2222 attr_type => "ia32_x87_attr_t",
2227 reg_req => { out => [ "vfp" ] },
2232 attr_type => "ia32_x87_attr_t",
2237 reg_req => { out => [ "vfp" ] },
2242 attr_type => "ia32_x87_attr_t",
2247 reg_req => { out => [ "vfp" ] },
2252 attr_type => "ia32_x87_attr_t",
2257 reg_req => { out => [ "vfp" ] },
2262 attr_type => "ia32_x87_attr_t",
2268 # we can't allow to rematerialize this node so we don't have
2269 # accidently produce Phi(Fucom, Fucom(ins_permuted))
2271 reg_req => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
2272 ins => [ "left", "right" ],
2273 outs => [ "flags" ],
2274 attr => "int ins_permuted",
2275 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2278 attr_type => "ia32_x87_attr_t",
2284 reg_req => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
2285 ins => [ "left", "right" ],
2286 outs => [ "flags" ],
2287 attr => "int ins_permuted",
2288 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2291 attr_type => "ia32_x87_attr_t",
2297 reg_req => { in => [ "vfp" ], out => [ "eax" ] },
2299 outs => [ "flags" ],
2300 attr => "int ins_permuted",
2301 init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
2304 attr_type => "ia32_x87_attr_t",
2310 reg_req => { in => [ "eax" ], out => [ "eflags" ] },
2312 outs => [ "flags" ],
2316 mode => $mode_flags,
2319 #------------------------------------------------------------------------#
2320 # ___ _____ __ _ _ _ #
2321 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
2322 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
2323 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
2324 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
2325 #------------------------------------------------------------------------#
2327 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
2328 # are swapped, we work this around in the emitter...
2331 state => "exc_pinned",
2332 rd_constructor => "NONE",
2334 emit => '. fadd%XM %x87_binop',
2336 attr_type => "ia32_x87_attr_t",
2340 state => "exc_pinned",
2341 rd_constructor => "NONE",
2343 emit => '. faddp%XM %x87_binop',
2345 attr_type => "ia32_x87_attr_t",
2349 state => "exc_pinned",
2350 rd_constructor => "NONE",
2352 emit => '. fmul%XM %x87_binop',
2354 attr_type => "ia32_x87_attr_t",
2358 state => "exc_pinned",
2359 rd_constructor => "NONE",
2361 emit => '. fmulp%XM %x87_binop',,
2363 attr_type => "ia32_x87_attr_t",
2367 state => "exc_pinned",
2368 rd_constructor => "NONE",
2370 emit => '. fsub%XM %x87_binop',
2372 attr_type => "ia32_x87_attr_t",
2376 state => "exc_pinned",
2377 rd_constructor => "NONE",
2379 # see note about gas bugs
2380 emit => '. fsubrp%XM %x87_binop',
2382 attr_type => "ia32_x87_attr_t",
2386 state => "exc_pinned",
2387 rd_constructor => "NONE",
2390 emit => '. fsubr%XM %x87_binop',
2392 attr_type => "ia32_x87_attr_t",
2396 state => "exc_pinned",
2397 rd_constructor => "NONE",
2400 # see note about gas bugs
2401 emit => '. fsubp%XM %x87_binop',
2403 attr_type => "ia32_x87_attr_t",
2407 rd_constructor => "NONE",
2411 attr_type => "ia32_x87_attr_t",
2414 # this node is just here, to keep the simulator running
2415 # we can omit this when a fprem simulation function exists
2417 rd_constructor => "NONE",
2419 emit => '. fprem1\n'.
2422 attr_type => "ia32_x87_attr_t",
2426 state => "exc_pinned",
2427 rd_constructor => "NONE",
2429 emit => '. fdiv%XM %x87_binop',
2431 attr_type => "ia32_x87_attr_t",
2435 state => "exc_pinned",
2436 rd_constructor => "NONE",
2438 # see note about gas bugs
2439 emit => '. fdivrp%XM %x87_binop',
2441 attr_type => "ia32_x87_attr_t",
2445 state => "exc_pinned",
2446 rd_constructor => "NONE",
2448 emit => '. fdivr%XM %x87_binop',
2450 attr_type => "ia32_x87_attr_t",
2454 state => "exc_pinned",
2455 rd_constructor => "NONE",
2457 # see note about gas bugs
2458 emit => '. fdivp%XM %x87_binop',
2460 attr_type => "ia32_x87_attr_t",
2464 rd_constructor => "NONE",
2468 attr_type => "ia32_x87_attr_t",
2473 rd_constructor => "NONE",
2477 attr_type => "ia32_x87_attr_t",
2480 # x87 Load and Store
2483 rd_constructor => "NONE",
2484 op_flags => "R|L|F",
2485 state => "exc_pinned",
2487 emit => '. fld%XM %AM',
2488 attr_type => "ia32_x87_attr_t",
2493 rd_constructor => "NONE",
2494 op_flags => "R|L|F",
2495 state => "exc_pinned",
2497 emit => '. fst%XM %AM',
2499 attr_type => "ia32_x87_attr_t",
2504 rd_constructor => "NONE",
2505 op_flags => "R|L|F",
2506 state => "exc_pinned",
2508 emit => '. fstp%XM %AM',
2510 attr_type => "ia32_x87_attr_t",
2517 state => "exc_pinned",
2518 rd_constructor => "NONE",
2520 emit => '. fild%XM %AM',
2521 attr_type => "ia32_x87_attr_t",
2526 state => "exc_pinned",
2527 rd_constructor => "NONE",
2529 emit => '. fist%XM %AM',
2531 attr_type => "ia32_x87_attr_t",
2536 state => "exc_pinned",
2537 rd_constructor => "NONE",
2539 emit => '. fistp%XM %AM',
2541 attr_type => "ia32_x87_attr_t",
2545 # SSE3 firsttp instruction
2547 state => "exc_pinned",
2548 rd_constructor => "NONE",
2550 emit => '. fisttp%XM %AM',
2552 attr_type => "ia32_x87_attr_t",
2559 op_flags => "R|c|K",
2561 reg_req => { out => [ "vfp" ] },
2563 attr_type => "ia32_x87_attr_t",
2568 op_flags => "R|c|K",
2570 reg_req => { out => [ "vfp" ] },
2572 attr_type => "ia32_x87_attr_t",
2577 op_flags => "R|c|K",
2579 reg_req => { out => [ "vfp" ] },
2581 attr_type => "ia32_x87_attr_t",
2586 op_flags => "R|c|K",
2588 reg_req => { out => [ "vfp" ] },
2590 attr_type => "ia32_x87_attr_t",
2595 op_flags => "R|c|K",
2597 reg_req => { out => [ "vfp" ] },
2599 attr_type => "ia32_x87_attr_t",
2604 op_flags => "R|c|K",
2606 reg_req => { out => [ "vfp" ] },
2607 emit => '. fldll2t',
2608 attr_type => "ia32_x87_attr_t",
2613 op_flags => "R|c|K",
2615 reg_req => { out => [ "vfp" ] },
2617 attr_type => "ia32_x87_attr_t",
2622 # Note that it is NEVER allowed to do CSE on these nodes
2623 # Moreover, note the virtual register requierements!
2628 cmp_attr => "return 1;",
2629 emit => '. fxch %X0',
2630 attr_type => "ia32_x87_attr_t",
2638 cmp_attr => "return 1;",
2639 emit => '. fld %X0',
2640 attr_type => "ia32_x87_attr_t",
2646 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
2647 cmp_attr => "return 1;",
2648 emit => '. fld %X0',
2649 attr_type => "ia32_x87_attr_t",
2656 cmp_attr => "return 1;",
2657 emit => '. fstp %X0',
2658 attr_type => "ia32_x87_attr_t",
2666 cmp_attr => "return 1;",
2667 emit => '. ffreep %X0',
2668 attr_type => "ia32_x87_attr_t",
2676 cmp_attr => "return 1;",
2678 attr_type => "ia32_x87_attr_t",
2686 cmp_attr => "return 1;",
2688 attr_type => "ia32_x87_attr_t",
2697 emit => ". fucom %X1\n".
2699 attr_type => "ia32_x87_attr_t",
2705 emit => ". fucomp %X1\n".
2707 attr_type => "ia32_x87_attr_t",
2713 emit => ". fucompp\n".
2715 attr_type => "ia32_x87_attr_t",
2721 emit => '. fucomi %X1',
2722 attr_type => "ia32_x87_attr_t",
2728 emit => '. fucompi %X1',
2729 attr_type => "ia32_x87_attr_t",
2737 attr_type => "ia32_x87_attr_t",
2742 # -------------------------------------------------------------------------------- #
2743 # ____ ____ _____ _ _ #
2744 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
2745 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
2746 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
2747 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
2749 # -------------------------------------------------------------------------------- #
2752 # Spilling and reloading of SSE registers, hardcoded, not generated #
2756 state => "exc_pinned",
2757 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2758 emit => '. movdqu %D0, %AM',
2759 outs => [ "res", "M" ],
2766 state => "exc_pinned",
2767 reg_req => { in => [ "gp", "gp", "none", "xmm" ] },
2768 ins => [ "base", "index", "mem", "val" ],
2769 emit => '. movdqu %binop',
2777 # Include the generated SIMD node specification written by the SIMD optimization
2778 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2779 unless ($return = do $my_script_name) {
2780 warn "couldn't parse $my_script_name: $@" if $@;
2781 warn "couldn't do $my_script_name: $!" unless defined $return;
2782 warn "couldn't run $my_script_name" unless $return;
2785 # Transform some attributes
2786 foreach my $op (keys(%nodes)) {
2787 my $node = $nodes{$op};
2788 my $op_attr_init = $node->{op_attr_init};
2790 if(defined($op_attr_init)) {
2791 $op_attr_init .= "\n\t";
2796 if(!defined($node->{latency})) {
2798 $node->{latency} = 0;
2800 die("Latency missing for op $op");
2803 $op_attr_init .= "attr->latency = ".$node->{latency} . ";";
2805 $node->{op_attr_init} = $op_attr_init;