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