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