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