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