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