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