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