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