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