3 # This is the specification for the ia32 assembler Firm-operations
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
13 # The node description is done as a perl hash initializer with the
14 # following structure:
19 # op_flags => "N|L|C|X|I|F|Y|H|c|K",
20 # irn_flags => "R|N|I|S"
21 # arity => "0|1|2|3 ... |variable|dynamic|any",
22 # state => "floats|pinned|mem_pinned|exc_pinned",
24 # { type => "type 1", name => "name 1" },
25 # { type => "type 2", name => "name 2" },
28 # comment => "any comment for constructor",
29 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 # cmp_attr => "c source code for comparing node attributes",
31 # emit => "emit code with templates",
32 # attr => "attitional attribute arguments for constructor"
33 # init_attr => "emit attribute initialization template"
34 # rd_constructor => "c source code which constructs an ir_node"
35 # latency => "latency of this operation (can be float)"
38 # ... # (all nodes you need to describe)
40 # ); # close the %nodes initializer
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
46 # C irop_flag_commutative
47 # X irop_flag_cfopcode
48 # I irop_flag_ip_cfopcode
51 # H irop_flag_highlevel
52 # c irop_flag_constlike
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
59 # I ignore for register allocation
60 # S modifies stack pointer
62 # state: state of the operation, OPTIONAL (default is "floats")
64 # arity: arity of the operation, MUST NOT BE OMITTED
66 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
67 # are always the first 3 arguments and are always autmatically
69 # If this key is missing the following arguments will be created:
70 # for i = 1 .. arity: ir_node *op_i
73 # outs: if a node defines more than one output, the names of the projections
74 # nodes having outs having automatically the mode mode_T
75 # One can also annotate some flags for each out, additional to irn_flags.
76 # They are separated from name with a colon ':', and concatenated by pipe '|'
77 # Only I and S are available at the moment (same meaning as in irn_flags).
78 # example: [ "frame:I", "stack:I|S", "M" ]
80 # comment: OPTIONAL comment for the node constructor
82 # rd_constructor: for every operation there will be a
83 # new_rd_<arch>_<op-name> function with the arguments from above
84 # which creates the ir_node corresponding to the defined operation
85 # you can either put the complete source code of this function here
87 # This key is OPTIONAL. If omitted, the following constructor will
89 # if (!op_<arch>_<op-name>) assert(0);
93 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
96 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
98 # latency: the latency of the operation, default is 1
102 # 0 - no special type
103 # 1 - caller save (register must be saved by the caller of a function)
104 # 2 - callee save (register must be saved by the called function)
105 # 4 - ignore (do not assign this register)
106 # 8 - emitter can choose an arbitrary register of this class
107 # 16 - the register is a virtual one
108 # 32 - register represents a state
109 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
112 { name => "eax", type => 1 },
113 { name => "edx", type => 1 },
114 { name => "ebx", type => 2 },
115 { name => "ecx", type => 1 },
116 { name => "esi", type => 2 },
117 { name => "edi", type => 2 },
118 { name => "ebp", type => 2 },
119 { name => "esp", type => 4 },
120 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
121 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
122 { mode => "mode_Iu" }
125 { name => "mm0", type => 4 },
126 { name => "mm1", type => 4 },
127 { name => "mm2", type => 4 },
128 { name => "mm3", type => 4 },
129 { name => "mm4", type => 4 },
130 { name => "mm5", type => 4 },
131 { name => "mm6", type => 4 },
132 { name => "mm7", type => 4 },
136 { name => "xmm0", type => 1 },
137 { name => "xmm1", type => 1 },
138 { name => "xmm2", type => 1 },
139 { name => "xmm3", type => 1 },
140 { name => "xmm4", type => 1 },
141 { name => "xmm5", type => 1 },
142 { name => "xmm6", type => 1 },
143 { name => "xmm7", type => 1 },
144 { name => "xmm_NOREG", type => 4 | 16 }, # we need a dummy register for NoReg nodes
145 { name => "xmm_UKNWN", type => 4 | 8 | 16}, # we need a dummy register for Unknown nodes
149 { name => "vf0", type => 1 | 16 },
150 { name => "vf1", type => 1 | 16 },
151 { name => "vf2", type => 1 | 16 },
152 { name => "vf3", type => 1 | 16 },
153 { name => "vf4", type => 1 | 16 },
154 { name => "vf5", type => 1 | 16 },
155 { name => "vf6", type => 1 | 16 },
156 { name => "vf7", type => 1 | 16 },
157 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
158 { name => "vfp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
162 { name => "st0", realname => "st", type => 4 },
163 { name => "st1", realname => "st(1)", type => 4 },
164 { name => "st2", realname => "st(2)", type => 4 },
165 { name => "st3", realname => "st(3)", type => 4 },
166 { name => "st4", realname => "st(4)", type => 4 },
167 { name => "st5", realname => "st(5)", type => 4 },
168 { name => "st6", realname => "st(6)", type => 4 },
169 { name => "st7", realname => "st(7)", type => 4 },
172 fp_cw => [ # the floating point control word
173 { name => "fpcw", type => 4 | 32},
174 { mode => "mode_fpcw" }
177 { name => "eflags", type => 4 },
178 { mode => "mode_Iu" }
181 { name => "fpsw", type => 4 },
182 { mode => "mode_Hu" }
187 CF => { reg => "eflags", bit => 0 },
188 PF => { reg => "eflags", bit => 2 },
189 AF => { reg => "eflags", bit => 4 },
190 ZF => { reg => "eflags", bit => 6 },
191 SF => { reg => "eflags", bit => 7 },
192 TF => { reg => "eflags", bit => 8 },
193 IF => { reg => "eflags", bit => 9 },
194 DF => { reg => "eflags", bit => 10 },
195 OF => { reg => "eflags", bit => 11 },
196 IOPL0 => { reg => "eflags", bit => 12 },
197 IOPL1 => { reg => "eflags", bit => 13 },
198 NT => { reg => "eflags", bit => 14 },
199 RF => { reg => "eflags", bit => 16 },
200 VM => { reg => "eflags", bit => 17 },
201 AC => { reg => "eflags", bit => 18 },
202 VIF => { reg => "eflags", bit => 19 },
203 VIP => { reg => "eflags", bit => 20 },
204 ID => { reg => "eflags", bit => 21 },
206 FP_IE => { reg => "fpsw", bit => 0 },
207 FP_DE => { reg => "fpsw", bit => 1 },
208 FP_ZE => { reg => "fpsw", bit => 2 },
209 FP_OE => { reg => "fpsw", bit => 3 },
210 FP_UE => { reg => "fpsw", bit => 4 },
211 FP_PE => { reg => "fpsw", bit => 5 },
212 FP_SF => { reg => "fpsw", bit => 6 },
213 FP_ES => { reg => "fpsw", bit => 7 },
214 FP_C0 => { reg => "fpsw", bit => 8 },
215 FP_C1 => { reg => "fpsw", bit => 9 },
216 FP_C2 => { reg => "fpsw", bit => 10 },
217 FP_TOP0 => { reg => "fpsw", bit => 11 },
218 FP_TOP1 => { reg => "fpsw", bit => 12 },
219 FP_TOP2 => { reg => "fpsw", bit => 13 },
220 FP_C3 => { reg => "fpsw", bit => 14 },
221 FP_B => { reg => "fpsw", bit => 15 },
223 FP_IM => { reg => "fpcw", bit => 0 },
224 FP_DM => { reg => "fpcw", bit => 1 },
225 FP_ZM => { reg => "fpcw", bit => 2 },
226 FP_OM => { reg => "fpcw", bit => 3 },
227 FP_UM => { reg => "fpcw", bit => 4 },
228 FP_PM => { reg => "fpcw", bit => 5 },
229 FP_PC0 => { reg => "fpcw", bit => 8 },
230 FP_PC1 => { reg => "fpcw", bit => 9 },
231 FP_RC0 => { reg => "fpcw", bit => 10 },
232 FP_RC1 => { reg => "fpcw", bit => 11 },
233 FP_X => { reg => "fpcw", bit => 12 }
237 GP => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
238 SSE => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
239 VFP => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
240 BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
245 bundels_per_cycle => 1
249 S0 => "${arch}_emit_source_register(env, node, 0);",
250 S1 => "${arch}_emit_source_register(env, node, 1);",
251 S2 => "${arch}_emit_source_register(env, node, 2);",
252 S3 => "${arch}_emit_source_register(env, node, 3);",
253 S4 => "${arch}_emit_source_register(env, node, 4);",
254 S5 => "${arch}_emit_source_register(env, node, 5);",
255 D0 => "${arch}_emit_dest_register(env, node, 0);",
256 D1 => "${arch}_emit_dest_register(env, node, 1);",
257 D2 => "${arch}_emit_dest_register(env, node, 2);",
258 D3 => "${arch}_emit_dest_register(env, node, 3);",
259 D4 => "${arch}_emit_dest_register(env, node, 4);",
260 D5 => "${arch}_emit_dest_register(env, node, 5);",
261 X0 => "${arch}_emit_x87_name(env, node, 0);",
262 X1 => "${arch}_emit_x87_name(env, node, 1);",
263 X2 => "${arch}_emit_x87_name(env, node, 2);",
264 C => "${arch}_emit_immediate(env, node);",
265 SE => "${arch}_emit_extend_suffix(env, get_ia32_ls_mode(node));",
266 ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
267 ia32_emit_mode_suffix(env, node);",
268 M => "${arch}_emit_mode_suffix(env, node);",
269 XM => "${arch}_emit_x87_mode_suffix(env, node);",
270 XXM => "${arch}_emit_xmm_mode_suffix(env, node);",
271 XSD => "${arch}_emit_xmm_mode_suffix_s(env, node);",
272 AM => "${arch}_emit_am(env, node);",
273 unop => "${arch}_emit_unop(env, node);",
274 binop => "${arch}_emit_binop(env, node);",
275 x87_binop => "${arch}_emit_x87_binop(env, node);",
278 #--------------------------------------------------#
281 # _ __ _____ __ _ _ __ ___ _ __ ___ #
282 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
283 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
284 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
287 #--------------------------------------------------#
289 $default_cmp_attr = "return ia32_compare_attr(attr_a, attr_b);";
290 $default_attr_type = "ia32_attr_t";
295 $mode_xmm = "mode_E";
296 $mode_gp = "mode_Iu";
297 $mode_fpcw = "mode_fpcw";
298 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
299 $fpcw_flags = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
300 "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
308 reg_req => { out => [ "gp_NOREG" ] },
315 out_arity => "variable",
318 #-----------------------------------------------------------------#
321 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
322 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
323 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
324 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
327 #-----------------------------------------------------------------#
329 # commutative operations
332 # All nodes supporting Addressmode have 5 INs:
333 # 1 - base r1 == NoReg in case of no AM or no base
334 # 2 - index r2 == NoReg in case of no AM or no index
335 # 3 - op1 r3 == always present
336 # 4 - op2 r4 == NoReg in case of immediate operation
337 # 5 - mem NoMem in case of no AM otherwise it takes the mem from the Load
341 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
342 ins => [ "base", "index", "left", "right", "mem" ],
343 emit => '. add%M %binop',
346 modified_flags => $status_flags
350 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
351 emit => '. adc%M %binop',
354 modified_flags => $status_flags
360 reg_req => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
367 outs => [ "low_res", "high_res" ],
369 modified_flags => $status_flags
375 cmp_attr => "return 1;",
381 cmp_attr => "return 1;",
386 # we should not rematrialize this node. It produces 2 results and has
387 # very strict constrains
388 reg_req => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
389 emit => '. mul%M %unop',
390 outs => [ "EAX", "EDX", "M" ],
393 modified_flags => $status_flags
397 # we should not rematrialize this node. It produces 2 results and has
398 # very strict constrains
400 cmp_attr => "return 1;",
401 outs => [ "EAX", "EDX", "M" ],
407 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
408 emit => '. imul%M %binop',
412 modified_flags => $status_flags
417 reg_req => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
418 emit => '. imul%M %unop',
419 outs => [ "EAX", "EDX", "M" ],
422 modified_flags => $status_flags
427 cmp_attr => "return 1;",
433 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
434 emit => '. and%M %binop',
437 modified_flags => $status_flags
442 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
443 emit => '. or%M %binop',
446 modified_flags => $status_flags
451 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
452 emit => '. xor%M %binop',
455 modified_flags => $status_flags
460 cmp_attr => "return 1;",
462 modified_flags => $status_flags
465 # not commutative operations
469 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
470 emit => '. sub%M %binop',
473 modified_flags => $status_flags
477 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3 !in_r4" ] },
478 emit => '. sbb%M %binop',
481 modified_flags => $status_flags
487 reg_req => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
494 outs => [ "low_res", "high_res" ],
496 modified_flags => $status_flags
501 cmp_attr => "return 1;",
506 cmp_attr => "return 1;",
512 state => "exc_pinned",
513 reg_req => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ], out => [ "eax", "edx", "none" ] },
514 attr => "ia32_op_flavour_t dm_flav",
515 init_attr => "attr->data.op_flav = dm_flav;",
516 emit => ". idiv%M %unop",
517 outs => [ "div_res", "mod_res", "M" ],
520 modified_flags => $status_flags
525 state => "exc_pinned",
526 reg_req => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ], out => [ "eax", "edx", "none" ] },
527 attr => "ia32_op_flavour_t dm_flav",
528 init_attr => "attr->data.op_flav = dm_flav;",
529 emit => ". div%M %unop",
530 outs => [ "div_res", "mod_res", "M" ],
533 modified_flags => $status_flags
538 reg_req => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
539 ins => [ "base", "index", "left", "right", "mem" ],
540 emit => '. shl%M %binop',
543 modified_flags => $status_flags
547 cmp_attr => "return 1;",
553 # Out requirements is: different from all in
554 # This is because, out must be different from LowPart and ShiftCount.
555 # We could say "!ecx !in_r4" but it can occur, that all values live through
556 # this Shift and the only value dying is the ShiftCount. Then there would be a
557 # register missing, as result must not be ecx and all other registers are
558 # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
559 # (and probably never will). So we create artificial interferences of the result
560 # with all inputs, so the spiller can always assure a free register.
561 reg_req => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
564 if (get_ia32_immop_type(node) == ia32_ImmNone) {
565 if (get_ia32_op_type(node) == ia32_AddrModeD) {
566 . shld%M %%cl, %S3, %AM
568 . shld%M %%cl, %S3, %S2
571 if (get_ia32_op_type(node) == ia32_AddrModeD) {
572 . shld%M %C, %S3, %AM
574 . shld%M %C, %S3, %S2
581 modified_flags => $status_flags
585 cmp_attr => "return 1;",
591 reg_req => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
592 emit => '. shr%M %binop',
595 modified_flags => $status_flags
599 cmp_attr => "return 1;",
605 # Out requirements is: different from all in
606 # This is because, out must be different from LowPart and ShiftCount.
607 # We could say "!ecx !in_r4" but it can occur, that all values live through
608 # this Shift and the only value dying is the ShiftCount. Then there would be a
609 # register missing, as result must not be ecx and all other registers are
610 # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
611 # (and probably never will). So we create artificial interferences of the result
612 # with all inputs, so the spiller can always assure a free register.
613 reg_req => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
615 if (get_ia32_immop_type(node) == ia32_ImmNone) {
616 if (get_ia32_op_type(node) == ia32_AddrModeD) {
617 . shrd%M %%cl, %S3, %AM
619 . shrd%M %%cl, %S3, %S2
622 if (get_ia32_op_type(node) == ia32_AddrModeD) {
623 . shrd%M %C, %S3, %AM
625 . shrd%M %C, %S3, %S2
632 modified_flags => $status_flags
636 cmp_attr => "return 1;",
642 reg_req => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
643 emit => '. sar%M %binop',
646 modified_flags => $status_flags
650 cmp_attr => "return 1;",
656 reg_req => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
657 emit => '. ror%M %binop',
660 modified_flags => $status_flags
665 reg_req => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
666 emit => '. rol%M %binop',
669 modified_flags => $status_flags
676 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
677 emit => '. neg%M %unop',
680 modified_flags => $status_flags
685 reg_req => { in => [ "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
692 outs => [ "low_res", "high_res" ],
694 modified_flags => $status_flags
699 cmp_attr => "return 1;",
705 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
706 emit => '. inc%M %unop',
709 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
714 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
715 emit => '. dec%M %unop',
718 modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
723 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
724 emit => '. not%M %unop',
735 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "none", "none"] },
736 outs => [ "false", "true" ],
738 units => [ "BRANCH" ],
744 reg_req => { in => [ "gp", "gp" ], out => [ "none", "none" ] },
745 outs => [ "false", "true" ],
747 units => [ "BRANCH" ],
753 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "none", "none" ] },
754 outs => [ "false", "true" ],
755 units => [ "BRANCH" ],
761 reg_req => { in => [ "gp", "gp" ] },
762 units => [ "BRANCH" ],
768 reg_req => { in => [ "gp" ], out => [ "none" ] },
770 units => [ "BRANCH" ],
776 reg_req => { out => [ "gp" ] },
785 reg_req => { out => [ "gp_UKNWN" ] },
795 reg_req => { out => [ "vfp_UKNWN" ] },
805 reg_req => { out => [ "xmm_UKNWN" ] },
815 reg_req => { out => [ "gp_NOREG" ] },
825 reg_req => { out => [ "vfp_NOREG" ] },
835 reg_req => { out => [ "xmm_NOREG" ] },
845 reg_req => { out => [ "fp_cw" ] },
849 modified_flags => $fpcw_flags
854 state => "exc_pinned",
855 reg_req => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
857 emit => ". fldcw %AM",
860 modified_flags => $fpcw_flags
865 state => "exc_pinned",
866 reg_req => { in => [ "gp", "gp", "fp_cw", "none" ], out => [ "none" ] },
868 emit => ". fnstcw %AM",
874 # we should not rematrialize this node. It produces 2 results and has
875 # very strict constrains
876 reg_req => { in => [ "gp" ], out => [ "eax in_r1", "edx" ] },
878 outs => [ "EAX", "EDX" ],
886 state => "exc_pinned",
887 reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
889 emit => ". mov%SE%ME%.l %AM, %D0",
890 outs => [ "res", "M" ],
896 cmp_attr => "return 1;",
897 outs => [ "res", "M" ],
903 cmp_attr => "return 1;",
904 state => "exc_pinned",
911 state => "exc_pinned",
912 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
913 emit => '. mov%M %binop',
921 state => "exc_pinned",
922 reg_req => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => ["none" ] },
923 emit => '. mov%M %binop',
931 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
932 emit => '. leal %AM, %D0',
936 modified_flags => [],
940 reg_req => { in => [ "gp", "gp", "gp", "esp", "none" ], out => [ "esp", "none" ] },
941 emit => '. push%M %unop',
942 outs => [ "stack:I|S", "M" ],
945 modified_flags => [],
949 reg_req => { in => [ "gp", "gp", "esp", "none" ], out => [ "esp", "gp", "none" ] },
950 emit => '. pop%M %unop',
951 outs => [ "stack:I|S", "res", "M" ],
954 modified_flags => [],
958 reg_req => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
960 outs => [ "frame:I", "stack:I|S", "M" ],
966 reg_req => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
968 outs => [ "frame:I", "stack:I|S" ],
975 reg_req => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "none" ] },
976 emit => '. addl %binop',
977 outs => [ "stack:S", "M" ],
979 modified_flags => $status_flags
984 reg_req => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "none" ] },
985 emit => '. subl %binop',
986 outs => [ "stack:S", "M" ],
988 modified_flags => $status_flags
993 reg_req => { out => [ "gp" ] },
997 # the int instruction
999 reg_req => { in => [ "none" ], out => [ "none" ] },
1001 attr => "tarval *tv",
1002 init_attr => "\tset_ia32_Immop_tarval(res, tv);",
1005 cmp_attr => "return 1;",
1009 #-----------------------------------------------------------------------------#
1010 # _____ _____ ______ __ _ _ _ #
1011 # / ____/ ____| ____| / _| | | | | | #
1012 # | (___| (___ | |__ | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1013 # \___ \\___ \| __| | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1014 # ____) |___) | |____ | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1015 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1016 #-----------------------------------------------------------------------------#
1018 # commutative operations
1022 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1023 emit => '. add%XXM %binop',
1031 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1032 emit => '. mul%XXM %binop',
1040 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1041 emit => '. max%XXM %binop',
1049 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1050 emit => '. min%XXM %binop',
1058 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1059 emit => '. andp%XSD %binop',
1067 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1068 emit => '. orp%XSD %binop',
1075 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1076 emit => '. xorp%XSD %binop',
1082 # not commutative operations
1086 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1087 emit => '. andnp%XSD %binop',
1095 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1096 emit => '. sub%XXM %binop',
1104 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4", "none" ] },
1105 outs => [ "res", "M" ],
1106 emit => '. div%XXM %binop',
1115 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1123 op_flags => "L|X|Y",
1124 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "none", "none" ] },
1125 outs => [ "false", "true" ],
1133 reg_req => { out => [ "xmm" ] },
1134 emit => '. mov%XXM %C, %D0',
1144 state => "exc_pinned",
1145 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1146 emit => '. mov%XXM %AM, %D0',
1147 outs => [ "res", "M" ],
1154 state => "exc_pinned",
1155 reg_req => { in => [ "gp", "gp", "xmm", "none" ] },
1156 emit => '. mov%XXM %binop',
1164 state => "exc_pinned",
1165 reg_req => { in => [ "gp", "gp", "xmm", "none" ] },
1166 ins => [ "base", "index", "val", "mem" ],
1167 emit => '. mov%XXM %S2, %AM',
1175 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1176 emit => '. cvtsi2ss %D0, %AM',
1184 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1185 emit => '. cvtsi2sd %unop',
1194 cmp_attr => "return 1;",
1200 cmp_attr => "return 1;",
1207 state => "exc_pinned",
1208 reg_req => { in => [ "gp", "gp", "none" ] },
1209 emit => '. fstp%XM %AM',
1218 state => "exc_pinned",
1219 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vf0", "none" ] },
1220 ins => [ "base", "index", "mem" ],
1221 emit => '. fld%XM %AM',
1222 outs => [ "res", "M" ],
1232 reg_req => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1233 outs => [ "DST", "SRC", "CNT", "M" ],
1235 modified_flags => [ "DF" ]
1241 reg_req => { in => [ "edi", "esi", "none" ], out => [ "edi", "esi", "none" ] },
1242 outs => [ "DST", "SRC", "M" ],
1244 modified_flags => [ "DF" ]
1250 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3", "none" ] },
1253 modified_flags => $status_flags
1257 reg_req => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => [ "in_r3", "none" ] },
1260 modified_flags => $status_flags
1264 reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1271 reg_req => { in => [ "gp", "gp", "xmm", "none" ], out => [ "gp", "none" ] },
1278 reg_req => { in => [ "gp", "gp", "xmm", "none" ], out => [ "xmm", "none" ] },
1286 reg_req => { in => [ "gp", "gp", "gp", "gp" ], out => [ "in_r4" ] },
1294 reg_req => { in => [ "gp", "gp", "gp" ], out => [ "in_r3" ] },
1302 reg_req => { in => [ "xmm", "xmm", "gp", "gp" ], out => [ "in_r4" ] },
1310 reg_req => { in => [ "vfp", "vfp", "gp", "gp" ], out => [ "in_r4" ] },
1318 reg_req => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "eax ebx ecx edx" ] },
1326 reg_req => { in => [ "gp" ], out => [ "eax ebx ecx edx" ] },
1334 reg_req => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "eax ebx ecx edx" ] },
1342 reg_req => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "eax ebx ecx edx" ] },
1350 reg_req => { in => [ "vfp", "vfp", "vfp", "vfp" ], out => [ "vfp" ] },
1356 #----------------------------------------------------------#
1358 # (_) | | | | / _| | | | #
1359 # __ ___ _ __| |_ _ _ __ _| | | |_| | ___ __ _| |_ #
1360 # \ \ / / | '__| __| | | |/ _` | | | _| |/ _ \ / _` | __| #
1361 # \ V /| | | | |_| |_| | (_| | | | | | | (_) | (_| | |_ #
1362 # \_/ |_|_| \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1364 # _ __ ___ __| | ___ ___ #
1365 # | '_ \ / _ \ / _` |/ _ \/ __| #
1366 # | | | | (_) | (_| | __/\__ \ #
1367 # |_| |_|\___/ \__,_|\___||___/ #
1368 #----------------------------------------------------------#
1372 reg_req => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1380 reg_req => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1388 cmp_attr => "return 1;",
1394 reg_req => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1401 cmp_attr => "return 1;",
1406 reg_req => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp", "none" ] },
1407 outs => [ "res", "M" ],
1413 cmp_attr => "return 1;",
1414 outs => [ "res", "M" ],
1419 reg_req => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1426 cmp_attr => "return 1;",
1432 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1440 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1448 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1456 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1464 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1470 # virtual Load and Store
1474 state => "exc_pinned",
1475 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1476 outs => [ "res", "M" ],
1483 state => "exc_pinned",
1484 reg_req => { in => [ "gp", "gp", "vfp", "none" ] },
1493 reg_req => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1494 outs => [ "res", "M" ],
1500 cmp_attr => "return 1;",
1501 outs => [ "res", "M" ],
1506 reg_req => { in => [ "gp", "gp", "vfp", "fpcw", "none" ] },
1513 cmp_attr => "return 1;",
1523 reg_req => { out => [ "vfp" ] },
1531 reg_req => { out => [ "vfp" ] },
1539 reg_req => { out => [ "vfp" ] },
1547 reg_req => { out => [ "vfp" ] },
1555 reg_req => { out => [ "vfp" ] },
1563 reg_req => { out => [ "vfp" ] },
1571 reg_req => { out => [ "vfp" ] },
1580 # init_attr => " set_ia32_ls_mode(res, mode);",
1581 reg_req => { out => [ "vfp" ] },
1591 op_flags => "L|X|Y",
1592 reg_req => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "none", "none", "eax" ] },
1593 outs => [ "false", "true", "temp_reg_eax" ],
1598 #------------------------------------------------------------------------#
1599 # ___ _____ __ _ _ _ #
1600 # __ _( _ )___ | / _| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
1601 # \ \/ / _ \ / / | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1602 # > < (_) |/ / | _| | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
1603 # /_/\_\___//_/ |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1604 #------------------------------------------------------------------------#
1606 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1607 # are swapped, we work this around in the emitter...
1611 rd_constructor => "NONE",
1613 emit => '. fadd%XM %x87_binop',
1618 rd_constructor => "NONE",
1620 emit => '. faddp %x87_binop',
1625 rd_constructor => "NONE",
1627 emit => '. fmul%XM %x87_binop',
1632 rd_constructor => "NONE",
1634 emit => '. fmulp %x87_binop',,
1639 rd_constructor => "NONE",
1641 emit => '. fsub%XM %x87_binop',
1646 rd_constructor => "NONE",
1648 # see note about gas bugs
1649 emit => '. fsubrp %x87_binop',
1654 rd_constructor => "NONE",
1657 emit => '. fsubr%XM %x87_binop',
1662 rd_constructor => "NONE",
1665 # see note about gas bugs
1666 emit => '. fsubp %x87_binop',
1671 rd_constructor => "NONE",
1676 # this node is just here, to keep the simulator running
1677 # we can omit this when a fprem simulation function exists
1680 rd_constructor => "NONE",
1687 rd_constructor => "NONE",
1689 emit => '. fdiv%XM %x87_binop',
1694 rd_constructor => "NONE",
1696 # see note about gas bugs
1697 emit => '. fdivrp %x87_binop',
1702 rd_constructor => "NONE",
1704 emit => '. fdivr%XM %x87_binop',
1709 rd_constructor => "NONE",
1711 # see note about gas bugs
1712 emit => '. fdivp %x87_binop',
1717 rd_constructor => "NONE",
1724 rd_constructor => "NONE",
1731 rd_constructor => "NONE",
1738 rd_constructor => "NONE",
1745 rd_constructor => "NONE",
1747 emit => '. fsqrt $',
1750 # x87 Load and Store
1753 rd_constructor => "NONE",
1754 op_flags => "R|L|F",
1755 state => "exc_pinned",
1757 emit => '. fld%XM %AM',
1761 rd_constructor => "NONE",
1762 op_flags => "R|L|F",
1763 state => "exc_pinned",
1765 emit => '. fst%XM %AM',
1770 rd_constructor => "NONE",
1771 op_flags => "R|L|F",
1772 state => "exc_pinned",
1774 emit => '. fstp%XM %AM',
1782 rd_constructor => "NONE",
1784 emit => '. fild%XM %AM',
1789 rd_constructor => "NONE",
1791 emit => '. fist%XM %AM',
1797 rd_constructor => "NONE",
1799 emit => '. fistp%XM %AM',
1806 op_flags => "R|c|K",
1813 op_flags => "R|c|K",
1820 op_flags => "R|c|K",
1827 op_flags => "R|c|K",
1834 op_flags => "R|c|K",
1841 op_flags => "R|c|K",
1844 emit => '. fldll2t',
1848 op_flags => "R|c|K",
1855 # Note that it is NEVER allowed to do CSE on these nodes
1856 # Moreover, note the virtual register requierements!
1861 cmp_attr => "return 1;",
1862 emit => '. fxch %X0',
1868 cmp_attr => "return 1;",
1869 emit => '. fld %X0',
1874 reg_req => { in => [ "vfp"], out => [ "vfp" ] },
1875 cmp_attr => "return 1;",
1876 emit => '. fld %X0',
1882 cmp_attr => "return 1;",
1883 emit => '. fstp %X0',
1889 op_flags => "L|X|Y",
1894 op_flags => "L|X|Y",
1899 op_flags => "L|X|Y",
1904 op_flags => "L|X|Y",
1909 op_flags => "L|X|Y",
1914 op_flags => "L|X|Y",
1919 # -------------------------------------------------------------------------------- #
1920 # ____ ____ _____ _ _ #
1921 # / ___/ ___|| ____| __ _____ ___| |_ ___ _ __ _ __ ___ __| | ___ ___ #
1922 # \___ \___ \| _| \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __| #
1923 # ___) |__) | |___ \ V / __/ (__| || (_) | | | | | | (_) | (_| | __/\__ \ #
1924 # |____/____/|_____| \_/ \___|\___|\__\___/|_| |_| |_|\___/ \__,_|\___||___/ #
1926 # -------------------------------------------------------------------------------- #
1929 # Spilling and reloading of SSE registers, hardcoded, not generated #
1933 state => "exc_pinned",
1934 reg_req => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1935 emit => '. movdqu %D0, %AM',
1936 outs => [ "res", "M" ],
1942 state => "exc_pinned",
1943 reg_req => { in => [ "gp", "gp", "xmm", "none" ] },
1944 emit => '. movdqu %binop',
1951 # Include the generated SIMD node specification written by the SIMD optimization
1952 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
1953 unless ($return = do $my_script_name) {
1954 warn "couldn't parse $my_script_name: $@" if $@;
1955 warn "couldn't do $my_script_name: $!" unless defined $return;
1956 warn "couldn't run $my_script_name" unless $return;