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