527c46c76c446758bad1dfd2e4baac4860712596
[libfirm] / ir / be / ia32 / ia32_spec.pl
1 # Creation: 2005/10/19
2 # $Id$
3 # This is the specification for the ia32 assembler Firm-operations
4
5 use File::Basename;
6
7 $new_emit_syntax = 1;
8 my $myname = $0;
9
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
11 $arch = "ia32";
12
13 # The node description is done as a perl hash initializer with the
14 # following structure:
15 #
16 # %nodes = (
17 #
18 # <op-name> => {
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",
23 #   args      => [
24 #                    { type => "type 1", name => "name 1" },
25 #                    { type => "type 2", name => "name 2" },
26 #                    ...
27 #                  ],
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)"
36 # },
37 #
38 # ... # (all nodes you need to describe)
39 #
40 # ); # close the %nodes initializer
41
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
44 #   N   irop_flag_none
45 #   L   irop_flag_labeled
46 #   C   irop_flag_commutative
47 #   X   irop_flag_cfopcode
48 #   I   irop_flag_ip_cfopcode
49 #   F   irop_flag_fragile
50 #   Y   irop_flag_forking
51 #   H   irop_flag_highlevel
52 #   c   irop_flag_constlike
53 #   K   irop_flag_keep
54 #
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
57 #   R   rematerializeable
58 #   N   not spillable
59 #   I   ignore for register allocation
60 #   S   modifies stack pointer
61 #
62 # state: state of the operation, OPTIONAL (default is "floats")
63 #
64 # arity: arity of the operation, MUST NOT BE OMITTED
65 #
66 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
67 #        are always the first 3 arguments and are always autmatically
68 #        created)
69 #        If this key is missing the following arguments will be created:
70 #        for i = 1 .. arity: ir_node *op_i
71 #        ir_mode *mode
72 #
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" ]
79 #
80 # comment: OPTIONAL comment for the node constructor
81 #
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
86 #
87 #      This key is OPTIONAL. If omitted, the following constructor will
88 #      be created:
89 #      if (!op_<arch>_<op-name>) assert(0);
90 #      for i = 1 to arity
91 #         set in[i] = op_i
92 #      done
93 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
94 #      return res
95 #
96 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
97 #
98 # latency: the latency of the operation, default is 1
99 #
100
101 # register types:
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
110 %reg_classes = (
111         gp => [
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" }
123         ],
124         xmm => [
125                 { name => "xmm0", type => 1 },
126                 { name => "xmm1", type => 1 },
127                 { name => "xmm2", type => 1 },
128                 { name => "xmm3", type => 1 },
129                 { name => "xmm4", type => 1 },
130                 { name => "xmm5", type => 1 },
131                 { name => "xmm6", type => 1 },
132                 { name => "xmm7", type => 1 },
133                 { name => "xmm_NOREG", type => 4 | 16 },     # we need a dummy register for NoReg nodes
134                 { name => "xmm_UKNWN", type => 4 | 8 | 16},  # we need a dummy register for Unknown nodes
135                 { mode => "mode_E" }
136         ],
137         vfp => [
138                 { name => "vf0", type => 1 | 16 },
139                 { name => "vf1", type => 1 | 16 },
140                 { name => "vf2", type => 1 | 16 },
141                 { name => "vf3", type => 1 | 16 },
142                 { name => "vf4", type => 1 | 16 },
143                 { name => "vf5", type => 1 | 16 },
144                 { name => "vf6", type => 1 | 16 },
145                 { name => "vf7", type => 1 | 16 },
146                 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
147                 { name => "vfp_UKNWN", type => 4 | 8 | 16 },  # we need a dummy register for Unknown nodes
148                 { mode => "mode_E" }
149         ],
150         st => [
151                 { name => "st0", realname => "st",    type => 4 },
152                 { name => "st1", realname => "st(1)", type => 4 },
153                 { name => "st2", realname => "st(2)", type => 4 },
154                 { name => "st3", realname => "st(3)", type => 4 },
155                 { name => "st4", realname => "st(4)", type => 4 },
156                 { name => "st5", realname => "st(5)", type => 4 },
157                 { name => "st6", realname => "st(6)", type => 4 },
158                 { name => "st7", realname => "st(7)", type => 4 },
159                 { mode => "mode_E" }
160         ],
161         fp_cw => [      # the floating point control word
162                 { name => "fpcw", type => 4 | 32},
163                 { mode => "mode_fpcw" }
164         ],
165         flags => [
166                 { name => "eflags", type => 4 },
167                 { mode => "mode_Iu" }
168         ],
169         fp_sw => [
170                 { name => "fpsw", type => 4 },
171                 { mode => "mode_Hu" }
172         ],
173 ); # %reg_classes
174
175 %flags = (
176         CF  => { reg => "eflags", bit => 0 },
177         PF  => { reg => "eflags", bit => 2 },
178         AF  => { reg => "eflags", bit => 4 },
179         ZF  => { reg => "eflags", bit => 6 },
180         SF  => { reg => "eflags", bit => 7 },
181         TF  => { reg => "eflags", bit => 8 },
182         IF  => { reg => "eflags", bit => 9 },
183         DF  => { reg => "eflags", bit => 10 },
184         OF  => { reg => "eflags", bit => 11 },
185         IOPL0 => { reg => "eflags", bit => 12 },
186         IOPL1 => { reg => "eflags", bit => 13 },
187         NT  => { reg => "eflags", bit => 14 },
188         RF  => { reg => "eflags", bit => 16 },
189         VM  => { reg => "eflags", bit => 17 },
190         AC  => { reg => "eflags", bit => 18 },
191         VIF => { reg => "eflags", bit => 19 },
192         VIP => { reg => "eflags", bit => 20 },
193         ID  => { reg => "eflags", bit => 21 },
194
195         FP_IE => { reg => "fpsw", bit => 0 },
196         FP_DE => { reg => "fpsw", bit => 1 },
197         FP_ZE => { reg => "fpsw", bit => 2 },
198         FP_OE => { reg => "fpsw", bit => 3 },
199         FP_UE => { reg => "fpsw", bit => 4 },
200         FP_PE => { reg => "fpsw", bit => 5 },
201         FP_SF => { reg => "fpsw", bit => 6 },
202         FP_ES => { reg => "fpsw", bit => 7 },
203         FP_C0 => { reg => "fpsw", bit => 8 },
204         FP_C1 => { reg => "fpsw", bit => 9 },
205         FP_C2 => { reg => "fpsw", bit => 10 },
206         FP_TOP0 => { reg => "fpsw", bit => 11 },
207         FP_TOP1 => { reg => "fpsw", bit => 12 },
208         FP_TOP2 => { reg => "fpsw", bit => 13 },
209         FP_C3 => { reg => "fpsw", bit => 14 },
210         FP_B  => { reg => "fpsw", bit => 15 },
211
212         FP_IM => { reg => "fpcw", bit => 0 },
213         FP_DM => { reg => "fpcw", bit => 1 },
214         FP_ZM => { reg => "fpcw", bit => 2 },
215         FP_OM => { reg => "fpcw", bit => 3 },
216         FP_UM => { reg => "fpcw", bit => 4 },
217         FP_PM => { reg => "fpcw", bit => 5 },
218         FP_PC0 => { reg => "fpcw", bit => 8 },
219         FP_PC1 => { reg => "fpcw", bit => 9 },
220         FP_RC0 => { reg => "fpcw", bit => 10 },
221         FP_RC1 => { reg => "fpcw", bit => 11 },
222         FP_X  => { reg => "fpcw", bit => 12 }
223 ); # %flags
224
225 %cpu = (
226         GP     => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
227         SSE    => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
228         VFP    => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
229         BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
230 ); # %cpu
231
232 %vliw = (
233         bundle_size       => 1,
234         bundels_per_cycle => 1
235 ); # vliw
236
237 %emit_templates = (
238         S0 => "${arch}_emit_source_register(env, node, 0);",
239         S1 => "${arch}_emit_source_register(env, node, 1);",
240         S2 => "${arch}_emit_source_register(env, node, 2);",
241         S3 => "${arch}_emit_source_register(env, node, 3);",
242         S4 => "${arch}_emit_source_register(env, node, 4);",
243         S5 => "${arch}_emit_source_register(env, node, 5);",
244         D0 => "${arch}_emit_dest_register(env, node, 0);",
245         D1 => "${arch}_emit_dest_register(env, node, 1);",
246         D2 => "${arch}_emit_dest_register(env, node, 2);",
247         D3 => "${arch}_emit_dest_register(env, node, 3);",
248         D4 => "${arch}_emit_dest_register(env, node, 4);",
249         D5 => "${arch}_emit_dest_register(env, node, 5);",
250         X0 => "${arch}_emit_x87_name(env, node, 0);",
251         X1 => "${arch}_emit_x87_name(env, node, 1);",
252         X2 => "${arch}_emit_x87_name(env, node, 2);",
253         C  => "${arch}_emit_immediate(env, node);",
254         SE => "${arch}_emit_extend_suffix(env, get_ia32_ls_mode(node));",
255         ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
256                    ia32_emit_mode_suffix(env, node);",
257         M  => "${arch}_emit_mode_suffix(env, node);",
258         XXM => "${arch}_emit_xmm_mode_suffix(env, node);",
259         XSD => "${arch}_emit_xmm_mode_suffix_s(env, node);",
260         AM => "${arch}_emit_am(env, node);",
261         unop => "${arch}_emit_unop(env, node);",
262         binop => "${arch}_emit_binop(env, node);",
263         x87_binop => "${arch}_emit_x87_binop(env, node);",
264 );
265
266 #--------------------------------------------------#
267 #                        _                         #
268 #                       (_)                        #
269 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
270 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
271 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
272 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
273 #                                      | |         #
274 #                                      |_|         #
275 #--------------------------------------------------#
276
277 $default_cmp_attr = "return ia32_compare_attr(attr_a, attr_b);";
278
279 %operands = (
280 );
281
282 $mode_xmm     = "mode_E";
283 $mode_gp      = "mode_Iu";
284 $mode_fpcw    = "mode_fpcw";
285 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
286 $fpcw_flags   = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
287                   "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
288
289 %nodes = (
290
291 #-----------------------------------------------------------------#
292 #  _       _                                         _            #
293 # (_)     | |                                       | |           #
294 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
295 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
296 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
297 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
298 #                   __/ |                                         #
299 #                  |___/                                          #
300 #-----------------------------------------------------------------#
301
302 # commutative operations
303
304 # NOTE:
305 # All nodes supporting Addressmode have 5 INs:
306 # 1 - base    r1 == NoReg in case of no AM or no base
307 # 2 - index   r2 == NoReg in case of no AM or no index
308 # 3 - op1     r3 == always present
309 # 4 - op2     r4 == NoReg in case of immediate operation
310 # 5 - mem     NoMem in case of no AM otherwise it takes the mem from the Load
311
312 Add => {
313         irn_flags => "R",
314         comment   => "construct Add: Add(a, b) = Add(b, a) = a + b",
315         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
316         emit      => '. addl %binop',
317         units     => [ "GP" ],
318         mode      => $mode_gp,
319         modified_flags => $status_flags
320 },
321
322 Adc => {
323         comment   => "construct Add with Carry: Adc(a, b) = Add(b, a) = a + b + carry",
324         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
325         emit      => '. adcl %binop',
326         units     => [ "GP" ],
327         mode      => $mode_gp,
328         modified_flags => $status_flags
329 },
330
331 Add64Bit => {
332         irn_flags => "R",
333         comment   => "construct 64Bit Add: Add(a_l, a_h, b_l, b_h) = a_l + b_l; a_h + b_h + carry",
334         arity     => 4,
335         reg_req   => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
336         emit      => '
337 . movl %S0, %D0
338 . movl %S1, %D1
339 . addl %S2, %D0
340 . adcl %S3, %D1
341 ',
342         outs      => [ "low_res", "high_res" ],
343         units     => [ "GP" ],
344         modified_flags => $status_flags
345 },
346
347 l_Add => {
348         op_flags  => "C",
349         irn_flags => "R",
350         cmp_attr  => "return 1;",
351         comment   => "construct lowered Add: Add(a, b) = Add(b, a) = a + b",
352         arity     => 2,
353 },
354
355 l_Adc => {
356         op_flags  => "C",
357         cmp_attr  => "return 1;",
358         comment   => "construct lowered Add with Carry: Adc(a, b) = Adc(b, a) = a + b + carry",
359         arity     => 2,
360 },
361
362 Mul => {
363         # we should not rematrialize this node. It produces 2 results and has
364         # very strict constrains
365         comment   => "construct MulS: MulS(a, b) = MulS(b, a) = a * b",
366         reg_req   => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
367         emit      => '. mull %unop',
368         outs      => [ "EAX", "EDX", "M" ],
369         latency   => 10,
370         units     => [ "GP" ],
371         modified_flags => $status_flags
372 },
373
374 l_Mul => {
375         # we should not rematrialize this node. It produces 2 results and has
376         # very strict constrains
377         op_flags  => "C",
378         cmp_attr  => "return 1;",
379         comment   => "construct lowered MulS: Mul(a, b) = Mul(b, a) = a * b",
380         outs      => [ "EAX", "EDX", "M" ],
381         arity     => 2
382 },
383
384 IMul => {
385         irn_flags => "R",
386         comment   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
387         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
388         emit      => '. imull %binop',
389         latency   => 5,
390         units     => [ "GP" ],
391         mode      => $mode_gp,
392         modified_flags => $status_flags
393 },
394
395 IMul1OP => {
396         irn_flags => "R",
397         comment   => "construct Mul (1 operand format): Mul(a, b) = Mul(b, a) = a * b",
398         reg_req   => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
399         emit      => '. imull %unop',
400         outs      => [ "EAX", "EDX", "M" ],
401         latency   => 5,
402         units     => [ "GP" ],
403         modified_flags => $status_flags
404 },
405
406 l_IMul => {
407         op_flags  => "C",
408         cmp_attr  => "return 1;",
409         comment   => "construct lowered IMul: IMul(a, b) = IMul(b, a) = a * b",
410         arity     => 2
411 },
412
413 And => {
414         irn_flags => "R",
415         comment   => "construct And: And(a, b) = And(b, a) = a AND b",
416         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
417         emit      => '. andl %binop',
418         units     => [ "GP" ],
419         mode      => $mode_gp,
420         modified_flags => $status_flags
421 },
422
423 Or => {
424         irn_flags => "R",
425         comment   => "construct Or: Or(a, b) = Or(b, a) = a OR b",
426         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
427         emit      => '. or%M %binop',
428         units     => [ "GP" ],
429         mode      => $mode_gp,
430         modified_flags => $status_flags
431 },
432
433 Xor => {
434         irn_flags => "R",
435         comment   => "construct Xor: Xor(a, b) = Xor(b, a) = a EOR b",
436         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
437         emit      => '. xorl %binop',
438         units     => [ "GP" ],
439         mode      => $mode_gp,
440         modified_flags => $status_flags
441 },
442
443 l_Xor => {
444         op_flags  => "C",
445         cmp_attr  => "return 1;",
446         comment   => "construct lowered Xor: Xor(a, b) = Xor(b, a) = a XOR b",
447         arity     => 2,
448         modified_flags => $status_flags
449 },
450
451 # not commutative operations
452
453 Sub => {
454         irn_flags => "R",
455         comment   => "construct Sub: Sub(a, b) = a - b",
456         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
457         emit      => '. subl %binop',
458         units     => [ "GP" ],
459         mode      => $mode_gp,
460         modified_flags => $status_flags
461 },
462
463 Sbb => {
464         comment   => "construct Sub with Carry: SubC(a, b) = a - b - carry",
465         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3 !in_r4" ] },
466         emit      => '. sbbl %binop',
467         units     => [ "GP" ],
468         mode      => $mode_gp,
469         modified_flags => $status_flags
470 },
471
472 Sub64Bit => {
473         irn_flags => "R",
474         comment   => "construct 64Bit Sub: Sub(a_l, a_h, b_l, b_h) = a_l - b_l; a_h - b_h - borrow",
475         arity     => 4,
476         reg_req   => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
477         emit      => '
478 . movl %S0, %D0
479 . movl %S1, %D1
480 . subl %S2, %D0
481 . sbbl %S3, %D1
482 ',
483         outs      => [ "low_res", "high_res" ],
484         units     => [ "GP" ],
485         modified_flags => $status_flags
486 },
487
488 l_Sub => {
489         irn_flags => "R",
490         cmp_attr  => "return 1;",
491         comment   => "construct lowered Sub: Sub(a, b) = a - b",
492         arity     => 2,
493 },
494
495 l_Sbb => {
496         cmp_attr  => "return 1;",
497         comment   => "construct lowered Sub with Carry: SubC(a, b) = a - b - carry",
498         arity     => 2,
499 },
500
501 IDiv => {
502         op_flags  => "F|L",
503         state     => "exc_pinned",
504         reg_req   => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ], out => [ "eax", "edx", "none" ] },
505         attr      => "ia32_op_flavour_t dm_flav",
506         init_attr => "attr->data.op_flav = dm_flav;",
507         emit      => ". idivl %unop",
508         outs      => [ "div_res", "mod_res", "M" ],
509         latency   => 25,
510         units     => [ "GP" ],
511         modified_flags => $status_flags
512 },
513
514 Div => {
515         op_flags  => "F|L",
516         state     => "exc_pinned",
517         reg_req   => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ], out => [ "eax", "edx", "none" ] },
518         attr      => "ia32_op_flavour_t dm_flav",
519         init_attr => "attr->data.op_flav = dm_flav;",
520         emit      => ". divl %unop",
521         outs      => [ "div_res", "mod_res", "M" ],
522         latency   => 25,
523         units     => [ "GP" ],
524         modified_flags => $status_flags
525 },
526
527 Shl => {
528         irn_flags => "R",
529         comment   => "construct Shl: Shl(a, b) = a << b",
530         reg_req   => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
531         emit      => '. shll %binop',
532         units     => [ "GP" ],
533         mode      => $mode_gp,
534         modified_flags => $status_flags
535 },
536
537 l_Shl => {
538         cmp_attr  => "return 1;",
539         comment   => "construct lowered Shl: Shl(a, b) = a << b",
540         arity     => 2
541 },
542
543 ShlD => {
544         irn_flags => "R",
545         comment   => "construct ShlD: ShlD(a, b, c) = a, b << count (shift left count bits from b into a)",
546         # Out requirements is: different from all in
547         # This is because, out must be different from LowPart and ShiftCount.
548         # We could say "!ecx !in_r4" but it can occur, that all values live through
549         # this Shift and the only value dying is the ShiftCount. Then there would be a
550         # register missing, as result must not be ecx and all other registers are
551         # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
552         # (and probably never will). So we create artificial interferences of the result
553         # with all inputs, so the spiller can always assure a free register.
554         reg_req   => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
555         emit      =>
556 '
557 if (get_ia32_immop_type(node) == ia32_ImmNone) {
558         if (get_ia32_op_type(node) == ia32_AddrModeD) {
559                 . shldl %%cl, %S3, %AM
560         } else {
561                 . shldl %%cl, %S3, %S2
562         }
563 } else {
564         if (get_ia32_op_type(node) == ia32_AddrModeD) {
565                 . shldl %C, %S3, %AM
566         } else {
567                 . shldl %C, %S3, %S2
568         }
569 }
570 ',
571         latency   => 6,
572         units     => [ "GP" ],
573         mode      => $mode_gp,
574         modified_flags => $status_flags
575 },
576
577 l_ShlD => {
578         cmp_attr  => "return 1;",
579         comment   => "construct lowered ShlD: ShlD(a, b, c) = a, b << count (shift left count bits from b into a)",
580         arity     => 3,
581 },
582
583 Shr => {
584         irn_flags => "R",
585         comment   => "construct Shr: Shr(a, b) = a >> b",
586         reg_req   => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
587         emit      => '. shrl %binop',
588         units     => [ "GP" ],
589         mode      => $mode_gp,
590         modified_flags => $status_flags
591 },
592
593 l_Shr => {
594         cmp_attr  => "return 1;",
595         comment   => "construct lowered Shr: Shr(a, b) = a << b",
596         arity     => 2
597 },
598
599 ShrD => {
600         irn_flags => "R",
601         comment   => "construct ShrD: ShrD(a, b, c) = a, b >> count (shift rigth count bits from a into b)",
602         # Out requirements is: different from all in
603         # This is because, out must be different from LowPart and ShiftCount.
604         # We could say "!ecx !in_r4" but it can occur, that all values live through
605         # this Shift and the only value dying is the ShiftCount. Then there would be a
606         # register missing, as result must not be ecx and all other registers are
607         # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
608         # (and probably never will). So we create artificial interferences of the result
609         # with all inputs, so the spiller can always assure a free register.
610         reg_req   => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
611         emit      => '
612 if (get_ia32_immop_type(node) == ia32_ImmNone) {
613         if (get_ia32_op_type(node) == ia32_AddrModeD) {
614                 . shrdl %%cl, %S3, %AM
615         } else {
616                 . shrdl %%cl, %S3, %S2
617         }
618 } else {
619         if (get_ia32_op_type(node) == ia32_AddrModeD) {
620                 . shrdl %C, %S3, %AM
621         } else {
622                 . shrdl %C, %S3, %S2
623         }
624 }
625 ',
626         latency   => 6,
627         units     => [ "GP" ],
628         mode      => $mode_gp,
629         modified_flags => $status_flags
630 },
631
632 l_ShrD => {
633         cmp_attr  => "return 1;",
634         comment   => "construct lowered ShrD: ShrD(a, b, c) = a, b >> count (shift rigth count bits from a into b)",
635         arity     => 3
636 },
637
638 Sar => {
639         irn_flags => "R",
640         comment   => "construct Shrs: Shrs(a, b) = a >> b",
641         reg_req   => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
642         emit      => '. sarl %binop',
643         units     => [ "GP" ],
644         mode      => $mode_gp,
645         modified_flags => $status_flags
646 },
647
648 l_Sar => {
649         cmp_attr  => "return 1;",
650         comment   => "construct lowered Sar: Sar(a, b) = a << b",
651         arity     => 2
652 },
653
654 Ror => {
655         irn_flags => "R",
656         comment   => "construct Ror: Ror(a, b) = a ROR b",
657         reg_req   => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
658         emit      => '. rorl %binop',
659         units     => [ "GP" ],
660         mode      => $mode_gp,
661         modified_flags => $status_flags
662 },
663
664 Rol => {
665         irn_flags => "R",
666         comment   => "construct Rol: Rol(a, b) = a ROL b",
667         reg_req   => { in => [ "gp", "gp", "gp", "ecx", "none" ], out => [ "in_r3 !in_r4" ] },
668         emit      => '. roll %binop',
669         units     => [ "GP" ],
670         mode      => $mode_gp,
671         modified_flags => $status_flags
672 },
673
674 # unary operations
675
676 Neg => {
677         irn_flags => "R",
678         comment   => "construct Minus: Minus(a) = -a",
679         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
680         emit      => '. negl %unop',
681         units     => [ "GP" ],
682         mode      => $mode_gp,
683         modified_flags => $status_flags
684 },
685
686 Minus64Bit => {
687         irn_flags => "R",
688         comment   => "construct 64Bit Minus: Minus(a_l, a_h, 0) = 0 - a_l; 0 - a_h - borrow",
689         arity     => 4,
690         reg_req   => { in => [ "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
691         emit      => '
692 . movl %S0, %D0
693 . movl %S0, %D1
694 . subl %S1, %D0
695 . sbbl %S2, %D1
696 ',
697         outs      => [ "low_res", "high_res" ],
698         units     => [ "GP" ],
699         modified_flags => $status_flags
700 },
701
702
703 l_Neg => {
704         cmp_attr  => "return 1;",
705         comment   => "construct lowered Minus: Minus(a) = -a",
706         arity     => 1,
707 },
708
709 Inc => {
710         irn_flags => "R",
711         comment   => "construct Increment: Inc(a) = a++",
712         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
713         emit      => '. incl %unop',
714         units     => [ "GP" ],
715         mode      => $mode_gp,
716         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
717 },
718
719 Dec => {
720         irn_flags => "R",
721         comment   => "construct Decrement: Dec(a) = a--",
722         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
723         emit      => '. decl %unop',
724         units     => [ "GP" ],
725         mode      => $mode_gp,
726         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
727 },
728
729 Not => {
730         irn_flags => "R",
731         comment   => "construct Not: Not(a) = !a",
732         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
733         emit      => '. notl %unop',
734         units     => [ "GP" ],
735         mode      => $mode_gp,
736         modified_flags => []
737 },
738
739 # other operations
740
741 CondJmp => {
742         state     => "pinned",
743         op_flags  => "L|X|Y",
744         comment   => "construct conditional jump: CMP A, B && JMPxx LABEL",
745         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ] },
746         outs      => [ "false", "true" ],
747         latency   => 3,
748         units     => [ "BRANCH" ],
749 },
750
751 TestJmp => {
752         state     => "pinned",
753         op_flags  => "L|X|Y",
754         comment   => "construct conditional jump: TEST A, B && JMPxx LABEL",
755         reg_req  => { in => [ "gp", "gp" ] },
756         outs      => [ "false", "true" ],
757         latency   => 3,
758         units     => [ "BRANCH" ],
759 },
760
761 CJmpAM => {
762         state     => "pinned",
763         op_flags  => "L|X|Y",
764         comment   => "construct conditional jump without CMP (replaces CondJmp): JMPxx LABEL",
765         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "none", "none" ] },
766         outs      => [ "false", "true" ],
767         units     => [ "BRANCH" ],
768 },
769
770 CJmp => {
771         state     => "pinned",
772         op_flags  => "L|X|Y",
773         comment   => "construct conditional jump without CMP (replaces TestJmp): JMPxx LABEL",
774         reg_req   => { in => [ "gp", "gp" ] },
775         units     => [ "BRANCH" ],
776 },
777
778 SwitchJmp => {
779         state     => "pinned",
780         op_flags  => "L|X|Y",
781         comment   => "construct switch",
782         reg_req   => { in => [ "gp" ], out => [ "none" ] },
783         latency   => 3,
784         units     => [ "BRANCH" ],
785 },
786
787 Const => {
788         op_flags  => "c",
789         irn_flags => "R",
790         comment   => "represents an integer constant",
791         reg_req   => { out => [ "gp" ] },
792         units     => [ "GP" ],
793         mode      => $mode_gp,
794 },
795
796 Unknown_GP => {
797         state     => "pinned",
798         op_flags  => "c",
799         irn_flags => "I",
800         comment   => "unknown value",
801         reg_req   => { out => [ "gp_UKNWN" ] },
802         units     => [],
803         emit      => "",
804         mode      => $mode_gp
805 },
806
807 Unknown_VFP => {
808         state     => "pinned",
809         op_flags  => "c",
810         irn_flags => "I",
811         comment   => "unknown value",
812         reg_req   => { out => [ "vfp_UKNWN" ] },
813         units     => [],
814         emit      => "",
815         mode      => "mode_E"
816 },
817
818 Unknown_XMM => {
819         state     => "pinned",
820         op_flags  => "c",
821         irn_flags => "I",
822         comment   => "unknown value",
823         reg_req   => { out => [ "xmm_UKNWN" ] },
824         units     => [],
825         emit      => "",
826         mode      => "mode_E"
827 },
828
829 NoReg_GP => {
830         state     => "pinned",
831         op_flags  => "c",
832         irn_flags => "I",
833         comment   => "noreg GP value",
834         reg_req   => { out => [ "gp_NOREG" ] },
835         units     => [],
836         emit      => "",
837         mode      => $mode_gp
838 },
839
840 NoReg_VFP => {
841         state     => "pinned",
842         op_flags  => "c",
843         irn_flags => "I",
844         comment   => "noreg VFP value",
845         reg_req   => { out => [ "vfp_NOREG" ] },
846         units     => [],
847         emit      => "",
848         mode      => "mode_E"
849 },
850
851 NoReg_XMM => {
852         state     => "pinned",
853         op_flags  => "c",
854         irn_flags => "I",
855         comment   => "noreg XMM value",
856         reg_req   => { out => [ "xmm_NOREG" ] },
857         units     => [],
858         emit      => "",
859         mode      => "mode_E"
860 },
861
862 ChangeCW => {
863         state     => "pinned",
864         op_flags  => "c",
865         irn_flags => "I",
866         comment   => "change floating point control word",
867         reg_req   => { out => [ "fp_cw" ] },
868         mode      => $mode_fpcw,
869         latency   => 3,
870         units     => [ "GP" ],
871         modified_flags => $fpcw_flags
872 },
873
874 FldCW => {
875         op_flags  => "L|F",
876         state     => "exc_pinned",
877         comment   => "load floating point control word FldCW(ptr, mem) = LD ptr -> reg",
878         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
879         latency   => 5,
880         emit      => ". fldcw %AM",
881         mode      => $mode_fpcw,
882         units     => [ "GP" ],
883         modified_flags => $fpcw_flags
884 },
885
886 FnstCW => {
887         op_flags  => "L|F",
888         state     => "exc_pinned",
889         comment   => "store floating point control word: FstCW(ptr, mem) = ST ptr -> reg",
890         reg_req   => { in => [ "gp", "gp", "fp_cw", "none" ], out => [ "none" ] },
891         latency   => 5,
892         emit      => ". fnstcw %AM",
893         mode      => "mode_M",
894         units     => [ "GP" ],
895 },
896
897 Cltd => {
898         # we should not rematrialize this node. It produces 2 results and has
899         # very strict constrains
900         comment   => "construct CDQ: sign extend EAX -> EDX:EAX",
901         reg_req   => { in => [ "gp" ], out => [ "eax in_r1", "edx" ] },
902         emit      => '. cltd',
903         outs      => [ "EAX", "EDX" ],
904         units     => [ "GP" ],
905 },
906
907 # Load / Store
908
909 Load => {
910         op_flags  => "L|F",
911         state     => "exc_pinned",
912         comment   => "construct Load: Load(ptr, mem) = LD ptr -> reg",
913         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
914         latency   => 3,
915         emit      => ". mov%SE%ME%.l %AM, %D0",
916         outs      => [ "res", "M" ],
917         units     => [ "GP" ],
918 },
919
920 l_Load => {
921         op_flags  => "L|F",
922         cmp_attr  => "return 1;",
923         comment   => "construct lowered Load: Load(ptr, mem) = LD ptr -> reg",
924         outs      => [ "res", "M" ],
925         arity     => 2,
926 },
927
928 l_Store => {
929         op_flags  => "L|F",
930         cmp_attr  => "return 1;",
931         state     => "exc_pinned",
932         comment   => "construct lowered Store: Store(ptr, val, mem) = ST ptr,val",
933         arity     => 3,
934         mode      => "mode_M",
935 },
936
937 Store => {
938         op_flags  => "L|F",
939         state     => "exc_pinned",
940         comment   => "construct Store: Store(ptr, val, mem) = ST ptr,val",
941         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
942         emit      => '. mov%M %binop',
943         latency   => 3,
944         units     => [ "GP" ],
945         mode      => "mode_M",
946 },
947
948 Store8Bit => {
949         op_flags  => "L|F",
950         state     => "exc_pinned",
951         comment   => "construct 8Bit Store: Store(ptr, val, mem) = ST ptr,val",
952         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => ["none" ] },
953         emit      => '. mov%M %binop',
954         latency   => 3,
955         units     => [ "GP" ],
956         mode      => "mode_M",
957 },
958
959 Lea => {
960         irn_flags => "R",
961         comment   => "construct Lea: Lea(a,b) = lea [a+b*const+offs] | res = a + b * const + offs with const = 0,1,2,4,8",
962         reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
963         emit      => '. leal %AM, %D0',
964         latency   => 2,
965         units     => [ "GP" ],
966         mode      => $mode_gp,
967         modified_flags => [],
968 },
969
970 Push => {
971         comment   => "push on the stack",
972         reg_req   => { in => [ "gp", "gp", "gp", "esp", "none" ], out => [ "esp", "none" ] },
973         emit      => '. pushl %unop',
974         outs      => [ "stack:I|S", "M" ],
975         latency   => 3,
976         units     => [ "GP" ],
977         modified_flags => [],
978 },
979
980 Pop => {
981         comment   => "pop a gp register from the stack",
982         reg_req   => { in => [ "gp", "gp", "esp", "none" ], out => [ "esp", "gp", "none" ] },
983         emit      => '. popl %unop',
984         outs      => [ "stack:I|S", "res", "M" ],
985         latency   => 4,
986         units     => [ "GP" ],
987         modified_flags => [],
988 },
989
990 Enter => {
991         comment   => "create stack frame",
992         reg_req   => { in => [ "esp" ], out => [ "ebp", "esp" ] },
993         emit      => '. enter',
994         outs      => [ "frame:I", "stack:I|S", "M" ],
995         latency   => 15,
996         units     => [ "GP" ],
997 },
998
999 Leave => {
1000         comment   => "destroy stack frame",
1001         reg_req   => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1002         emit      => '. leave',
1003         outs      => [ "frame:I", "stack:I|S" ],
1004         latency   => 3,
1005         units     => [ "GP" ],
1006 },
1007
1008 AddSP => {
1009         irn_flags => "I",
1010         comment   => "allocate space on stack",
1011         reg_req   => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "none" ] },
1012         emit      => '. addl %binop',
1013         outs      => [ "stack:S", "M" ],
1014         units     => [ "GP" ],
1015         modified_flags => $status_flags
1016 },
1017
1018 SubSP => {
1019         irn_flags => "I",
1020         comment   => "free space on stack",
1021         reg_req   => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "none" ] },
1022         emit      => '. subl %binop',
1023         outs      => [ "stack:S", "M" ],
1024         units     => [ "GP" ],
1025         modified_flags => $status_flags
1026 },
1027
1028 LdTls => {
1029         irn_flags => "R",
1030         comment   => "get the TLS base address",
1031         reg_req   => { out => [ "gp" ] },
1032         units     => [ "GP" ],
1033 },
1034
1035
1036
1037 #-----------------------------------------------------------------------------#
1038 #   _____ _____ ______    __ _             _                     _            #
1039 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
1040 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1041 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1042 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1043 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1044 #-----------------------------------------------------------------------------#
1045
1046 # commutative operations
1047
1048 xAdd => {
1049         irn_flags => "R",
1050         comment   => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
1051         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1052         emit      => '. add%XXM %binop',
1053         latency   => 4,
1054         units     => [ "SSE" ],
1055         mode      => "mode_E",
1056 },
1057
1058 xMul => {
1059         irn_flags => "R",
1060         comment   => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
1061         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1062         emit      => '. mul%XXM %binop',
1063         latency   => 4,
1064         units     => [ "SSE" ],
1065         mode      => "mode_E",
1066 },
1067
1068 xMax => {
1069         irn_flags => "R",
1070         comment   => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
1071         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1072         emit      => '. max%XXM %binop',
1073         latency   => 2,
1074         units     => [ "SSE" ],
1075         mode      => "mode_E",
1076 },
1077
1078 xMin => {
1079         irn_flags => "R",
1080         comment   => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
1081         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1082         emit      => '. min%XXM %binop',
1083         latency   => 2,
1084         units     => [ "SSE" ],
1085         mode      => "mode_E",
1086 },
1087
1088 xAnd => {
1089         irn_flags => "R",
1090         comment   => "construct SSE And: And(a, b) = a AND b",
1091         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1092         emit      => '. andp%XSD %binop',
1093         latency   => 3,
1094         units     => [ "SSE" ],
1095         mode      => "mode_E",
1096 },
1097
1098 xOr => {
1099         irn_flags => "R",
1100         comment   => "construct SSE Or: Or(a, b) = a OR b",
1101         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1102         emit      => '. orp%XSD %binop',
1103         units     => [ "SSE" ],
1104         mode      => "mode_E",
1105 },
1106
1107 xXor => {
1108         irn_flags => "R",
1109         comment   => "construct SSE Xor: Xor(a, b) = a XOR b",
1110         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1111         emit      => '. xorp%XSD %binop',
1112         latency   => 3,
1113         units     => [ "SSE" ],
1114         mode      => "mode_E",
1115 },
1116
1117 # not commutative operations
1118
1119 xAndNot => {
1120         irn_flags => "R",
1121         comment   => "construct SSE AndNot: AndNot(a, b) = a AND NOT b",
1122         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1123         emit      => '. andnp%XSD %binop',
1124         latency   => 3,
1125         units     => [ "SSE" ],
1126         mode      => "mode_E",
1127 },
1128
1129 xSub => {
1130         irn_flags => "R",
1131         comment   => "construct SSE Sub: Sub(a, b) = a - b",
1132         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1133         emit      => '. sub%XXM %binop',
1134         latency   => 4,
1135         units     => [ "SSE" ],
1136         mode      => "mode_E",
1137 },
1138
1139 xDiv => {
1140         irn_flags => "R",
1141         comment   => "construct SSE Div: Div(a, b) = a / b",
1142         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1143         outs      => [ "res", "M" ],
1144         emit      => '. div%XXM %binop',
1145         latency   => 16,
1146         units     => [ "SSE" ],
1147 },
1148
1149 # other operations
1150
1151 xCmp => {
1152         irn_flags => "R",
1153         comment   => "construct SSE Compare: Cmp(a, b) == a = a cmp b",
1154         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1155         latency   => 3,
1156         units     => [ "SSE" ],
1157         mode      => "mode_E",
1158 },
1159
1160 xCondJmp => {
1161         state     => "pinned",
1162         op_flags  => "L|X|Y",
1163         comment   => "construct conditional jump: UCOMIS A, B && JMPxx LABEL",
1164         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "none", "none" ] },
1165         outs      => [ "false", "true" ],
1166         latency   => 5,
1167         units     => [ "SSE" ],
1168 },
1169
1170 xConst => {
1171         op_flags  => "c",
1172         irn_flags => "R",
1173         comment   => "represents a SSE constant",
1174         reg_req   => { out => [ "xmm" ] },
1175         emit      => '. mov%XXM %C, %D0',
1176         latency   => 2,
1177         units     => [ "SSE" ],
1178         mode      => "mode_E",
1179 },
1180
1181 # Load / Store
1182
1183 xLoad => {
1184         op_flags  => "L|F",
1185         state     => "exc_pinned",
1186         comment   => "construct SSE Load: Load(ptr, mem) = LD ptr",
1187         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1188         emit      => '. mov%XXM %AM, %D0',
1189         outs      => [ "res", "M" ],
1190         latency   => 2,
1191         units     => [ "SSE" ],
1192 },
1193
1194 xStore => {
1195         op_flags => "L|F",
1196         state    => "exc_pinned",
1197         comment  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
1198         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
1199         emit     => '. mov%XXM %binop',
1200         latency  => 2,
1201         units    => [ "SSE" ],
1202         mode     => "mode_M",
1203 },
1204
1205 xStoreSimple => {
1206         op_flags => "L|F",
1207         state    => "exc_pinned",
1208         comment  => "construct Store without index: Store(ptr, val, mem) = ST ptr,val",
1209         reg_req  => { in => [ "gp", "xmm", "none" ] },
1210         emit     => '. mov%XXM %S1, %AM',
1211         latency  => 2,
1212         units    => [ "SSE" ],
1213         mode     => "mode_M",
1214 },
1215
1216 CvtSI2SS => {
1217         op_flags => "L|F",
1218         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1219         emit     => '. cvtsi2ss %D0, %AM',
1220         latency  => 2,
1221         units    => [ "SSE" ],
1222         mode     => $mode_xmm
1223 },
1224
1225 CvtSI2SD => {
1226         op_flags => "L|F",
1227         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1228         emit     => '. cvtsi2sd %unop',
1229         latency  => 2,
1230         units    => [ "SSE" ],
1231         mode     => $mode_xmm
1232 },
1233
1234
1235 l_X87toSSE => {
1236         op_flags => "L|F",
1237         comment  => "construct: transfer a value from x87 FPU into a SSE register",
1238         cmp_attr => "return 1;",
1239         arity    => 3,
1240 },
1241
1242 l_SSEtoX87 => {
1243         op_flags => "L|F",
1244         comment  => "construct: transfer a value from SSE register to x87 FPU",
1245         cmp_attr => "return 1;",
1246         arity    => 3,
1247 },
1248
1249 GetST0 => {
1250         op_flags => "L|F",
1251         irn_flags => "I",
1252         state    => "exc_pinned",
1253         comment  => "store ST0 onto stack",
1254         reg_req  => { in => [ "gp", "gp", "none" ] },
1255         emit     => '. fstp%M %AM',
1256         latency  => 4,
1257         units    => [ "SSE" ],
1258         mode     => "mode_M",
1259 },
1260
1261 SetST0 => {
1262         op_flags => "L|F",
1263         irn_flags => "I",
1264         state    => "exc_pinned",
1265         comment  => "load ST0 from stack",
1266         reg_req  => { in => [ "gp", "none" ], out => [ "vf0", "none" ] },
1267         emit     => '. fld%M %AM',
1268         outs     => [ "res", "M" ],
1269         latency  => 2,
1270         units     => [ "SSE" ],
1271 },
1272
1273 # CopyB
1274
1275 CopyB => {
1276         op_flags => "F|H",
1277         state    => "pinned",
1278         comment  => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
1279         reg_req  => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1280         outs     => [ "DST", "SRC", "CNT", "M" ],
1281         units    => [ "GP" ],
1282         modified_flags => [ "DF" ]
1283 },
1284
1285 CopyB_i => {
1286         op_flags => "F|H",
1287         state    => "pinned",
1288         comment  => "implements a memcopy: CopyB(dst, src, mem) == memcpy(dst, src, attr(size))",
1289         reg_req  => { in => [ "edi", "esi", "none" ], out => [  "edi", "esi", "none" ] },
1290         outs     => [ "DST", "SRC", "M" ],
1291         units    => [ "GP" ],
1292         modified_flags => [ "DF" ]
1293 },
1294
1295 # Conversions
1296
1297 Conv_I2I => {
1298         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3", "none" ] },
1299         comment  => "construct Conv Int -> Int",
1300         units    => [ "GP" ],
1301         mode     => $mode_gp,
1302         modified_flags => $status_flags
1303 },
1304
1305 Conv_I2I8Bit => {
1306         reg_req  => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => [ "in_r3", "none" ] },
1307         comment  => "construct Conv Int -> Int",
1308         units    => [ "GP" ],
1309         mode     => $mode_gp,
1310         modified_flags => $status_flags
1311 },
1312
1313 Conv_I2FP => {
1314         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1315         comment  => "construct Conv Int -> Floating Point",
1316         latency  => 10,
1317         units    => [ "SSE" ],
1318         mode     => "mode_E",
1319 },
1320
1321 Conv_FP2I => {
1322         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "gp", "none" ] },
1323         comment  => "construct Conv Floating Point -> Int",
1324         latency  => 10,
1325         units    => [ "SSE" ],
1326         mode     => $mode_gp,
1327 },
1328
1329 Conv_FP2FP => {
1330         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "xmm", "none" ] },
1331         comment  => "construct Conv Floating Point -> Floating Point",
1332         latency  => 8,
1333         units    => [ "SSE" ],
1334         mode     => "mode_E",
1335 },
1336
1337 CmpCMov => {
1338         irn_flags => "R",
1339         comment   => "construct Conditional Move: CMov(sel, a, b) == sel ? a : b",
1340         reg_req   => { in => [ "gp", "gp", "gp", "gp" ], out => [ "in_r4" ] },
1341         latency   => 2,
1342         units     => [ "GP" ],
1343         mode      => $mode_gp,
1344 },
1345
1346 PsiCondCMov => {
1347         irn_flags => "R",
1348         comment   => "check if Psi condition tree evaluates to true and move result accordingly",
1349         reg_req   => { in => [ "gp", "gp", "gp" ], out => [ "in_r3" ] },
1350         latency   => 2,
1351         units     => [ "GP" ],
1352         mode      => $mode_gp,
1353 },
1354
1355 xCmpCMov => {
1356         irn_flags => "R",
1357         comment   => "construct Conditional Move: SSE Compare + int CMov ",
1358         reg_req   => { in => [ "xmm", "xmm", "gp", "gp" ], out => [ "in_r4" ] },
1359         latency   => 5,
1360         units     => [ "SSE" ],
1361         mode      => $mode_gp,
1362 },
1363
1364 vfCmpCMov => {
1365         irn_flags => "R",
1366         comment   => "construct Conditional Move: x87 Compare + int CMov",
1367         reg_req   => { in => [ "vfp", "vfp", "gp", "gp" ], out => [ "in_r4" ] },
1368         latency   => 10,
1369         units     => [ "VFP" ],
1370         mode      => $mode_gp,
1371 },
1372
1373 CmpSet => {
1374         irn_flags => "R",
1375         comment   => "construct Set: Set(sel) == sel ? 1 : 0",
1376         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "eax ebx ecx edx" ] },
1377         latency   => 2,
1378         units     => [ "GP" ],
1379         mode      => $mode_gp,
1380 },
1381
1382 PsiCondSet => {
1383         irn_flags => "R",
1384         comment   => "check if Psi condition tree evaluates to true and set result accordingly",
1385         reg_req   => { in => [ "gp" ], out => [ "eax ebx ecx edx" ] },
1386         latency   => 2,
1387         units     => [ "GP" ],
1388         mode      => $mode_gp,
1389 },
1390
1391 xCmpSet => {
1392         irn_flags => "R",
1393         comment   => "construct Set: SSE Compare + int Set",
1394         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "eax ebx ecx edx" ] },
1395         latency   => 5,
1396         units     => [ "SSE" ],
1397         mode      => $mode_gp,
1398 },
1399
1400 vfCmpSet => {
1401         irn_flags => "R",
1402         comment   => "construct Set: x87 Compare + int Set",
1403         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "eax ebx ecx edx" ] },
1404         latency   => 10,
1405         units     => [ "VFP" ],
1406         mode      => $mode_gp,
1407 },
1408
1409 vfCMov => {
1410         irn_flags => "R",
1411         comment   => "construct x87 Conditional Move: vfCMov(sel, a, b) = sel ? a : b",
1412         reg_req   => { in => [ "vfp", "vfp", "vfp", "vfp" ], out => [ "vfp" ] },
1413         latency   => 10,
1414         units     => [ "VFP" ],
1415         mode      => "mode_E",
1416 },
1417
1418 #----------------------------------------------------------#
1419 #        _      _               _    __ _             _    #
1420 #       (_)    | |             | |  / _| |           | |   #
1421 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1422 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1423 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1424 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1425 #                 | |                                      #
1426 #  _ __   ___   __| | ___  ___                             #
1427 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1428 # | | | | (_) | (_| |  __/\__ \                            #
1429 # |_| |_|\___/ \__,_|\___||___/                            #
1430 #----------------------------------------------------------#
1431
1432 vfadd => {
1433         irn_flags => "R",
1434         comment   => "virtual fp Add: Add(a, b) = Add(b, a) = a + b",
1435         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1436         latency   => 4,
1437         units     => [ "VFP" ],
1438         mode      => "mode_E",
1439 },
1440
1441 vfmul => {
1442         irn_flags => "R",
1443         comment   => "virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1444         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1445         latency   => 4,
1446         units     => [ "VFP" ],
1447         mode      => "mode_E",
1448 },
1449
1450 l_vfmul => {
1451         op_flags  => "C",
1452         cmp_attr  => "return 1;",
1453         comment   => "lowered virtual fp Mul: Mul(a, b) = Mul(b, a) = a * b",
1454         arity     => 2,
1455 },
1456
1457 vfsub => {
1458         irn_flags => "R",
1459         comment   => "virtual fp Sub: Sub(a, b) = a - b",
1460         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1461         latency   => 4,
1462         units     => [ "VFP" ],
1463         mode      => "mode_E",
1464 },
1465
1466 l_vfsub => {
1467         cmp_attr  => "return 1;",
1468         comment   => "lowered virtual fp Sub: Sub(a, b) = a - b",
1469         arity     => 2,
1470 },
1471
1472 vfdiv => {
1473         comment   => "virtual fp Div: Div(a, b) = a / b",
1474         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1475         outs      => [ "res", "M" ],
1476         latency   => 20,
1477         units     => [ "VFP" ],
1478 },
1479
1480 l_vfdiv => {
1481         cmp_attr  => "return 1;",
1482         comment   => "lowered virtual fp Div: Div(a, b) = a / b",
1483         outs      => [ "res", "M" ],
1484         arity     => 2,
1485 },
1486
1487 vfprem => {
1488         comment   => "virtual fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1489         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "vfp" ] },
1490         latency   => 20,
1491         units     => [ "VFP" ],
1492         mode      => "mode_E",
1493 },
1494
1495 l_vfprem => {
1496         cmp_attr  => "return 1;",
1497         comment   => "lowered virtual fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1498         arity     => 2,
1499 },
1500
1501 vfabs => {
1502         irn_flags => "R",
1503         comment   => "virtual fp Abs: Abs(a) = |a|",
1504         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1505         latency   => 2,
1506         units     => [ "VFP" ],
1507         mode      => "mode_E",
1508 },
1509
1510 vfchs => {
1511         irn_flags => "R",
1512         comment   => "virtual fp Chs: Chs(a) = -a",
1513         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1514         latency   => 2,
1515         units     => [ "VFP" ],
1516         mode      => "mode_E",
1517 },
1518
1519 vfsin => {
1520         irn_flags => "R",
1521         comment   => "virtual fp Sin: Sin(a) = sin(a)",
1522         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1523         latency   => 150,
1524         units     => [ "VFP" ],
1525         mode      => "mode_E",
1526 },
1527
1528 vfcos => {
1529         irn_flags => "R",
1530         comment   => "virtual fp Cos: Cos(a) = cos(a)",
1531         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1532         latency   => 150,
1533         units     => [ "VFP" ],
1534         mode      => "mode_E",
1535 },
1536
1537 vfsqrt => {
1538         irn_flags => "R",
1539         comment   => "virtual fp Sqrt: Sqrt(a) = a ^ 0.5",
1540         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1541         latency   => 30,
1542         units     => [ "VFP" ],
1543         mode      => "mode_E",
1544 },
1545
1546 # virtual Load and Store
1547
1548 vfld => {
1549         op_flags  => "L|F",
1550         state     => "exc_pinned",
1551         comment   => "virtual fp Load: Load(ptr, mem) = LD ptr -> reg",
1552         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1553         outs      => [ "res", "M" ],
1554         latency   => 2,
1555         units     => [ "VFP" ],
1556 },
1557
1558 vfst => {
1559         op_flags  => "L|F",
1560         state     => "exc_pinned",
1561         comment   => "virtual fp Store: Store(ptr, val, mem) = ST ptr,val",
1562         reg_req   => { in => [ "gp", "gp", "vfp", "none" ] },
1563         latency   => 2,
1564         units     => [ "VFP" ],
1565         mode      => "mode_M",
1566 },
1567
1568 # Conversions
1569
1570 vfild => {
1571         comment   => "virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1572         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1573         outs      => [ "res", "M" ],
1574         latency   => 4,
1575         units     => [ "VFP" ],
1576 },
1577
1578 l_vfild => {
1579         cmp_attr  => "return 1;",
1580         comment   => "lowered virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1581         outs      => [ "res", "M" ],
1582         arity     => 2,
1583 },
1584
1585 vfist => {
1586         comment   => "virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1587         reg_req   => { in => [ "gp", "gp", "vfp", "fpcw", "none" ] },
1588         latency   => 4,
1589         units     => [ "VFP" ],
1590         mode      => "mode_M",
1591 },
1592
1593 l_vfist => {
1594         cmp_attr  => "return 1;",
1595         comment   => "lowered virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1596         arity     => 3,
1597         mode      => "mode_M",
1598 },
1599
1600
1601 # constants
1602
1603 vfldz => {
1604         irn_flags => "R",
1605         comment   => "virtual fp Load 0.0: Ld 0.0 -> reg",
1606         reg_req   => { out => [ "vfp" ] },
1607         latency   => 4,
1608         units     => [ "VFP" ],
1609         mode      => "mode_E",
1610 },
1611
1612 vfld1 => {
1613         irn_flags => "R",
1614         comment   => "virtual fp Load 1.0: Ld 1.0 -> reg",
1615         reg_req   => { out => [ "vfp" ] },
1616         latency   => 4,
1617         units     => [ "VFP" ],
1618         mode      => "mode_E",
1619 },
1620
1621 vfldpi => {
1622         irn_flags => "R",
1623         comment   => "virtual fp Load pi: Ld pi -> reg",
1624         reg_req   => { out => [ "vfp" ] },
1625         latency   => 4,
1626         units     => [ "VFP" ],
1627         mode      => "mode_E",
1628 },
1629
1630 vfldln2 => {
1631         irn_flags => "R",
1632         comment   => "virtual fp Load ln 2: Ld ln 2 -> reg",
1633         reg_req   => { out => [ "vfp" ] },
1634         latency   => 4,
1635         units     => [ "VFP" ],
1636         mode      => "mode_E",
1637 },
1638
1639 vfldlg2 => {
1640         irn_flags => "R",
1641         comment   => "virtual fp Load lg 2: Ld lg 2 -> reg",
1642         reg_req   => { out => [ "vfp" ] },
1643         latency   => 4,
1644         units     => [ "VFP" ],
1645         mode      => "mode_E",
1646 },
1647
1648 vfldl2t => {
1649         irn_flags => "R",
1650         comment   => "virtual fp Load ld 10: Ld ld 10 -> reg",
1651         reg_req   => { out => [ "vfp" ] },
1652         latency   => 4,
1653         units     => [ "VFP" ],
1654         mode      => "mode_E",
1655 },
1656
1657 vfldl2e => {
1658         irn_flags => "R",
1659         comment   => "virtual fp Load ld e: Ld ld e -> reg",
1660         reg_req   => { out => [ "vfp" ] },
1661         latency   => 4,
1662         units     => [ "VFP" ],
1663         mode      => "mode_E",
1664 },
1665
1666 vfConst => {
1667         op_flags  => "c",
1668         irn_flags => "R",
1669 #  init_attr => "  set_ia32_ls_mode(res, mode);",
1670         comment   => "represents a virtual floating point constant",
1671         reg_req   => { out => [ "vfp" ] },
1672         latency   => 3,
1673         units     => [ "VFP" ],
1674         mode      => "mode_E",
1675 },
1676
1677 # other
1678
1679 vfCondJmp => {
1680         state     => "pinned",
1681         op_flags  => "L|X|Y",
1682         comment   => "represents a virtual floating point compare",
1683         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "none", "none", "eax" ] },
1684         outs      => [ "false", "true", "temp_reg_eax" ],
1685         latency   => 10,
1686         units     => [ "VFP" ],
1687 },
1688
1689 #------------------------------------------------------------------------#
1690 #       ___ _____    __ _             _                     _            #
1691 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1692 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1693 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1694 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1695 #------------------------------------------------------------------------#
1696
1697 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1698 #       are swapped, we work this around in the emitter...
1699
1700 fadd => {
1701         op_flags  => "R",
1702         rd_constructor => "NONE",
1703         comment   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1704         reg_req   => { },
1705         emit      => '. fadd%M %x87_binop',
1706 },
1707
1708 faddp => {
1709         op_flags  => "R",
1710         rd_constructor => "NONE",
1711         comment   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
1712         reg_req   => { },
1713         emit      => '. faddp %x87_binop',
1714 },
1715
1716 fmul => {
1717         op_flags  => "R",
1718         rd_constructor => "NONE",
1719         comment   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1720         reg_req   => { },
1721         emit      => '. fmul%M %x87_binop',
1722 },
1723
1724 fmulp => {
1725         op_flags  => "R",
1726         rd_constructor => "NONE",
1727         comment   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
1728         reg_req   => { },
1729         emit      => '. fmulp %x87_binop',,
1730 },
1731
1732 fsub => {
1733         op_flags  => "R",
1734         rd_constructor => "NONE",
1735         comment   => "x87 fp Sub: Sub(a, b) = a - b",
1736         reg_req   => { },
1737         emit      => '. fsub%M %x87_binop',
1738 },
1739
1740 fsubp => {
1741         op_flags  => "R",
1742         rd_constructor => "NONE",
1743         comment   => "x87 fp Sub: Sub(a, b) = a - b",
1744         reg_req   => { },
1745 # see note about gas bugs
1746         emit      => '. fsubrp %x87_binop',
1747 },
1748
1749 fsubr => {
1750         op_flags  => "R",
1751         rd_constructor => "NONE",
1752         irn_flags => "R",
1753         comment   => "x87 fp SubR: SubR(a, b) = b - a",
1754         reg_req   => { },
1755         emit      => '. fsubr%M %x87_binop',
1756 },
1757
1758 fsubrp => {
1759         op_flags  => "R",
1760         rd_constructor => "NONE",
1761         irn_flags => "R",
1762         comment   => "x87 fp SubR: SubR(a, b) = b - a",
1763         reg_req   => { },
1764 # see note about gas bugs
1765         emit      => '. fsubp %x87_binop',
1766 },
1767
1768 fprem => {
1769         op_flags  => "R",
1770         rd_constructor => "NONE",
1771         comment   => "x87 fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1772         reg_req   => { },
1773         emit      => '. fprem1',
1774 },
1775
1776 # this node is just here, to keep the simulator running
1777 # we can omit this when a fprem simulation function exists
1778 fpremp => {
1779         op_flags  => "R",
1780         rd_constructor => "NONE",
1781         comment   => "x87 fp Rem: Rem(a, b) = a - Q * b (Q is integer)",
1782         reg_req   => { },
1783         emit      => '. fprem1',
1784 },
1785
1786 fdiv => {
1787         op_flags  => "R",
1788         rd_constructor => "NONE",
1789         comment   => "x87 fp Div: Div(a, b) = a / b",
1790         reg_req   => { },
1791         emit      => '. fdiv%M %x87_binop',
1792 },
1793
1794 fdivp => {
1795         op_flags  => "R",
1796         rd_constructor => "NONE",
1797         comment   => "x87 fp Div: Div(a, b) = a / b",
1798         reg_req   => { },
1799 # see note about gas bugs
1800         emit      => '. fdivrp %x87_binop',
1801 },
1802
1803 fdivr => {
1804         op_flags  => "R",
1805         rd_constructor => "NONE",
1806         comment   => "x87 fp DivR: DivR(a, b) = b / a",
1807         reg_req   => { },
1808         emit      => '. fdivr%M %x87_binop',
1809 },
1810
1811 fdivrp => {
1812         op_flags  => "R",
1813         rd_constructor => "NONE",
1814         comment   => "x87 fp DivR: DivR(a, b) = b / a",
1815         reg_req   => { },
1816 # see note about gas bugs
1817         emit      => '. fdivp %x87_binop',
1818 },
1819
1820 fabs => {
1821         op_flags  => "R",
1822         rd_constructor => "NONE",
1823         comment   => "x87 fp Abs: Abs(a) = |a|",
1824         reg_req   => { },
1825         emit      => '. fabs',
1826 },
1827
1828 fchs => {
1829         op_flags  => "R",
1830         rd_constructor => "NONE",
1831         comment   => "x87 fp Chs: Chs(a) = -a",
1832         reg_req   => { },
1833         emit      => '. fchs',
1834 },
1835
1836 fsin => {
1837         op_flags  => "R",
1838         rd_constructor => "NONE",
1839         comment   => "x87 fp Sin: Sin(a) = sin(a)",
1840         reg_req   => { },
1841         emit      => '. fsin',
1842 },
1843
1844 fcos => {
1845         op_flags  => "R",
1846         rd_constructor => "NONE",
1847         comment   => "x87 fp Cos: Cos(a) = cos(a)",
1848         reg_req   => { },
1849         emit      => '. fcos',
1850 },
1851
1852 fsqrt => {
1853         op_flags  => "R",
1854         rd_constructor => "NONE",
1855         comment   => "x87 fp Sqrt: Sqrt(a) = a ^ 0.5",
1856         reg_req   => { },
1857         emit      => '. fsqrt $',
1858 },
1859
1860 # x87 Load and Store
1861
1862 fld => {
1863         rd_constructor => "NONE",
1864         op_flags  => "R|L|F",
1865         state     => "exc_pinned",
1866         comment   => "x87 fp Load: Load(ptr, mem) = LD ptr -> reg",
1867         reg_req   => { },
1868         emit      => '. fld%M %AM',
1869 },
1870
1871 fst => {
1872         rd_constructor => "NONE",
1873         op_flags  => "R|L|F",
1874         state     => "exc_pinned",
1875         comment   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1876         reg_req   => { },
1877         emit      => '. fst%M %AM',
1878         mode      => "mode_M",
1879 },
1880
1881 fstp => {
1882         rd_constructor => "NONE",
1883         op_flags  => "R|L|F",
1884         state     => "exc_pinned",
1885         comment   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1886         reg_req   => { },
1887         emit      => '. fstp%M %AM',
1888         mode      => "mode_M",
1889 },
1890
1891 # Conversions
1892
1893 fild => {
1894         op_flags  => "R",
1895         rd_constructor => "NONE",
1896         comment   => "x87 fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1897         reg_req   => { },
1898         emit      => '. fild%M %AM',
1899 },
1900
1901 fist => {
1902         op_flags  => "R",
1903         rd_constructor => "NONE",
1904         comment   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1905         reg_req   => { },
1906         emit      => '. fist%M %AM',
1907         mode      => "mode_M",
1908 },
1909
1910 fistp => {
1911         op_flags  => "R",
1912         rd_constructor => "NONE",
1913         comment   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1914         reg_req   => { },
1915         emit      => '. fistp%M %AM',
1916         mode      => "mode_M",
1917 },
1918
1919 # constants
1920
1921 fldz => {
1922         op_flags  => "R|c",
1923         irn_flags  => "R",
1924         comment   => "x87 fp Load 0.0: Ld 0.0 -> reg",
1925         reg_req   => { },
1926         emit      => '. fldz',
1927 },
1928
1929 fld1 => {
1930         op_flags  => "R|c",
1931         irn_flags  => "R",
1932         comment   => "x87 fp Load 1.0: Ld 1.0 -> reg",
1933         reg_req   => { },
1934         emit      => '. fld1',
1935 },
1936
1937 fldpi => {
1938         op_flags  => "R|c",
1939         irn_flags  => "R",
1940         comment   => "x87 fp Load pi: Ld pi -> reg",
1941         reg_req   => { },
1942         emit      => '. fldpi',
1943 },
1944
1945 fldln2 => {
1946         op_flags  => "R|c",
1947         irn_flags  => "R",
1948         comment   => "x87 fp Load ln 2: Ld ln 2 -> reg",
1949         reg_req   => { },
1950         emit      => '. fldln2',
1951 },
1952
1953 fldlg2 => {
1954         op_flags  => "R|c",
1955         irn_flags  => "R",
1956         comment   => "x87 fp Load lg 2: Ld lg 2 -> reg",
1957         reg_req   => { },
1958         emit      => '. fldlg2',
1959 },
1960
1961 fldl2t => {
1962         op_flags  => "R|c",
1963         irn_flags  => "R",
1964         comment   => "x87 fp Load ld 10: Ld ld 10 -> reg",
1965         reg_req   => { },
1966         emit      => '. fldll2t',
1967 },
1968
1969 fldl2e => {
1970         op_flags  => "R|c",
1971         irn_flags  => "R",
1972         comment   => "x87 fp Load ld e: Ld ld e -> reg",
1973         reg_req   => { },
1974         emit      => '. fldl2e',
1975 },
1976
1977 # fxch, fpush, fpop
1978 # Note that it is NEVER allowed to do CSE on these nodes
1979 # Moreover, note the virtual register requierements!
1980
1981 fxch => {
1982         op_flags  => "R|K",
1983         comment   => "x87 stack exchange",
1984         reg_req   => { },
1985         cmp_attr  => "return 1;",
1986         emit      => '. fxch %X0',
1987 },
1988
1989 fpush => {
1990         op_flags  => "R|K",
1991         comment   => "x87 stack push",
1992         reg_req   => {},
1993         cmp_attr  => "return 1;",
1994         emit      => '. fld %X0',
1995 },
1996
1997 fpushCopy => {
1998         op_flags  => "R",
1999         comment   => "x87 stack push",
2000         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2001         cmp_attr  => "return 1;",
2002         emit      => '. fld %X0',
2003 },
2004
2005 fpop => {
2006         op_flags  => "R|K",
2007         comment   => "x87 stack pop",
2008         reg_req   => { },
2009         cmp_attr  => "return 1;",
2010         emit      => '. fstp %X0',
2011 },
2012
2013 # compare
2014
2015 fcomJmp => {
2016         op_flags  => "L|X|Y",
2017         comment   => "floating point compare",
2018         reg_req   => { },
2019 },
2020
2021 fcompJmp => {
2022         op_flags  => "L|X|Y",
2023         comment   => "floating point compare and pop",
2024         reg_req   => { },
2025 },
2026
2027 fcomppJmp => {
2028         op_flags  => "L|X|Y",
2029         comment   => "floating point compare and pop twice",
2030         reg_req   => { },
2031 },
2032
2033 fcomrJmp => {
2034         op_flags  => "L|X|Y",
2035         comment   => "floating point compare reverse",
2036         reg_req   => { },
2037 },
2038
2039 fcomrpJmp => {
2040         op_flags  => "L|X|Y",
2041         comment   => "floating point compare reverse and pop",
2042         reg_req   => { },
2043 },
2044
2045 fcomrppJmp => {
2046         op_flags  => "L|X|Y",
2047         comment   => "floating point compare reverse and pop twice",
2048         reg_req   => { },
2049 },
2050
2051
2052 # -------------------------------------------------------------------------------- #
2053 #  ____ ____  _____                  _                               _             #
2054 # / ___/ ___|| ____| __   _____  ___| |_ ___  _ __   _ __   ___   __| | ___  ___   #
2055 # \___ \___ \|  _|   \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __|  #
2056 #  ___) |__) | |___   \ V /  __/ (__| || (_) | |    | | | | (_) | (_| |  __/\__ \  #
2057 # |____/____/|_____|   \_/ \___|\___|\__\___/|_|    |_| |_|\___/ \__,_|\___||___/  #
2058 #                                                                                  #
2059 # -------------------------------------------------------------------------------- #
2060
2061
2062 # Spilling and reloading of SSE registers, hardcoded, not generated #
2063
2064 xxLoad => {
2065         op_flags  => "L|F",
2066         state     => "exc_pinned",
2067         comment   => "construct SSE Load: Load(ptr, mem) = LD ptr",
2068         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2069         emit      => '. movdqu %D0, %AM',
2070         outs      => [ "res", "M" ],
2071         units     => [ "SSE" ],
2072 },
2073
2074 xxStore => {
2075         op_flags => "L|F",
2076         state    => "exc_pinned",
2077         comment  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
2078         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
2079         emit     => '. movdqu %binop',
2080         units    => [ "SSE" ],
2081         mode     => "mode_M",
2082 },
2083
2084 ); # end of %nodes
2085
2086 # Include the generated SIMD node specification written by the SIMD optimization
2087 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2088 unless ($return = do $my_script_name) {
2089         warn "couldn't parse $my_script_name: $@" if $@;
2090         warn "couldn't do $my_script_name: $!"    unless defined $return;
2091         warn "couldn't run $my_script_name"       unless $return;
2092 }