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