a5e56154724c2973262def0c7d407c4b2746cc48
[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 xZero => {
1303         irn_flags => "R",
1304         reg_req   => { out => [ "xmm" ] },
1305         emit      => '. xorp%XSD %D1, %D1',
1306         latency   => 3,
1307         units     => [ "SSE" ],
1308         mode      => "mode_E",
1309 },
1310
1311 # commutative operations
1312
1313 xAdd => {
1314         irn_flags => "R",
1315         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1316         emit      => '. add%XXM %binop',
1317         latency   => 4,
1318         units     => [ "SSE" ],
1319         mode      => "mode_E",
1320 },
1321
1322 xMul => {
1323         irn_flags => "R",
1324         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1325         emit      => '. mul%XXM %binop',
1326         latency   => 4,
1327         units     => [ "SSE" ],
1328         mode      => "mode_E",
1329 },
1330
1331 xMax => {
1332         irn_flags => "R",
1333         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1334         emit      => '. max%XXM %binop',
1335         latency   => 2,
1336         units     => [ "SSE" ],
1337         mode      => "mode_E",
1338 },
1339
1340 xMin => {
1341         irn_flags => "R",
1342         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1343         emit      => '. min%XXM %binop',
1344         latency   => 2,
1345         units     => [ "SSE" ],
1346         mode      => "mode_E",
1347 },
1348
1349 xAnd => {
1350         irn_flags => "R",
1351         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1352         emit      => '. andp%XSD %binop',
1353         latency   => 3,
1354         units     => [ "SSE" ],
1355         mode      => "mode_E",
1356 },
1357
1358 xOr => {
1359         irn_flags => "R",
1360         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1361         emit      => '. orp%XSD %binop',
1362         units     => [ "SSE" ],
1363         mode      => "mode_E",
1364 },
1365
1366 xXor => {
1367         irn_flags => "R",
1368         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1369         emit      => '. xorp%XSD %binop',
1370         latency   => 3,
1371         units     => [ "SSE" ],
1372         mode      => "mode_E",
1373 },
1374
1375 # not commutative operations
1376
1377 xAndNot => {
1378         irn_flags => "R",
1379         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1380         emit      => '. andnp%XSD %binop',
1381         latency   => 3,
1382         units     => [ "SSE" ],
1383         mode      => "mode_E",
1384 },
1385
1386 xSub => {
1387         irn_flags => "R",
1388         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3" ] },
1389         emit      => '. sub%XXM %binop',
1390         latency   => 4,
1391         units     => [ "SSE" ],
1392         mode      => "mode_E",
1393 },
1394
1395 xDiv => {
1396         irn_flags => "R",
1397         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4", "none" ] },
1398         outs      => [ "res", "M" ],
1399         emit      => '. div%XXM %binop',
1400         latency   => 16,
1401         units     => [ "SSE" ],
1402 },
1403
1404 # other operations
1405
1406 xCmp => {
1407         irn_flags => "R",
1408         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "in_r3 !in_r4" ] },
1409         latency   => 3,
1410         units     => [ "SSE" ],
1411         mode      => "mode_E",
1412 },
1413
1414 xCmpJmp => {
1415         state     => "pinned",
1416         op_flags  => "L|X|Y",
1417         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "none", "none" ] },
1418         ins       => [ "base", "index", "left", "right", "mem" ],
1419         outs      => [ "false", "true" ],
1420         attr      => "long pnc",
1421         init_attr => "attr->pn_code = pnc;",
1422         latency   => 5,
1423         units     => [ "SSE" ],
1424 },
1425
1426 # Load / Store
1427
1428 xLoad => {
1429         op_flags  => "L|F",
1430         state     => "exc_pinned",
1431         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1432         emit      => '. mov%XXM %AM, %D0',
1433         attr      => "ir_mode *load_mode",
1434         init_attr => "attr->ls_mode = load_mode;",
1435         outs      => [ "res", "M" ],
1436         latency   => 2,
1437         units     => [ "SSE" ],
1438 },
1439
1440 xStore => {
1441         op_flags => "L|F",
1442         state    => "exc_pinned",
1443         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
1444         emit     => '. mov%XXM %SI2, %AM',
1445         latency  => 2,
1446         units    => [ "SSE" ],
1447         mode     => "mode_M",
1448 },
1449
1450 xStoreSimple => {
1451         op_flags => "L|F",
1452         state    => "exc_pinned",
1453         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
1454         ins      => [ "base", "index", "val", "mem" ],
1455         emit     => '. mov%XXM %S2, %AM',
1456         latency  => 2,
1457         units    => [ "SSE" ],
1458         mode     => "mode_M",
1459 },
1460
1461 CvtSI2SS => {
1462         op_flags => "L|F",
1463         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1464         emit     => '. cvtsi2ss %D0, %AM',
1465         latency  => 2,
1466         units    => [ "SSE" ],
1467         mode     => $mode_xmm
1468 },
1469
1470 CvtSI2SD => {
1471         op_flags => "L|F",
1472         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm" ] },
1473         emit     => '. cvtsi2sd %unop2',
1474         latency  => 2,
1475         units    => [ "SSE" ],
1476         mode     => $mode_xmm
1477 },
1478
1479
1480 l_X87toSSE => {
1481         op_flags => "L|F",
1482         cmp_attr => "return 1;",
1483         arity    => 3,
1484 },
1485
1486 l_SSEtoX87 => {
1487         op_flags => "L|F",
1488         cmp_attr => "return 1;",
1489         arity    => 3,
1490 },
1491
1492 # CopyB
1493
1494 CopyB => {
1495         op_flags => "F|H",
1496         state    => "pinned",
1497         reg_req  => { in => [ "edi", "esi", "ecx", "none" ], out => [ "edi", "esi", "ecx", "none" ] },
1498         outs     => [ "DST", "SRC", "CNT", "M" ],
1499         units    => [ "GP" ],
1500         modified_flags => [ "DF" ]
1501 },
1502
1503 CopyB_i => {
1504         op_flags => "F|H",
1505         state    => "pinned",
1506         reg_req  => { in => [ "edi", "esi", "none" ], out => [  "edi", "esi", "none" ] },
1507         outs     => [ "DST", "SRC", "M" ],
1508         units    => [ "GP" ],
1509         modified_flags => [ "DF" ]
1510 },
1511
1512 # Conversions
1513
1514 Conv_I2I => {
1515         state     => "exc_pinned",
1516         reg_req   => { in => [ "gp", "gp", "gp", "none" ], out => [ "in_r3", "none" ] },
1517         units     => [ "GP" ],
1518         ins       => [ "base", "index", "val", "mem" ],
1519         attr      => "ir_mode *smaller_mode",
1520         init_attr => "attr->ls_mode = smaller_mode;",
1521         mode      => $mode_gp,
1522         modified_flags => $status_flags
1523 },
1524
1525 Conv_I2I8Bit => {
1526         state     => "exc_pinned",
1527         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "none" ], out => [ "in_r3", "none" ] },
1528         ins       => [ "base", "index", "val", "mem" ],
1529         units     => [ "GP" ],
1530         attr      => "ir_mode *smaller_mode",
1531         init_attr => "attr->ls_mode = smaller_mode;",
1532         mode      => $mode_gp,
1533         modified_flags => $status_flags
1534 },
1535
1536 Conv_I2FP => {
1537         reg_req  => { in => [ "gp", "gp", "gp", "none" ], out => [ "xmm", "none" ] },
1538         latency  => 10,
1539         units    => [ "SSE" ],
1540         mode     => "mode_E",
1541 },
1542
1543 Conv_FP2I => {
1544         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "gp", "none" ] },
1545         latency  => 10,
1546         units    => [ "SSE" ],
1547         mode     => $mode_gp,
1548 },
1549
1550 Conv_FP2FP => {
1551         reg_req  => { in => [ "gp", "gp", "xmm", "none" ], out => [ "xmm", "none" ] },
1552         latency  => 8,
1553         units    => [ "SSE" ],
1554         mode     => "mode_E",
1555 },
1556
1557 CmpCMov => {
1558         irn_flags => "R",
1559         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ], out => [ "in_r7" ] },
1560         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true", "val_false" ],
1561         attr      => "pn_Cmp pn_code",
1562         init_attr => "attr->pn_code = pn_code;",
1563         latency   => 2,
1564         units     => [ "GP" ],
1565         mode      => $mode_gp,
1566 },
1567
1568 CmpCMov8Bit => {
1569         irn_flags => "R",
1570         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ], out => [ "in_r7" ] },
1571         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true", "val_false" ],
1572         attr      => "pn_Cmp pn_code",
1573         init_attr => "attr->pn_code = pn_code;",
1574         latency   => 2,
1575         units     => [ "GP" ],
1576         mode      => $mode_gp,
1577 },
1578
1579 TestCMov => {
1580         irn_flags => "R",
1581         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ],
1582                        out => [ "in_r7" ] },
1583         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1584                        "val_false" ],
1585         attr      => "pn_Cmp pn_code",
1586         init_attr => "attr->pn_code = pn_code;",
1587         latency   => 2,
1588         units     => [ "GP" ],
1589         mode      => $mode_gp,
1590 },
1591
1592 TestCMov8Bit => {
1593         irn_flags => "R",
1594         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none", "gp", "gp" ],
1595                        out => [ "in_r7" ] },
1596         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1597                        "val_false" ],
1598         attr      => "pn_Cmp pn_code",
1599         init_attr => "attr->pn_code = pn_code;",
1600         latency   => 2,
1601         units     => [ "GP" ],
1602         mode      => $mode_gp,
1603 },
1604
1605 xCmpCMov => {
1606         irn_flags => "R",
1607         reg_req   => { in => [ "xmm", "xmm", "gp", "gp" ], out => [ "in_r4" ] },
1608         latency   => 5,
1609         units     => [ "SSE" ],
1610         mode      => $mode_gp,
1611 },
1612
1613 vfCmpCMov => {
1614         irn_flags => "R",
1615         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "gp", "gp" ],
1616                        out => [ "in_r7" ] },
1617         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem", "val_true",
1618                        "val_false" ],
1619         latency   => 10,
1620         units     => [ "VFP", "GP" ],
1621         mode      => $mode_gp,
1622         attr_type => "ia32_x87_attr_t",
1623 },
1624
1625 CmpSet => {
1626         irn_flags => "R",
1627         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ],
1628                        out => [ "eax ebx ecx edx" ] },
1629         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1630         attr      => "pn_Cmp pn_code",
1631         init_attr => "attr->pn_code = pn_code;",
1632         latency   => 2,
1633         units     => [ "GP" ],
1634         mode      => $mode_gp,
1635 },
1636
1637 CmpSet8Bit => {
1638         irn_flags => "R",
1639         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1640                                "none" ],
1641                        out => [ "eax ebx ecx edx" ] },
1642         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1643         attr      => "pn_Cmp pn_code",
1644         init_attr => "attr->pn_code = pn_code;",
1645         latency   => 2,
1646         units     => [ "GP" ],
1647         mode      => $mode_gp,
1648 },
1649
1650 TestSet => {
1651         irn_flags => "R",
1652         reg_req   => { in => [ "gp", "gp", "gp", "gp", "none" ],
1653                        out => [ "eax ebx ecx edx" ] },
1654         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1655         attr      => "pn_Cmp pn_code",
1656         init_attr => "attr->pn_code = pn_code;",
1657         latency   => 2,
1658         units     => [ "GP" ],
1659         mode      => $mode_gp,
1660 },
1661
1662 TestSet8Bit => {
1663         irn_flags => "R",
1664         reg_req   => { in => [ "gp", "gp", "eax ebx ecx edx", "eax ebx ecx edx",
1665                                "none" ],
1666                        out => [ "eax ebx ecx edx" ] },
1667         ins       => [ "base", "index", "cmp_left", "cmp_right", "mem" ],
1668         attr      => "pn_Cmp pn_code",
1669         init_attr => "attr->pn_code = pn_code;",
1670         latency   => 2,
1671         units     => [ "GP" ],
1672         mode      => $mode_gp,
1673 },
1674
1675 xCmpSet => {
1676         irn_flags => "R",
1677         reg_req   => { in => [ "gp", "gp", "xmm", "xmm", "none" ], out => [ "eax ebx ecx edx" ] },
1678         latency   => 5,
1679         units     => [ "SSE" ],
1680         mode      => $mode_gp,
1681 },
1682
1683 vfCmpSet => {
1684         irn_flags => "R",
1685         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none" ], out => [ "eax ebx ecx edx" ] },
1686         latency   => 10,
1687         units     => [ "VFP" ],
1688         mode      => $mode_gp,
1689         attr_type => "ia32_x87_attr_t",
1690 },
1691
1692 vfCMov => {
1693         irn_flags => "R",
1694         reg_req   => { in => [ "vfp", "vfp", "vfp", "vfp" ], out => [ "vfp" ] },
1695         latency   => 10,
1696         units     => [ "VFP" ],
1697         mode      => "mode_E",
1698         attr_type => "ia32_x87_attr_t",
1699 },
1700
1701 #----------------------------------------------------------#
1702 #        _      _               _    __ _             _    #
1703 #       (_)    | |             | |  / _| |           | |   #
1704 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
1705 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
1706 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
1707 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
1708 #                 | |                                      #
1709 #  _ __   ___   __| | ___  ___                             #
1710 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
1711 # | | | | (_) | (_| |  __/\__ \                            #
1712 # |_| |_|\___/ \__,_|\___||___/                            #
1713 #----------------------------------------------------------#
1714
1715 vfadd => {
1716         irn_flags => "R",
1717         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1718         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1719         latency   => 4,
1720         units     => [ "VFP" ],
1721         mode      => "mode_E",
1722         attr_type => "ia32_x87_attr_t",
1723 },
1724
1725 vfmul => {
1726         irn_flags => "R",
1727         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1728         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1729         latency   => 4,
1730         units     => [ "VFP" ],
1731         mode      => "mode_E",
1732         attr_type => "ia32_x87_attr_t",
1733 },
1734
1735 l_vfmul => {
1736         op_flags  => "C",
1737         cmp_attr  => "return 1;",
1738         arity     => 2,
1739 },
1740
1741 vfsub => {
1742         irn_flags => "R",
1743         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1744         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1745         latency   => 4,
1746         units     => [ "VFP" ],
1747         mode      => "mode_E",
1748         attr_type => "ia32_x87_attr_t",
1749 },
1750
1751 l_vfsub => {
1752         cmp_attr  => "return 1;",
1753         arity     => 2,
1754 },
1755
1756 vfdiv => {
1757         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp", "none" ] },
1758         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1759         outs      => [ "res", "M" ],
1760         latency   => 20,
1761         units     => [ "VFP" ],
1762         attr_type => "ia32_x87_attr_t",
1763 },
1764
1765 l_vfdiv => {
1766         cmp_attr  => "return 1;",
1767         outs      => [ "res", "M" ],
1768         arity     => 2,
1769 },
1770
1771 vfprem => {
1772         reg_req   => { in => [ "gp", "gp", "vfp", "vfp", "none", "fpcw" ], out => [ "vfp" ] },
1773         ins       => [ "base", "index", "left", "right", "mem", "fpcw" ],
1774         latency   => 20,
1775         units     => [ "VFP" ],
1776         mode      => "mode_E",
1777         attr_type => "ia32_x87_attr_t",
1778 },
1779
1780 l_vfprem => {
1781         cmp_attr  => "return 1;",
1782         arity     => 2,
1783 },
1784
1785 vfabs => {
1786         irn_flags => "R",
1787         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1788         ins       => [ "value" ],
1789         latency   => 2,
1790         units     => [ "VFP" ],
1791         mode      => "mode_E",
1792         attr_type => "ia32_x87_attr_t",
1793 },
1794
1795 vfchs => {
1796         irn_flags => "R",
1797         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
1798         ins       => [ "value" ],
1799         latency   => 2,
1800         units     => [ "VFP" ],
1801         mode      => "mode_E",
1802         attr_type => "ia32_x87_attr_t",
1803 },
1804
1805 # virtual Load and Store
1806
1807 vfld => {
1808         op_flags  => "L|F",
1809         state     => "exc_pinned",
1810         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1811         ins       => [ "base", "index", "mem" ],
1812         outs      => [ "res", "M" ],
1813         attr      => "ir_mode *load_mode",
1814         init_attr => "attr->attr.ls_mode = load_mode;",
1815         latency   => 2,
1816         units     => [ "VFP" ],
1817         attr_type => "ia32_x87_attr_t",
1818 },
1819
1820 vfst => {
1821         op_flags  => "L|F",
1822         state     => "exc_pinned",
1823         reg_req   => { in => [ "gp", "gp", "vfp", "none" ] },
1824         ins       => [ "base", "index", "val", "mem" ],
1825         attr      => "ir_mode *store_mode",
1826         init_attr => "attr->attr.ls_mode = store_mode;",
1827         latency   => 2,
1828         units     => [ "VFP" ],
1829         mode      => "mode_M",
1830         attr_type => "ia32_x87_attr_t",
1831 },
1832
1833 # Conversions
1834
1835 vfild => {
1836         state     => "exc_pinned",
1837         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "vfp", "none" ] },
1838         outs      => [ "res", "M" ],
1839         ins       => [ "base", "index", "mem" ],
1840         latency   => 4,
1841         units     => [ "VFP" ],
1842         attr_type => "ia32_x87_attr_t",
1843 },
1844
1845 l_vfild => {
1846         cmp_attr  => "return 1;",
1847         outs      => [ "res", "M" ],
1848         arity     => 2,
1849 },
1850
1851 vfist => {
1852         state     => "exc_pinned",
1853         reg_req   => { in => [ "gp", "gp", "vfp", "fpcw", "none" ] },
1854         ins       => [ "base", "index", "val", "fpcw", "mem" ],
1855         latency   => 4,
1856         units     => [ "VFP" ],
1857         mode      => "mode_M",
1858         attr_type => "ia32_x87_attr_t",
1859 },
1860
1861 l_vfist => {
1862         cmp_attr  => "return 1;",
1863         state     => "exc_pinned",
1864         arity     => 3,
1865         mode      => "mode_M",
1866 },
1867
1868
1869 # constants
1870
1871 vfldz => {
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 vfld1 => {
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 vfldpi => {
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 vfldln2 => {
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 vfldlg2 => {
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 vfldl2t => {
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 vfldl2e => {
1926         irn_flags => "R",
1927         reg_req   => { out => [ "vfp" ] },
1928         latency   => 4,
1929         units     => [ "VFP" ],
1930         mode      => "mode_E",
1931         attr_type => "ia32_x87_attr_t",
1932 },
1933
1934 # other
1935
1936 vfCmpJmp => {
1937         state     => "pinned",
1938         op_flags  => "L|X|Y",
1939         reg_req   => { in => [ "vfp", "vfp" ], out => [ "none", "none", "eax" ] },
1940         ins       => [ "left", "right" ],
1941         outs      => [ "false", "true", "temp_reg_eax" ],
1942         attr      => "long pnc",
1943         init_attr => "attr->attr.pn_code = pnc;",
1944         latency   => 10,
1945         units     => [ "VFP" ],
1946         attr_type => "ia32_x87_attr_t",
1947 },
1948
1949 #------------------------------------------------------------------------#
1950 #       ___ _____    __ _             _                     _            #
1951 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
1952 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
1953 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
1954 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
1955 #------------------------------------------------------------------------#
1956
1957 # Note: gas is strangely buggy: fdivrp and fdivp as well as fsubrp and fsubp
1958 #       are swapped, we work this around in the emitter...
1959
1960 fadd => {
1961         op_flags  => "R",
1962         rd_constructor => "NONE",
1963         reg_req   => { },
1964         emit      => '. fadd%XM %x87_binop',
1965         attr_type => "ia32_x87_attr_t",
1966 },
1967
1968 faddp => {
1969         op_flags  => "R",
1970         rd_constructor => "NONE",
1971         reg_req   => { },
1972         emit      => '. faddp%XM %x87_binop',
1973         attr_type => "ia32_x87_attr_t",
1974 },
1975
1976 fmul => {
1977         op_flags  => "R",
1978         rd_constructor => "NONE",
1979         reg_req   => { },
1980         emit      => '. fmul%XM %x87_binop',
1981         attr_type => "ia32_x87_attr_t",
1982 },
1983
1984 fmulp => {
1985         op_flags  => "R",
1986         rd_constructor => "NONE",
1987         reg_req   => { },
1988         emit      => '. fmulp%XM %x87_binop',,
1989         attr_type => "ia32_x87_attr_t",
1990 },
1991
1992 fsub => {
1993         op_flags  => "R",
1994         rd_constructor => "NONE",
1995         reg_req   => { },
1996         emit      => '. fsub%XM %x87_binop',
1997         attr_type => "ia32_x87_attr_t",
1998 },
1999
2000 fsubp => {
2001         op_flags  => "R",
2002         rd_constructor => "NONE",
2003         reg_req   => { },
2004 # see note about gas bugs
2005         emit      => '. fsubrp%XM %x87_binop',
2006         attr_type => "ia32_x87_attr_t",
2007 },
2008
2009 fsubr => {
2010         op_flags  => "R",
2011         rd_constructor => "NONE",
2012         irn_flags => "R",
2013         reg_req   => { },
2014         emit      => '. fsubr%XM %x87_binop',
2015         attr_type => "ia32_x87_attr_t",
2016 },
2017
2018 fsubrp => {
2019         op_flags  => "R",
2020         rd_constructor => "NONE",
2021         irn_flags => "R",
2022         reg_req   => { },
2023 # see note about gas bugs
2024         emit      => '. fsubp%XM %x87_binop',
2025         attr_type => "ia32_x87_attr_t",
2026 },
2027
2028 fprem => {
2029         op_flags  => "R",
2030         rd_constructor => "NONE",
2031         reg_req   => { },
2032         emit      => '. fprem1',
2033         attr_type => "ia32_x87_attr_t",
2034 },
2035
2036 # this node is just here, to keep the simulator running
2037 # we can omit this when a fprem simulation function exists
2038 fpremp => {
2039         op_flags  => "R",
2040         rd_constructor => "NONE",
2041         reg_req   => { },
2042         emit      => '. fprem1',
2043         attr_type => "ia32_x87_attr_t",
2044 },
2045
2046 fdiv => {
2047         op_flags  => "R",
2048         rd_constructor => "NONE",
2049         reg_req   => { },
2050         emit      => '. fdiv%XM %x87_binop',
2051         attr_type => "ia32_x87_attr_t",
2052 },
2053
2054 fdivp => {
2055         op_flags  => "R",
2056         rd_constructor => "NONE",
2057         reg_req   => { },
2058 # see note about gas bugs
2059         emit      => '. fdivrp%XM %x87_binop',
2060         attr_type => "ia32_x87_attr_t",
2061 },
2062
2063 fdivr => {
2064         op_flags  => "R",
2065         rd_constructor => "NONE",
2066         reg_req   => { },
2067         emit      => '. fdivr%XM %x87_binop',
2068         attr_type => "ia32_x87_attr_t",
2069 },
2070
2071 fdivrp => {
2072         op_flags  => "R",
2073         rd_constructor => "NONE",
2074         reg_req   => { },
2075 # see note about gas bugs
2076         emit      => '. fdivp%XM %x87_binop',
2077         attr_type => "ia32_x87_attr_t",
2078 },
2079
2080 fabs => {
2081         op_flags  => "R",
2082         rd_constructor => "NONE",
2083         reg_req   => { },
2084         emit      => '. fabs',
2085         attr_type => "ia32_x87_attr_t",
2086 },
2087
2088 fchs => {
2089         op_flags  => "R|K",
2090         rd_constructor => "NONE",
2091         reg_req   => { },
2092         emit      => '. fchs',
2093         attr_type => "ia32_x87_attr_t",
2094 },
2095
2096 # x87 Load and Store
2097
2098 fld => {
2099         rd_constructor => "NONE",
2100         op_flags  => "R|L|F",
2101         state     => "exc_pinned",
2102         reg_req   => { },
2103         emit      => '. fld%XM %AM',
2104         attr_type => "ia32_x87_attr_t",
2105 },
2106
2107 fst => {
2108         rd_constructor => "NONE",
2109         op_flags  => "R|L|F",
2110         state     => "exc_pinned",
2111         reg_req   => { },
2112         emit      => '. fst%XM %AM',
2113         mode      => "mode_M",
2114         attr_type => "ia32_x87_attr_t",
2115 },
2116
2117 fstp => {
2118         rd_constructor => "NONE",
2119         op_flags  => "R|L|F",
2120         state     => "exc_pinned",
2121         reg_req   => { },
2122         emit      => '. fstp%XM %AM',
2123         mode      => "mode_M",
2124         attr_type => "ia32_x87_attr_t",
2125 },
2126
2127 # Conversions
2128
2129 fild => {
2130         op_flags  => "R",
2131         rd_constructor => "NONE",
2132         reg_req   => { },
2133         emit      => '. fild%M %AM',
2134         attr_type => "ia32_x87_attr_t",
2135 },
2136
2137 fist => {
2138         op_flags  => "R",
2139         state     => "exc_pinned",
2140         rd_constructor => "NONE",
2141         reg_req   => { },
2142         emit      => '. fist%M %AM',
2143         mode      => "mode_M",
2144         attr_type => "ia32_x87_attr_t",
2145 },
2146
2147 fistp => {
2148         op_flags  => "R",
2149         state     => "exc_pinned",
2150         rd_constructor => "NONE",
2151         reg_req   => { },
2152         emit      => '. fistp%M %AM',
2153         mode      => "mode_M",
2154         attr_type => "ia32_x87_attr_t",
2155 },
2156
2157 # constants
2158
2159 fldz => {
2160         op_flags  => "R|c|K",
2161         irn_flags  => "R",
2162         reg_req   => { },
2163         emit      => '. fldz',
2164         attr_type => "ia32_x87_attr_t",
2165 },
2166
2167 fld1 => {
2168         op_flags  => "R|c|K",
2169         irn_flags  => "R",
2170         reg_req   => { },
2171         emit      => '. fld1',
2172         attr_type => "ia32_x87_attr_t",
2173 },
2174
2175 fldpi => {
2176         op_flags  => "R|c|K",
2177         irn_flags  => "R",
2178         reg_req   => { },
2179         emit      => '. fldpi',
2180         attr_type => "ia32_x87_attr_t",
2181 },
2182
2183 fldln2 => {
2184         op_flags  => "R|c|K",
2185         irn_flags  => "R",
2186         reg_req   => { },
2187         emit      => '. fldln2',
2188         attr_type => "ia32_x87_attr_t",
2189 },
2190
2191 fldlg2 => {
2192         op_flags  => "R|c|K",
2193         irn_flags  => "R",
2194         reg_req   => { },
2195         emit      => '. fldlg2',
2196         attr_type => "ia32_x87_attr_t",
2197 },
2198
2199 fldl2t => {
2200         op_flags  => "R|c|K",
2201         irn_flags  => "R",
2202         reg_req   => { },
2203         emit      => '. fldll2t',
2204         attr_type => "ia32_x87_attr_t",
2205 },
2206
2207 fldl2e => {
2208         op_flags  => "R|c|K",
2209         irn_flags  => "R",
2210         reg_req   => { },
2211         emit      => '. fldl2e',
2212         attr_type => "ia32_x87_attr_t",
2213 },
2214
2215 # fxch, fpush, fpop
2216 # Note that it is NEVER allowed to do CSE on these nodes
2217 # Moreover, note the virtual register requierements!
2218
2219 fxch => {
2220         op_flags  => "R|K",
2221         reg_req   => { },
2222         cmp_attr  => "return 1;",
2223         emit      => '. fxch %X0',
2224         attr_type => "ia32_x87_attr_t",
2225 },
2226
2227 fpush => {
2228         op_flags  => "R|K",
2229         reg_req   => {},
2230         cmp_attr  => "return 1;",
2231         emit      => '. fld %X0',
2232         attr_type => "ia32_x87_attr_t",
2233 },
2234
2235 fpushCopy => {
2236         op_flags  => "R",
2237         reg_req   => { in => [ "vfp"], out => [ "vfp" ] },
2238         cmp_attr  => "return 1;",
2239         emit      => '. fld %X0',
2240         attr_type => "ia32_x87_attr_t",
2241 },
2242
2243 fpop => {
2244         op_flags  => "R|K",
2245         reg_req   => { },
2246         cmp_attr  => "return 1;",
2247         emit      => '. fstp %X0',
2248         attr_type => "ia32_x87_attr_t",
2249 },
2250
2251 # compare
2252
2253 fcomJmp => {
2254         op_flags  => "L|X|Y",
2255         reg_req   => { },
2256         attr_type => "ia32_x87_attr_t",
2257 },
2258
2259 fcompJmp => {
2260         op_flags  => "L|X|Y",
2261         reg_req   => { },
2262         attr_type => "ia32_x87_attr_t",
2263 },
2264
2265 fcomppJmp => {
2266         op_flags  => "L|X|Y",
2267         reg_req   => { },
2268         attr_type => "ia32_x87_attr_t",
2269 },
2270
2271 fcomrJmp => {
2272         op_flags  => "L|X|Y",
2273         reg_req   => { },
2274         attr_type => "ia32_x87_attr_t",
2275 },
2276
2277 fcomrpJmp => {
2278         op_flags  => "L|X|Y",
2279         reg_req   => { },
2280         attr_type => "ia32_x87_attr_t",
2281 },
2282
2283 fcomrppJmp => {
2284         op_flags  => "L|X|Y",
2285         reg_req   => { },
2286         attr_type => "ia32_x87_attr_t",
2287 },
2288
2289
2290 # -------------------------------------------------------------------------------- #
2291 #  ____ ____  _____                  _                               _             #
2292 # / ___/ ___|| ____| __   _____  ___| |_ ___  _ __   _ __   ___   __| | ___  ___   #
2293 # \___ \___ \|  _|   \ \ / / _ \/ __| __/ _ \| '__| | '_ \ / _ \ / _` |/ _ \/ __|  #
2294 #  ___) |__) | |___   \ V /  __/ (__| || (_) | |    | | | | (_) | (_| |  __/\__ \  #
2295 # |____/____/|_____|   \_/ \___|\___|\__\___/|_|    |_| |_|\___/ \__,_|\___||___/  #
2296 #                                                                                  #
2297 # -------------------------------------------------------------------------------- #
2298
2299
2300 # Spilling and reloading of SSE registers, hardcoded, not generated #
2301
2302 xxLoad => {
2303         op_flags  => "L|F",
2304         state     => "exc_pinned",
2305         reg_req   => { in => [ "gp", "gp", "none" ], out => [ "xmm", "none" ] },
2306         emit      => '. movdqu %D0, %AM',
2307         outs      => [ "res", "M" ],
2308         units     => [ "SSE" ],
2309 },
2310
2311 xxStore => {
2312         op_flags => "L|F",
2313         state    => "exc_pinned",
2314         reg_req  => { in => [ "gp", "gp", "xmm", "none" ] },
2315         emit     => '. movdqu %binop',
2316         units    => [ "SSE" ],
2317         mode     => "mode_M",
2318 },
2319
2320 ); # end of %nodes
2321
2322 # Include the generated SIMD node specification written by the SIMD optimization
2323 $my_script_name = dirname($myname) . "/../ia32/ia32_simd_spec.pl";
2324 unless ($return = do $my_script_name) {
2325         warn "couldn't parse $my_script_name: $@" if $@;
2326         warn "couldn't do $my_script_name: $!"    unless defined $return;
2327         warn "couldn't run $my_script_name"       unless $return;
2328 }