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