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