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