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