558581385b511e974aa27bef724234e769dba15d
[libfirm] / ir / be / ia32 / ia32_spec.pl
1 # Creation: 2005/10/19
2 # $Id$
3 # This is the specification for the ia32 assembler Firm-operations
4
5 use File::Basename;
6
7 $new_emit_syntax = 1;
8 my $myname = $0;
9
10 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
11 $arch = "ia32";
12
13 # The node description is done as a perl hash initializer with the
14 # following structure:
15 #
16 # %nodes = (
17 #
18 # <op-name> => {
19 #   op_flags  => "N|L|C|X|I|F|Y|H|c|K",
20 #   irn_flags => "R|N|I|S"
21 #   arity     => "0|1|2|3 ... |variable|dynamic|any",
22 #   state     => "floats|pinned|mem_pinned|exc_pinned",
23 #   args      => [
24 #                    { type => "type 1", name => "name 1" },
25 #                    { type => "type 2", name => "name 2" },
26 #                    ...
27 #                  ],
28 #   comment   => "any comment for constructor",
29 #   reg_req   => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 #   cmp_attr  => "c source code for comparing node attributes",
31 #   emit      => "emit code with templates",
32 #   attr      => "attitional attribute arguments for constructor"
33 #   init_attr => "emit attribute initialization template"
34 #   rd_constructor => "c source code which constructs an ir_node"
35 #   latency   => "latency of this operation (can be float)"
36 #   attr_type => "name of the attribute struct",
37 # },
38 #
39 # ... # (all nodes you need to describe)
40 #
41 # ); # close the %nodes initializer
42
43 # op_flags: flags for the operation, OPTIONAL (default is "N")
44 # the op_flags correspond to the firm irop_flags:
45 #   N   irop_flag_none
46 #   L   irop_flag_labeled
47 #   C   irop_flag_commutative
48 #   X   irop_flag_cfopcode
49 #   I   irop_flag_ip_cfopcode
50 #   F   irop_flag_fragile
51 #   Y   irop_flag_forking
52 #   H   irop_flag_highlevel
53 #   c   irop_flag_constlike
54 #   K   irop_flag_keep
55 #
56 # irn_flags: special node flags, OPTIONAL (default is 0)
57 # following irn_flags are supported:
58 #   R   rematerializeable
59 #   N   not spillable
60 #   I   ignore for register allocation
61 #   S   modifies stack pointer
62 #
63 # state: state of the operation, OPTIONAL (default is "floats")
64 #
65 # arity: arity of the operation, MUST NOT BE OMITTED
66 #
67 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
68 #        are always the first 3 arguments and are always autmatically
69 #        created)
70 #        If this key is missing the following arguments will be created:
71 #        for i = 1 .. arity: ir_node *op_i
72 #        ir_mode *mode
73 #
74 # outs:  if a node defines more than one output, the names of the projections
75 #        nodes having outs having automatically the mode mode_T
76 #        One can also annotate some flags for each out, additional to irn_flags.
77 #        They are separated from name with a colon ':', and concatenated by pipe '|'
78 #        Only I and S are available at the moment (same meaning as in irn_flags).
79 #        example: [ "frame:I", "stack:I|S", "M" ]
80 #
81 # comment: OPTIONAL comment for the node constructor
82 #
83 # rd_constructor: for every operation there will be a
84 #      new_rd_<arch>_<op-name> function with the arguments from above
85 #      which creates the ir_node corresponding to the defined operation
86 #      you can either put the complete source code of this function here
87 #
88 #      This key is OPTIONAL. If omitted, the following constructor will
89 #      be created:
90 #      if (!op_<arch>_<op-name>) assert(0);
91 #      for i = 1 to arity
92 #         set in[i] = op_i
93 #      done
94 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
95 #      return res
96 #
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
98 #
99 # latency: the latency of the operation, default is 1
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 => "eax", type => 1 },
114                 { name => "edx", type => 1 },
115                 { name => "ebx", type => 2 },
116                 { name => "ecx", type => 1 },
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" }
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 | 16 },
151                 { name => "vf1", type => 1 | 16 },
152                 { name => "vf2", type => 1 | 16 },
153                 { name => "vf3", type => 1 | 16 },
154                 { name => "vf4", type => 1 | 16 },
155                 { name => "vf5", type => 1 | 16 },
156                 { name => "vf6", type => 1 | 16 },
157                 { name => "vf7", type => 1 | 16 },
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" }
172         ],
173         fp_cw => [      # the floating point control word
174                 { name => "fpcw", type => 4 | 32},
175                 { mode => "mode_fpcw" }
176         ],
177         flags => [
178                 { name => "eflags", type => 4 },
179                 { mode => "mode_Iu" }
180         ],
181         fp_sw => [
182                 { name => "fpsw", type => 4 },
183                 { mode => "mode_Hu" }
184         ],
185 ); # %reg_classes
186
187 %flags = (
188         CF  => { reg => "eflags", bit => 0 },
189         PF  => { reg => "eflags", bit => 2 },
190         AF  => { reg => "eflags", bit => 4 },
191         ZF  => { reg => "eflags", bit => 6 },
192         SF  => { reg => "eflags", bit => 7 },
193         TF  => { reg => "eflags", bit => 8 },
194         IF  => { reg => "eflags", bit => 9 },
195         DF  => { reg => "eflags", bit => 10 },
196         OF  => { reg => "eflags", bit => 11 },
197         IOPL0 => { reg => "eflags", bit => 12 },
198         IOPL1 => { reg => "eflags", bit => 13 },
199         NT  => { reg => "eflags", bit => 14 },
200         RF  => { reg => "eflags", bit => 16 },
201         VM  => { reg => "eflags", bit => 17 },
202         AC  => { reg => "eflags", bit => 18 },
203         VIF => { reg => "eflags", bit => 19 },
204         VIP => { reg => "eflags", bit => 20 },
205         ID  => { reg => "eflags", bit => 21 },
206
207         FP_IE => { reg => "fpsw", bit => 0 },
208         FP_DE => { reg => "fpsw", bit => 1 },
209         FP_ZE => { reg => "fpsw", bit => 2 },
210         FP_OE => { reg => "fpsw", bit => 3 },
211         FP_UE => { reg => "fpsw", bit => 4 },
212         FP_PE => { reg => "fpsw", bit => 5 },
213         FP_SF => { reg => "fpsw", bit => 6 },
214         FP_ES => { reg => "fpsw", bit => 7 },
215         FP_C0 => { reg => "fpsw", bit => 8 },
216         FP_C1 => { reg => "fpsw", bit => 9 },
217         FP_C2 => { reg => "fpsw", bit => 10 },
218         FP_TOP0 => { reg => "fpsw", bit => 11 },
219         FP_TOP1 => { reg => "fpsw", bit => 12 },
220         FP_TOP2 => { reg => "fpsw", bit => 13 },
221         FP_C3 => { reg => "fpsw", bit => 14 },
222         FP_B  => { reg => "fpsw", bit => 15 },
223
224         FP_IM => { reg => "fpcw", bit => 0 },
225         FP_DM => { reg => "fpcw", bit => 1 },
226         FP_ZM => { reg => "fpcw", bit => 2 },
227         FP_OM => { reg => "fpcw", bit => 3 },
228         FP_UM => { reg => "fpcw", bit => 4 },
229         FP_PM => { reg => "fpcw", bit => 5 },
230         FP_PC0 => { reg => "fpcw", bit => 8 },
231         FP_PC1 => { reg => "fpcw", bit => 9 },
232         FP_RC0 => { reg => "fpcw", bit => 10 },
233         FP_RC1 => { reg => "fpcw", bit => 11 },
234         FP_X  => { reg => "fpcw", bit => 12 }
235 ); # %flags
236
237 %cpu = (
238         GP     => [ 1, "GP_EAX", "GP_EBX", "GP_ECX", "GP_EDX", "GP_ESI", "GP_EDI", "GP_EBP" ],
239         SSE    => [ 1, "SSE_XMM0", "SSE_XMM1", "SSE_XMM2", "SSE_XMM3", "SSE_XMM4", "SSE_XMM5", "SSE_XMM6", "SSE_XMM7" ],
240         VFP    => [ 1, "VFP_VF0", "VFP_VF1", "VFP_VF2", "VFP_VF3", "VFP_VF4", "VFP_VF5", "VFP_VF6", "VFP_VF7" ],
241         BRANCH => [ 1, "BRANCH1", "BRANCH2" ],
242 ); # %cpu
243
244 %vliw = (
245         bundle_size       => 1,
246         bundels_per_cycle => 1
247 ); # vliw
248
249 %emit_templates = (
250         S0 => "${arch}_emit_source_register(env, node, 0);",
251         S1 => "${arch}_emit_source_register(env, node, 1);",
252         S2 => "${arch}_emit_source_register(env, node, 2);",
253         S3 => "${arch}_emit_source_register(env, node, 3);",
254         S4 => "${arch}_emit_source_register(env, node, 4);",
255         S5 => "${arch}_emit_source_register(env, node, 5);",
256         SB1 => "${arch}_emit_8bit_source_register(env, node, 1);",
257         SB2 => "${arch}_emit_8bit_source_register(env, node, 2);",
258         SW0 => "${arch}_emit_16bit_source_register(env, node, 0);",
259         SI0 => "${arch}_emit_source_register_or_immediate(env, node, 0);",
260         SI1 => "${arch}_emit_source_register_or_immediate(env, node, 1);",
261         SI2 => "${arch}_emit_source_register_or_immediate(env, node, 2);",
262         SI3 => "${arch}_emit_source_register_or_immediate(env, node, 3);",
263         D0 => "${arch}_emit_dest_register(env, node, 0);",
264         D1 => "${arch}_emit_dest_register(env, node, 1);",
265         D2 => "${arch}_emit_dest_register(env, node, 2);",
266         D3 => "${arch}_emit_dest_register(env, node, 3);",
267         D4 => "${arch}_emit_dest_register(env, node, 4);",
268         D5 => "${arch}_emit_dest_register(env, node, 5);",
269         X0 => "${arch}_emit_x87_name(env, node, 0);",
270         X1 => "${arch}_emit_x87_name(env, node, 1);",
271         X2 => "${arch}_emit_x87_name(env, node, 2);",
272         SE => "${arch}_emit_extend_suffix(env, get_ia32_ls_mode(node));",
273         ME => "if(get_mode_size_bits(get_ia32_ls_mode(node)) != 32)\n
274                    ia32_emit_mode_suffix(env, node);",
275         M  => "${arch}_emit_mode_suffix(env, node);",
276         XM => "${arch}_emit_x87_mode_suffix(env, node);",
277         XXM => "${arch}_emit_xmm_mode_suffix(env, node);",
278         XSD => "${arch}_emit_xmm_mode_suffix_s(env, node);",
279         AM => "${arch}_emit_am(env, node);",
280         unop0 => "${arch}_emit_unop(env, node, 0);",
281         unop1 => "${arch}_emit_unop(env, node, 1);",
282         unop2 => "${arch}_emit_unop(env, node, 2);",
283         unop3 => "${arch}_emit_unop(env, node, 3);",
284         unop4 => "${arch}_emit_unop(env, node, 4);",
285         DAM0  => "${arch}_emit_am_or_dest_register(env, node, 0);",
286         DAM1  => "${arch}_emit_am_or_dest_register(env, node, 0);",
287         binop => "${arch}_emit_binop(env, node);",
288         x87_binop => "${arch}_emit_x87_binop(env, node);",
289 );
290
291 #--------------------------------------------------#
292 #                        _                         #
293 #                       (_)                        #
294 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
295 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
296 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
297 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
298 #                                      | |         #
299 #                                      |_|         #
300 #--------------------------------------------------#
301
302 $default_attr_type = "ia32_attr_t";
303 $default_copy_attr = "ia32_copy_attr";
304
305 sub ia32_custom_init_attr {
306         my $node = shift;
307         my $name = shift;
308         my $res = "";
309         if(defined($node->{modified_flags})) {
310                 $res .= "\t/*attr->data.flags |= arch_irn_flags_modify_flags;*/\n";
311         }
312         if(defined($node->{am})) {
313                 my $am = $node->{am};
314                 if($am eq "full,binary") {
315                         $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_binary);";
316                 } elsif($am eq "full,unary") {
317                         $res .= "\tset_ia32_am_support(res, ia32_am_Full, ia32_am_unary);";
318                 } elsif($am eq "source,binary") {
319                         $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_binary);";
320                 } elsif($am eq "dest,unary") {
321                         $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_unary);";
322                 } elsif($am eq "dest,binary") {
323                         $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_binary);";
324                 } elsif($am eq "dest,ternary") {
325                         $res .= "\tset_ia32_am_support(res, ia32_am_Dest, ia32_am_ternary);";
326                 } elsif($am eq "source,ternary") {
327                         $res .= "\tset_ia32_am_support(res, ia32_am_Source, ia32_am_ternary);";
328                 } elsif($am eq "none") {
329                         # nothing to do
330                 } else {
331                         die("Invalid address mode '$am' specified on op $name");
332                 }
333         }
334         return $res;
335 }
336 $custom_init_attr_func = \&ia32_custom_init_attr;
337
338 %init_attr = (
339         ia32_attr_t     => "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
340         ia32_x87_attr_t =>
341                 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
342                 "\tinit_ia32_x87_attributes(res);",
343         ia32_asm_attr_t =>
344                 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
345                 "\tinit_ia32_x87_attributes(res);".
346                 "\tinit_ia32_asm_attributes(res);",
347         ia32_immediate_attr_t =>
348                 "\tinit_ia32_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);\n".
349                 "\tinit_ia32_immediate_attributes(res, symconst, symconst_sign, offset);"
350 );
351
352 %compare_attr = (
353         ia32_attr_t           => "ia32_compare_nodes_attr",
354         ia32_x87_attr_t       => "ia32_compare_x87_attr",
355         ia32_asm_attr_t       => "ia32_compare_asm_attr",
356         ia32_immediate_attr_t => "ia32_compare_immediate_attr",
357 );
358
359 %operands = (
360 );
361
362 $mode_xmm     = "mode_E";
363 $mode_gp      = "mode_Iu";
364 $mode_fpcw    = "mode_fpcw";
365 $status_flags = [ "CF", "PF", "AF", "ZF", "SF", "OF" ];
366 $fpcw_flags   = [ "FP_IM", "FP_DM", "FP_ZM", "FP_OM", "FP_UM", "FP_PM",
367                   "FP_PC0", "FP_PC1", "FP_RC0", "FP_RC1", "FP_X" ];
368
369 %nodes = (
370
371 Immediate => {
372         state     => "pinned",
373         op_flags  => "c",
374         irn_flags => "I",
375         reg_req   => { out => [ "gp_NOREG" ] },
376         attr      => "ir_entity *symconst, int symconst_sign, long offset",
377         attr_type => "ia32_immediate_attr_t",
378         latency   => 0,
379         mode      => $mode_gp,
380 },
381
382 Asm => {
383         mode      => "mode_T",
384         arity     => "variable",
385         out_arity => "variable",
386         attr_type => "ia32_asm_attr_t",
387         latency   => 100,
388 },
389
390 ProduceVal => {
391         op_flags  => "c",
392         irn_flags => "R",
393         reg_req   => { out => [ "gp" ] },
394         emit      => "",
395         units     => [ ],
396         latency   => 0,
397         mode      => $mode_gp,
398         cmp_attr  => "return 1;",
399 },
400
401 #-----------------------------------------------------------------#
402 #  _       _                                         _            #
403 # (_)     | |                                       | |           #
404 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
405 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
406 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
407 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
408 #                   __/ |                                         #
409 #                  |___/                                          #
410 #-----------------------------------------------------------------#
411
412 # commutative operations
413
414 # NOTE:
415 # All nodes supporting Addressmode have 5 INs:
416 # 1 - base    r1 == NoReg in case of no AM or no base
417 # 2 - index   r2 == NoReg in case of no AM or no index
418 # 3 - op1     r3 == always present
419 # 4 - op2     r4 == NoReg in case of immediate operation
420 # 5 - mem     NoMem in case of no AM otherwise it takes the mem from the Load
421
422 Add => {
423         irn_flags => "R",
424         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
425         ins       => [ "base", "index", "left", "right", "mem" ],
426         emit      => '. add%M %binop',
427         am        => "full,binary",
428         am        => "full,binary",
429         units     => [ "GP" ],
430         mode      => $mode_gp,
431         modified_flags => $status_flags
432 },
433
434 AddMem => {
435         irn_flags => "R",
436         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
437         ins       => [ "base", "index", "val", "mem" ],
438         emit      => ". add%M %SI2, %AM",
439         units     => [ "GP" ],
440         mode      => "mode_M",
441         modified_flags => $status_flags
442 },
443
444 Adc => {
445         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
446         emit      => '. adc%M %binop',
447         am        => "full,binary",
448         units     => [ "GP" ],
449         mode      => $mode_gp,
450         modified_flags => $status_flags
451 },
452
453 Add64Bit => {
454         irn_flags => "R",
455         arity     => 4,
456         reg_req   => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
457         emit      => '
458 . movl %S0, %D0
459 . movl %S1, %D1
460 . addl %SI2, %D0
461 . adcl %SI3, %D1
462 ',
463         outs      => [ "low_res", "high_res" ],
464         units     => [ "GP" ],
465         modified_flags => $status_flags
466 },
467
468 l_Add => {
469         op_flags  => "C",
470         irn_flags => "R",
471         cmp_attr  => "return 1;",
472         arity     => 2,
473 },
474
475 l_Adc => {
476         op_flags  => "C",
477         cmp_attr  => "return 1;",
478         arity     => 2,
479 },
480
481 Mul => {
482         # we should not rematrialize this node. It produces 2 results and has
483         # very strict constrains
484         reg_req   => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
485         emit      => '. mul%M %unop3',
486         outs      => [ "EAX", "EDX", "M" ],
487         ins       => [ "base", "index", "val_high", "val_low", "mem" ],
488         am        => "source,binary",
489         am        => "source,binary",
490         latency   => 10,
491         units     => [ "GP" ],
492         modified_flags => $status_flags
493 },
494
495 l_Mul => {
496         # we should not rematrialize this node. It produces 2 results and has
497         # very strict constrains
498         op_flags  => "C",
499         cmp_attr  => "return 1;",
500         outs      => [ "EAX", "EDX", "M" ],
501         arity     => 2
502 },
503
504 IMul => {
505         irn_flags => "R",
506         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
507         ins       => [ "base", "index", "left", "right", "mem" ],
508         emit      => '. imul%M %binop',
509         am        => "source,binary",
510         latency   => 5,
511         units     => [ "GP" ],
512         mode      => $mode_gp,
513         modified_flags => $status_flags
514 },
515
516 IMul1OP => {
517         irn_flags => "R",
518         reg_req   => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
519         emit      => '. imul%M %unop3',
520         outs      => [ "EAX", "EDX", "M" ],
521         ins       => [ "base", "index", "val_high", "val_low", "mem" ],
522         am        => "source,binary",
523         latency   => 5,
524         units     => [ "GP" ],
525         modified_flags => $status_flags
526 },
527
528 l_IMul => {
529         # we should not rematrialize this node. It produces 2 results and has
530         # very strict constrains
531         op_flags  => "C",
532         cmp_attr  => "return 1;",
533         outs      => [ "EAX", "EDX", "M" ],
534         arity     => 2
535 },
536
537 And => {
538         irn_flags => "R",
539         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
540         ins       => [ "base", "index", "left", "right", "mem" ],
541         am        => "full,binary",
542         emit      => '. and%M %binop',
543         units     => [ "GP" ],
544         mode      => $mode_gp,
545         modified_flags => $status_flags
546 },
547
548 AndMem => {
549         irn_flags => "R",
550         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
551         emit      => '. and%M %SI2, %AM',
552         units     => [ "GP" ],
553         mode      => "mode_M",
554         modified_flags => $status_flags
555 },
556
557 Or => {
558         irn_flags => "R",
559         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
560         ins       => [ "base", "index", "left", "right", "mem" ],
561         am        => "full,binary",
562         emit      => '. or%M %binop',
563         units     => [ "GP" ],
564         mode      => $mode_gp,
565         modified_flags => $status_flags
566 },
567
568 OrMem => {
569         irn_flags => "R",
570         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
571         ins       => [ "base", "index", "val", "mem" ],
572         emit      => '. or%M %SI2, %AM',
573         units     => [ "GP" ],
574         mode      => "mode_M",
575         modified_flags => $status_flags
576 },
577
578 Xor => {
579         irn_flags => "R",
580         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
581         ins       => [ "base", "index", "left", "right", "mem" ],
582         am        => "full,binary",
583         emit      => '. xor%M %binop',
584         units     => [ "GP" ],
585         mode      => $mode_gp,
586         modified_flags => $status_flags
587 },
588
589 XorMem => {
590         irn_flags => "R",
591         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
592         ins       => [ "base", "index", "val", "mem" ],
593         emit      => '. xor%M %SI2, %AM',
594         units     => [ "GP" ],
595         mode      => "mode_M",
596         modified_flags => $status_flags
597 },
598
599 l_Xor => {
600         op_flags  => "C",
601         cmp_attr  => "return 1;",
602         arity     => 2,
603         modified_flags => $status_flags
604 },
605
606 # not commutative operations
607
608 Sub => {
609         irn_flags => "R",
610         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
611         ins       => [ "base", "index", "left", "right", "mem" ],
612         am        => "full,binary",
613         emit      => '. sub%M %binop',
614         units     => [ "GP" ],
615         mode      => $mode_gp,
616         modified_flags => $status_flags
617 },
618
619 SubMem => {
620         irn_flags => "R",
621         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
622         ins       => [ "base", "index", "val", "mem" ],
623         emit      => '. sub%M %SI2, %AM',
624         units     => [ "GP" ],
625         mode      => 'mode_M',
626         modified_flags => $status_flags
627 },
628
629 Sbb => {
630         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3 !in_r4" ] },
631         ins       => [ "base", "index", "left", "right", "mem" ],
632         am        => "full,binary",
633         emit      => '. sbb%M %binop',
634         units     => [ "GP" ],
635         mode      => $mode_gp,
636         modified_flags => $status_flags
637 },
638
639 Sub64Bit => {
640         irn_flags => "R",
641         arity     => 4,
642         reg_req   => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
643         emit      => '
644 . movl %S0, %D0
645 . movl %S1, %D1
646 . subl %SI2, %D0
647 . sbbl %SI3, %D1
648 ',
649         outs      => [ "low_res", "high_res" ],
650         units     => [ "GP" ],
651         modified_flags => $status_flags
652 },
653
654 l_Sub => {
655         irn_flags => "R",
656         cmp_attr  => "return 1;",
657         arity     => 2,
658 },
659
660 l_Sbb => {
661         cmp_attr  => "return 1;",
662         arity     => 2,
663 },
664
665 IDiv => {
666         op_flags  => "F|L",
667         state     => "exc_pinned",
668         reg_req   => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ],
669                        out => [ "eax", "edx", "none" ] },
670         ins       => [ "base", "index", "left_low", "left_high", "right", "mem" ],
671         outs      => [ "div_res", "mod_res", "M" ],
672         attr      => "ia32_op_flavour_t dm_flav",
673         am        => "source,ternary",
674         init_attr => "attr->data.op_flav = dm_flav;",
675         emit      => ". idiv%M %unop4",
676         latency   => 25,
677         units     => [ "GP" ],
678         modified_flags => $status_flags
679 },
680
681 Div => {
682         op_flags  => "F|L",
683         state     => "exc_pinned",
684         reg_req   => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ],
685                        out => [ "eax", "edx", "none" ] },
686         ins       => [ "base", "index", "left_low", "left_high", "right", "mem" ],
687         outs      => [ "div_res", "mod_res", "M" ],
688         attr      => "ia32_op_flavour_t dm_flav",
689         am        => "source,ternary",
690         init_attr => "attr->data.op_flav = dm_flav;",
691         emit      => ". div%M %unop4",
692         latency   => 25,
693         units     => [ "GP" ],
694         modified_flags => $status_flags
695 },
696
697 Shl => {
698         irn_flags => "R",
699         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
700         ins       => [ "left", "right" ],
701         am        => "dest,binary",
702         am        => "dest,binary",
703         emit      => '. shl %SB1, %S0',
704         units     => [ "GP" ],
705         mode      => $mode_gp,
706         modified_flags => $status_flags
707 },
708
709 ShlMem => {
710         irn_flags => "R",
711         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
712         ins       => [ "base", "index", "count", "mem" ],
713         emit      => '. shl%M %SI2, %AM',
714         units     => [ "GP" ],
715         mode      => "mode_M",
716         modified_flags => $status_flags
717 },
718
719 l_ShlDep => {
720         cmp_attr  => "return 1;",
721         # value, cnt, dependency
722         arity     => 3
723 },
724
725 ShlD => {
726         # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shl
727         #
728         # Out requirements is: different from all in
729         # This is because, out must be different from LowPart and ShiftCount.
730         # We could say "!ecx !in_r4" but it can occur, that all values live through
731         # this Shift and the only value dying is the ShiftCount. Then there would be a
732         # register missing, as result must not be ecx and all other registers are
733         # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
734         # (and probably never will). So we create artificial interferences of the result
735         # with all inputs, so the spiller can always assure a free register.
736         # reg_req   => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
737
738         irn_flags => "R",
739         reg_req   => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
740         ins       => [ "left_high", "left_low", "right" ],
741         am        => "dest,ternary",
742         emit      => '. shld%M %SB2, %S1, %S0',
743         latency   => 6,
744         units     => [ "GP" ],
745         mode      => $mode_gp,
746         modified_flags => $status_flags
747 },
748
749 l_ShlD => {
750         cmp_attr  => "return 1;",
751         arity     => 3,
752 },
753
754 Shr => {
755         irn_flags => "R",
756         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
757         ins       => [ "val", "count" ],
758         am        => "dest,binary",
759         emit      => '. shr %SB1, %S0',
760         units     => [ "GP" ],
761         mode      => $mode_gp,
762         modified_flags => $status_flags
763 },
764
765 ShrMem => {
766         irn_flags => "R",
767         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
768         ins       => [ "base", "index", "count", "mem" ],
769         emit      => '. shr%M %SI2, %AM',
770         units     => [ "GP" ],
771         mode      => "mode_M",
772         modified_flags => $status_flags
773 },
774
775 l_ShrDep => {
776         cmp_attr  => "return 1;",
777         # value, cnt, dependency
778         arity     => 3
779 },
780
781 ShrD => {
782         # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shr
783         #
784         # Out requirements is: different from all in
785         # This is because, out must be different from LowPart and ShiftCount.
786         # We could say "!ecx !in_r4" but it can occur, that all values live through
787         # this Shift and the only value dying is the ShiftCount. Then there would be a
788         # register missing, as result must not be ecx and all other registers are
789         # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
790         # (and probably never will). So we create artificial interferences of the result
791         # with all inputs, so the spiller can always assure a free register.
792         # reg_req   => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
793
794         irn_flags => "R",
795         reg_req   => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
796         ins       => [ "left_high", "left_low", "right" ],
797         am        => "dest,ternary",
798         emit      => '. shrd%M %SB2, %S1, %S0',
799         latency   => 6,
800         units     => [ "GP" ],
801         mode      => $mode_gp,
802         modified_flags => $status_flags
803 },
804
805 l_ShrD => {
806         cmp_attr  => "return 1;",
807         arity     => 3
808 },
809
810 Sar => {
811         irn_flags => "R",
812         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
813         ins       => [ "val", "count" ],
814         am        => "dest,binary",
815         emit      => '. sar %SB1, %S0',
816         units     => [ "GP" ],
817         mode      => $mode_gp,
818         modified_flags => $status_flags
819 },
820
821 SarMem => {
822         irn_flags => "R",
823         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
824         ins       => [ "base", "index", "count", "mem" ],
825         emit      => '. sar%M %SI2, %AM',
826         units     => [ "GP" ],
827         mode      => "mode_M",
828         modified_flags => $status_flags
829 },
830
831 l_Sar => {
832         cmp_attr  => "return 1;",
833         # value, cnt
834         arity     => 2
835 },
836
837 l_SarDep => {
838         cmp_attr  => "return 1;",
839         # value, cnt, dependency
840         arity     => 3
841 },
842
843 Ror => {
844         irn_flags => "R",
845         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
846         ins       => [ "val", "count" ],
847         am        => "dest,binary",
848         emit      => '. ror %SB1, %S0',
849         units     => [ "GP" ],
850         mode      => $mode_gp,
851         modified_flags => $status_flags
852 },
853
854 RorMem => {
855         irn_flags => "R",
856         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
857         ins       => [ "base", "index", "count", "mem" ],
858         emit      => '. ror%M %SI2, %AM',
859         units     => [ "GP" ],
860         mode      => "mode_M",
861         modified_flags => $status_flags
862 },
863
864 Rol => {
865         irn_flags => "R",
866         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
867         ins       => [ "val", "count" ],
868         am        => "dest,binary",
869         emit      => '. rol %SB1, %S0',
870         units     => [ "GP" ],
871         mode      => $mode_gp,
872         modified_flags => $status_flags
873 },
874
875 RolMem => {
876         irn_flags => "R",
877         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
878         ins       => [ "base", "index", "count", "mem" ],
879         emit      => '. rol%M %SI2, %AM',
880         units     => [ "GP" ],
881         mode      => "mode_M",
882         modified_flags => $status_flags
883 },
884
885 # unary operations
886
887 Neg => {
888         irn_flags => "R",
889         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
890         emit      => '. neg %S0',
891         ins       => [ "val" ],
892         am        => "dest,unary",
893         units     => [ "GP" ],
894         mode      => $mode_gp,
895         modified_flags => $status_flags
896 },
897
898 NegMem => {
899         irn_flags => "R",
900         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
901         ins       => [ "base", "index", "mem" ],
902         emit      => '. neg%M %AM',
903         units     => [ "GP" ],
904         mode      => "mode_M",
905         modified_flags => $status_flags
906 },
907
908 Minus64Bit => {
909         irn_flags => "R",
910         reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
911         outs      => [ "low_res", "high_res" ],
912         units     => [ "GP" ],
913         modified_flags => $status_flags
914 },
915
916
917 l_Neg => {
918         cmp_attr  => "return 1;",
919         arity     => 1,
920 },
921
922 Inc => {
923         irn_flags => "R",
924         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
925         am        => "dest,unary",
926         emit      => '. inc %S0',
927         units     => [ "GP" ],
928         mode      => $mode_gp,
929         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
930 },
931
932 IncMem => {
933         irn_flags => "R",
934         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
935         ins       => [ "base", "index", "mem" ],
936         emit      => '. inc%M %AM',
937         units     => [ "GP" ],
938         mode      => "mode_M",
939         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
940 },
941
942 Dec => {
943         irn_flags => "R",
944         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
945         am        => "dest,unary",
946         emit      => '. dec %S0',
947         units     => [ "GP" ],
948         mode      => $mode_gp,
949         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
950 },
951
952 DecMem => {
953         irn_flags => "R",
954         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
955         ins       => [ "base", "index", "mem" ],
956         emit      => '. dec%M %AM',
957         units     => [ "GP" ],
958         mode      => "mode_M",
959         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
960 },
961
962 Not => {
963         irn_flags => "R",
964         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
965         ins       => [ "val" ],
966         am        => "dest,unary",
967         emit      => '. not %S0',
968         units     => [ "GP" ],
969         mode      => $mode_gp,
970         modified_flags => []
971 },
972
973 NotMem => {
974         irn_flags => "R",
975         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
976         ins       => [ "base", "index", "mem" ],
977         emit      => '. not%M %AM',
978         units     => [ "GP" ],
979         mode      => "mode_M",
980         modified_flags => [],
981 },
982
983 # other operations
984
985 CmpJmp => {
986         state     => "pinned",
987         op_flags  => "L|X|Y",
988         reg_req   => { in  => [ "gp", "gp", "gp", "gp", "none" ],
989                        out => [ "none", "none"] },
990         ins       => [ "base", "index", "left", "right", "mem" ],
991         outs      => [ "false", "true" ],
992         attr      => "long pnc",
993         am        => "source,binary",
994         init_attr => "attr->pn_code = pnc;",
995         latency   => 3,
996         units     => [ "BRANCH" ],
997 },
998
999 CmpJmp8Bit => {
1000         state     => "pinned",
1001         op_flags  => "L|X|Y",
1002         reg_req   => { in  => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1003                                 "none" ],
1004                        out => [ "none", "none"] },
1005         ins       => [ "base", "index", "left", "right", "mem" ],
1006         outs      => [ "false", "true" ],
1007         attr      => "long pnc",
1008         am        => "source,binary",
1009         init_attr => "attr->pn_code = pnc;",
1010         latency   => 3,
1011         units     => [ "BRANCH" ],
1012 },
1013
1014 TestJmp => {
1015         state     => "pinned",
1016         op_flags  => "L|X|Y",
1017         reg_req   => { in  => [ "gp", "gp", "gp", "gp", "none" ],
1018                        out => [ "none", "none" ] },
1019         ins       => [ "base", "index", "left", "right", "mem" ],
1020         outs      => [ "false", "true" ],
1021         attr      => "long pnc",
1022         am        => "source,binary",
1023         init_attr => "attr->pn_code = pnc;",
1024         latency   => 3,
1025         units     => [ "BRANCH" ],
1026 },
1027
1028 TestJmp8Bit => {
1029         state     => "pinned",
1030         op_flags  => "L|X|Y",
1031         reg_req   => { in  => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1032                                 "none" ],
1033                        out => [ "none", "none" ] },
1034         ins       => [ "base", "index", "left", "right", "mem" ],
1035         outs      => [ "false", "true" ],
1036         attr      => "long pnc",
1037         am        => "source,binary",
1038         init_attr => "attr->pn_code = pnc;",
1039         latency   => 3,
1040         units     => [ "BRANCH" ],
1041 },
1042
1043 SwitchJmp => {
1044         state     => "pinned",
1045         op_flags  => "L|X|Y",
1046         reg_req   => { in => [ "gp" ], out => [ "none" ] },
1047         latency   => 3,
1048         units     => [ "BRANCH" ],
1049         mode      => "mode_T",
1050 },
1051
1052 IJmp => {
1053         state     => "pinned",
1054         op_flags  => "X",
1055         reg_req   => { in => [ "gp" ] },
1056         emit      => '. jmp *%S0',
1057         units     => [ "BRANCH" ],
1058         mode      => "mode_X",
1059         modified_flags => []
1060 },
1061
1062 Const => {
1063         op_flags  => "c",
1064         irn_flags => "R",
1065         reg_req   => { out => [ "gp" ] },
1066         units     => [ "GP" ],
1067         attr      => "ir_entity *symconst, int symconst_sign, long offset",
1068         attr_type => "ia32_immediate_attr_t",
1069         mode      => $mode_gp,
1070 },
1071
1072 Unknown_GP => {
1073         state     => "pinned",
1074         op_flags  => "c",
1075         irn_flags => "I",
1076         reg_req   => { out => [ "gp_UKNWN" ] },
1077         units     => [],
1078         emit      => "",
1079         mode      => $mode_gp
1080 },
1081
1082 Unknown_VFP => {
1083         state     => "pinned",
1084         op_flags  => "c",
1085         irn_flags => "I",
1086         reg_req   => { out => [ "vfp_UKNWN" ] },
1087         units     => [],
1088         emit      => "",
1089         mode      => "mode_E",
1090         attr_type => "ia32_x87_attr_t",
1091 },
1092
1093 Unknown_XMM => {
1094         state     => "pinned",
1095         op_flags  => "c",
1096         irn_flags => "I",
1097         reg_req   => { out => [ "xmm_UKNWN" ] },
1098         units     => [],
1099         emit      => "",
1100         mode      => "mode_E"
1101 },
1102
1103 NoReg_GP => {
1104         state     => "pinned",
1105         op_flags  => "c",
1106         irn_flags => "I",
1107         reg_req   => { out => [ "gp_NOREG" ] },
1108         units     => [],
1109         emit      => "",
1110         mode      => $mode_gp
1111 },
1112
1113 NoReg_VFP => {
1114         state     => "pinned",
1115         op_flags  => "c",
1116         irn_flags => "I",
1117         reg_req   => { out => [ "vfp_NOREG" ] },
1118         units     => [],
1119         emit      => "",
1120         mode      => "mode_E",
1121         attr_type => "ia32_x87_attr_t",
1122 },
1123
1124 NoReg_XMM => {
1125         state     => "pinned",
1126         op_flags  => "c",
1127         irn_flags => "I",
1128         reg_req   => { out => [ "xmm_NOREG" ] },
1129         units     => [],
1130         emit      => "",
1131         mode      => "mode_E"
1132 },
1133
1134 ChangeCW => {
1135         state     => "pinned",
1136         op_flags  => "c",
1137         irn_flags => "I",
1138         reg_req   => { out => [ "fp_cw" ] },
1139         mode      => $mode_fpcw,
1140         latency   => 3,
1141         units     => [ "GP" ],
1142         modified_flags => $fpcw_flags
1143 },
1144
1145 FldCW => {
1146         op_flags  => "L|F",
1147         state     => "pinned",
1148         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1149         ins       => [ "base", "index", "mem" ],
1150         latency   => 5,
1151         emit      => ". fldcw %AM",
1152         mode      => $mode_fpcw,
1153         units     => [ "GP" ],
1154         modified_flags => $fpcw_flags
1155 },
1156
1157 FnstCW => {
1158         op_flags  => "L|F",
1159         state     => "pinned",
1160         reg_req   => { in => [ "gp", "gp", "fp_cw", "none" ], out => [ "none" ] },
1161         ins       => [ "base", "index", "fpcw", "mem" ],
1162         latency   => 5,
1163         emit      => ". fnstcw %AM",
1164         mode      => "mode_M",
1165         units     => [ "GP" ],
1166 },
1167
1168 Cltd => {
1169         # we should not rematrialize this node. It produces 2 results and has
1170         # very strict constrains
1171         reg_req   => { in => [ "eax", "edx" ], out => [ "edx" ] },
1172         ins       => [ "val", "globbered" ],
1173         emit      => '. cltd',
1174         mode      => $mode_gp,
1175         units     => [ "GP" ],
1176 },
1177
1178 # Load / Store
1179 #
1180 # Note that we add additional latency values depending on address mode, so a
1181 # lateny of 0 for load is correct
1182
1183 Load => {
1184         op_flags  => "L|F",
1185         state     => "exc_pinned",
1186         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1187         ins       => [ "base", "index", "mem" ],
1188         outs      => [ "res", "M" ],
1189         latency   => 0,
1190         emit      => ". mov%SE%ME%.l %AM, %D0",
1191         units     => [ "GP" ],
1192 },
1193
1194 l_Load => {
1195         op_flags  => "L|F",
1196         cmp_attr  => "return 1;",
1197         outs      => [ "res", "M" ],
1198         arity     => 2,
1199 },
1200
1201 l_Store => {
1202         op_flags  => "L|F",
1203         cmp_attr  => "return 1;",
1204         state     => "exc_pinned",
1205         arity     => 3,
1206         mode      => "mode_M",
1207 },
1208
1209 Store => {
1210         op_flags  => "L|F",
1211         state     => "exc_pinned",
1212         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
1213         ins       => [ "base", "index", "val", "mem" ],
1214         emit      => '. mov%M %SI2, %AM',
1215         latency   => 2,
1216         units     => [ "GP" ],
1217         mode      => "mode_M",
1218 },
1219
1220 Store8Bit => {
1221         op_flags  => "L|F",
1222         state     => "exc_pinned",
1223         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => ["none" ] },
1224         emit      => '. mov%M %SB2, %AM',
1225         latency   => 2,
1226         units     => [ "GP" ],
1227         mode      => "mode_M",
1228 },
1229
1230 Lea => {
1231         irn_flags => "R",
1232         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
1233         ins       => [ "base", "index" ],
1234         emit      => '. leal %AM, %D0',
1235         latency   => 2,
1236         units     => [ "GP" ],
1237         mode      => $mode_gp,
1238         modified_flags => [],
1239 },
1240
1241 Push => {
1242         reg_req   => { in => [ "gp", "gp", "gp", "esp", "none" ], out => [ "esp", "none" ] },
1243         emit      => '. push%M %unop2',
1244         ins       => [ "base", "index", "val", "stack", "mem" ],
1245         outs      => [ "stack:I|S", "M" ],
1246         am        => "source,binary",
1247         latency   => 2,
1248         units     => [ "GP" ],
1249         modified_flags => [],
1250 },
1251
1252 Pop => {
1253         reg_req   => { in => [ "gp", "gp", "esp", "none" ], out => [ "esp", "gp", "none" ] },
1254         emit      => '. pop%M %DAM1',
1255         outs      => [ "stack:I|S", "res", "M" ],
1256         ins       => [ "base", "index", "stack", "mem" ],
1257         am        => "dest,unary",
1258         latency   => 3, # Pop is more expensive than Push on Athlon
1259         units     => [ "GP" ],
1260         modified_flags => [],
1261 },
1262
1263 Enter => {
1264         reg_req   => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1265         emit      => '. enter',
1266         outs      => [ "frame:I", "stack:I|S", "M" ],
1267         latency   => 15,
1268         units     => [ "GP" ],
1269 },
1270
1271 Leave => {
1272         reg_req   => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1273         emit      => '. leave',
1274         outs      => [ "frame:I", "stack:I|S" ],
1275         latency   => 3,
1276         units     => [ "GP" ],
1277 },
1278
1279 AddSP => {
1280         irn_flags => "I",
1281         state     => "pinned",
1282         reg_req   => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "none" ] },
1283         am        => "source,binary",
1284         emit      => '. addl %binop',
1285         outs      => [ "stack:S", "M" ],
1286         units     => [ "GP" ],
1287         modified_flags => $status_flags
1288 },
1289
1290 SubSP => {
1291 #irn_flags => "I",
1292         state     => "pinned",
1293         reg_req   => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "gp", "none" ] },
1294         am        => "source,binary",
1295         emit      => ". subl %binop\n".
1296                      ". movl %%esp, %D1",
1297         outs      => [ "stack:I|S", "addr", "M" ],
1298         units     => [ "GP" ],
1299         modified_flags => $status_flags
1300 },
1301
1302 LdTls => {
1303         irn_flags => "R",
1304         reg_req   => { out => [ "gp" ] },
1305         units     => [ "GP" ],
1306 },
1307
1308 # the int instruction
1309 int => {
1310         reg_req   => { in => [ "gp" ], out => [ "none" ] },
1311         mode      => "mode_M",
1312         emit      => '. int %SI0',
1313         units     => [ "GP" ],
1314         cmp_attr  => "return 1;",
1315 },
1316
1317
1318 #-----------------------------------------------------------------------------#
1319 #   _____ _____ ______    __ _             _                     _            #
1320 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
1321 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1322 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1323 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1324 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1325 #-----------------------------------------------------------------------------#
1326
1327 xZero => {
1328         irn_flags => "R",
1329         reg_req   => { out => [ "xmm" ] },
1330         emit      => '. xorp%XSD %D1, %D1',
1331         latency   => 3,
1332         units     => [ "SSE" ],
1333         mode      => "mode_E",
1334 },
1335
1336 # commutative operations
1337
1338 xAdd => {
1339         irn_flags => "R",
1340         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1341         emit      => '. add%XXM %binop',
1342         latency   => 4,
1343         units     => [ "SSE" ],
1344         mode      => "mode_E",
1345 },
1346
1347 xMul => {
1348         irn_flags => "R",
1349         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1350         emit      => '. mul%XXM %binop',
1351         latency   => 4,
1352         units     => [ "SSE" ],
1353         mode      => "mode_E",
1354 },
1355
1356 xMax => {
1357         irn_flags => "R",
1358         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1359         emit      => '. max%XXM %binop',
1360         latency   => 2,
1361         units     => [ "SSE" ],
1362         mode      => "mode_E",
1363 },
1364
1365 xMin => {
1366         irn_flags => "R",
1367         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1368         emit      => '. min%XXM %binop',
1369         latency   => 2,
1370         units     => [ "SSE" ],
1371         mode      => "mode_E",
1372 },
1373
1374 xAnd => {
1375         irn_flags => "R",
1376         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1377         emit      => '. andp%XSD %binop',
1378         latency   => 3,
1379         units     => [ "SSE" ],
1380         mode      => "mode_E",
1381 },
1382
1383 xOr => {
1384         irn_flags => "R",
1385         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1386         emit      => '. orp%XSD %binop',
1387         units     => [ "SSE" ],
1388         mode      => "mode_E",
1389 },
1390
1391 xXor => {
1392         irn_flags => "R",
1393         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1394         emit      => '. xorp%XSD %binop',
1395         latency   => 3,
1396         units     => [ "SSE" ],
1397         mode      => "mode_E",
1398 },
1399
1400 # not commutative operations
1401
1402 xAndNot => {
1403         irn_flags => "R",
1404         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1405         emit      => '. andnp%XSD %binop',
1406         latency   => 3,
1407         units     => [ "SSE" ],
1408         mode      => "mode_E",
1409 },
1410
1411 xSub => {
1412         irn_flags => "R",
1413         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1414         emit      => '. sub%XXM %binop',
1415         latency   => 4,
1416         units     => [ "SSE" ],
1417         mode      => "mode_E",
1418 },
1419
1420 xDiv => {
1421         irn_flags => "R",
1422         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4", "none" ] },
1423         outs      => [ "res", "M" ],
1424         emit      => '. div%XXM %binop',
1425         latency   => 16,
1426         units     => [ "SSE" ],
1427 },
1428
1429 # other operations
1430
1431 xCmp => {
1432         irn_flags => "R",
1433         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1434         latency   => 3,
1435         units     => [ "SSE" ],
1436         mode      => "mode_E",
1437 },
1438
1439 xCmpJmp => {
1440         state     => "pinned",
1441         op_flags  => "L|X|Y",
1442         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "none", "none" ] },
1443         ins       => [ "base", "index", "left", "right", "mem" ],
1444         outs      => [ "false", "true" ],
1445         attr      => "long pnc",
1446         init_attr => "attr->pn_code = pnc;",
1447         latency   => 5,
1448         units     => [ "SSE" ],
1449 },
1450
1451 # Load / Store
1452
1453 xLoad => {
1454         op_flags  => "L|F",
1455         state     => "exc_pinned",
1456         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1457         emit      => '. mov%XXM %AM, %D0',
1458         attr      => "ir_mode *load_mode",
1459         init_attr => "attr->ls_mode = load_mode;",
1460         outs      => [ "res", "M" ],
1461         latency   => 0,
1462         units     => [ "SSE" ],
1463 },
1464
1465 xStore => {
1466         op_flags => "L|F",
1467         state    => "exc_pinned",
1468         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
1469         emit     => '. mov%XXM %S2, %AM',
1470         latency  => 0,
1471         units    => [ "SSE" ],
1472         mode     => "mode_M",
1473 },
1474
1475 xStoreSimple => {
1476         op_flags => "L|F",
1477         state    => "exc_pinned",
1478         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
1479         ins      => [ "base", "index", "val", "mem" ],
1480         emit     => '. mov%XXM %S2, %AM',
1481         latency  => 0,
1482         units    => [ "SSE" ],
1483         mode     => "mode_M",
1484 },
1485
1486 CvtSI2SS => {
1487         op_flags => "L|F",
1488         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1489         emit     => '. cvtsi2ss %D0, %AM',
1490         latency  => 2,
1491         units    => [ "SSE" ],
1492         mode     => $mode_xmm
1493 },
1494
1495 CvtSI2SD => {
1496         op_flags => "L|F",
1497         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1498         emit     => '. cvtsi2sd %unop2',
1499         latency  => 2,
1500         units    => [ "SSE" ],
1501         mode     => $mode_xmm
1502 },
1503
1504
1505 l_X87toSSE => {
1506         op_flags => "L|F",
1507         cmp_attr => "return 1;",
1508         arity    => 3,
1509 },
1510
1511 l_SSEtoX87 => {
1512         op_flags => "L|F",
1513         cmp_attr => "return 1;",
1514         arity    => 3,
1515 },
1516
1517 # CopyB
1518
1519 CopyB => {
1520         op_flags => "F|H",
1521         state    => "pinned",
1522         reg_req  => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1523         outs     => [ "DST", "SRC", "CNT", "M" ],
1524         units    => [ "GP" ],
1525         modified_flags => [ "DF" ]
1526 },
1527
1528 CopyB_i => {
1529         op_flags => "F|H",
1530         state    => "pinned",
1531         reg_req  => { in => [ "edi", "esi", "none" ], out => [  "edi", "esi", "none" ] },
1532         outs     => [ "DST", "SRC", "M" ],
1533         units    => [ "GP" ],
1534         modified_flags => [ "DF" ]
1535 },
1536
1537 # Conversions
1538
1539 Conv_I2I => {
1540         state     => "exc_pinned",
1541         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3", "none" ] },
1542         units     => [ "GP" ],
1543         ins       => [ "base", "index", "val", "mem" ],
1544         attr      => "ir_mode *smaller_mode",
1545         init_attr => "attr->ls_mode = smaller_mode;",
1546         mode      => $mode_gp,
1547         modified_flags => $status_flags
1548 },
1549
1550 Conv_I2I8Bit => {
1551         state     => "exc_pinned",
1552         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => [ "in_r3", "none" ] },
1553         ins       => [ "base", "index", "val", "mem" ],
1554         units     => [ "GP" ],
1555         attr      => "ir_mode *smaller_mode",
1556         init_attr => "attr->ls_mode = smaller_mode;",
1557         mode      => $mode_gp,
1558         modified_flags => $status_flags
1559 },
1560
1561 Conv_I2FP => {
1562         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1563         latency  => 10,
1564         units    => [ "SSE" ],
1565         mode     => "mode_E",
1566 },
1567
1568 Conv_FP2I => {
1569         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "gp", "none" ] },
1570         latency  => 10,
1571         units    => [ "SSE" ],
1572         mode     => $mode_gp,
1573 },
1574
1575 Conv_FP2FP => {
1576         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "xmm", "none" ] },
1577         latency  => 8,
1578         units    => [ "SSE" ],
1579         mode     => "mode_E",
1580 },
1581
1582 CmpCMov => {
1583         irn_flags => "R",
1584         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ], out => [ "in_r7" ] },
1585         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true", "val_false" ],
1586         attr      => "pn_Cmp pn_code",
1587         init_attr => "attr->pn_code = pn_code;",
1588         latency   => 2,
1589         units     => [ "GP" ],
1590         mode      => $mode_gp,
1591 },
1592
1593 CmpCMov8Bit => {
1594         irn_flags => "R",
1595         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ], out => [ "in_r7" ] },
1596         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true", "val_false" ],
1597         attr      => "pn_Cmp pn_code",
1598         init_attr => "attr->pn_code = pn_code;",
1599         latency   => 2,
1600         units     => [ "GP" ],
1601         mode      => $mode_gp,
1602 },
1603
1604 TestCMov => {
1605         irn_flags => "R",
1606         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ],
1607                        out => [ "in_r7" ] },
1608         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1609                        "val_false" ],
1610         attr      => "pn_Cmp pn_code",
1611         init_attr => "attr->pn_code = pn_code;",
1612         latency   => 2,
1613         units     => [ "GP" ],
1614         mode      => $mode_gp,
1615 },
1616
1617 TestCMov8Bit => {
1618         irn_flags => "R",
1619         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ],
1620                        out => [ "in_r7" ] },
1621         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1622                        "val_false" ],
1623         attr      => "pn_Cmp pn_code",
1624         init_attr => "attr->pn_code = pn_code;",
1625         latency   => 2,
1626         units     => [ "GP" ],
1627         mode      => $mode_gp,
1628 },
1629
1630 xCmpCMov => {
1631         irn_flags => "R",
1632         reg_req   => { in => [ "xmm", "xmm", "gp", "gp" ], out => [ "in_r4" ] },
1633         latency   => 5,
1634         units     => [ "SSE" ],
1635         mode      => $mode_gp,
1636 },
1637
1638 vfCmpCMov => {
1639         irn_flags => "R",
1640         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "gp", "gp" ],
1641                        out => [ "in_r7" ] },
1642         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1643                        "val_false" ],
1644         latency   => 10,
1645         units     => [ "VFP", "GP" ],
1646         mode      => $mode_gp,
1647         attr_type => "ia32_x87_attr_t",
1648 },
1649
1650 CmpSet => {
1651         irn_flags => "R",
1652         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ],
1653                        out => [ "eax ebx ecx edx" ] },
1654         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1655         attr      => "pn_Cmp pn_code",
1656         init_attr => "attr->pn_code = pn_code;",
1657         latency   => 2,
1658         units     => [ "GP" ],
1659         mode      => $mode_gp,
1660 },
1661
1662 CmpSet8Bit => {
1663         irn_flags => "R",
1664         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1665                                "none" ],
1666                        out => [ "eax ebx ecx edx" ] },
1667         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1668         attr      => "pn_Cmp pn_code",
1669         init_attr => "attr->pn_code = pn_code;",
1670         latency   => 2,
1671         units     => [ "GP" ],
1672         mode      => $mode_gp,
1673 },
1674
1675 TestSet => {
1676         irn_flags => "R",
1677         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ],
1678                        out => [ "eax ebx ecx edx" ] },
1679         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1680         attr      => "pn_Cmp pn_code",
1681         init_attr => "attr->pn_code = pn_code;",
1682         latency   => 2,
1683         units     => [ "GP" ],
1684         mode      => $mode_gp,
1685 },
1686
1687 TestSet8Bit => {
1688         irn_flags => "R",
1689         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1690                                "none" ],
1691                        out => [ "eax ebx ecx edx" ] },
1692         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1693         attr      => "pn_Cmp pn_code",
1694         init_attr => "attr->pn_code = pn_code;",
1695         latency   => 2,
1696         units     => [ "GP" ],
1697         mode      => $mode_gp,
1698 },
1699
1700 xCmpSet => {
1701         irn_flags => "R",
1702         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "eax ebx ecx edx" ] },
1703         latency   => 5,
1704         units     => [ "SSE" ],
1705         mode      => $mode_gp,
1706 },
1707
1708 vfCmpSet => {
1709         irn_flags => "R",
1710         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "eax ebx ecx edx" ] },
1711         latency   => 10,
1712         units     => [ "VFP" ],
1713         mode      => $mode_gp,
1714         attr_type => "ia32_x87_attr_t",
1715 },
1716
1717 vfCMov => {
1718         irn_flags => "R",
1719         reg_req   => { in => [ "vfp", "vfp", "vfp", "vfp" ], out => [ "vfp" ] },
1720         latency   => 10,
1721         units     => [ "VFP" ],
1722         mode      => "mode_E",
1723         attr_type => "ia32_x87_attr_t",
1724 },
1725
1726 #----------------------------------------------------------#
1727 #        _      _               _    __ _             _    #
1728 #       (_)    | |             | |  / _| |           | |   #
1729 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1730 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1731 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1732 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1733 #                 | |                                      #
1734 #  _ __   ___   __| | ___  ___                             #
1735 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1736 # | | | | (_) | (_| |  __/\__ \                            #
1737 # |_| |_|\___/ \__,_|\___||___/                            #
1738 #----------------------------------------------------------#
1739
1740 vfadd => {
1741         irn_flags => "R",
1742         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1743         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1744         latency   => 4,
1745         units     => [ "VFP" ],
1746         mode      => "mode_E",
1747         attr_type => "ia32_x87_attr_t",
1748 },
1749
1750 vfmul => {
1751         irn_flags => "R",
1752         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1753         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1754         latency   => 4,
1755         units     => [ "VFP" ],
1756         mode      => "mode_E",
1757         attr_type => "ia32_x87_attr_t",
1758 },
1759
1760 l_vfmul => {
1761         op_flags  => "C",
1762         cmp_attr  => "return 1;",
1763         arity     => 2,
1764 },
1765
1766 vfsub => {
1767         irn_flags => "R",
1768         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1769         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1770         latency   => 4,
1771         units     => [ "VFP" ],
1772         mode      => "mode_E",
1773         attr_type => "ia32_x87_attr_t",
1774 },
1775
1776 l_vfsub => {
1777         cmp_attr  => "return 1;",
1778         arity     => 2,
1779 },
1780
1781 vfdiv => {
1782         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp", "none" ] },
1783         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1784         outs      => [ "res", "M" ],
1785         latency   => 20,
1786         units     => [ "VFP" ],
1787         attr_type => "ia32_x87_attr_t",
1788 },
1789
1790 l_vfdiv => {
1791         cmp_attr  => "return 1;",
1792         outs      => [ "res", "M" ],
1793         arity     => 2,
1794 },
1795
1796 vfprem => {
1797         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1798         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1799         latency   => 20,
1800         units     => [ "VFP" ],
1801         mode      => "mode_E",
1802         attr_type => "ia32_x87_attr_t",
1803 },
1804
1805 l_vfprem => {
1806         cmp_attr  => "return 1;",
1807         arity     => 2,
1808 },
1809
1810 vfabs => {
1811         irn_flags => "R",
1812         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1813         ins       => [ "value" ],
1814         latency   => 2,
1815         units     => [ "VFP" ],
1816         mode      => "mode_E",
1817         attr_type => "ia32_x87_attr_t",
1818 },
1819
1820 vfchs => {
1821         irn_flags => "R",
1822         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1823         ins       => [ "value" ],
1824         latency   => 2,
1825         units     => [ "VFP" ],
1826         mode      => "mode_E",
1827         attr_type => "ia32_x87_attr_t",
1828 },
1829
1830 # virtual Load and Store
1831
1832 vfld => {
1833         op_flags  => "L|F",
1834         state     => "exc_pinned",
1835         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1836         ins       => [ "base", "index", "mem" ],
1837         outs      => [ "res", "M" ],
1838         attr      => "ir_mode *load_mode",
1839         init_attr => "attr->attr.ls_mode = load_mode;",
1840         latency   => 2,
1841         units     => [ "VFP" ],
1842         attr_type => "ia32_x87_attr_t",
1843 },
1844
1845 vfst => {
1846         op_flags  => "L|F",
1847         state     => "exc_pinned",
1848         reg_req   => { in => [ "gp", "gp", "vfp", "none" ] },
1849         ins       => [ "base", "index", "val", "mem" ],
1850         attr      => "ir_mode *store_mode",
1851         init_attr => "attr->attr.ls_mode = store_mode;",
1852         latency   => 2,
1853         units     => [ "VFP" ],
1854         mode      => "mode_M",
1855         attr_type => "ia32_x87_attr_t",
1856 },
1857
1858 # Conversions
1859
1860 vfild => {
1861         state     => "exc_pinned",
1862         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1863         outs      => [ "res", "M" ],
1864         ins       => [ "base", "index", "mem" ],
1865         latency   => 4,
1866         units     => [ "VFP" ],
1867         attr_type => "ia32_x87_attr_t",
1868 },
1869
1870 l_vfild => {
1871         cmp_attr  => "return 1;",
1872         outs      => [ "res", "M" ],
1873         arity     => 2,
1874 },
1875
1876 vfist => {
1877         state     => "exc_pinned",
1878         reg_req   => { in => [ "gp", "gp", "vfp", "fpcw", "none" ] },
1879         ins       => [ "base", "index", "val", "fpcw", "mem" ],
1880         latency   => 4,
1881         units     => [ "VFP" ],
1882         mode      => "mode_M",
1883         attr_type => "ia32_x87_attr_t",
1884 },
1885
1886 l_vfist => {
1887         cmp_attr  => "return 1;",
1888         state     => "exc_pinned",
1889         arity     => 3,
1890         mode      => "mode_M",
1891 },
1892
1893
1894 # constants
1895
1896 vfldz => {
1897         irn_flags => "R",
1898         reg_req   => { out => [ "vfp" ] },
1899         latency   => 4,
1900         units     => [ "VFP" ],
1901         mode      => "mode_E",
1902         attr_type => "ia32_x87_attr_t",
1903 },
1904
1905 vfld1 => {
1906         irn_flags => "R",
1907         reg_req   => { out => [ "vfp" ] },
1908         latency   => 4,
1909         units     => [ "VFP" ],
1910         mode      => "mode_E",
1911         attr_type => "ia32_x87_attr_t",
1912 },
1913
1914 vfldpi => {
1915         irn_flags => "R",
1916         reg_req   => { out => [ "vfp" ] },
1917         latency   => 4,
1918         units     => [ "VFP" ],
1919         mode      => "mode_E",
1920         attr_type => "ia32_x87_attr_t",
1921 },
1922
1923 vfldln2 => {
1924         irn_flags => "R",
1925         reg_req   => { out => [ "vfp" ] },
1926         latency   => 4,
1927         units     => [ "VFP" ],
1928         mode      => "mode_E",
1929         attr_type => "ia32_x87_attr_t",
1930 },
1931
1932 vfldlg2 => {
1933         irn_flags => "R",
1934         reg_req   => { out => [ "vfp" ] },
1935         latency   => 4,
1936         units     => [ "VFP" ],
1937         mode      => "mode_E",
1938         attr_type => "ia32_x87_attr_t",
1939 },
1940
1941 vfldl2t => {
1942         irn_flags => "R",
1943         reg_req   => { out => [ "vfp" ] },
1944         latency   => 4,
1945         units     => [ "VFP" ],
1946         mode      => "mode_E",
1947         attr_type => "ia32_x87_attr_t",
1948 },
1949
1950 vfldl2e => {
1951         irn_flags => "R",
1952         reg_req   => { out => [ "vfp" ] },
1953         latency   => 4,
1954         units     => [ "VFP" ],
1955         mode      => "mode_E",
1956         attr_type => "ia32_x87_attr_t",
1957 },
1958
1959 # other
1960
1961 vfCmpJmp => {
1962         state     => "pinned",
1963         op_flags  => "L|X|Y",
1964         reg_req   => { in => [ "vfp", "vfp" ], out => [ "none", "none", "eax" ] },
1965         ins       => [ "left", "right" ],
1966         outs      => [ "false", "true", "temp_reg_eax" ],
1967         attr      => "long pnc",
1968         init_attr => "attr->attr.pn_code = pnc;",
1969         latency   => 10,
1970         units     => [ "VFP" ],
1971         attr_type => "ia32_x87_attr_t",
1972 },
1973
1974 #------------------------------------------------------------------------#
1975 #       ___ _____    __ _             _                     _            #
1976 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1977 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1978 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1979 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1980 #------------------------------------------------------------------------#
1981
1982 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1983 #       are swapped, we work this around in the emitter...
1984
1985 fadd => {
1986         op_flags  => "R",
1987         rd_constructor => "NONE",
1988         reg_req   => { },
1989         emit      => '. fadd%XM %x87_binop',
1990         attr_type => "ia32_x87_attr_t",
1991 },
1992
1993 faddp => {
1994         op_flags  => "R",
1995         rd_constructor => "NONE",
1996         reg_req   => { },
1997         emit      => '. faddp%XM %x87_binop',
1998         attr_type => "ia32_x87_attr_t",
1999 },
2000
2001 fmul => {
2002         op_flags  => "R",
2003         rd_constructor => "NONE",
2004         reg_req   => { },
2005         emit      => '. fmul%XM %x87_binop',
2006         attr_type => "ia32_x87_attr_t",
2007 },
2008
2009 fmulp => {
2010         op_flags  => "R",
2011         rd_constructor => "NONE",
2012         reg_req   => { },
2013         emit      => '. fmulp%XM %x87_binop',,
2014         attr_type => "ia32_x87_attr_t",
2015 },
2016
2017 fsub => {
2018         op_flags  => "R",
2019         rd_constructor => "NONE",
2020         reg_req   => { },
2021         emit      => '. fsub%XM %x87_binop',
2022         attr_type => "ia32_x87_attr_t",
2023 },
2024
2025 fsubp => {
2026         op_flags  => "R",
2027         rd_constructor => "NONE",
2028         reg_req   => { },
2029 # see note about gas bugs
2030         emit      => '. fsubrp%XM %x87_binop',
2031         attr_type => "ia32_x87_attr_t",
2032 },
2033
2034 fsubr => {
2035         op_flags  => "R",
2036         rd_constructor => "NONE",
2037         irn_flags => "R",
2038         reg_req   => { },
2039         emit      => '. fsubr%XM %x87_binop',
2040         attr_type => "ia32_x87_attr_t",
2041 },
2042
2043 fsubrp => {
2044         op_flags  => "R",
2045         rd_constructor => "NONE",
2046         irn_flags => "R",
2047         reg_req   => { },
2048 # see note about gas bugs
2049         emit      => '. fsubp%XM %x87_binop',
2050         attr_type => "ia32_x87_attr_t",
2051 },
2052
2053 fprem => {
2054         op_flags  => "R",
2055         rd_constructor => "NONE",
2056         reg_req   => { },
2057         emit      => '. fprem1',
2058         attr_type => "ia32_x87_attr_t",
2059 },
2060
2061 # this node is just here, to keep the simulator running
2062 # we can omit this when a fprem simulation function exists
2063 fpremp => {
2064         op_flags  => "R",
2065         rd_constructor => "NONE",
2066         reg_req   => { },
2067         emit      => '. fprem1',
2068         attr_type => "ia32_x87_attr_t",
2069 },
2070
2071 fdiv => {
2072         op_flags  => "R",
2073         rd_constructor => "NONE",
2074         reg_req   => { },
2075         emit      => '. fdiv%XM %x87_binop',
2076         attr_type => "ia32_x87_attr_t",
2077 },
2078
2079 fdivp => {
2080         op_flags  => "R",
2081         rd_constructor => "NONE",
2082         reg_req   => { },
2083 # see note about gas bugs
2084         emit      => '. fdivrp%XM %x87_binop',
2085         attr_type => "ia32_x87_attr_t",
2086 },
2087
2088 fdivr => {
2089         op_flags  => "R",
2090         rd_constructor => "NONE",
2091         reg_req   => { },
2092         emit      => '. fdivr%XM %x87_binop',
2093         attr_type => "ia32_x87_attr_t",
2094 },
2095
2096 fdivrp => {
2097         op_flags  => "R",
2098         rd_constructor => "NONE",
2099         reg_req   => { },
2100 # see note about gas bugs
2101         emit      => '. fdivp%XM %x87_binop',
2102         attr_type => "ia32_x87_attr_t",
2103 },
2104
2105 fabs => {
2106         op_flags  => "R",
2107         rd_constructor => "NONE",
2108         reg_req   => { },
2109         emit      => '. fabs',
2110         attr_type => "ia32_x87_attr_t",
2111 },
2112
2113 fchs => {
2114         op_flags  => "R|K",
2115         rd_constructor => "NONE",
2116         reg_req   => { },
2117         emit      => '. fchs',
2118         attr_type => "ia32_x87_attr_t",
2119 },
2120
2121 # x87 Load and Store
2122
2123 fld => {
2124         rd_constructor => "NONE",
2125         op_flags  => "R|L|F",
2126         state     => "exc_pinned",
2127         reg_req   => { },
2128         emit      => '. fld%XM %AM',
2129         attr_type => "ia32_x87_attr_t",
2130 },
2131
2132 fst => {
2133         rd_constructor => "NONE",
2134         op_flags  => "R|L|F",
2135         state     => "exc_pinned",
2136         reg_req   => { },
2137         emit      => '. fst%XM %AM',
2138         mode      => "mode_M",
2139         attr_type => "ia32_x87_attr_t",
2140 },
2141
2142 fstp => {
2143         rd_constructor => "NONE",
2144         op_flags  => "R|L|F",
2145         state     => "exc_pinned",
2146         reg_req   => { },
2147         emit      => '. fstp%XM %AM',
2148         mode      => "mode_M",
2149         attr_type => "ia32_x87_attr_t",
2150 },
2151
2152 # Conversions
2153
2154 fild => {
2155         op_flags  => "R",
2156         rd_constructor => "NONE",
2157         reg_req   => { },
2158         emit      => '. fild%M %AM',
2159         attr_type => "ia32_x87_attr_t",
2160 },
2161
2162 fist => {
2163         op_flags  => "R",
2164         state     => "exc_pinned",
2165         rd_constructor => "NONE",
2166         reg_req   => { },
2167         emit      => '. fist%M %AM',
2168         mode      => "mode_M",
2169         attr_type => "ia32_x87_attr_t",
2170 },
2171
2172 fistp => {
2173         op_flags  => "R",
2174         state     => "exc_pinned",
2175         rd_constructor => "NONE",
2176         reg_req   => { },
2177         emit      => '. fistp%M %AM',
2178         mode      => "mode_M",
2179         attr_type => "ia32_x87_attr_t",
2180 },
2181
2182 # constants
2183
2184 fldz => {
2185         op_flags  => "R|c|K",
2186         irn_flags  => "R",
2187         reg_req   => { },
2188         emit      => '. fldz',
2189         attr_type => "ia32_x87_attr_t",
2190 },
2191
2192 fld1 => {
2193         op_flags  => "R|c|K",
2194         irn_flags  => "R",
2195         reg_req   => { },
2196         emit      => '. fld1',
2197         attr_type => "ia32_x87_attr_t",
2198 },
2199
2200 fldpi => {
2201         op_flags  => "R|c|K",
2202         irn_flags  => "R",
2203         reg_req   => { },
2204         emit      => '. fldpi',
2205         attr_type => "ia32_x87_attr_t",
2206 },
2207
2208 fldln2 => {
2209         op_flags  => "R|c|K",
2210         irn_flags  => "R",
2211         reg_req   => { },
2212         emit      => '. fldln2',
2213         attr_type => "ia32_x87_attr_t",
2214 },
2215
2216 fldlg2 => {
2217         op_flags  => "R|c|K",
2218         irn_flags  => "R",
2219         reg_req   => { },
2220         emit      => '. fldlg2',
2221         attr_type => "ia32_x87_attr_t",
2222 },
2223
2224 fldl2t => {
2225         op_flags  => "R|c|K",
2226         irn_flags  => "R",
2227         reg_req   => { },
2228         emit      => '. fldll2t',
2229         attr_type => "ia32_x87_attr_t",
2230 },
2231
2232 fldl2e => {
2233         op_flags  => "R|c|K",
2234         irn_flags  => "R",
2235         reg_req   => { },
2236         emit      => '. fldl2e',
2237         attr_type => "ia32_x87_attr_t",
2238 },
2239
2240 # fxch, fpush, fpop
2241 # Note that it is NEVER allowed to do CSE on these nodes
2242 # Moreover, note the virtual register requierements!
2243
2244 fxch => {
2245         op_flags  => "R|K",
2246         reg_req   => { },
2247         cmp_attr  => "return 1;",
2248         emit      => '. fxch %X0',
2249         attr_type => "ia32_x87_attr_t",
2250 },
2251
2252 fpush => {
2253         op_flags  => "R|K",
2254         reg_req   => {},
2255         cmp_attr  => "return 1;",
2256         emit      => '. fld %X0',
2257         attr_type => "ia32_x87_attr_t",
2258 },
2259
2260 fpushCopy => {
2261         op_flags  => "R",
2262         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2263         cmp_attr  => "return 1;",
2264         emit      => '. fld %X0',
2265         attr_type => "ia32_x87_attr_t",
2266 },
2267
2268 fpop => {
2269         op_flags  => "R|K",
2270         reg_req   => { },
2271         cmp_attr  => "return 1;",
2272         emit      => '. fstp %X0',
2273         attr_type => "ia32_x87_attr_t",
2274 },
2275
2276 # compare
2277
2278 fcomJmp => {
2279         op_flags  => "L|X|Y",
2280         reg_req   => { },
2281         attr_type => "ia32_x87_attr_t",
2282 },
2283
2284 fcompJmp => {
2285         op_flags  => "L|X|Y",
2286         reg_req   => { },
2287         attr_type => "ia32_x87_attr_t",
2288 },
2289
2290 fcomppJmp => {
2291         op_flags  => "L|X|Y",
2292         reg_req   => { },
2293         attr_type => "ia32_x87_attr_t",
2294 },
2295
2296 fcomrJmp => {
2297         op_flags  => "L|X|Y",
2298         reg_req   => { },
2299         attr_type => "ia32_x87_attr_t",
2300 },
2301
2302 fcomrpJmp => {
2303         op_flags  => "L|X|Y",
2304         reg_req   => { },
2305         attr_type => "ia32_x87_attr_t",
2306 },
2307
2308 fcomrppJmp => {
2309         op_flags  => "L|X|Y",
2310         reg_req   => { },
2311         attr_type => "ia32_x87_attr_t",
2312 },
2313
2314
2315 # -------------------------------------------------------------------------------- #
2316 #  ____ ____  _____                  _                               _             #
2317 # / ___/ ___|| ____| __   _____  ___| |_ ___  _ __   _ __   ___   __| | ___  ___   #
2318 # \___ \___ \|  _|   \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __|  #
2319 #  ___) |__) | |___   \ V /  __/ (__| || (_) | |    | | | | (_) | (_| |  __/\__ \  #
2320 # |____/____/|_____|   \_/ \___|\___|\__\___/|_|    |_| |_|\___/ \__,_|\___||___/  #
2321 #                                                                                  #
2322 # -------------------------------------------------------------------------------- #
2323
2324
2325 # Spilling and reloading of SSE registers, hardcoded, not generated #
2326
2327 xxLoad => {
2328         op_flags  => "L|F",
2329         state     => "exc_pinned",
2330         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2331         emit      => '. movdqu %D0, %AM',
2332         outs      => [ "res", "M" ],
2333         units     => [ "SSE" ],
2334 },
2335
2336 xxStore => {
2337         op_flags => "L|F",
2338         state    => "exc_pinned",
2339         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
2340         emit     => '. movdqu %binop',
2341         units    => [ "SSE" ],
2342         mode     => "mode_M",
2343 },
2344
2345 ); # end of %nodes
2346
2347 # Include the generated SIMD node specification written by the SIMD optimization
2348 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2349 unless ($return = do $my_script_name) {
2350         warn "couldn't parse $my_script_name: $@" if $@;
2351         warn "couldn't do $my_script_name: $!"    unless defined $return;
2352         warn "couldn't run $my_script_name"       unless $return;
2353 }