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