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