32c926d1b5cd61c62a37de9608f92b52c433ddd4
[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         units     => [ "GP" ],
429         mode      => $mode_gp,
430         modified_flags => $status_flags
431 },
432
433 AddMem => {
434         irn_flags => "R",
435         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
436         ins       => [ "base", "index", "val", "mem" ],
437         emit      => ". add%M %SI2, %AM",
438         units     => [ "GP" ],
439         mode      => "mode_M",
440         modified_flags => $status_flags
441 },
442
443 Adc => {
444         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "flags" ], out => [ "in_r3" ] },
445         ins       => [ "base", "index", "left", "right", "mem", "eflags" ],
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 Mul => {
469         # we should not rematrialize this node. It produces 2 results and has
470         # very strict constrains
471         reg_req   => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
472         emit      => '. mul%M %unop3',
473         outs      => [ "EAX", "EDX", "M" ],
474         ins       => [ "base", "index", "val_high", "val_low", "mem" ],
475         am        => "source,binary",
476         latency   => 10,
477         units     => [ "GP" ],
478         modified_flags => $status_flags
479 },
480
481 l_Mul => {
482         # we should not rematrialize this node. It produces 2 results and has
483         # very strict constrains
484         op_flags  => "C",
485         cmp_attr  => "return 1;",
486         outs      => [ "EAX", "EDX", "M" ],
487         arity     => 2
488 },
489
490 IMul => {
491         irn_flags => "R",
492         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
493         ins       => [ "base", "index", "left", "right", "mem" ],
494         emit      => '. imul%M %binop',
495         am        => "source,binary",
496         latency   => 5,
497         units     => [ "GP" ],
498         mode      => $mode_gp,
499         modified_flags => $status_flags
500 },
501
502 IMul1OP => {
503         irn_flags => "R",
504         reg_req   => { in => [ "gp", "gp", "eax", "gp", "none" ], out => [ "eax", "edx", "none" ] },
505         emit      => '. imul%M %unop3',
506         outs      => [ "EAX", "EDX", "M" ],
507         ins       => [ "base", "index", "val_high", "val_low", "mem" ],
508         am        => "source,binary",
509         latency   => 5,
510         units     => [ "GP" ],
511         modified_flags => $status_flags
512 },
513
514 l_IMul => {
515         # we should not rematrialize this node. It produces 2 results and has
516         # very strict constrains
517         op_flags  => "C",
518         cmp_attr  => "return 1;",
519         outs      => [ "EAX", "EDX", "M" ],
520         arity     => 2
521 },
522
523 And => {
524         irn_flags => "R",
525         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
526         ins       => [ "base", "index", "left", "right", "mem" ],
527         am        => "full,binary",
528         emit      => '. and%M %binop',
529         units     => [ "GP" ],
530         mode      => $mode_gp,
531         modified_flags => $status_flags
532 },
533
534 AndMem => {
535         irn_flags => "R",
536         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
537         emit      => '. and%M %SI2, %AM',
538         units     => [ "GP" ],
539         mode      => "mode_M",
540         modified_flags => $status_flags
541 },
542
543 Or => {
544         irn_flags => "R",
545         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
546         ins       => [ "base", "index", "left", "right", "mem" ],
547         am        => "full,binary",
548         emit      => '. or%M %binop',
549         units     => [ "GP" ],
550         mode      => $mode_gp,
551         modified_flags => $status_flags
552 },
553
554 OrMem => {
555         irn_flags => "R",
556         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
557         ins       => [ "base", "index", "val", "mem" ],
558         emit      => '. or%M %SI2, %AM',
559         units     => [ "GP" ],
560         mode      => "mode_M",
561         modified_flags => $status_flags
562 },
563
564 Xor => {
565         irn_flags => "R",
566         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
567         ins       => [ "base", "index", "left", "right", "mem" ],
568         am        => "full,binary",
569         emit      => '. xor%M %binop',
570         units     => [ "GP" ],
571         mode      => $mode_gp,
572         modified_flags => $status_flags
573 },
574
575 XorMem => {
576         irn_flags => "R",
577         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
578         ins       => [ "base", "index", "val", "mem" ],
579         emit      => '. xor%M %SI2, %AM',
580         units     => [ "GP" ],
581         mode      => "mode_M",
582         modified_flags => $status_flags
583 },
584
585 # not commutative operations
586
587 Sub => {
588         irn_flags => "R",
589         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3" ] },
590         ins       => [ "base", "index", "left", "right", "mem" ],
591         am        => "full,binary",
592         emit      => '. sub%M %binop',
593         units     => [ "GP" ],
594         mode      => $mode_gp,
595         modified_flags => $status_flags
596 },
597
598 SubMem => {
599         irn_flags => "R",
600         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
601         ins       => [ "base", "index", "val", "mem" ],
602         emit      => '. sub%M %SI2, %AM',
603         units     => [ "GP" ],
604         mode      => 'mode_M',
605         modified_flags => $status_flags
606 },
607
608 Sbb => {
609         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ], out => [ "in_r3 !in_r4" ] },
610         ins       => [ "base", "index", "left", "right", "mem" ],
611         am        => "full,binary",
612         emit      => '. sbb%M %binop',
613         units     => [ "GP" ],
614         mode      => $mode_gp,
615         modified_flags => $status_flags
616 },
617
618 Sub64Bit => {
619         irn_flags => "R",
620         arity     => 4,
621         reg_req   => { in => [ "gp", "gp", "gp", "gp" ], out => [ "!in", "!in" ] },
622         emit      => '
623 . movl %S0, %D0
624 . movl %S1, %D1
625 . subl %SI2, %D0
626 . sbbl %SI3, %D1
627 ',
628         outs      => [ "low_res", "high_res" ],
629         units     => [ "GP" ],
630         modified_flags => $status_flags
631 },
632
633 IDiv => {
634         op_flags  => "F|L",
635         state     => "exc_pinned",
636         reg_req   => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ],
637                        out => [ "eax", "edx", "none" ] },
638         ins       => [ "base", "index", "left_low", "left_high", "right", "mem" ],
639         outs      => [ "div_res", "mod_res", "M" ],
640         attr      => "ia32_op_flavour_t dm_flav",
641         am        => "source,ternary",
642         init_attr => "attr->data.op_flav = dm_flav;",
643         emit      => ". idiv%M %unop4",
644         latency   => 25,
645         units     => [ "GP" ],
646         modified_flags => $status_flags
647 },
648
649 Div => {
650         op_flags  => "F|L",
651         state     => "exc_pinned",
652         reg_req   => { in => [ "gp", "gp", "eax", "edx", "gp", "none" ],
653                        out => [ "eax", "edx", "none" ] },
654         ins       => [ "base", "index", "left_low", "left_high", "right", "mem" ],
655         outs      => [ "div_res", "mod_res", "M" ],
656         attr      => "ia32_op_flavour_t dm_flav",
657         am        => "source,ternary",
658         init_attr => "attr->data.op_flav = dm_flav;",
659         emit      => ". div%M %unop4",
660         latency   => 25,
661         units     => [ "GP" ],
662         modified_flags => $status_flags
663 },
664
665 Shl => {
666         irn_flags => "R",
667         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
668         ins       => [ "left", "right" ],
669         am        => "dest,binary",
670         emit      => '. shl %SB1, %S0',
671         units     => [ "GP" ],
672         mode      => $mode_gp,
673         modified_flags => $status_flags
674 },
675
676 ShlMem => {
677         irn_flags => "R",
678         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
679         ins       => [ "base", "index", "count", "mem" ],
680         emit      => '. shl%M %SI2, %AM',
681         units     => [ "GP" ],
682         mode      => "mode_M",
683         modified_flags => $status_flags
684 },
685
686 l_ShlDep => {
687         cmp_attr  => "return 1;",
688         # value, cnt, dependency
689         arity     => 3
690 },
691
692 ShlD => {
693         # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shl
694         #
695         # Out requirements is: different from all in
696         # This is because, out must be different from LowPart and ShiftCount.
697         # We could say "!ecx !in_r4" but it can occur, that all values live through
698         # this Shift and the only value dying is the ShiftCount. Then there would be a
699         # register missing, as result must not be ecx and all other registers are
700         # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
701         # (and probably never will). So we create artificial interferences of the result
702         # with all inputs, so the spiller can always assure a free register.
703         # reg_req   => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
704
705         irn_flags => "R",
706         reg_req   => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
707         ins       => [ "left_high", "left_low", "right" ],
708         am        => "dest,ternary",
709         emit      => '. shld%M %SB2, %S1, %S0',
710         latency   => 6,
711         units     => [ "GP" ],
712         mode      => $mode_gp,
713         modified_flags => $status_flags
714 },
715
716 l_ShlD => {
717         cmp_attr  => "return 1;",
718         arity     => 3,
719 },
720
721 Shr => {
722         irn_flags => "R",
723         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
724         ins       => [ "val", "count" ],
725         am        => "dest,binary",
726         emit      => '. shr %SB1, %S0',
727         units     => [ "GP" ],
728         mode      => $mode_gp,
729         modified_flags => $status_flags
730 },
731
732 ShrMem => {
733         irn_flags => "R",
734         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
735         ins       => [ "base", "index", "count", "mem" ],
736         emit      => '. shr%M %SI2, %AM',
737         units     => [ "GP" ],
738         mode      => "mode_M",
739         modified_flags => $status_flags
740 },
741
742 l_ShrDep => {
743         cmp_attr  => "return 1;",
744         # value, cnt, dependency
745         arity     => 3
746 },
747
748 ShrD => {
749         # FIXME: WHY? the right requirement is in_r3 !in_r5, especially this is the same as in Shr
750         #
751         # Out requirements is: different from all in
752         # This is because, out must be different from LowPart and ShiftCount.
753         # We could say "!ecx !in_r4" but it can occur, that all values live through
754         # this Shift and the only value dying is the ShiftCount. Then there would be a
755         # register missing, as result must not be ecx and all other registers are
756         # occupied. What we should write is "!in_r4 !in_r5", but this is not supported
757         # (and probably never will). So we create artificial interferences of the result
758         # with all inputs, so the spiller can always assure a free register.
759         # reg_req   => { in => [ "gp", "gp", "gp", "gp", "ecx", "none" ], out => [ "!in" ] },
760
761         irn_flags => "R",
762         reg_req   => { in => [ "gp", "gp", "ecx" ], out => [ "in_r1 !in_r3" ] },
763         ins       => [ "left_high", "left_low", "right" ],
764         am        => "dest,ternary",
765         emit      => '. shrd%M %SB2, %S1, %S0',
766         latency   => 6,
767         units     => [ "GP" ],
768         mode      => $mode_gp,
769         modified_flags => $status_flags
770 },
771
772 l_ShrD => {
773         cmp_attr  => "return 1;",
774         arity     => 3
775 },
776
777 Sar => {
778         irn_flags => "R",
779         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
780         ins       => [ "val", "count" ],
781         am        => "dest,binary",
782         emit      => '. sar %SB1, %S0',
783         units     => [ "GP" ],
784         mode      => $mode_gp,
785         modified_flags => $status_flags
786 },
787
788 SarMem => {
789         irn_flags => "R",
790         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
791         ins       => [ "base", "index", "count", "mem" ],
792         emit      => '. sar%M %SI2, %AM',
793         units     => [ "GP" ],
794         mode      => "mode_M",
795         modified_flags => $status_flags
796 },
797
798 l_Sar => {
799         cmp_attr  => "return 1;",
800         # value, cnt
801         arity     => 2
802 },
803
804 l_SarDep => {
805         cmp_attr  => "return 1;",
806         # value, cnt, dependency
807         arity     => 3
808 },
809
810 Ror => {
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      => '. ror %SB1, %S0',
816         units     => [ "GP" ],
817         mode      => $mode_gp,
818         modified_flags => $status_flags
819 },
820
821 RorMem => {
822         irn_flags => "R",
823         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
824         ins       => [ "base", "index", "count", "mem" ],
825         emit      => '. ror%M %SI2, %AM',
826         units     => [ "GP" ],
827         mode      => "mode_M",
828         modified_flags => $status_flags
829 },
830
831 Rol => {
832         irn_flags => "R",
833         reg_req   => { in => [ "gp", "ecx" ], out => [ "in_r1 !in_r2" ] },
834         ins       => [ "val", "count" ],
835         am        => "dest,binary",
836         emit      => '. rol %SB1, %S0',
837         units     => [ "GP" ],
838         mode      => $mode_gp,
839         modified_flags => $status_flags
840 },
841
842 RolMem => {
843         irn_flags => "R",
844         reg_req   => { in => [ "gp", "gp", "ecx", "none" ], out => [ "none" ] },
845         ins       => [ "base", "index", "count", "mem" ],
846         emit      => '. rol%M %SI2, %AM',
847         units     => [ "GP" ],
848         mode      => "mode_M",
849         modified_flags => $status_flags
850 },
851
852 # unary operations
853
854 Neg => {
855         irn_flags => "R",
856         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
857         emit      => '. neg %S0',
858         ins       => [ "val" ],
859         am        => "dest,unary",
860         units     => [ "GP" ],
861         mode      => $mode_gp,
862         modified_flags => $status_flags
863 },
864
865 NegMem => {
866         irn_flags => "R",
867         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
868         ins       => [ "base", "index", "mem" ],
869         emit      => '. neg%M %AM',
870         units     => [ "GP" ],
871         mode      => "mode_M",
872         modified_flags => $status_flags
873 },
874
875 Minus64Bit => {
876         irn_flags => "R",
877         reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1", "gp" ] },
878         outs      => [ "low_res", "high_res" ],
879         units     => [ "GP" ],
880         modified_flags => $status_flags
881 },
882
883
884 l_Neg => {
885         cmp_attr  => "return 1;",
886         arity     => 1,
887 },
888
889 Inc => {
890         irn_flags => "R",
891         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
892         am        => "dest,unary",
893         emit      => '. inc %S0',
894         units     => [ "GP" ],
895         mode      => $mode_gp,
896         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
897 },
898
899 IncMem => {
900         irn_flags => "R",
901         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
902         ins       => [ "base", "index", "mem" ],
903         emit      => '. inc%M %AM',
904         units     => [ "GP" ],
905         mode      => "mode_M",
906         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
907 },
908
909 Dec => {
910         irn_flags => "R",
911         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
912         am        => "dest,unary",
913         emit      => '. dec %S0',
914         units     => [ "GP" ],
915         mode      => $mode_gp,
916         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
917 },
918
919 DecMem => {
920         irn_flags => "R",
921         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
922         ins       => [ "base", "index", "mem" ],
923         emit      => '. dec%M %AM',
924         units     => [ "GP" ],
925         mode      => "mode_M",
926         modified_flags => [ "OF", "SF", "ZF", "AF", "PF" ]
927 },
928
929 Not => {
930         irn_flags => "R",
931         reg_req   => { in => [ "gp" ], out => [ "in_r1" ] },
932         ins       => [ "val" ],
933         am        => "dest,unary",
934         emit      => '. not %S0',
935         units     => [ "GP" ],
936         mode      => $mode_gp,
937         modified_flags => []
938 },
939
940 NotMem => {
941         irn_flags => "R",
942         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
943         ins       => [ "base", "index", "mem" ],
944         emit      => '. not%M %AM',
945         units     => [ "GP" ],
946         mode      => "mode_M",
947         modified_flags => [],
948 },
949
950 # other operations
951
952 CmpJmp => {
953         state     => "pinned",
954         op_flags  => "L|X|Y",
955         reg_req   => { in  => [ "gp", "gp", "gp", "gp", "none" ],
956                        out => [ "none", "none"] },
957         ins       => [ "base", "index", "left", "right", "mem" ],
958         outs      => [ "false", "true" ],
959         attr      => "long pnc",
960         am        => "source,binary",
961         init_attr => "attr->pn_code = pnc;",
962         latency   => 3,
963         units     => [ "BRANCH" ],
964 },
965
966 CmpJmp8Bit => {
967         state     => "pinned",
968         op_flags  => "L|X|Y",
969         reg_req   => { in  => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
970                                 "none" ],
971                        out => [ "none", "none"] },
972         ins       => [ "base", "index", "left", "right", "mem" ],
973         outs      => [ "false", "true" ],
974         attr      => "long pnc",
975         am        => "source,binary",
976         init_attr => "attr->pn_code = pnc;",
977         latency   => 3,
978         units     => [ "BRANCH" ],
979 },
980
981 TestJmp => {
982         state     => "pinned",
983         op_flags  => "L|X|Y",
984         reg_req   => { in  => [ "gp", "gp", "gp", "gp", "none" ],
985                        out => [ "none", "none" ] },
986         ins       => [ "base", "index", "left", "right", "mem" ],
987         outs      => [ "false", "true" ],
988         attr      => "long pnc",
989         am        => "source,binary",
990         init_attr => "attr->pn_code = pnc;",
991         latency   => 3,
992         units     => [ "BRANCH" ],
993 },
994
995 TestJmp8Bit => {
996         state     => "pinned",
997         op_flags  => "L|X|Y",
998         reg_req   => { in  => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
999                                 "none" ],
1000                        out => [ "none", "none" ] },
1001         ins       => [ "base", "index", "left", "right", "mem" ],
1002         outs      => [ "false", "true" ],
1003         attr      => "long pnc",
1004         am        => "source,binary",
1005         init_attr => "attr->pn_code = pnc;",
1006         latency   => 3,
1007         units     => [ "BRANCH" ],
1008 },
1009
1010 SwitchJmp => {
1011         state     => "pinned",
1012         op_flags  => "L|X|Y",
1013         reg_req   => { in => [ "gp" ], out => [ "none" ] },
1014         latency   => 3,
1015         units     => [ "BRANCH" ],
1016         mode      => "mode_T",
1017 },
1018
1019 IJmp => {
1020         state     => "pinned",
1021         op_flags  => "X",
1022         reg_req   => { in => [ "gp" ] },
1023         emit      => '. jmp *%S0',
1024         units     => [ "BRANCH" ],
1025         mode      => "mode_X",
1026         modified_flags => []
1027 },
1028
1029 Const => {
1030         op_flags  => "c",
1031         irn_flags => "R",
1032         reg_req   => { out => [ "gp" ] },
1033         units     => [ "GP" ],
1034         attr      => "ir_entity *symconst, int symconst_sign, long offset",
1035         attr_type => "ia32_immediate_attr_t",
1036         mode      => $mode_gp,
1037 },
1038
1039 Unknown_GP => {
1040         state     => "pinned",
1041         op_flags  => "c",
1042         irn_flags => "I",
1043         reg_req   => { out => [ "gp_UKNWN" ] },
1044         units     => [],
1045         emit      => "",
1046         mode      => $mode_gp
1047 },
1048
1049 Unknown_VFP => {
1050         state     => "pinned",
1051         op_flags  => "c",
1052         irn_flags => "I",
1053         reg_req   => { out => [ "vfp_UKNWN" ] },
1054         units     => [],
1055         emit      => "",
1056         mode      => "mode_E",
1057         attr_type => "ia32_x87_attr_t",
1058 },
1059
1060 Unknown_XMM => {
1061         state     => "pinned",
1062         op_flags  => "c",
1063         irn_flags => "I",
1064         reg_req   => { out => [ "xmm_UKNWN" ] },
1065         units     => [],
1066         emit      => "",
1067         mode      => "mode_E"
1068 },
1069
1070 NoReg_GP => {
1071         state     => "pinned",
1072         op_flags  => "c",
1073         irn_flags => "I",
1074         reg_req   => { out => [ "gp_NOREG" ] },
1075         units     => [],
1076         emit      => "",
1077         mode      => $mode_gp
1078 },
1079
1080 NoReg_VFP => {
1081         state     => "pinned",
1082         op_flags  => "c",
1083         irn_flags => "I",
1084         reg_req   => { out => [ "vfp_NOREG" ] },
1085         units     => [],
1086         emit      => "",
1087         mode      => "mode_E",
1088         attr_type => "ia32_x87_attr_t",
1089 },
1090
1091 NoReg_XMM => {
1092         state     => "pinned",
1093         op_flags  => "c",
1094         irn_flags => "I",
1095         reg_req   => { out => [ "xmm_NOREG" ] },
1096         units     => [],
1097         emit      => "",
1098         mode      => "mode_E"
1099 },
1100
1101 ChangeCW => {
1102         state     => "pinned",
1103         op_flags  => "c",
1104         irn_flags => "I",
1105         reg_req   => { out => [ "fp_cw" ] },
1106         mode      => $mode_fpcw,
1107         latency   => 3,
1108         units     => [ "GP" ],
1109         modified_flags => $fpcw_flags
1110 },
1111
1112 FldCW => {
1113         op_flags  => "L|F",
1114         state     => "pinned",
1115         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "fp_cw" ] },
1116         ins       => [ "base", "index", "mem" ],
1117         latency   => 5,
1118         emit      => ". fldcw %AM",
1119         mode      => $mode_fpcw,
1120         units     => [ "GP" ],
1121         modified_flags => $fpcw_flags
1122 },
1123
1124 FnstCW => {
1125         op_flags  => "L|F",
1126         state     => "pinned",
1127         reg_req   => { in => [ "gp", "gp", "fp_cw", "none" ], out => [ "none" ] },
1128         ins       => [ "base", "index", "fpcw", "mem" ],
1129         latency   => 5,
1130         emit      => ". fnstcw %AM",
1131         mode      => "mode_M",
1132         units     => [ "GP" ],
1133 },
1134
1135 Cltd => {
1136         # we should not rematrialize this node. It produces 2 results and has
1137         # very strict constrains
1138         reg_req   => { in => [ "eax", "edx" ], out => [ "edx" ] },
1139         ins       => [ "val", "globbered" ],
1140         emit      => '. cltd',
1141         mode      => $mode_gp,
1142         units     => [ "GP" ],
1143 },
1144
1145 # Load / Store
1146 #
1147 # Note that we add additional latency values depending on address mode, so a
1148 # lateny of 0 for load is correct
1149
1150 Load => {
1151         op_flags  => "L|F",
1152         state     => "exc_pinned",
1153         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
1154         ins       => [ "base", "index", "mem" ],
1155         outs      => [ "res", "M" ],
1156         latency   => 0,
1157         emit      => ". mov%SE%ME%.l %AM, %D0",
1158         units     => [ "GP" ],
1159 },
1160
1161 l_Load => {
1162         op_flags  => "L|F",
1163         cmp_attr  => "return 1;",
1164         outs      => [ "res", "M" ],
1165         arity     => 2,
1166 },
1167
1168 l_Store => {
1169         op_flags  => "L|F",
1170         cmp_attr  => "return 1;",
1171         state     => "exc_pinned",
1172         arity     => 3,
1173         mode      => "mode_M",
1174 },
1175
1176 Store => {
1177         op_flags  => "L|F",
1178         state     => "exc_pinned",
1179         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
1180         ins       => [ "base", "index", "val", "mem" ],
1181         emit      => '. mov%M %SI2, %AM',
1182         latency   => 2,
1183         units     => [ "GP" ],
1184         mode      => "mode_M",
1185 },
1186
1187 Store8Bit => {
1188         op_flags  => "L|F",
1189         state     => "exc_pinned",
1190         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => ["none" ] },
1191         emit      => '. mov%M %SB2, %AM',
1192         latency   => 2,
1193         units     => [ "GP" ],
1194         mode      => "mode_M",
1195 },
1196
1197 Lea => {
1198         irn_flags => "R",
1199         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
1200         ins       => [ "base", "index" ],
1201         emit      => '. leal %AM, %D0',
1202         latency   => 2,
1203         units     => [ "GP" ],
1204         mode      => $mode_gp,
1205         modified_flags => [],
1206 },
1207
1208 Push => {
1209         reg_req   => { in => [ "gp", "gp", "gp", "esp", "none" ], out => [ "esp", "none" ] },
1210         emit      => '. push%M %unop2',
1211         ins       => [ "base", "index", "val", "stack", "mem" ],
1212         outs      => [ "stack:I|S", "M" ],
1213         am        => "source,binary",
1214         latency   => 2,
1215         units     => [ "GP" ],
1216         modified_flags => [],
1217 },
1218
1219 Pop => {
1220         reg_req   => { in => [ "gp", "gp", "esp", "none" ], out => [ "esp", "gp", "none" ] },
1221         emit      => '. pop%M %DAM1',
1222         outs      => [ "stack:I|S", "res", "M" ],
1223         ins       => [ "base", "index", "stack", "mem" ],
1224         am        => "dest,unary",
1225         latency   => 3, # Pop is more expensive than Push on Athlon
1226         units     => [ "GP" ],
1227         modified_flags => [],
1228 },
1229
1230 Enter => {
1231         reg_req   => { in => [ "esp" ], out => [ "ebp", "esp", "none" ] },
1232         emit      => '. enter',
1233         outs      => [ "frame:I", "stack:I|S", "M" ],
1234         latency   => 15,
1235         units     => [ "GP" ],
1236 },
1237
1238 Leave => {
1239         reg_req   => { in => [ "esp", "ebp" ], out => [ "ebp", "esp" ] },
1240         emit      => '. leave',
1241         outs      => [ "frame:I", "stack:I|S" ],
1242         latency   => 3,
1243         units     => [ "GP" ],
1244 },
1245
1246 AddSP => {
1247         irn_flags => "I",
1248         state     => "pinned",
1249         reg_req   => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "none" ] },
1250         am        => "source,binary",
1251         emit      => '. addl %binop',
1252         outs      => [ "stack:S", "M" ],
1253         units     => [ "GP" ],
1254         modified_flags => $status_flags
1255 },
1256
1257 SubSP => {
1258 #irn_flags => "I",
1259         state     => "pinned",
1260         reg_req   => { in => [ "gp", "gp", "esp", "gp", "none" ], out => [ "in_r3", "gp", "none" ] },
1261         am        => "source,binary",
1262         emit      => ". subl %binop\n".
1263                      ". movl %%esp, %D1",
1264         outs      => [ "stack:I|S", "addr", "M" ],
1265         units     => [ "GP" ],
1266         modified_flags => $status_flags
1267 },
1268
1269 LdTls => {
1270         irn_flags => "R",
1271         reg_req   => { out => [ "gp" ] },
1272         units     => [ "GP" ],
1273 },
1274
1275 # the int instruction
1276 int => {
1277         reg_req   => { in => [ "gp" ], out => [ "none" ] },
1278         mode      => "mode_M",
1279         emit      => '. int %SI0',
1280         units     => [ "GP" ],
1281         cmp_attr  => "return 1;",
1282 },
1283
1284
1285 #-----------------------------------------------------------------------------#
1286 #   _____ _____ ______    __ _             _                     _            #
1287 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
1288 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1289 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1290 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1291 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1292 #-----------------------------------------------------------------------------#
1293
1294 xZero => {
1295         irn_flags => "R",
1296         reg_req   => { out => [ "xmm" ] },
1297         emit      => '. xorp%XSD %D1, %D1',
1298         latency   => 3,
1299         units     => [ "SSE" ],
1300         mode      => "mode_E",
1301 },
1302
1303 # commutative operations
1304
1305 xAdd => {
1306         irn_flags => "R",
1307         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1308         emit      => '. add%XXM %binop',
1309         latency   => 4,
1310         units     => [ "SSE" ],
1311         mode      => "mode_E",
1312 },
1313
1314 xMul => {
1315         irn_flags => "R",
1316         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1317         emit      => '. mul%XXM %binop',
1318         latency   => 4,
1319         units     => [ "SSE" ],
1320         mode      => "mode_E",
1321 },
1322
1323 xMax => {
1324         irn_flags => "R",
1325         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1326         emit      => '. max%XXM %binop',
1327         latency   => 2,
1328         units     => [ "SSE" ],
1329         mode      => "mode_E",
1330 },
1331
1332 xMin => {
1333         irn_flags => "R",
1334         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1335         emit      => '. min%XXM %binop',
1336         latency   => 2,
1337         units     => [ "SSE" ],
1338         mode      => "mode_E",
1339 },
1340
1341 xAnd => {
1342         irn_flags => "R",
1343         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1344         emit      => '. andp%XSD %binop',
1345         latency   => 3,
1346         units     => [ "SSE" ],
1347         mode      => "mode_E",
1348 },
1349
1350 xOr => {
1351         irn_flags => "R",
1352         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1353         emit      => '. orp%XSD %binop',
1354         units     => [ "SSE" ],
1355         mode      => "mode_E",
1356 },
1357
1358 xXor => {
1359         irn_flags => "R",
1360         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1361         emit      => '. xorp%XSD %binop',
1362         latency   => 3,
1363         units     => [ "SSE" ],
1364         mode      => "mode_E",
1365 },
1366
1367 # not commutative operations
1368
1369 xAndNot => {
1370         irn_flags => "R",
1371         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1372         emit      => '. andnp%XSD %binop',
1373         latency   => 3,
1374         units     => [ "SSE" ],
1375         mode      => "mode_E",
1376 },
1377
1378 xSub => {
1379         irn_flags => "R",
1380         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1381         emit      => '. sub%XXM %binop',
1382         latency   => 4,
1383         units     => [ "SSE" ],
1384         mode      => "mode_E",
1385 },
1386
1387 xDiv => {
1388         irn_flags => "R",
1389         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4", "none" ] },
1390         outs      => [ "res", "M" ],
1391         emit      => '. div%XXM %binop',
1392         latency   => 16,
1393         units     => [ "SSE" ],
1394 },
1395
1396 # other operations
1397
1398 xCmp => {
1399         irn_flags => "R",
1400         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1401         latency   => 3,
1402         units     => [ "SSE" ],
1403         mode      => "mode_E",
1404 },
1405
1406 xCmpJmp => {
1407         state     => "pinned",
1408         op_flags  => "L|X|Y",
1409         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "none", "none" ] },
1410         ins       => [ "base", "index", "left", "right", "mem" ],
1411         outs      => [ "false", "true" ],
1412         attr      => "long pnc",
1413         init_attr => "attr->pn_code = pnc;",
1414         latency   => 5,
1415         units     => [ "SSE" ],
1416 },
1417
1418 # Load / Store
1419
1420 xLoad => {
1421         op_flags  => "L|F",
1422         state     => "exc_pinned",
1423         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1424         emit      => '. mov%XXM %AM, %D0',
1425         attr      => "ir_mode *load_mode",
1426         init_attr => "attr->ls_mode = load_mode;",
1427         outs      => [ "res", "M" ],
1428         latency   => 0,
1429         units     => [ "SSE" ],
1430 },
1431
1432 xStore => {
1433         op_flags => "L|F",
1434         state    => "exc_pinned",
1435         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
1436         emit     => '. mov%XXM %S2, %AM',
1437         latency  => 0,
1438         units    => [ "SSE" ],
1439         mode     => "mode_M",
1440 },
1441
1442 xStoreSimple => {
1443         op_flags => "L|F",
1444         state    => "exc_pinned",
1445         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
1446         ins      => [ "base", "index", "val", "mem" ],
1447         emit     => '. mov%XXM %S2, %AM',
1448         latency  => 0,
1449         units    => [ "SSE" ],
1450         mode     => "mode_M",
1451 },
1452
1453 CvtSI2SS => {
1454         op_flags => "L|F",
1455         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1456         emit     => '. cvtsi2ss %D0, %AM',
1457         latency  => 2,
1458         units    => [ "SSE" ],
1459         mode     => $mode_xmm
1460 },
1461
1462 CvtSI2SD => {
1463         op_flags => "L|F",
1464         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1465         emit     => '. cvtsi2sd %unop2',
1466         latency  => 2,
1467         units    => [ "SSE" ],
1468         mode     => $mode_xmm
1469 },
1470
1471
1472 l_X87toSSE => {
1473         op_flags => "L|F",
1474         cmp_attr => "return 1;",
1475         arity    => 3,
1476 },
1477
1478 l_SSEtoX87 => {
1479         op_flags => "L|F",
1480         cmp_attr => "return 1;",
1481         arity    => 3,
1482 },
1483
1484 # CopyB
1485
1486 CopyB => {
1487         op_flags => "F|H",
1488         state    => "pinned",
1489         reg_req  => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1490         outs     => [ "DST", "SRC", "CNT", "M" ],
1491         units    => [ "GP" ],
1492         modified_flags => [ "DF" ]
1493 },
1494
1495 CopyB_i => {
1496         op_flags => "F|H",
1497         state    => "pinned",
1498         reg_req  => { in => [ "edi", "esi", "none" ], out => [  "edi", "esi", "none" ] },
1499         outs     => [ "DST", "SRC", "M" ],
1500         units    => [ "GP" ],
1501         modified_flags => [ "DF" ]
1502 },
1503
1504 # Conversions
1505
1506 Conv_I2I => {
1507         state     => "exc_pinned",
1508         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3", "none" ] },
1509         units     => [ "GP" ],
1510         ins       => [ "base", "index", "val", "mem" ],
1511         attr      => "ir_mode *smaller_mode",
1512         init_attr => "attr->ls_mode = smaller_mode;",
1513         mode      => $mode_gp,
1514         modified_flags => $status_flags
1515 },
1516
1517 Conv_I2I8Bit => {
1518         state     => "exc_pinned",
1519         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => [ "in_r3", "none" ] },
1520         ins       => [ "base", "index", "val", "mem" ],
1521         units     => [ "GP" ],
1522         attr      => "ir_mode *smaller_mode",
1523         init_attr => "attr->ls_mode = smaller_mode;",
1524         mode      => $mode_gp,
1525         modified_flags => $status_flags
1526 },
1527
1528 Conv_I2FP => {
1529         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1530         latency  => 10,
1531         units    => [ "SSE" ],
1532         mode     => "mode_E",
1533 },
1534
1535 Conv_FP2I => {
1536         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "gp", "none" ] },
1537         latency  => 10,
1538         units    => [ "SSE" ],
1539         mode     => $mode_gp,
1540 },
1541
1542 Conv_FP2FP => {
1543         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "xmm", "none" ] },
1544         latency  => 8,
1545         units    => [ "SSE" ],
1546         mode     => "mode_E",
1547 },
1548
1549 CmpCMov => {
1550         irn_flags => "R",
1551         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ], out => [ "in_r7" ] },
1552         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true", "val_false" ],
1553         attr      => "pn_Cmp pn_code",
1554         init_attr => "attr->pn_code = pn_code;",
1555         latency   => 2,
1556         units     => [ "GP" ],
1557         mode      => $mode_gp,
1558 },
1559
1560 CmpCMov8Bit => {
1561         irn_flags => "R",
1562         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ], out => [ "in_r7" ] },
1563         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true", "val_false" ],
1564         attr      => "pn_Cmp pn_code",
1565         init_attr => "attr->pn_code = pn_code;",
1566         latency   => 2,
1567         units     => [ "GP" ],
1568         mode      => $mode_gp,
1569 },
1570
1571 TestCMov => {
1572         irn_flags => "R",
1573         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ],
1574                        out => [ "in_r7" ] },
1575         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1576                        "val_false" ],
1577         attr      => "pn_Cmp pn_code",
1578         init_attr => "attr->pn_code = pn_code;",
1579         latency   => 2,
1580         units     => [ "GP" ],
1581         mode      => $mode_gp,
1582 },
1583
1584 TestCMov8Bit => {
1585         irn_flags => "R",
1586         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ],
1587                        out => [ "in_r7" ] },
1588         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1589                        "val_false" ],
1590         attr      => "pn_Cmp pn_code",
1591         init_attr => "attr->pn_code = pn_code;",
1592         latency   => 2,
1593         units     => [ "GP" ],
1594         mode      => $mode_gp,
1595 },
1596
1597 xCmpCMov => {
1598         irn_flags => "R",
1599         reg_req   => { in => [ "xmm", "xmm", "gp", "gp" ], out => [ "in_r4" ] },
1600         latency   => 5,
1601         units     => [ "SSE" ],
1602         mode      => $mode_gp,
1603 },
1604
1605 vfCmpCMov => {
1606         irn_flags => "R",
1607         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "gp", "gp" ],
1608                        out => [ "in_r7" ] },
1609         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1610                        "val_false" ],
1611         latency   => 10,
1612         units     => [ "VFP", "GP" ],
1613         mode      => $mode_gp,
1614         attr_type => "ia32_x87_attr_t",
1615 },
1616
1617 CmpSet => {
1618         irn_flags => "R",
1619         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ],
1620                        out => [ "eax ebx ecx edx" ] },
1621         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1622         attr      => "pn_Cmp pn_code",
1623         init_attr => "attr->pn_code = pn_code;",
1624         latency   => 2,
1625         units     => [ "GP" ],
1626         mode      => $mode_gp,
1627 },
1628
1629 CmpSet8Bit => {
1630         irn_flags => "R",
1631         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1632                                "none" ],
1633                        out => [ "eax ebx ecx edx" ] },
1634         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1635         attr      => "pn_Cmp pn_code",
1636         init_attr => "attr->pn_code = pn_code;",
1637         latency   => 2,
1638         units     => [ "GP" ],
1639         mode      => $mode_gp,
1640 },
1641
1642 TestSet => {
1643         irn_flags => "R",
1644         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ],
1645                        out => [ "eax ebx ecx edx" ] },
1646         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1647         attr      => "pn_Cmp pn_code",
1648         init_attr => "attr->pn_code = pn_code;",
1649         latency   => 2,
1650         units     => [ "GP" ],
1651         mode      => $mode_gp,
1652 },
1653
1654 TestSet8Bit => {
1655         irn_flags => "R",
1656         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1657                                "none" ],
1658                        out => [ "eax ebx ecx edx" ] },
1659         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1660         attr      => "pn_Cmp pn_code",
1661         init_attr => "attr->pn_code = pn_code;",
1662         latency   => 2,
1663         units     => [ "GP" ],
1664         mode      => $mode_gp,
1665 },
1666
1667 xCmpSet => {
1668         irn_flags => "R",
1669         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "eax ebx ecx edx" ] },
1670         latency   => 5,
1671         units     => [ "SSE" ],
1672         mode      => $mode_gp,
1673 },
1674
1675 vfCmpSet => {
1676         irn_flags => "R",
1677         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "eax ebx ecx edx" ] },
1678         latency   => 10,
1679         units     => [ "VFP" ],
1680         mode      => $mode_gp,
1681         attr_type => "ia32_x87_attr_t",
1682 },
1683
1684 vfCMov => {
1685         irn_flags => "R",
1686         reg_req   => { in => [ "vfp", "vfp", "vfp", "vfp" ], out => [ "vfp" ] },
1687         latency   => 10,
1688         units     => [ "VFP" ],
1689         mode      => "mode_E",
1690         attr_type => "ia32_x87_attr_t",
1691 },
1692
1693 #----------------------------------------------------------#
1694 #        _      _               _    __ _             _    #
1695 #       (_)    | |             | |  / _| |           | |   #
1696 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1697 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1698 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1699 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1700 #                 | |                                      #
1701 #  _ __   ___   __| | ___  ___                             #
1702 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1703 # | | | | (_) | (_| |  __/\__ \                            #
1704 # |_| |_|\___/ \__,_|\___||___/                            #
1705 #----------------------------------------------------------#
1706
1707 vfadd => {
1708         irn_flags => "R",
1709         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1710         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1711         latency   => 4,
1712         units     => [ "VFP" ],
1713         mode      => "mode_E",
1714         attr_type => "ia32_x87_attr_t",
1715 },
1716
1717 vfmul => {
1718         irn_flags => "R",
1719         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1720         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1721         latency   => 4,
1722         units     => [ "VFP" ],
1723         mode      => "mode_E",
1724         attr_type => "ia32_x87_attr_t",
1725 },
1726
1727 l_vfmul => {
1728         op_flags  => "C",
1729         cmp_attr  => "return 1;",
1730         arity     => 2,
1731 },
1732
1733 vfsub => {
1734         irn_flags => "R",
1735         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1736         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1737         latency   => 4,
1738         units     => [ "VFP" ],
1739         mode      => "mode_E",
1740         attr_type => "ia32_x87_attr_t",
1741 },
1742
1743 l_vfsub => {
1744         cmp_attr  => "return 1;",
1745         arity     => 2,
1746 },
1747
1748 vfdiv => {
1749         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp", "none" ] },
1750         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1751         outs      => [ "res", "M" ],
1752         latency   => 20,
1753         units     => [ "VFP" ],
1754         attr_type => "ia32_x87_attr_t",
1755 },
1756
1757 l_vfdiv => {
1758         cmp_attr  => "return 1;",
1759         outs      => [ "res", "M" ],
1760         arity     => 2,
1761 },
1762
1763 vfprem => {
1764         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1765         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1766         latency   => 20,
1767         units     => [ "VFP" ],
1768         mode      => "mode_E",
1769         attr_type => "ia32_x87_attr_t",
1770 },
1771
1772 l_vfprem => {
1773         cmp_attr  => "return 1;",
1774         arity     => 2,
1775 },
1776
1777 vfabs => {
1778         irn_flags => "R",
1779         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1780         ins       => [ "value" ],
1781         latency   => 2,
1782         units     => [ "VFP" ],
1783         mode      => "mode_E",
1784         attr_type => "ia32_x87_attr_t",
1785 },
1786
1787 vfchs => {
1788         irn_flags => "R",
1789         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1790         ins       => [ "value" ],
1791         latency   => 2,
1792         units     => [ "VFP" ],
1793         mode      => "mode_E",
1794         attr_type => "ia32_x87_attr_t",
1795 },
1796
1797 # virtual Load and Store
1798
1799 vfld => {
1800         op_flags  => "L|F",
1801         state     => "exc_pinned",
1802         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1803         ins       => [ "base", "index", "mem" ],
1804         outs      => [ "res", "M" ],
1805         attr      => "ir_mode *load_mode",
1806         init_attr => "attr->attr.ls_mode = load_mode;",
1807         latency   => 2,
1808         units     => [ "VFP" ],
1809         attr_type => "ia32_x87_attr_t",
1810 },
1811
1812 vfst => {
1813         op_flags  => "L|F",
1814         state     => "exc_pinned",
1815         reg_req   => { in => [ "gp", "gp", "vfp", "none" ] },
1816         ins       => [ "base", "index", "val", "mem" ],
1817         attr      => "ir_mode *store_mode",
1818         init_attr => "attr->attr.ls_mode = store_mode;",
1819         latency   => 2,
1820         units     => [ "VFP" ],
1821         mode      => "mode_M",
1822         attr_type => "ia32_x87_attr_t",
1823 },
1824
1825 # Conversions
1826
1827 vfild => {
1828         state     => "exc_pinned",
1829         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1830         outs      => [ "res", "M" ],
1831         ins       => [ "base", "index", "mem" ],
1832         latency   => 4,
1833         units     => [ "VFP" ],
1834         attr_type => "ia32_x87_attr_t",
1835 },
1836
1837 l_vfild => {
1838         cmp_attr  => "return 1;",
1839         outs      => [ "res", "M" ],
1840         arity     => 2,
1841 },
1842
1843 vfist => {
1844         state     => "exc_pinned",
1845         reg_req   => { in => [ "gp", "gp", "vfp", "fpcw", "none" ] },
1846         ins       => [ "base", "index", "val", "fpcw", "mem" ],
1847         latency   => 4,
1848         units     => [ "VFP" ],
1849         mode      => "mode_M",
1850         attr_type => "ia32_x87_attr_t",
1851 },
1852
1853 l_vfist => {
1854         cmp_attr  => "return 1;",
1855         state     => "exc_pinned",
1856         arity     => 3,
1857         mode      => "mode_M",
1858 },
1859
1860
1861 # constants
1862
1863 vfldz => {
1864         irn_flags => "R",
1865         reg_req   => { out => [ "vfp" ] },
1866         latency   => 4,
1867         units     => [ "VFP" ],
1868         mode      => "mode_E",
1869         attr_type => "ia32_x87_attr_t",
1870 },
1871
1872 vfld1 => {
1873         irn_flags => "R",
1874         reg_req   => { out => [ "vfp" ] },
1875         latency   => 4,
1876         units     => [ "VFP" ],
1877         mode      => "mode_E",
1878         attr_type => "ia32_x87_attr_t",
1879 },
1880
1881 vfldpi => {
1882         irn_flags => "R",
1883         reg_req   => { out => [ "vfp" ] },
1884         latency   => 4,
1885         units     => [ "VFP" ],
1886         mode      => "mode_E",
1887         attr_type => "ia32_x87_attr_t",
1888 },
1889
1890 vfldln2 => {
1891         irn_flags => "R",
1892         reg_req   => { out => [ "vfp" ] },
1893         latency   => 4,
1894         units     => [ "VFP" ],
1895         mode      => "mode_E",
1896         attr_type => "ia32_x87_attr_t",
1897 },
1898
1899 vfldlg2 => {
1900         irn_flags => "R",
1901         reg_req   => { out => [ "vfp" ] },
1902         latency   => 4,
1903         units     => [ "VFP" ],
1904         mode      => "mode_E",
1905         attr_type => "ia32_x87_attr_t",
1906 },
1907
1908 vfldl2t => {
1909         irn_flags => "R",
1910         reg_req   => { out => [ "vfp" ] },
1911         latency   => 4,
1912         units     => [ "VFP" ],
1913         mode      => "mode_E",
1914         attr_type => "ia32_x87_attr_t",
1915 },
1916
1917 vfldl2e => {
1918         irn_flags => "R",
1919         reg_req   => { out => [ "vfp" ] },
1920         latency   => 4,
1921         units     => [ "VFP" ],
1922         mode      => "mode_E",
1923         attr_type => "ia32_x87_attr_t",
1924 },
1925
1926 # other
1927
1928 vfCmpJmp => {
1929         state     => "pinned",
1930         op_flags  => "L|X|Y",
1931         reg_req   => { in => [ "vfp", "vfp" ], out => [ "none", "none", "eax" ] },
1932         ins       => [ "left", "right" ],
1933         outs      => [ "false", "true", "temp_reg_eax" ],
1934         attr      => "long pnc",
1935         init_attr => "attr->attr.pn_code = pnc;",
1936         latency   => 10,
1937         units     => [ "VFP" ],
1938         attr_type => "ia32_x87_attr_t",
1939 },
1940
1941 #------------------------------------------------------------------------#
1942 #       ___ _____    __ _             _                     _            #
1943 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1944 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1945 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1946 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1947 #------------------------------------------------------------------------#
1948
1949 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1950 #       are swapped, we work this around in the emitter...
1951
1952 fadd => {
1953         op_flags  => "R",
1954         rd_constructor => "NONE",
1955         reg_req   => { },
1956         emit      => '. fadd%XM %x87_binop',
1957         attr_type => "ia32_x87_attr_t",
1958 },
1959
1960 faddp => {
1961         op_flags  => "R",
1962         rd_constructor => "NONE",
1963         reg_req   => { },
1964         emit      => '. faddp%XM %x87_binop',
1965         attr_type => "ia32_x87_attr_t",
1966 },
1967
1968 fmul => {
1969         op_flags  => "R",
1970         rd_constructor => "NONE",
1971         reg_req   => { },
1972         emit      => '. fmul%XM %x87_binop',
1973         attr_type => "ia32_x87_attr_t",
1974 },
1975
1976 fmulp => {
1977         op_flags  => "R",
1978         rd_constructor => "NONE",
1979         reg_req   => { },
1980         emit      => '. fmulp%XM %x87_binop',,
1981         attr_type => "ia32_x87_attr_t",
1982 },
1983
1984 fsub => {
1985         op_flags  => "R",
1986         rd_constructor => "NONE",
1987         reg_req   => { },
1988         emit      => '. fsub%XM %x87_binop',
1989         attr_type => "ia32_x87_attr_t",
1990 },
1991
1992 fsubp => {
1993         op_flags  => "R",
1994         rd_constructor => "NONE",
1995         reg_req   => { },
1996 # see note about gas bugs
1997         emit      => '. fsubrp%XM %x87_binop',
1998         attr_type => "ia32_x87_attr_t",
1999 },
2000
2001 fsubr => {
2002         op_flags  => "R",
2003         rd_constructor => "NONE",
2004         irn_flags => "R",
2005         reg_req   => { },
2006         emit      => '. fsubr%XM %x87_binop',
2007         attr_type => "ia32_x87_attr_t",
2008 },
2009
2010 fsubrp => {
2011         op_flags  => "R",
2012         rd_constructor => "NONE",
2013         irn_flags => "R",
2014         reg_req   => { },
2015 # see note about gas bugs
2016         emit      => '. fsubp%XM %x87_binop',
2017         attr_type => "ia32_x87_attr_t",
2018 },
2019
2020 fprem => {
2021         op_flags  => "R",
2022         rd_constructor => "NONE",
2023         reg_req   => { },
2024         emit      => '. fprem1',
2025         attr_type => "ia32_x87_attr_t",
2026 },
2027
2028 # this node is just here, to keep the simulator running
2029 # we can omit this when a fprem simulation function exists
2030 fpremp => {
2031         op_flags  => "R",
2032         rd_constructor => "NONE",
2033         reg_req   => { },
2034         emit      => '. fprem1',
2035         attr_type => "ia32_x87_attr_t",
2036 },
2037
2038 fdiv => {
2039         op_flags  => "R",
2040         rd_constructor => "NONE",
2041         reg_req   => { },
2042         emit      => '. fdiv%XM %x87_binop',
2043         attr_type => "ia32_x87_attr_t",
2044 },
2045
2046 fdivp => {
2047         op_flags  => "R",
2048         rd_constructor => "NONE",
2049         reg_req   => { },
2050 # see note about gas bugs
2051         emit      => '. fdivrp%XM %x87_binop',
2052         attr_type => "ia32_x87_attr_t",
2053 },
2054
2055 fdivr => {
2056         op_flags  => "R",
2057         rd_constructor => "NONE",
2058         reg_req   => { },
2059         emit      => '. fdivr%XM %x87_binop',
2060         attr_type => "ia32_x87_attr_t",
2061 },
2062
2063 fdivrp => {
2064         op_flags  => "R",
2065         rd_constructor => "NONE",
2066         reg_req   => { },
2067 # see note about gas bugs
2068         emit      => '. fdivp%XM %x87_binop',
2069         attr_type => "ia32_x87_attr_t",
2070 },
2071
2072 fabs => {
2073         op_flags  => "R",
2074         rd_constructor => "NONE",
2075         reg_req   => { },
2076         emit      => '. fabs',
2077         attr_type => "ia32_x87_attr_t",
2078 },
2079
2080 fchs => {
2081         op_flags  => "R|K",
2082         rd_constructor => "NONE",
2083         reg_req   => { },
2084         emit      => '. fchs',
2085         attr_type => "ia32_x87_attr_t",
2086 },
2087
2088 # x87 Load and Store
2089
2090 fld => {
2091         rd_constructor => "NONE",
2092         op_flags  => "R|L|F",
2093         state     => "exc_pinned",
2094         reg_req   => { },
2095         emit      => '. fld%XM %AM',
2096         attr_type => "ia32_x87_attr_t",
2097 },
2098
2099 fst => {
2100         rd_constructor => "NONE",
2101         op_flags  => "R|L|F",
2102         state     => "exc_pinned",
2103         reg_req   => { },
2104         emit      => '. fst%XM %AM',
2105         mode      => "mode_M",
2106         attr_type => "ia32_x87_attr_t",
2107 },
2108
2109 fstp => {
2110         rd_constructor => "NONE",
2111         op_flags  => "R|L|F",
2112         state     => "exc_pinned",
2113         reg_req   => { },
2114         emit      => '. fstp%XM %AM',
2115         mode      => "mode_M",
2116         attr_type => "ia32_x87_attr_t",
2117 },
2118
2119 # Conversions
2120
2121 fild => {
2122         op_flags  => "R",
2123         rd_constructor => "NONE",
2124         reg_req   => { },
2125         emit      => '. fild%M %AM',
2126         attr_type => "ia32_x87_attr_t",
2127 },
2128
2129 fist => {
2130         op_flags  => "R",
2131         state     => "exc_pinned",
2132         rd_constructor => "NONE",
2133         reg_req   => { },
2134         emit      => '. fist%M %AM',
2135         mode      => "mode_M",
2136         attr_type => "ia32_x87_attr_t",
2137 },
2138
2139 fistp => {
2140         op_flags  => "R",
2141         state     => "exc_pinned",
2142         rd_constructor => "NONE",
2143         reg_req   => { },
2144         emit      => '. fistp%M %AM',
2145         mode      => "mode_M",
2146         attr_type => "ia32_x87_attr_t",
2147 },
2148
2149 # constants
2150
2151 fldz => {
2152         op_flags  => "R|c|K",
2153         irn_flags  => "R",
2154         reg_req   => { },
2155         emit      => '. fldz',
2156         attr_type => "ia32_x87_attr_t",
2157 },
2158
2159 fld1 => {
2160         op_flags  => "R|c|K",
2161         irn_flags  => "R",
2162         reg_req   => { },
2163         emit      => '. fld1',
2164         attr_type => "ia32_x87_attr_t",
2165 },
2166
2167 fldpi => {
2168         op_flags  => "R|c|K",
2169         irn_flags  => "R",
2170         reg_req   => { },
2171         emit      => '. fldpi',
2172         attr_type => "ia32_x87_attr_t",
2173 },
2174
2175 fldln2 => {
2176         op_flags  => "R|c|K",
2177         irn_flags  => "R",
2178         reg_req   => { },
2179         emit      => '. fldln2',
2180         attr_type => "ia32_x87_attr_t",
2181 },
2182
2183 fldlg2 => {
2184         op_flags  => "R|c|K",
2185         irn_flags  => "R",
2186         reg_req   => { },
2187         emit      => '. fldlg2',
2188         attr_type => "ia32_x87_attr_t",
2189 },
2190
2191 fldl2t => {
2192         op_flags  => "R|c|K",
2193         irn_flags  => "R",
2194         reg_req   => { },
2195         emit      => '. fldll2t',
2196         attr_type => "ia32_x87_attr_t",
2197 },
2198
2199 fldl2e => {
2200         op_flags  => "R|c|K",
2201         irn_flags  => "R",
2202         reg_req   => { },
2203         emit      => '. fldl2e',
2204         attr_type => "ia32_x87_attr_t",
2205 },
2206
2207 # fxch, fpush, fpop
2208 # Note that it is NEVER allowed to do CSE on these nodes
2209 # Moreover, note the virtual register requierements!
2210
2211 fxch => {
2212         op_flags  => "R|K",
2213         reg_req   => { },
2214         cmp_attr  => "return 1;",
2215         emit      => '. fxch %X0',
2216         attr_type => "ia32_x87_attr_t",
2217 },
2218
2219 fpush => {
2220         op_flags  => "R|K",
2221         reg_req   => {},
2222         cmp_attr  => "return 1;",
2223         emit      => '. fld %X0',
2224         attr_type => "ia32_x87_attr_t",
2225 },
2226
2227 fpushCopy => {
2228         op_flags  => "R",
2229         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2230         cmp_attr  => "return 1;",
2231         emit      => '. fld %X0',
2232         attr_type => "ia32_x87_attr_t",
2233 },
2234
2235 fpop => {
2236         op_flags  => "R|K",
2237         reg_req   => { },
2238         cmp_attr  => "return 1;",
2239         emit      => '. fstp %X0',
2240         attr_type => "ia32_x87_attr_t",
2241 },
2242
2243 # compare
2244
2245 fcomJmp => {
2246         op_flags  => "L|X|Y",
2247         reg_req   => { },
2248         attr_type => "ia32_x87_attr_t",
2249 },
2250
2251 fcompJmp => {
2252         op_flags  => "L|X|Y",
2253         reg_req   => { },
2254         attr_type => "ia32_x87_attr_t",
2255 },
2256
2257 fcomppJmp => {
2258         op_flags  => "L|X|Y",
2259         reg_req   => { },
2260         attr_type => "ia32_x87_attr_t",
2261 },
2262
2263 fcomrJmp => {
2264         op_flags  => "L|X|Y",
2265         reg_req   => { },
2266         attr_type => "ia32_x87_attr_t",
2267 },
2268
2269 fcomrpJmp => {
2270         op_flags  => "L|X|Y",
2271         reg_req   => { },
2272         attr_type => "ia32_x87_attr_t",
2273 },
2274
2275 fcomrppJmp => {
2276         op_flags  => "L|X|Y",
2277         reg_req   => { },
2278         attr_type => "ia32_x87_attr_t",
2279 },
2280
2281
2282 # -------------------------------------------------------------------------------- #
2283 #  ____ ____  _____                  _                               _             #
2284 # / ___/ ___|| ____| __   _____  ___| |_ ___  _ __   _ __   ___   __| | ___  ___   #
2285 # \___ \___ \|  _|   \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __|  #
2286 #  ___) |__) | |___   \ V /  __/ (__| || (_) | |    | | | | (_) | (_| |  __/\__ \  #
2287 # |____/____/|_____|   \_/ \___|\___|\__\___/|_|    |_| |_|\___/ \__,_|\___||___/  #
2288 #                                                                                  #
2289 # -------------------------------------------------------------------------------- #
2290
2291
2292 # Spilling and reloading of SSE registers, hardcoded, not generated #
2293
2294 xxLoad => {
2295         op_flags  => "L|F",
2296         state     => "exc_pinned",
2297         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2298         emit      => '. movdqu %D0, %AM',
2299         outs      => [ "res", "M" ],
2300         units     => [ "SSE" ],
2301 },
2302
2303 xxStore => {
2304         op_flags => "L|F",
2305         state    => "exc_pinned",
2306         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
2307         emit     => '. movdqu %binop',
2308         units    => [ "SSE" ],
2309         mode     => "mode_M",
2310 },
2311
2312 ); # end of %nodes
2313
2314 # Include the generated SIMD node specification written by the SIMD optimization
2315 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2316 unless ($return = do $my_script_name) {
2317         warn "couldn't parse $my_script_name: $@" if $@;
2318         warn "couldn't do $my_script_name: $!"    unless defined $return;
2319         warn "couldn't run $my_script_name"       unless $return;
2320 }