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