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