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