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