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