fixed/improved assembler nodes
[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 #   attr_type => "name of the attribute struct",
37 # },
38 #
39 # ... # (all nodes you need to describe)
40 #
41 # ); # close the %nodes initializer
42
43 # op_flags: flags for the operation, OPTIONAL (default is "N")
44 # the op_flags correspond to the firm irop_flags:
45 #   N   irop_flag_none
46 #   L   irop_flag_labeled
47 #   C   irop_flag_commutative
48 #   X   irop_flag_cfopcode
49 #   I   irop_flag_ip_cfopcode
50 #   F   irop_flag_fragile
51 #   Y   irop_flag_forking
52 #   H   irop_flag_highlevel
53 #   c   irop_flag_constlike
54 #   K   irop_flag_keep
55 #
56 # irn_flags: special node flags, OPTIONAL (default is 0)
57 # following irn_flags are supported:
58 #   R   rematerializeable
59 #   N   not spillable
60 #   I   ignore for register allocation
61 #   S   modifies stack pointer
62 #
63 # state: state of the operation, OPTIONAL (default is "floats")
64 #
65 # arity: arity of the operation, MUST NOT BE OMITTED
66 #
67 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
68 #        are always the first 3 arguments and are always autmatically
69 #        created)
70 #        If this key is missing the following arguments will be created:
71 #        for i = 1 .. arity: ir_node *op_i
72 #        ir_mode *mode
73 #
74 # outs:  if a node defines more than one output, the names of the projections
75 #        nodes having outs having automatically the mode mode_T
76 #        One can also annotate some flags for each out, additional to irn_flags.
77 #        They are separated from name with a colon ':', and concatenated by pipe '|'
78 #        Only I and S are available at the moment (same meaning as in irn_flags).
79 #        example: [ "frame:I", "stack:I|S", "M" ]
80 #
81 # comment: OPTIONAL comment for the node constructor
82 #
83 # rd_constructor: for every operation there will be a
84 #      new_rd_<arch>_<op-name> function with the arguments from above
85 #      which creates the ir_node corresponding to the defined operation
86 #      you can either put the complete source code of this function here
87 #
88 #      This key is OPTIONAL. If omitted, the following constructor will
89 #      be created:
90 #      if (!op_<arch>_<op-name>) assert(0);
91 #      for i = 1 to arity
92 #         set in[i] = op_i
93 #      done
94 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
95 #      return res
96 #
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
98 #
99 # latency: the latency of the operation, default is 1
100 #
101
102 # register types:
103 #   0 - no special type
104 #   1 - caller save (register must be saved by the caller of a function)
105 #   2 - callee save (register must be saved by the called function)
106 #   4 - ignore (do not assign this register)
107 #   8 - emitter can choose an arbitrary register of this class
108 #  16 - the register is a virtual one
109 #  32 - register represents a state
110 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
111 %reg_classes = (
112         gp => [
113                 { name => "edx", type => 1 },
114                 { name => "ecx", type => 1 },
115                 { name => "eax", type => 1 },
116                 { name => "ebx", type => 2 },
117                 { name => "esi", type => 2 },
118                 { name => "edi", type => 2 },
119                 { name => "ebp", type => 2 },
120                 { name => "esp", type => 4 },
121                 { name => "gp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
122                 { name => "gp_UKNWN", type => 4 | 8 | 16 },  # we need a dummy register for Unknown nodes
123                 { mode => "mode_Iu" }
124         ],
125         mmx => [
126                 { name => "mm0", type => 4 },
127                 { name => "mm1", type => 4 },
128                 { name => "mm2", type => 4 },
129                 { name => "mm3", type => 4 },
130                 { name => "mm4", type => 4 },
131                 { name => "mm5", type => 4 },
132                 { name => "mm6", type => 4 },
133                 { name => "mm7", type => 4 },
134                 { mode => "mode_E", flags => "manual_ra" }
135         ],
136         xmm => [
137                 { name => "xmm0", type => 1 },
138                 { name => "xmm1", type => 1 },
139                 { name => "xmm2", type => 1 },
140                 { name => "xmm3", type => 1 },
141                 { name => "xmm4", type => 1 },
142                 { name => "xmm5", type => 1 },
143                 { name => "xmm6", type => 1 },
144                 { name => "xmm7", type => 1 },
145                 { name => "xmm_NOREG", type => 4 | 16 },     # we need a dummy register for NoReg nodes
146                 { name => "xmm_UKNWN", type => 4 | 8 | 16},  # we need a dummy register for Unknown nodes
147                 { mode => "mode_E" }
148         ],
149         vfp => [
150                 { name => "vf0", type => 1 | 16 },
151                 { name => "vf1", type => 1 | 16 },
152                 { name => "vf2", type => 1 | 16 },
153                 { name => "vf3", type => 1 | 16 },
154                 { name => "vf4", type => 1 | 16 },
155                 { name => "vf5", type => 1 | 16 },
156                 { name => "vf6", type => 1 | 16 },
157                 { name => "vf7", type => 1 | 16 },
158                 { name => "vfp_NOREG", type => 4 | 8 | 16 }, # we need a dummy register for NoReg nodes
159                 { name => "vfp_UKNWN", type => 4 | 8 | 16 },  # we need a dummy register for Unknown nodes
160                 { mode => "mode_E" }
161         ],
162         st => [
163                 { name => "st0", realname => "st",    type => 4 },
164                 { name => "st1", realname => "st(1)", type => 4 },
165                 { name => "st2", realname => "st(2)", type => 4 },
166                 { name => "st3", realname => "st(3)", type => 4 },
167                 { name => "st4", realname => "st(4)", type => 4 },
168                 { name => "st5", realname => "st(5)", type => 4 },
169                 { name => "st6", realname => "st(6)", type => 4 },
170                 { name => "st7", realname => "st(7)", type => 4 },
171                 { mode => "mode_E", flags => "manual_ra" }
172         ],
173         fp_cw => [      # the floating point control word
174                 { name => "fpcw", type => 4|32 },
175                 { mode => "mode_fpcw", flags => "manual_ra|state" }
176         ],
177         flags => [
178                 { name => "eflags", type => 0 },
179                 { mode => "mode_Iu", flags => "manual_ra" }
180         ],
181 ); # %reg_classes
182
183 %cpu = (
184         GP     => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
185         SSE    => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
186         VFP    => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
187         BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
188 ); # %cpu
189
190 %vliw = (
191         bundle_size       => 1,
192         bundels_per_cycle => 1
193 ); # vliw
194
195 %emit_templates = (
196         S0 => "${arch}_emit_source_register(node, 0);",
197         S1 => "${arch}_emit_source_register(node, 1);",
198         S2 => "${arch}_emit_source_register(node, 2);",
199         S3 => "${arch}_emit_source_register(node, 3);",
200         SB1 => "${arch}_emit_8bit_source_register_or_immediate(node, 1);",
201         SB2 => "${arch}_emit_8bit_source_register_or_immediate(node, 2);",
202         SB3 => "${arch}_emit_8bit_source_register_or_immediate(node, 3);",
203         SI3 => "${arch}_emit_source_register_or_immediate(node, 3);",
204         D0 => "${arch}_emit_dest_register(node, 0);",
205         D1 => "${arch}_emit_dest_register(node, 1);",
206         DB0 => "${arch}_emit_8bit_dest_register(node, 0);",
207         X0 => "${arch}_emit_x87_register(node, 0);",
208         X1 => "${arch}_emit_x87_register(node, 1);",
209         SE => "${arch}_emit_extend_suffix(get_ia32_ls_mode(node));",
210         ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
211                    ia32_emit_mode_suffix(node);",
212         M  => "${arch}_emit_mode_suffix(node);",
213         XM => "${arch}_emit_x87_mode_suffix(node);",
214         XXM => "${arch}_emit_xmm_mode_suffix(node);",
215         XSD => "${arch}_emit_xmm_mode_suffix_s(node);",
216         AM => "${arch}_emit_am(node);",
217         unop3 => "${arch}_emit_unop(node, 3);",
218         unop4 => "${arch}_emit_unop(node, 4);",
219         unop5 => "${arch}_emit_unop(node, 5);",
220         DAM1  => "${arch}_emit_am_or_dest_register(node, 1);",
221         binop => "${arch}_emit_binop(node);",
222         x87_binop => "${arch}_emit_x87_binop(node);",
223         CMP0  => "${arch}_emit_cmp_suffix_node(node, 0);",
224 );
225
226 #--------------------------------------------------#
227 #                        _                         #
228 #                       (_)                        #
229 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
230 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
231 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
232 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
233 #                                      | |         #
234 #                                      |_|         #
235 #--------------------------------------------------#
236
237 $default_attr_type = "ia32_attr_t";
238 $default_copy_attr = "ia32_copy_attr";
239
240 sub ia32_custom_init_attr {
241         my $node = shift;
242         my $name = shift;
243         my $res = "";
244         if(defined($node->{modified_flags})) {
245                 $res .= "\tset_ia32_flags(res, get_ia32_flags(res) | arch_irn_flags_modify_flags);\n";
246         }
247         if(defined($node->{am})) {
248                 my $am = $node->{am};
249                 if($am eq "full,binary") {
250                         $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
251                 } elsif($am eq "full,unary") {
252                         $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
253                 } elsif($am eq "source,unary") {
254                         $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_unary);";
255                 } elsif($am eq "source,binary") {
256                         $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
257                 } elsif($am eq "dest,unary") {
258                         $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
259                 } elsif($am eq "dest,binary") {
260                         $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
261                 } elsif($am eq "dest,ternary") {
262                         $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
263                 } elsif($am eq "source,ternary") {
264                         $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
265                 } elsif($am eq "none") {
266                         # nothing to do
267                 } else {
268                         die("Invalid address mode '$am' specified on op $name");
269                 }
270         }
271         return $res;
272 }
273 $custom_init_attr_func = \&ia32_custom_init_attr;
274
275 %init_attr = (
276         ia32_attr_t     => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
277         ia32_x87_attr_t =>
278                 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
279                 "\tinit_ia32_x87_attributes(res);",
280         ia32_asm_attr_t =>
281                 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
282                 "\tinit_ia32_x87_attributes(res);".
283                 "\tinit_ia32_asm_attributes(res);",
284         ia32_immediate_attr_t =>
285                 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
286                 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);"
287 );
288
289 %compare_attr = (
290         ia32_attr_t           => "ia32_compare_nodes_attr",
291         ia32_x87_attr_t       => "ia32_compare_x87_attr",
292         ia32_asm_attr_t       => "ia32_compare_asm_attr",
293         ia32_immediate_attr_t => "ia32_compare_immediate_attr",
294 );
295
296 %operands = (
297 );
298
299 $mode_xmm     = "mode_E";
300 $mode_gp      = "mode_Iu";
301 $mode_flags   = "mode_Iu";
302 $mode_fpcw    = "mode_fpcw";
303 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
304 $fpcw_flags   = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
305                   "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
306
307 %nodes = (
308
309 Immediate => {
310         state     => "pinned",
311         op_flags  => "c",
312         irn_flags => "I",
313         reg_req   => { out => [ "gp_NOREG" ] },
314         attr      => "ir_entity *symconst, int symconst_sign, long offset",
315         attr_type => "ia32_immediate_attr_t",
316         latency   => 0,
317         mode      => $mode_gp,
318 },
319
320 Asm => {
321         mode      => "mode_T",
322         arity     => "variable",
323         out_arity => "variable",
324         attr_type => "ia32_asm_attr_t",
325         attr      => "ident *asm_text, const ia32_asm_reg_t *register_map",
326         init_attr => "attr->asm_text = asm_text;\n".
327                      "\tattr->register_map = register_map;\n",
328         latency   => 10,
329         modified_flags => 1,
330 },
331
332 ProduceVal => {
333         op_flags  => "c",
334         irn_flags => "R",
335         reg_req   => { out => [ "gp" ] },
336         emit      => "",
337         units     => [ ],
338         latency   => 0,
339         mode      => $mode_gp,
340         cmp_attr  => "return 1;",
341 },
342
343 #-----------------------------------------------------------------#
344 #  _       _                                         _            #
345 # (_)     | |                                       | |           #
346 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
347 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
348 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
349 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
350 #                   __/ |                                         #
351 #                  |___/                                          #
352 #-----------------------------------------------------------------#
353
354 # commutative operations
355
356 Add => {
357         irn_flags => "R",
358         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5", "none", "flags" ] },
359         ins       => [ "base", "index", "mem", "left", "right" ],
360         emit      => '. add%M %binop',
361         am        => "full,binary",
362         units     => [ "GP" ],
363         mode      => $mode_gp,
364         modified_flags => $status_flags
365 },
366
367 AddMem => {
368         irn_flags => "R",
369         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
370         ins       => [ "base", "index", "mem", "val" ],
371         emit      => ". add%M %SI3, %AM",
372         units     => [ "GP" ],
373         mode      => "mode_M",
374         modified_flags => $status_flags
375 },
376
377 AddMem8Bit => {
378         irn_flags => "R",
379         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
380         ins       => [ "base", "index", "mem", "val" ],
381         emit      => ". add%M %SB3, %AM",
382         units     => [ "GP" ],
383         mode      => "mode_M",
384         modified_flags => $status_flags
385 },
386
387 Adc => {
388         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 in_r5" ] },
389         ins       => [ "base", "index", "mem", "left", "right", "eflags" ],
390         emit      => '. adc%M %binop',
391         am        => "full,binary",
392         units     => [ "GP" ],
393         mode      => $mode_gp,
394         modified_flags => $status_flags
395 },
396
397 l_Add => {
398         op_flags  => "C",
399         reg_req   => { in => [ "none", "none" ], out => [ "none" ] },
400         ins       => [ "left", "right" ],
401 },
402
403 l_Adc => {
404         reg_req   => { in => [ "none", "none", "none" ], out => [ "none" ] },
405         ins       => [ "left", "right", "eflags" ],
406 },
407
408 Mul => {
409         # we should not rematrialize this node. It produces 2 results and has
410         # very strict constrains
411         reg_req   => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
412         ins       => [ "base", "index", "mem", "val_high", "val_low" ],
413         emit      => '. mul%M %unop4',
414         outs      => [ "EAX", "EDX", "M" ],
415         am        => "source,binary",
416         latency   => 10,
417         units     => [ "GP" ],
418         modified_flags => $status_flags
419 },
420
421 l_Mul => {
422         # we should not rematrialize this node. It produces 2 results and has
423         # very strict constrains
424         op_flags  => "C",
425         cmp_attr  => "return 1;",
426         outs      => [ "EAX", "EDX", "M" ],
427         arity     => 2
428 },
429
430 IMul => {
431         irn_flags => "R",
432         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
433         ins       => [ "base", "index", "mem", "left", "right" ],
434         emit      => '. imul%M %binop',
435         am        => "source,binary",
436         latency   => 5,
437         units     => [ "GP" ],
438         mode      => $mode_gp,
439         modified_flags => $status_flags
440 },
441
442 IMul1OP => {
443         irn_flags => "R",
444         reg_req   => { in => [ "gp", "gp", "none", "eax", "gp" ], out => [ "eax", "edx", "none" ] },
445         ins       => [ "base", "index", "mem", "val_high", "val_low" ],
446         emit      => '. imul%M %unop4',
447         outs      => [ "EAX", "EDX", "M" ],
448         am        => "source,binary",
449         latency   => 5,
450         units     => [ "GP" ],
451         modified_flags => $status_flags
452 },
453
454 l_IMul => {
455         # we should not rematrialize this node. It produces 2 results and has
456         # very strict constrains
457         op_flags  => "C",
458         cmp_attr  => "return 1;",
459         outs      => [ "EAX", "EDX", "M" ],
460         arity     => 2
461 },
462
463 And => {
464         irn_flags => "R",
465         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
466         ins       => [ "base", "index", "mem", "left", "right" ],
467         am        => "full,binary",
468         emit      => '. and%M %binop',
469         units     => [ "GP" ],
470         mode      => $mode_gp,
471         modified_flags => $status_flags
472 },
473
474 AndMem => {
475         irn_flags => "R",
476         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
477         ins       => [ "base", "index", "mem", "val" ],
478         emit      => '. and%M %SI3, %AM',
479         units     => [ "GP" ],
480         mode      => "mode_M",
481         modified_flags => $status_flags
482 },
483
484 AndMem8Bit => {
485         irn_flags => "R",
486         reg_req   => { in => [ "gp", "gp", "none",  "eax ebx ecx edx" ], out => [ "none" ] },
487         ins       => [ "base", "index", "mem", "val" ],
488         emit      => '. and%M %SB3, %AM',
489         units     => [ "GP" ],
490         mode      => "mode_M",
491         modified_flags => $status_flags
492 },
493
494 Or => {
495         irn_flags => "R",
496         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
497         ins       => [ "base", "index", "mem", "left", "right" ],
498         am        => "full,binary",
499         emit      => '. or%M %binop',
500         units     => [ "GP" ],
501         mode      => $mode_gp,
502         modified_flags => $status_flags
503 },
504
505 OrMem => {
506         irn_flags => "R",
507         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
508         ins       => [ "base", "index", "mem", "val" ],
509         emit      => '. or%M %SI3, %AM',
510         units     => [ "GP" ],
511         mode      => "mode_M",
512         modified_flags => $status_flags
513 },
514
515 OrMem8Bit => {
516         irn_flags => "R",
517         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
518         ins       => [ "base", "index", "mem", "val" ],
519         emit      => '. or%M %SB3, %AM',
520         units     => [ "GP" ],
521         mode      => "mode_M",
522         modified_flags => $status_flags
523 },
524
525 Xor => {
526         irn_flags => "R",
527         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4 in_r5" ] },
528         ins       => [ "base", "index", "mem", "left", "right" ],
529         am        => "full,binary",
530         emit      => '. xor%M %binop',
531         units     => [ "GP" ],
532         mode      => $mode_gp,
533         modified_flags => $status_flags
534 },
535
536 XorMem => {
537         irn_flags => "R",
538         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
539         ins       => [ "base", "index", "mem", "val" ],
540         emit      => '. xor%M %SI3, %AM',
541         units     => [ "GP" ],
542         mode      => "mode_M",
543         modified_flags => $status_flags
544 },
545
546 XorMem8Bit => {
547         irn_flags => "R",
548         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
549         ins       => [ "base", "index", "mem", "val" ],
550         emit      => '. xor%M %SB3, %AM',
551         units     => [ "GP" ],
552         mode      => "mode_M",
553         modified_flags => $status_flags
554 },
555
556 # not commutative operations
557
558 Sub => {
559         irn_flags => "R",
560         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ], out => [ "in_r4", "none", "flags" ] },
561         ins       => [ "base", "index", "mem", "left", "right" ],
562         am        => "full,binary",
563         emit      => '. sub%M %binop',
564         units     => [ "GP" ],
565         mode      => $mode_gp,
566         modified_flags => $status_flags
567 },
568
569 SubMem => {
570         irn_flags => "R",
571         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
572         ins       => [ "base", "index", "mem", "val" ],
573         emit      => '. sub%M %SI3, %AM',
574         units     => [ "GP" ],
575         mode      => 'mode_M',
576         modified_flags => $status_flags
577 },
578
579 SubMem8Bit => {
580         irn_flags => "R",
581         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "none" ] },
582         ins       => [ "base", "index", "mem", "val" ],
583         emit      => '. sub%M %SB3, %AM',
584         units     => [ "GP" ],
585         mode      => 'mode_M',
586         modified_flags => $status_flags
587 },
588
589 Sbb => {
590         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "flags" ], out => [ "in_r4 !in_r5" ] },
591         ins       => [ "base", "index", "mem", "left", "right", "eflags" ],
592         am        => "full,binary",
593         emit      => '. sbb%M %binop',
594         units     => [ "GP" ],
595         mode      => $mode_gp,
596         modified_flags => $status_flags
597 },
598
599 l_Sub => {
600         reg_req   => { in => [ "none", "none" ], out => [ "none" ] },
601         ins       => [ "left", "right" ],
602 },
603
604 l_Sbb => {
605         reg_req   => { in => [ "none", "none", "none" ], out => [ "none" ] },
606         ins       => [ "left", "right", "eflags" ],
607 },
608
609 IDiv => {
610         op_flags  => "F|L",
611         state     => "exc_pinned",
612         reg_req   => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
613         ins       => [ "base", "index", "mem", "left_low", "left_high", "right" ],
614         outs      => [ "div_res", "mod_res", "M" ],
615         am        => "source,ternary",
616         emit      => ". idiv%M %unop5",
617         latency   => 25,
618         units     => [ "GP" ],
619         modified_flags => $status_flags
620 },
621
622 Div => {
623         op_flags  => "F|L",
624         state     => "exc_pinned",
625         reg_req   => { in => [ "gp", "gp", "none", "eax", "edx", "gp" ], out => [ "eax", "edx", "none" ] },
626         ins       => [ "base", "index", "mem", "left_low", "left_high", "right" ],
627         outs      => [ "div_res", "mod_res", "M" ],
628         am        => "source,ternary",
629         emit      => ". div%M %unop5",
630         latency   => 25,
631         units     => [ "GP" ],
632         modified_flags => $status_flags
633 },
634
635 Shl => {
636         irn_flags => "R",
637         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
638         ins       => [ "left", "right" ],
639         emit      => '. shl %SB1, %S0',
640         units     => [ "GP" ],
641         mode      => $mode_gp,
642         modified_flags => $status_flags
643 },
644
645 ShlMem => {
646         irn_flags => "R",
647         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
648         ins       => [ "base", "index", "mem", "count" ],
649         emit      => '. shl%M %SB3, %AM',
650         units     => [ "GP" ],
651         mode      => "mode_M",
652         modified_flags => $status_flags
653 },
654
655 l_ShlDep => {
656         cmp_attr  => "return 1;",
657         # value, cnt, dependency
658         arity     => 3
659 },
660
661 ShlD => {
662         irn_flags => "R",
663         # see ShrD about the strange out constraint
664         reg_req   => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
665         ins       => [ "left_high", "left_low", "right" ],
666         emit      => ". shld%M %SB2, %S1, %S0\n".
667                      ". movl %S0, %D0",
668         latency   => 6,
669         units     => [ "GP" ],
670         mode      => $mode_gp,
671         modified_flags => $status_flags
672 },
673
674 l_ShlD => {
675         cmp_attr  => "return 1;",
676         arity     => 3,
677 },
678
679 Shr => {
680         irn_flags => "R",
681         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
682         ins       => [ "val", "count" ],
683         emit      => '. shr %SB1, %S0',
684         units     => [ "GP" ],
685         mode      => $mode_gp,
686         modified_flags => $status_flags
687 },
688
689 ShrMem => {
690         irn_flags => "R",
691         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
692         ins       => [ "base", "index", "mem", "count" ],
693         emit      => '. shr%M %SB3, %AM',
694         units     => [ "GP" ],
695         mode      => "mode_M",
696         modified_flags => $status_flags
697 },
698
699 l_ShrDep => {
700         cmp_attr  => "return 1;",
701         # value, cnt, dependency
702         arity     => 3
703 },
704
705 ShrD => {
706         # What's going on with the out constraint here? We would like to write
707         # "in_r2" and be done. However in firm we only support should_be_same
708         # constraints at the moment. Which means they could be non-fullfilled in
709         # some cases. Now when all values happen to live through the node, out
710         # is ecx and in_r2 not ecx, then we're screwed. Because in this case we
711         # need a 4th Register.
712         #
713         # The best solution for this is extending the register allocator to support
714         # must_be_same constraints which create a copy when the in_r2 value
715         # lives through (this ensures that we have the 4th register in the cases
716         # when we need it and can always fix the situation).
717         #
718         # For now I'm doing this ultra ugly !in hack which allocates 4 registers
719         # and creates an extra mov
720         irn_flags => "R",
721         reg_req   => { in => [ "gp", "gp", "ecx" ], out => [ "!in" ] },
722         ins       => [ "left_high", "left_low", "right" ],
723         emit      => ". shrd%M %SB2, %S1, %S0\n".
724                      ". movl   %S0, %D0",
725         latency   => 6,
726         units     => [ "GP" ],
727         mode      => $mode_gp,
728         modified_flags => $status_flags
729 },
730
731 l_ShrD => {
732         cmp_attr  => "return 1;",
733         arity     => 3
734 },
735
736 Sar => {
737         irn_flags => "R",
738         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
739         ins       => [ "val", "count" ],
740         emit      => '. sar %SB1, %S0',
741         units     => [ "GP" ],
742         mode      => $mode_gp,
743         modified_flags => $status_flags
744 },
745
746 SarMem => {
747         irn_flags => "R",
748         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
749         ins       => [ "base", "index", "mem", "count" ],
750         emit      => '. sar%M %SB3, %AM',
751         units     => [ "GP" ],
752         mode      => "mode_M",
753         modified_flags => $status_flags
754 },
755
756 l_SarDep => {
757         cmp_attr  => "return 1;",
758         # value, cnt, dependency
759         arity     => 3
760 },
761
762 Ror => {
763         irn_flags => "R",
764         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
765         ins       => [ "val", "count" ],
766         emit      => '. ror %SB1, %S0',
767         units     => [ "GP" ],
768         mode      => $mode_gp,
769         modified_flags => $status_flags
770 },
771
772 RorMem => {
773         irn_flags => "R",
774         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
775         ins       => [ "base", "index", "mem", "count" ],
776         emit      => '. ror%M %SB3, %AM',
777         units     => [ "GP" ],
778         mode      => "mode_M",
779         modified_flags => $status_flags
780 },
781
782 Rol => {
783         irn_flags => "R",
784         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
785         ins       => [ "val", "count" ],
786         emit      => '. rol %SB1, %S0',
787         units     => [ "GP" ],
788         mode      => $mode_gp,
789         modified_flags => $status_flags
790 },
791
792 RolMem => {
793         irn_flags => "R",
794         reg_req   => { in => [ "gp", "gp", "none", "ecx" ], out => [ "none" ] },
795         ins       => [ "base", "index", "mem", "count" ],
796         emit      => '. rol%M %SB3, %AM',
797         units     => [ "GP" ],
798         mode      => "mode_M",
799         modified_flags => $status_flags
800 },
801
802 # unary operations
803
804 Neg => {
805         irn_flags => "R",
806         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
807         emit      => '. neg %S0',
808         ins       => [ "val" ],
809         units     => [ "GP" ],
810         mode      => $mode_gp,
811         modified_flags => $status_flags
812 },
813
814 NegMem => {
815         irn_flags => "R",
816         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
817         ins       => [ "base", "index", "mem" ],
818         emit      => '. neg%M %AM',
819         units     => [ "GP" ],
820         mode      => "mode_M",
821         modified_flags => $status_flags
822 },
823
824 Minus64Bit => {
825         irn_flags => "R",
826         reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
827         outs      => [ "low_res", "high_res" ],
828         units     => [ "GP" ],
829         modified_flags => $status_flags
830 },
831
832
833 l_Neg => {
834         cmp_attr  => "return 1;",
835         arity     => 1,
836 },
837
838 Inc => {
839         irn_flags => "R",
840         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
841         emit      => '. inc %S0',
842         units     => [ "GP" ],
843         mode      => $mode_gp,
844         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
845 },
846
847 IncMem => {
848         irn_flags => "R",
849         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
850         ins       => [ "base", "index", "mem" ],
851         emit      => '. inc%M %AM',
852         units     => [ "GP" ],
853         mode      => "mode_M",
854         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
855 },
856
857 Dec => {
858         irn_flags => "R",
859         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
860         emit      => '. dec %S0',
861         units     => [ "GP" ],
862         mode      => $mode_gp,
863         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
864 },
865
866 DecMem => {
867         irn_flags => "R",
868         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
869         ins       => [ "base", "index", "mem" ],
870         emit      => '. dec%M %AM',
871         units     => [ "GP" ],
872         mode      => "mode_M",
873         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
874 },
875
876 Not => {
877         irn_flags => "R",
878         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
879         ins       => [ "val" ],
880         emit      => '. not %S0',
881         units     => [ "GP" ],
882         mode      => $mode_gp,
883 },
884
885 NotMem => {
886         irn_flags => "R",
887         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
888         ins       => [ "base", "index", "mem" ],
889         emit      => '. not%M %AM',
890         units     => [ "GP" ],
891         mode      => "mode_M",
892 },
893
894 # other operations
895
896 Cmp => {
897         irn_flags => "R",
898         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
899         ins       => [ "base", "index", "mem", "left", "right" ],
900         outs      => [ "eflags" ],
901         am        => "source,binary",
902         emit      => '. cmp%M %binop',
903         attr      => "int ins_permuted, int cmp_unsigned",
904         init_attr => "attr->data.ins_permuted   = ins_permuted;\n".
905                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
906         latency   => 1,
907         units     => [ "GP" ],
908         mode      => $mode_flags,
909         modified_flags => $status_flags
910 },
911
912 Cmp8Bit => {
913         irn_flags => "R",
914         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
915         ins       => [ "base", "index", "mem", "left", "right" ],
916         outs      => [ "eflags" ],
917         am        => "source,binary",
918         emit      => '. cmpb %binop',
919         attr      => "int ins_permuted, int cmp_unsigned",
920         init_attr => "attr->data.ins_permuted   = ins_permuted;\n".
921                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
922         latency   => 1,
923         units     => [ "GP" ],
924         mode      => $mode_flags,
925         modified_flags => $status_flags
926 },
927
928 Test => {
929         irn_flags => "R",
930         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp" ] , out => [ "flags" ] },
931         ins       => [ "base", "index", "mem", "left", "right" ],
932         outs      => [ "eflags" ],
933         am        => "source,binary",
934         emit      => '. test%M %binop',
935         attr      => "int ins_permuted, int cmp_unsigned",
936         init_attr => "attr->data.ins_permuted = ins_permuted;\n".
937                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
938         latency   => 1,
939         units     => [ "GP" ],
940         mode      => $mode_flags,
941         modified_flags => $status_flags
942 },
943
944 Test8Bit => {
945         irn_flags => "R",
946         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx", "eax ebx ecx edx" ] , out => [ "flags" ] },
947         ins       => [ "base", "index", "mem", "left", "right" ],
948         outs      => [ "eflags" ],
949         am        => "source,binary",
950         emit      => '. testb %binop',
951         attr      => "int ins_permuted, int cmp_unsigned",
952         init_attr => "attr->data.ins_permuted = ins_permuted;\n".
953                      "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
954         latency   => 1,
955         units     => [ "GP" ],
956         mode      => $mode_flags,
957         modified_flags => $status_flags
958 },
959
960 Set => {
961         #irn_flags => "R",
962         reg_req   => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
963         ins       => [ "eflags" ],
964         attr      => "pn_Cmp pnc",
965         init_attr => "attr->pn_code = pnc;\nset_ia32_ls_mode(res, mode_Bu);\n",
966         emit      => '. set%CMP0 %DB0',
967         latency   => 1,
968         units     => [ "GP" ],
969         mode      => $mode_gp,
970 },
971
972 CMov => {
973         #irn_flags => "R",
974         # (note: leave the false,true order intact to make it compatible with other
975         #  ia32_binary ops)
976         reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ], out => [ "in_r4 in_r5" ] },
977         ins       => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
978         am        => "source,binary",
979         attr      => "int ins_permuted, pn_Cmp pn_code",
980         init_attr => "attr->pn_code          = pn_code;\n".
981                      "attr->data.ins_permuted = ins_permuted;",
982         latency   => 1,
983         units     => [ "GP" ],
984         mode      => $mode_gp,
985 },
986
987 Jcc => {
988         state     => "pinned",
989         op_flags  => "L|X|Y",
990         reg_req   => { in  => [ "eflags" ], out => [ "none", "none" ] },
991         ins       => [ "eflags" ],
992         outs      => [ "false", "true" ],
993         attr      => "pn_Cmp pnc",
994         init_attr => "attr->pn_code = pnc;",
995         latency   => 2,
996         units     => [ "BRANCH" ],
997 },
998
999 SwitchJmp => {
1000         state     => "pinned",
1001         op_flags  => "L|X|Y",
1002         reg_req   => { in => [ "gp" ], out => [ "none" ] },
1003         latency   => 3,
1004         units     => [ "BRANCH" ],
1005         mode      => "mode_T",
1006         modified_flags => $status_flags
1007 },
1008
1009 IJmp => {
1010         state     => "pinned",
1011         op_flags  => "X",
1012         reg_req   => { in => [ "gp" ] },
1013         emit      => '. jmp *%S0',
1014         units     => [ "BRANCH" ],
1015         mode      => "mode_X",
1016 },
1017
1018 Const => {
1019         op_flags  => "c",
1020         irn_flags => "R",
1021         reg_req   => { out => [ "gp" ] },
1022         units     => [ "GP" ],
1023         attr      => "ir_entity *symconst, int symconst_sign, long offset",
1024         attr_type => "ia32_immediate_attr_t",
1025         mode      => $mode_gp,
1026 # depends on the const and is set in ia32_transform
1027 # modified_flags => $status_flags
1028 },
1029
1030 Unknown_GP => {
1031         state     => "pinned",
1032         op_flags  => "c",
1033         irn_flags => "I",
1034         reg_req   => { out => [ "gp_UKNWN" ] },
1035         units     => [],
1036         emit      => "",
1037         mode      => $mode_gp
1038 },
1039
1040 Unknown_VFP => {
1041         state     => "pinned",
1042         op_flags  => "c",
1043         irn_flags => "I",
1044         reg_req   => { out => [ "vfp_UKNWN" ] },
1045         units     => [],
1046         emit      => "",
1047         mode      => "mode_E",
1048         attr_type => "ia32_x87_attr_t",
1049 },
1050
1051 Unknown_XMM => {
1052         state     => "pinned",
1053         op_flags  => "c",
1054         irn_flags => "I",
1055         reg_req   => { out => [ "xmm_UKNWN" ] },
1056         units     => [],
1057         emit      => "",
1058         mode      => "mode_E"
1059 },
1060
1061 NoReg_GP => {
1062         state     => "pinned",
1063         op_flags  => "c",
1064         irn_flags => "I",
1065         reg_req   => { out => [ "gp_NOREG" ] },
1066         units     => [],
1067         emit      => "",
1068         mode      => $mode_gp
1069 },
1070
1071 NoReg_VFP => {
1072         state     => "pinned",
1073         op_flags  => "c",
1074         irn_flags => "I",
1075         reg_req   => { out => [ "vfp_NOREG" ] },
1076         units     => [],
1077         emit      => "",
1078         mode      => "mode_E",
1079         attr_type => "ia32_x87_attr_t",
1080 },
1081
1082 NoReg_XMM => {
1083         state     => "pinned",
1084         op_flags  => "c",
1085         irn_flags => "I",
1086         reg_req   => { out => [ "xmm_NOREG" ] },
1087         units     => [],
1088         emit      => "",
1089         mode      => "mode_E"
1090 },
1091
1092 ChangeCW => {
1093         state     => "pinned",
1094         op_flags  => "c",
1095         irn_flags => "I",
1096         reg_req   => { out => [ "fp_cw" ] },
1097         mode      => $mode_fpcw,
1098         latency   => 3,
1099         units     => [ "GP" ],
1100         modified_flags => $fpcw_flags
1101 },
1102
1103 FldCW => {
1104         op_flags  => "L|F",
1105         state     => "pinned",
1106         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1107         ins       => [ "base", "index", "mem" ],
1108         latency   => 5,
1109         emit      => ". fldcw %AM",
1110         mode      => $mode_fpcw,
1111         units     => [ "GP" ],
1112         modified_flags => $fpcw_flags
1113 },
1114
1115 FnstCW => {
1116         op_flags  => "L|F",
1117         state     => "pinned",
1118         reg_req   => { in => [ "gp", "gp", "none", "fp_cw" ], out => [ "none" ] },
1119         ins       => [ "base", "index", "mem", "fpcw" ],
1120         latency   => 5,
1121         emit      => ". fnstcw %AM",
1122         mode      => "mode_M",
1123         units     => [ "GP" ],
1124 },
1125
1126 Cltd => {
1127         # we should not rematrialize this node. It has very strict constraints.
1128         reg_req   => { in => [ "eax", "edx" ], out => [ "edx" ] },
1129         ins       => [ "val", "globbered" ],
1130         emit      => '. cltd',
1131         mode      => $mode_gp,
1132         units     => [ "GP" ],
1133 },
1134
1135 # Load / Store
1136 #
1137 # Note that we add additional latency values depending on address mode, so a
1138 # lateny of 0 for load is correct
1139
1140 Load => {
1141         op_flags  => "L|F",
1142         state     => "exc_pinned",
1143         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1144         ins       => [ "base", "index", "mem" ],
1145         outs      => [ "res", "M" ],
1146         latency   => 0,
1147         emit      => ". mov%SE%ME%.l %AM, %D0",
1148         units     => [ "GP" ],
1149 },
1150
1151 l_Load => {
1152         op_flags  => "L|F",
1153         cmp_attr  => "return 1;",
1154         outs      => [ "res", "M" ],
1155         arity     => 2,
1156 },
1157
1158 l_Store => {
1159         op_flags  => "L|F",
1160         cmp_attr  => "return 1;",
1161         state     => "exc_pinned",
1162         arity     => 3,
1163         mode      => "mode_M",
1164 },
1165
1166 Store => {
1167         op_flags  => "L|F",
1168         state     => "exc_pinned",
1169         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "none" ] },
1170         ins       => [ "base", "index", "mem", "val" ],
1171         emit      => '. mov%M %SI3, %AM',
1172         latency   => 2,
1173         units     => [ "GP" ],
1174         mode      => "mode_M",
1175 },
1176
1177 Store8Bit => {
1178         op_flags  => "L|F",
1179         state     => "exc_pinned",
1180         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => ["none" ] },
1181         ins       => [ "base", "index", "mem", "val" ],
1182         emit      => '. mov%M %SB3, %AM',
1183         latency   => 2,
1184         units     => [ "GP" ],
1185         mode      => "mode_M",
1186 },
1187
1188 Lea => {
1189         irn_flags => "R",
1190         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
1191         ins       => [ "base", "index" ],
1192         emit      => '. leal %AM, %D0',
1193         latency   => 2,
1194         units     => [ "GP" ],
1195         mode      => $mode_gp,
1196 # well this isn't true for Lea, but we often transform Lea back to Add, Inc
1197 # or Dec, so we set the flag
1198         modified_flags => 1,
1199 },
1200
1201 Push => {
1202         reg_req   => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "esp", "none" ] },
1203         ins       => [ "base", "index", "mem", "val", "stack" ],
1204         emit      => '. push%M %unop4',
1205         outs      => [ "stack:I|S", "M" ],
1206         am        => "source,binary",
1207         latency   => 2,
1208         units     => [ "GP" ],
1209 },
1210
1211 Pop => {
1212         reg_req   => { in => [ "gp", "gp", "none", "esp" ], out => [ "esp", "gp", "none" ] },
1213         emit      => '. pop%M %DAM1',
1214         outs      => [ "stack:I|S", "res", "M" ],
1215         ins       => [ "base", "index", "mem", "stack" ],
1216         am        => "dest,unary",
1217         latency   => 3, # Pop is more expensive than Push on Athlon
1218         units     => [ "GP" ],
1219 },
1220
1221 Enter => {
1222         reg_req   => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1223         emit      => '. enter',
1224         outs      => [ "frame:I", "stack:I|S", "M" ],
1225         latency   => 15,
1226         units     => [ "GP" ],
1227 },
1228
1229 Leave => {
1230         reg_req   => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1231         emit      => '. leave',
1232         outs      => [ "frame:I", "stack:I|S" ],
1233         latency   => 3,
1234         units     => [ "GP" ],
1235 },
1236
1237 AddSP => {
1238         irn_flags => "I",
1239         state     => "pinned",
1240         reg_req   => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "none" ] },
1241         ins       => [ "base", "index", "mem", "stack", "size" ],
1242         am        => "source,binary",
1243         emit      => '. addl %binop',
1244         outs      => [ "stack:S", "M" ],
1245         units     => [ "GP" ],
1246         modified_flags => $status_flags
1247 },
1248
1249 SubSP => {
1250 #irn_flags => "I",
1251         state     => "pinned",
1252         reg_req   => { in => [ "gp", "gp", "none", "esp", "gp" ], out => [ "in_r4", "gp", "none" ] },
1253         ins       => [ "base", "index", "mem", "stack", "size" ],
1254         am        => "source,binary",
1255         emit      => ". subl %binop\n".
1256                      ". movl %%esp, %D1",
1257         outs      => [ "stack:I|S", "addr", "M" ],
1258         units     => [ "GP" ],
1259         modified_flags => $status_flags
1260 },
1261
1262 LdTls => {
1263         irn_flags => "R",
1264         reg_req   => { out => [ "gp" ] },
1265         units     => [ "GP" ],
1266 },
1267
1268
1269 #-----------------------------------------------------------------------------#
1270 #   _____ _____ ______    __ _             _                     _            #
1271 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
1272 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1273 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1274 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1275 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1276 #-----------------------------------------------------------------------------#
1277
1278 xZero => {
1279         irn_flags => "R",
1280         reg_req   => { out => [ "xmm" ] },
1281         emit      => '. xorp%XSD %D0, %D0',
1282         latency   => 3,
1283         units     => [ "SSE" ],
1284         mode      => "mode_E",
1285 },
1286
1287 # commutative operations
1288
1289 xAdd => {
1290         irn_flags => "R",
1291         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1292         ins       => [ "base", "index", "mem", "left", "right" ],
1293         am        => "source,binary",
1294         emit      => '. add%XXM %binop',
1295         latency   => 4,
1296         units     => [ "SSE" ],
1297         mode      => "mode_E",
1298 },
1299
1300 xMul => {
1301         irn_flags => "R",
1302         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1303         ins       => [ "base", "index", "mem", "left", "right" ],
1304         am        => "source,binary",
1305         emit      => '. mul%XXM %binop',
1306         latency   => 4,
1307         units     => [ "SSE" ],
1308         mode      => "mode_E",
1309 },
1310
1311 xMax => {
1312         irn_flags => "R",
1313         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1314         ins       => [ "base", "index", "mem", "left", "right" ],
1315         am        => "source,binary",
1316         emit      => '. max%XXM %binop',
1317         latency   => 2,
1318         units     => [ "SSE" ],
1319         mode      => "mode_E",
1320 },
1321
1322 xMin => {
1323         irn_flags => "R",
1324         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1325         ins       => [ "base", "index", "mem", "left", "right" ],
1326         am        => "source,binary",
1327         emit      => '. min%XXM %binop',
1328         latency   => 2,
1329         units     => [ "SSE" ],
1330         mode      => "mode_E",
1331 },
1332
1333 xAnd => {
1334         irn_flags => "R",
1335         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1336         ins       => [ "base", "index", "mem", "left", "right" ],
1337         am        => "source,binary",
1338         emit      => '. andp%XSD %binop',
1339         latency   => 3,
1340         units     => [ "SSE" ],
1341         mode      => "mode_E",
1342 },
1343
1344 xOr => {
1345         irn_flags => "R",
1346         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1347         ins       => [ "base", "index", "mem", "left", "right" ],
1348         am        => "source,binary",
1349         emit      => '. orp%XSD %binop',
1350         units     => [ "SSE" ],
1351         mode      => "mode_E",
1352 },
1353
1354 xXor => {
1355         irn_flags => "R",
1356         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 in_r5" ] },
1357         ins       => [ "base", "index", "mem", "left", "right" ],
1358         am        => "source,binary",
1359         emit      => '. xorp%XSD %binop',
1360         latency   => 3,
1361         units     => [ "SSE" ],
1362         mode      => "mode_E",
1363 },
1364
1365 # not commutative operations
1366
1367 xAndNot => {
1368         irn_flags => "R",
1369         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5" ] },
1370         ins       => [ "base", "index", "mem", "left", "right" ],
1371         am        => "source,binary",
1372         emit      => '. andnp%XSD %binop',
1373         latency   => 3,
1374         units     => [ "SSE" ],
1375         mode      => "mode_E",
1376 },
1377
1378 xSub => {
1379         irn_flags => "R",
1380         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4" ] },
1381         ins       => [ "base", "index", "mem", "left", "right" ],
1382         am        => "source,binary",
1383         emit      => '. sub%XXM %binop',
1384         latency   => 4,
1385         units     => [ "SSE" ],
1386         mode      => "mode_E",
1387 },
1388
1389 xDiv => {
1390         irn_flags => "R",
1391         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "in_r4 !in_r5", "none" ] },
1392         ins       => [ "base", "index", "mem", "left", "right" ],
1393         am        => "source,binary",
1394         outs      => [ "res", "M" ],
1395         emit      => '. div%XXM %binop',
1396         latency   => 16,
1397         units     => [ "SSE" ],
1398 },
1399
1400 # other operations
1401
1402 Ucomi => {
1403         irn_flags => "R",
1404         reg_req   => { in => [ "gp", "gp", "none", "xmm", "xmm" ], out => [ "eflags" ] },
1405         ins       => [ "base", "index", "mem", "left", "right" ],
1406         outs      => [ "flags" ],
1407         am        => "source,binary",
1408         attr      => "int ins_permuted",
1409         init_attr => "attr->data.ins_permuted = ins_permuted;",
1410         emit      => ' .ucomi%XXM %binop',
1411         latency   => 3,
1412         units     => [ "SSE" ],
1413         mode      => $mode_flags,
1414         modified_flags => 1,
1415 },
1416
1417 # Load / Store
1418
1419 xLoad => {
1420         op_flags  => "L|F",
1421         state     => "exc_pinned",
1422         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1423         ins       => [ "base", "index", "mem" ],
1424         emit      => '. mov%XXM %AM, %D0',
1425         attr      => "ir_mode *load_mode",
1426         init_attr => "attr->ls_mode = load_mode;",
1427         outs      => [ "res", "M" ],
1428         latency   => 0,
1429         units     => [ "SSE" ],
1430 },
1431
1432 xStore => {
1433         op_flags => "L|F",
1434         state    => "exc_pinned",
1435         reg_req  => { in => [ "gp", "gp", "none", "xmm" ] },
1436         ins       => [ "base", "index", "mem", "val" ],
1437         emit     => '. mov%XXM %S3, %AM',
1438         latency  => 0,
1439         units    => [ "SSE" ],
1440         mode     => "mode_M",
1441 },
1442
1443 xStoreSimple => {
1444         op_flags => "L|F",
1445         state    => "exc_pinned",
1446         reg_req  => { in => [ "gp", "gp", "none", "xmm" ] },
1447         ins      => [ "base", "index", "mem", "val" ],
1448         emit     => '. mov%XXM %S3, %AM',
1449         latency  => 0,
1450         units    => [ "SSE" ],
1451         mode     => "mode_M",
1452 },
1453
1454 CvtSI2SS => {
1455         op_flags => "L|F",
1456         reg_req  => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1457         ins      => [ "base", "index", "mem", "val" ],
1458         am       => "source,unary",
1459         emit     => '. cvtsi2ss %unop3, %D0',
1460         latency  => 2,
1461         units    => [ "SSE" ],
1462         mode     => $mode_xmm
1463 },
1464
1465 CvtSI2SD => {
1466         op_flags => "L|F",
1467         reg_req  => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm" ] },
1468         ins      => [ "base", "index", "mem", "val" ],
1469         am       => "source,unary",
1470         emit     => '. cvtsi2sd %unop3, %D0',
1471         latency  => 2,
1472         units    => [ "SSE" ],
1473         mode     => $mode_xmm
1474 },
1475
1476
1477 l_X87toSSE => {
1478         op_flags => "L|F",
1479         cmp_attr => "return 1;",
1480         arity    => 3,
1481 },
1482
1483 l_SSEtoX87 => {
1484         op_flags => "L|F",
1485         cmp_attr => "return 1;",
1486         arity    => 3,
1487 },
1488
1489 # CopyB
1490
1491 CopyB => {
1492         op_flags => "F|H",
1493         state    => "pinned",
1494         reg_req  => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1495         outs     => [ "DST", "SRC", "CNT", "M" ],
1496         units    => [ "GP" ],
1497 # we don't care about this flag, so no need to mark this node
1498 #       modified_flags => [ "DF" ]
1499 },
1500
1501 CopyB_i => {
1502         op_flags => "F|H",
1503         state    => "pinned",
1504         reg_req  => { in => [ "edi", "esi", "none" ], out => [  "edi", "esi", "none" ] },
1505         outs     => [ "DST", "SRC", "M" ],
1506         units    => [ "GP" ],
1507 # we don't care about this flag, so no need to mark this node
1508 #       modified_flags => [ "DF" ]
1509 },
1510
1511 # Conversions
1512
1513 Conv_I2I => {
1514         state     => "exc_pinned",
1515         reg_req   => { in => [ "gp", "gp", "none", "gp" ], out => [ "gp", "none" ] },
1516         ins       => [ "base", "index", "mem", "val" ],
1517         am        => "source,unary",
1518         units     => [ "GP" ],
1519         attr      => "ir_mode *smaller_mode",
1520         init_attr => "attr->ls_mode = smaller_mode;",
1521         mode      => $mode_gp,
1522 },
1523
1524 Conv_I2I8Bit => {
1525         state     => "exc_pinned",
1526         reg_req   => { in => [ "gp", "gp", "none", "eax ebx ecx edx" ], out => [ "gp", "none" ] },
1527         ins       => [ "base", "index", "mem", "val" ],
1528         am        => "source,unary",
1529         units     => [ "GP" ],
1530         attr      => "ir_mode *smaller_mode",
1531         init_attr => "attr->ls_mode = smaller_mode;",
1532         mode      => $mode_gp,
1533 },
1534
1535 Conv_I2FP => {
1536         reg_req  => { in => [ "gp", "gp", "none", "gp" ], out => [ "xmm", "none" ] },
1537         ins      => [ "base", "index", "mem", "val" ],
1538         am       => "source,unary",
1539         latency  => 10,
1540         units    => [ "SSE" ],
1541         mode     => "mode_E",
1542 },
1543
1544 Conv_FP2I => {
1545         reg_req  => { in => [ "gp", "gp", "none", "xmm" ], out => [ "gp", "none" ] },
1546         ins      => [ "base", "index", "mem", "val" ],
1547         am       => "source,unary",
1548         latency  => 10,
1549         units    => [ "SSE" ],
1550         mode     => $mode_gp,
1551 },
1552
1553 Conv_FP2FP => {
1554         reg_req  => { in => [ "gp", "gp", "none", "xmm" ], out => [ "xmm", "none" ] },
1555         ins      => [ "base", "index", "mem", "val" ],
1556         am       => "source,unary",
1557         latency  => 8,
1558         units    => [ "SSE" ],
1559         mode     => "mode_E",
1560 },
1561
1562 #----------------------------------------------------------#
1563 #        _      _               _    __ _             _    #
1564 #       (_)    | |             | |  / _| |           | |   #
1565 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1566 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1567 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1568 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1569 #                 | |                                      #
1570 #  _ __   ___   __| | ___  ___                             #
1571 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1572 # | | | | (_) | (_| |  __/\__ \                            #
1573 # |_| |_|\___/ \__,_|\___||___/                            #
1574 #----------------------------------------------------------#
1575
1576 # spilling disabled for all float nodes for now, because the fpcw handler
1577 # runs before spilling and we might end up with wrong fpcw then
1578
1579 vfadd => {
1580 #       irn_flags => "R",
1581         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1582         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
1583         am        => "source,binary",
1584         latency   => 4,
1585         units     => [ "VFP" ],
1586         mode      => "mode_E",
1587         attr_type => "ia32_x87_attr_t",
1588 },
1589
1590 vfmul => {
1591 #       irn_flags => "R",
1592         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1593         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
1594         am        => "source,binary",
1595         latency   => 4,
1596         units     => [ "VFP" ],
1597         mode      => "mode_E",
1598         attr_type => "ia32_x87_attr_t",
1599 },
1600
1601 vfsub => {
1602 #       irn_flags => "R",
1603         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1604         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
1605         am        => "source,binary",
1606         latency   => 4,
1607         units     => [ "VFP" ],
1608         mode      => "mode_E",
1609         attr_type => "ia32_x87_attr_t",
1610 },
1611
1612 vfdiv => {
1613         reg_req   => { in => [ "gp", "gp", "none", "vfp", "vfp", "fpcw" ], out => [ "vfp", "none" ] },
1614         ins       => [ "base", "index", "mem", "left", "right", "fpcw" ],
1615         am        => "source,binary",
1616         outs      => [ "res", "M" ],
1617         latency   => 20,
1618         units     => [ "VFP" ],
1619         attr_type => "ia32_x87_attr_t",
1620 },
1621
1622 vfprem => {
1623         reg_req   => { in => [ "vfp", "vfp", "fpcw" ], out => [ "vfp" ] },
1624         ins       => [ "left", "right", "fpcw" ],
1625         latency   => 20,
1626         units     => [ "VFP" ],
1627         mode      => "mode_E",
1628         attr_type => "ia32_x87_attr_t",
1629 },
1630
1631 vfabs => {
1632         irn_flags => "R",
1633         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1634         ins       => [ "value" ],
1635         latency   => 2,
1636         units     => [ "VFP" ],
1637         mode      => "mode_E",
1638         attr_type => "ia32_x87_attr_t",
1639 },
1640
1641 vfchs => {
1642         irn_flags => "R",
1643         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1644         ins       => [ "value" ],
1645         latency   => 2,
1646         units     => [ "VFP" ],
1647         mode      => "mode_E",
1648         attr_type => "ia32_x87_attr_t",
1649 },
1650
1651 # virtual Load and Store
1652
1653 vfld => {
1654         op_flags  => "L|F",
1655         state     => "exc_pinned",
1656         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1657         ins       => [ "base", "index", "mem" ],
1658         outs      => [ "res", "M" ],
1659         attr      => "ir_mode *load_mode",
1660         init_attr => "attr->attr.ls_mode = load_mode;",
1661         latency   => 2,
1662         units     => [ "VFP" ],
1663         attr_type => "ia32_x87_attr_t",
1664 },
1665
1666 vfst => {
1667         op_flags  => "L|F",
1668         state     => "exc_pinned",
1669         reg_req   => { in => [ "gp", "gp", "none", "vfp" ] },
1670         ins       => [ "base", "index", "mem", "val" ],
1671         attr      => "ir_mode *store_mode",
1672         init_attr => "attr->attr.ls_mode = store_mode;",
1673         latency   => 2,
1674         units     => [ "VFP" ],
1675         mode      => "mode_M",
1676         attr_type => "ia32_x87_attr_t",
1677 },
1678
1679 # Conversions
1680
1681 vfild => {
1682         state     => "exc_pinned",
1683         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1684         outs      => [ "res", "M" ],
1685         ins       => [ "base", "index", "mem" ],
1686         latency   => 4,
1687         units     => [ "VFP" ],
1688         attr_type => "ia32_x87_attr_t",
1689 },
1690
1691 l_vfild => {
1692         cmp_attr  => "return 1;",
1693         outs      => [ "res", "M" ],
1694         arity     => 2,
1695 },
1696
1697 vfist => {
1698         state     => "exc_pinned",
1699         reg_req   => { in => [ "gp", "gp", "none", "vfp", "fpcw" ] },
1700         ins       => [ "base", "index", "mem", "val", "fpcw" ],
1701         latency   => 4,
1702         units     => [ "VFP" ],
1703         mode      => "mode_M",
1704         attr_type => "ia32_x87_attr_t",
1705 },
1706
1707 l_vfist => {
1708         cmp_attr  => "return 1;",
1709         state     => "exc_pinned",
1710         arity     => 3,
1711         mode      => "mode_M",
1712 },
1713
1714
1715 # constants
1716
1717 vfldz => {
1718         irn_flags => "R",
1719         reg_req   => { out => [ "vfp" ] },
1720         latency   => 4,
1721         units     => [ "VFP" ],
1722         mode      => "mode_E",
1723         attr_type => "ia32_x87_attr_t",
1724 },
1725
1726 vfld1 => {
1727         irn_flags => "R",
1728         reg_req   => { out => [ "vfp" ] },
1729         latency   => 4,
1730         units     => [ "VFP" ],
1731         mode      => "mode_E",
1732         attr_type => "ia32_x87_attr_t",
1733 },
1734
1735 vfldpi => {
1736         irn_flags => "R",
1737         reg_req   => { out => [ "vfp" ] },
1738         latency   => 4,
1739         units     => [ "VFP" ],
1740         mode      => "mode_E",
1741         attr_type => "ia32_x87_attr_t",
1742 },
1743
1744 vfldln2 => {
1745         irn_flags => "R",
1746         reg_req   => { out => [ "vfp" ] },
1747         latency   => 4,
1748         units     => [ "VFP" ],
1749         mode      => "mode_E",
1750         attr_type => "ia32_x87_attr_t",
1751 },
1752
1753 vfldlg2 => {
1754         irn_flags => "R",
1755         reg_req   => { out => [ "vfp" ] },
1756         latency   => 4,
1757         units     => [ "VFP" ],
1758         mode      => "mode_E",
1759         attr_type => "ia32_x87_attr_t",
1760 },
1761
1762 vfldl2t => {
1763         irn_flags => "R",
1764         reg_req   => { out => [ "vfp" ] },
1765         latency   => 4,
1766         units     => [ "VFP" ],
1767         mode      => "mode_E",
1768         attr_type => "ia32_x87_attr_t",
1769 },
1770
1771 vfldl2e => {
1772         irn_flags => "R",
1773         reg_req   => { out => [ "vfp" ] },
1774         latency   => 4,
1775         units     => [ "VFP" ],
1776         mode      => "mode_E",
1777         attr_type => "ia32_x87_attr_t",
1778 },
1779
1780 # other
1781
1782 vFucomFnstsw => {
1783 # we can't allow to rematerialize this node so we don't have
1784 #  accidently produce Phi(Fucom, Fucom(ins_permuted))
1785 #       irn_flags => "R",
1786         reg_req   => { in => [ "vfp", "vfp" ], out => [ "eax" ] },
1787         ins       => [ "left", "right" ],
1788         outs      => [ "flags" ],
1789         attr      => "int ins_permuted",
1790         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1791         latency   => 3,
1792         units     => [ "VFP" ],
1793         attr_type => "ia32_x87_attr_t",
1794         mode      => $mode_gp
1795 },
1796
1797 vFucomi => {
1798         irn_flags => "R",
1799         reg_req   => { in => [ "vfp", "vfp" ], out => [ "eflags" ] },
1800         ins       => [ "left", "right" ],
1801         outs      => [ "flags" ],
1802         attr      => "int ins_permuted",
1803         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1804         latency   => 3,
1805         units     => [ "VFP" ],
1806         attr_type => "ia32_x87_attr_t",
1807         mode      => $mode_gp
1808 },
1809
1810 vFtstFnstsw => {
1811 #       irn_flags => "R",
1812         reg_req   => { in => [ "vfp" ], out => [ "eax" ] },
1813         ins       => [ "left" ],
1814         outs      => [ "flags" ],
1815         attr      => "int ins_permuted",
1816         init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
1817         latency   => 3,
1818         units     => [ "VFP" ],
1819         attr_type => "ia32_x87_attr_t",
1820         mode      => $mode_gp
1821 },
1822
1823 Sahf => {
1824         irn_flags => "R",
1825         reg_req   => { in => [ "eax" ], out => [ "eflags" ] },
1826         ins       => [ "val" ],
1827         outs      => [ "flags" ],
1828         emit      => '. sahf',
1829         units     => [ "GP" ],
1830         mode      => $mode_flags,
1831 },
1832
1833 #------------------------------------------------------------------------#
1834 #       ___ _____    __ _             _                     _            #
1835 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1836 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1837 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1838 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1839 #------------------------------------------------------------------------#
1840
1841 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1842 #       are swapped, we work this around in the emitter...
1843
1844 fadd => {
1845         op_flags  => "R",
1846         rd_constructor => "NONE",
1847         reg_req   => { },
1848         emit      => '. fadd%XM %x87_binop',
1849         attr_type => "ia32_x87_attr_t",
1850 },
1851
1852 faddp => {
1853         op_flags  => "R",
1854         rd_constructor => "NONE",
1855         reg_req   => { },
1856         emit      => '. faddp%XM %x87_binop',
1857         attr_type => "ia32_x87_attr_t",
1858 },
1859
1860 fmul => {
1861         op_flags  => "R",
1862         rd_constructor => "NONE",
1863         reg_req   => { },
1864         emit      => '. fmul%XM %x87_binop',
1865         attr_type => "ia32_x87_attr_t",
1866 },
1867
1868 fmulp => {
1869         op_flags  => "R",
1870         rd_constructor => "NONE",
1871         reg_req   => { },
1872         emit      => '. fmulp%XM %x87_binop',,
1873         attr_type => "ia32_x87_attr_t",
1874 },
1875
1876 fsub => {
1877         op_flags  => "R",
1878         rd_constructor => "NONE",
1879         reg_req   => { },
1880         emit      => '. fsub%XM %x87_binop',
1881         attr_type => "ia32_x87_attr_t",
1882 },
1883
1884 fsubp => {
1885         op_flags  => "R",
1886         rd_constructor => "NONE",
1887         reg_req   => { },
1888 # see note about gas bugs
1889         emit      => '. fsubrp%XM %x87_binop',
1890         attr_type => "ia32_x87_attr_t",
1891 },
1892
1893 fsubr => {
1894         op_flags  => "R",
1895         rd_constructor => "NONE",
1896         irn_flags => "R",
1897         reg_req   => { },
1898         emit      => '. fsubr%XM %x87_binop',
1899         attr_type => "ia32_x87_attr_t",
1900 },
1901
1902 fsubrp => {
1903         op_flags  => "R",
1904         rd_constructor => "NONE",
1905         irn_flags => "R",
1906         reg_req   => { },
1907 # see note about gas bugs
1908         emit      => '. fsubp%XM %x87_binop',
1909         attr_type => "ia32_x87_attr_t",
1910 },
1911
1912 fprem => {
1913         op_flags  => "R",
1914         rd_constructor => "NONE",
1915         reg_req   => { },
1916         emit      => '. fprem1',
1917         attr_type => "ia32_x87_attr_t",
1918 },
1919
1920 # this node is just here, to keep the simulator running
1921 # we can omit this when a fprem simulation function exists
1922 fpremp => {
1923         op_flags  => "R",
1924         rd_constructor => "NONE",
1925         reg_req   => { },
1926         emit      => '. fprem1',
1927         attr_type => "ia32_x87_attr_t",
1928 },
1929
1930 fdiv => {
1931         op_flags  => "R",
1932         rd_constructor => "NONE",
1933         reg_req   => { },
1934         emit      => '. fdiv%XM %x87_binop',
1935         attr_type => "ia32_x87_attr_t",
1936 },
1937
1938 fdivp => {
1939         op_flags  => "R",
1940         rd_constructor => "NONE",
1941         reg_req   => { },
1942 # see note about gas bugs
1943         emit      => '. fdivrp%XM %x87_binop',
1944         attr_type => "ia32_x87_attr_t",
1945 },
1946
1947 fdivr => {
1948         op_flags  => "R",
1949         rd_constructor => "NONE",
1950         reg_req   => { },
1951         emit      => '. fdivr%XM %x87_binop',
1952         attr_type => "ia32_x87_attr_t",
1953 },
1954
1955 fdivrp => {
1956         op_flags  => "R",
1957         rd_constructor => "NONE",
1958         reg_req   => { },
1959 # see note about gas bugs
1960         emit      => '. fdivp%XM %x87_binop',
1961         attr_type => "ia32_x87_attr_t",
1962 },
1963
1964 fabs => {
1965         op_flags  => "R",
1966         rd_constructor => "NONE",
1967         reg_req   => { },
1968         emit      => '. fabs',
1969         attr_type => "ia32_x87_attr_t",
1970 },
1971
1972 fchs => {
1973         op_flags  => "R|K",
1974         rd_constructor => "NONE",
1975         reg_req   => { },
1976         emit      => '. fchs',
1977         attr_type => "ia32_x87_attr_t",
1978 },
1979
1980 # x87 Load and Store
1981
1982 fld => {
1983         rd_constructor => "NONE",
1984         op_flags  => "R|L|F",
1985         state     => "exc_pinned",
1986         reg_req   => { },
1987         emit      => '. fld%XM %AM',
1988         attr_type => "ia32_x87_attr_t",
1989 },
1990
1991 fst => {
1992         rd_constructor => "NONE",
1993         op_flags  => "R|L|F",
1994         state     => "exc_pinned",
1995         reg_req   => { },
1996         emit      => '. fst%XM %AM',
1997         mode      => "mode_M",
1998         attr_type => "ia32_x87_attr_t",
1999 },
2000
2001 fstp => {
2002         rd_constructor => "NONE",
2003         op_flags  => "R|L|F",
2004         state     => "exc_pinned",
2005         reg_req   => { },
2006         emit      => '. fstp%XM %AM',
2007         mode      => "mode_M",
2008         attr_type => "ia32_x87_attr_t",
2009 },
2010
2011 # Conversions
2012
2013 fild => {
2014         op_flags  => "R",
2015         rd_constructor => "NONE",
2016         reg_req   => { },
2017         emit      => '. fild%M %AM',
2018         attr_type => "ia32_x87_attr_t",
2019 },
2020
2021 fist => {
2022         op_flags  => "R",
2023         state     => "exc_pinned",
2024         rd_constructor => "NONE",
2025         reg_req   => { },
2026         emit      => '. fist%M %AM',
2027         mode      => "mode_M",
2028         attr_type => "ia32_x87_attr_t",
2029 },
2030
2031 fistp => {
2032         op_flags  => "R",
2033         state     => "exc_pinned",
2034         rd_constructor => "NONE",
2035         reg_req   => { },
2036         emit      => '. fistp%M %AM',
2037         mode      => "mode_M",
2038         attr_type => "ia32_x87_attr_t",
2039 },
2040
2041 # constants
2042
2043 fldz => {
2044         op_flags  => "R|c|K",
2045         irn_flags => "R",
2046         reg_req   => { out => [ "vfp" ] },
2047         emit      => '. fldz',
2048         attr_type => "ia32_x87_attr_t",
2049 },
2050
2051 fld1 => {
2052         op_flags  => "R|c|K",
2053         irn_flags => "R",
2054         reg_req   => { out => [ "vfp" ] },
2055         emit      => '. fld1',
2056         attr_type => "ia32_x87_attr_t",
2057 },
2058
2059 fldpi => {
2060         op_flags  => "R|c|K",
2061         irn_flags => "R",
2062         reg_req   => { out => [ "vfp" ] },
2063         emit      => '. fldpi',
2064         attr_type => "ia32_x87_attr_t",
2065 },
2066
2067 fldln2 => {
2068         op_flags  => "R|c|K",
2069         irn_flags => "R",
2070         reg_req   => { out => [ "vfp" ] },
2071         emit      => '. fldln2',
2072         attr_type => "ia32_x87_attr_t",
2073 },
2074
2075 fldlg2 => {
2076         op_flags  => "R|c|K",
2077         irn_flags => "R",
2078         reg_req   => { out => [ "vfp" ] },
2079         emit      => '. fldlg2',
2080         attr_type => "ia32_x87_attr_t",
2081 },
2082
2083 fldl2t => {
2084         op_flags  => "R|c|K",
2085         irn_flags => "R",
2086         reg_req   => { out => [ "vfp" ] },
2087         emit      => '. fldll2t',
2088         attr_type => "ia32_x87_attr_t",
2089 },
2090
2091 fldl2e => {
2092         op_flags  => "R|c|K",
2093         irn_flags => "R",
2094         reg_req   => { out => [ "vfp" ] },
2095         emit      => '. fldl2e',
2096         attr_type => "ia32_x87_attr_t",
2097 },
2098
2099 # fxch, fpush, fpop
2100 # Note that it is NEVER allowed to do CSE on these nodes
2101 # Moreover, note the virtual register requierements!
2102
2103 fxch => {
2104         op_flags  => "R|K",
2105         reg_req   => { },
2106         cmp_attr  => "return 1;",
2107         emit      => '. fxch %X0',
2108         attr_type => "ia32_x87_attr_t",
2109         mode      => "mode_ANY",
2110 },
2111
2112 fpush => {
2113         op_flags  => "R|K",
2114         reg_req   => {},
2115         cmp_attr  => "return 1;",
2116         emit      => '. fld %X0',
2117         attr_type => "ia32_x87_attr_t",
2118         mode      => "mode_ANY",
2119 },
2120
2121 fpushCopy => {
2122         op_flags  => "R",
2123         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2124         cmp_attr  => "return 1;",
2125         emit      => '. fld %X0',
2126         attr_type => "ia32_x87_attr_t",
2127 },
2128
2129 fpop => {
2130         op_flags  => "K",
2131         reg_req   => { },
2132         cmp_attr  => "return 1;",
2133         emit      => '. fstp %X0',
2134         attr_type => "ia32_x87_attr_t",
2135         mode      => "mode_ANY",
2136 },
2137
2138 ffreep => {
2139         op_flags  => "K",
2140         reg_req   => { },
2141         cmp_attr  => "return 1;",
2142         emit      => '. ffreep %X0',
2143         attr_type => "ia32_x87_attr_t",
2144         mode      => "mode_ANY",
2145 },
2146
2147 emms => {
2148         op_flags  => "K",
2149         reg_req   => { },
2150         cmp_attr  => "return 1;",
2151         emit      => '. emms',
2152         attr_type => "ia32_x87_attr_t",
2153         mode      => "mode_ANY",
2154 },
2155
2156 femms => {
2157         op_flags  => "K",
2158         reg_req   => { },
2159         cmp_attr  => "return 1;",
2160         emit      => '. femms',
2161         attr_type => "ia32_x87_attr_t",
2162         mode      => "mode_ANY",
2163 },
2164
2165 # compare
2166
2167 FucomFnstsw => {
2168         reg_req   => { },
2169         emit      => ". fucom %X1\n".
2170                      ". fnstsw",
2171         attr_type => "ia32_x87_attr_t",
2172 },
2173
2174 FucompFnstsw => {
2175         reg_req   => { },
2176         emit      => ". fucomp %X1\n".
2177                      ". fnstsw",
2178         attr_type => "ia32_x87_attr_t",
2179 },
2180
2181 FucomppFnstsw => {
2182         reg_req   => { },
2183         emit      => ". fucompp\n".
2184                      ". fnstsw",
2185         attr_type => "ia32_x87_attr_t",
2186 },
2187
2188 Fucomi => {
2189         reg_req   => { },
2190         emit      => '. fucomi %X1',
2191         attr_type => "ia32_x87_attr_t",
2192 },
2193
2194 Fucompi => {
2195         reg_req   => { },
2196         emit      => '. fucompi %X1',
2197         attr_type => "ia32_x87_attr_t",
2198 },
2199
2200 FtstFnstsw => {
2201         reg_req   => { },
2202         emit      => ". ftst\n".
2203                      ". fnstsw",
2204         attr_type => "ia32_x87_attr_t",
2205 },
2206
2207
2208 # -------------------------------------------------------------------------------- #
2209 #  ____ ____  _____                  _                               _             #
2210 # / ___/ ___|| ____| __   _____  ___| |_ ___  _ __   _ __   ___   __| | ___  ___   #
2211 # \___ \___ \|  _|   \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __|  #
2212 #  ___) |__) | |___   \ V /  __/ (__| || (_) | |    | | | | (_) | (_| |  __/\__ \  #
2213 # |____/____/|_____|   \_/ \___|\___|\__\___/|_|    |_| |_|\___/ \__,_|\___||___/  #
2214 #                                                                                  #
2215 # -------------------------------------------------------------------------------- #
2216
2217
2218 # Spilling and reloading of SSE registers, hardcoded, not generated #
2219
2220 xxLoad => {
2221         op_flags  => "L|F",
2222         state     => "exc_pinned",
2223         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2224         emit      => '. movdqu %D0, %AM',
2225         outs      => [ "res", "M" ],
2226         units     => [ "SSE" ],
2227 },
2228
2229 xxStore => {
2230         op_flags => "L|F",
2231         state    => "exc_pinned",
2232         reg_req  => { in => [ "gp", "gp", "none", "xmm" ] },
2233         ins      => [ "base", "index", "mem", "val" ],
2234         emit     => '. movdqu %binop',
2235         units    => [ "SSE" ],
2236         mode     => "mode_M",
2237 },
2238
2239 ); # end of %nodes
2240
2241 # Include the generated SIMD node specification written by the SIMD optimization
2242 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2243 unless ($return = do $my_script_name) {
2244         warn "couldn't parse $my_script_name: $@" if $@;
2245         warn "couldn't do $my_script_name: $!"    unless defined $return;
2246         warn "couldn't run $my_script_name"       unless $return;
2247 }