register slots are now automatically allocated together with the $ARCH_attribute
[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 string marks the beginning of a comment in emit
9 $comment_string = "/*";
10
11 # the number of additional opcodes you want to register
12 #$additional_opcodes = 0;
13
14 # The node description is done as a perl hash initializer with the
15 # following structure:
16 #
17 # %nodes = (
18 #
19 # <op-name> => {
20 #   "op_flags"  => "N|L|C|X|I|F|Y|H|c|K",
21 #   "irn_flags" => "R|N|I"
22 #   "arity"     => "0|1|2|3 ... |variable|dynamic|any",
23 #   "state"     => "floats|pinned|mem_pinned|exc_pinned",
24 #   "args"      => [
25 #                    { "type" => "type 1", "name" => "name 1" },
26 #                    { "type" => "type 2", "name" => "name 2" },
27 #                    ...
28 #                  ],
29 #   "comment"   => "any comment for constructor",
30 #   "reg_req"   => { "in" => [ "reg_class|register" ], "out" => [ "reg_class|register|in_rX" ] },
31 #   "cmp_attr"  => "c source code for comparing node attributes",
32 #   "emit"      => "emit code with templates",
33 #   "attr"      => "attitional attribute arguments for constructor"
34 #   "init_attr" => "emit attribute initialization template"
35 #   "rd_constructor" => "c source code which constructs an ir_node"
36 # },
37 #
38 # ... # (all nodes you need to describe)
39 #
40 # ); # close the %nodes initializer
41
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 # the op_flags correspond to the firm irop_flags:
44 #   N   irop_flag_none
45 #   L   irop_flag_labeled
46 #   C   irop_flag_commutative
47 #   X   irop_flag_cfopcode
48 #   I   irop_flag_ip_cfopcode
49 #   F   irop_flag_fragile
50 #   Y   irop_flag_forking
51 #   H   irop_flag_highlevel
52 #   c   irop_flag_constlike
53 #   K   irop_flag_keep
54 #
55 # irn_flags: special node flags, OPTIONAL (default is 0)
56 # following irn_flags are supported:
57 #   R   rematerializeable
58 #   N   not spillable
59 #   I   ignore for register allocation
60 #
61 # state: state of the operation, OPTIONAL (default is "floats")
62 #
63 # arity: arity of the operation, MUST NOT BE OMITTED
64 #
65 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
66 #        are always the first 3 arguments and are always autmatically
67 #        created)
68 #        If this key is missing the following arguments will be created:
69 #        for i = 1 .. arity: ir_node *op_i
70 #        ir_mode *mode
71 #
72 # outs:  if a node defines more than one output, the names of the projections
73 #        nodes having outs having automatically the mode mode_T
74 #
75 # comment: OPTIONAL comment for the node constructor
76 #
77 # rd_constructor: for every operation there will be a
78 #      new_rd_<arch>_<op-name> function with the arguments from above
79 #      which creates the ir_node corresponding to the defined operation
80 #      you can either put the complete source code of this function here
81 #
82 #      This key is OPTIONAL. If omitted, the following constructor will
83 #      be created:
84 #      if (!op_<arch>_<op-name>) assert(0);
85 #      for i = 1 to arity
86 #         set in[i] = op_i
87 #      done
88 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
89 #      return res
90 #
91 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
92
93 # register types:
94 #   0 - no special type
95 #   1 - caller save (register must be saved by the caller of a function)
96 #   2 - callee save (register must be saved by the called function)
97 #   4 - ignore (do not assign this register)
98 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
99 %reg_classes = (
100   "gp" => [
101             { "name" => "eax", "type" => 1 },
102             { "name" => "edx", "type" => 1 },
103             { "name" => "ebx", "type" => 2 },
104             { "name" => "ecx", "type" => 1 },
105             { "name" => "esi", "type" => 2 },
106             { "name" => "edi", "type" => 2 },
107             { "name" => "ebp", "type" => 2 },
108             { "name" => "esp", "type" => 4 },
109             { "name" => "gp_NOREG", "type" => 6 },  # we need a dummy register for NoReg nodes
110             { "name" => "gp_UKNWN", "type" => 6 },  # we need a dummy register for Unknown nodes
111                         { "mode" => "mode_P" }
112           ],
113   "xmm" => [
114             { "name" => "xmm0", "type" => 1 },
115             { "name" => "xmm1", "type" => 1 },
116             { "name" => "xmm2", "type" => 1 },
117             { "name" => "xmm3", "type" => 1 },
118             { "name" => "xmm4", "type" => 1 },
119             { "name" => "xmm5", "type" => 1 },
120             { "name" => "xmm6", "type" => 1 },
121             { "name" => "xmm7", "type" => 1 },
122             { "name" => "xmm_NOREG", "type" => 6 },  # we need a dummy register for NoReg nodes
123             { "name" => "xmm_UKNWN", "type" => 6 },  # we need a dummy register for Unknown nodes
124                         { "mode" => "mode_D" }
125           ],
126   "vfp" => [
127             { "name" => "vf0", "type" => 1 },
128             { "name" => "vf1", "type" => 1 },
129             { "name" => "vf2", "type" => 1 },
130             { "name" => "vf3", "type" => 1 },
131             { "name" => "vf4", "type" => 1 },
132             { "name" => "vf5", "type" => 1 },
133             { "name" => "vf6", "type" => 1 },
134             { "name" => "vf7", "type" => 1 },
135             { "name" => "vfp_NOREG", "type" => 6 },  # we need a dummy register for NoReg nodes
136             { "name" => "vfp_UKNWN", "type" => 6 },  # we need a dummy register for Unknown nodes
137                         { "mode" => "mode_E" }
138           ],
139   "st" => [
140             { "name" => "st0", "type" => 1 },
141             { "name" => "st1", "type" => 1 },
142             { "name" => "st2", "type" => 1 },
143             { "name" => "st3", "type" => 1 },
144             { "name" => "st4", "type" => 1 },
145             { "name" => "st5", "type" => 1 },
146             { "name" => "st6", "type" => 1 },
147             { "name" => "st7", "type" => 1 },
148             { "name" => "st_NOREG", "type" => 6 },  # we need a dummy register for NoReg nodes
149             { "name" => "st_UKNWN", "type" => 6 },  # we need a dummy register for Unknown nodes
150                         { "mode" => "mode_E" }
151           ]
152 ); # %reg_classes
153
154 #--------------------------------------------------#
155 #                        _                         #
156 #                       (_)                        #
157 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
158 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
159 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
160 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
161 #                                      | |         #
162 #                                      |_|         #
163 #--------------------------------------------------#
164
165 %operands = (
166 );
167
168 %nodes = (
169
170 #-----------------------------------------------------------------#
171 #  _       _                                         _            #
172 # (_)     | |                                       | |           #
173 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
174 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
175 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
176 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
177 #                   __/ |                                         #
178 #                  |___/                                          #
179 #-----------------------------------------------------------------#
180
181 # commutative operations
182
183 # NOTE:
184 # All nodes supporting Addressmode have 5 INs:
185 # 1 - base    r1 == NoReg in case of no AM or no base
186 # 2 - index   r2 == NoReg in case of no AM or no index
187 # 3 - op1     r3 == always present
188 # 4 - op2     r4 == NoReg in case of immediate operation
189 # 5 - mem     NoMem in case of no AM otherwise it takes the mem from the Load
190
191 "Add" => {
192   "irn_flags" => "R",
193   "comment"   => "construct Add: Add(a, b) = Add(b, a) = a + b",
194   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
195   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
196   "emit"      => '. add %ia32_emit_binop /* Add(%A1, %A2) -> %D1 */',
197   "outs"      => [ "res", "M" ],
198 },
199
200 "Mul" => {
201   "irn_flags" => "R",
202   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
203   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
204   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
205   "emit"      => '. imul %ia32_emit_binop /* Mul(%A1, %A2) -> %D1 */',
206   "outs"      => [ "res", "M" ],
207 },
208
209 # Mulh is an exception from the 4 INs with AM because the target is always EAX:EDX
210 "Mulh" => {
211   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
212   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
213   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "eax in_r3", "edx in_r4" ] },
214   "emit"      => '. imul %ia32_emit_binop /* Mulh(%A1, %A2) -> %D1 */',
215   "outs"      => [ "EAX", "EDX", "M" ],
216 },
217
218 "And" => {
219   "irn_flags" => "R",
220   "comment"   => "construct And: And(a, b) = And(b, a) = a AND b",
221   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
222   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
223   "emit"      => '. and %ia32_emit_binop /* And(%A1, %A2) -> %D1 */',
224   "outs"      => [ "res", "M" ],
225 },
226
227 "Or" => {
228   "irn_flags" => "R",
229   "comment"   => "construct Or: Or(a, b) = Or(b, a) = a OR b",
230   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
231   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
232   "emit"      => '. or %ia32_emit_binop /* Or(%A1, %A2) -> %D1 */',
233   "outs"      => [ "res", "M" ],
234 },
235
236 "Eor" => {
237   "irn_flags" => "R",
238   "comment"   => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
239   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
240   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
241   "emit"      => '. xor %ia32_emit_binop /* Xor(%A1, %A2) -> %D1 */',
242   "outs"      => [ "res", "M" ],
243 },
244
245 "Max" => {
246   "irn_flags" => "R",
247   "comment"   => "construct Max: Max(a, b) = Max(b, a) = a > b ? a : b",
248   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
249   "emit"      =>
250 '2. cmp %S1, %S2 /* prepare Max (%S1 - %S2), (%A1, %A2) */
251   if (mode_is_signed(get_irn_mode(n))) {
252 4.  cmovl %D1, %S2 /* %S1 is less %S2 */
253   }
254   else {
255 4.  cmovb %D1, %S2 /* %S1 is below %S2 */
256   }
257 '
258 },
259
260 "Min" => {
261   "irn_flags" => "R",
262   "comment"   => "construct Min: Min(a, b) = Min(b, a) = a < b ? a : b",
263   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
264   "emit"      =>
265 '2. cmp %S1, %S2 /* prepare Min (%S1 - %S2), (%A1, %A2) */
266   if (mode_is_signed(get_irn_mode(n))) {
267 2.  cmovg %D1, %S2 /* %S1 is greater %S2 */
268   }
269   else {
270 2.  cmova %D1, %S2, %D1 /* %S1 is above %S2 */
271   }
272 '
273 },
274
275 "CMov" => {
276   "irn_flags" => "R",
277   "comment"   => "construct Mux: Mux(sel, a, b) == sel ? a : b",
278   "reg_req"   => { "in" => [ "gp", "gp", "gp" ], "out" => [ "in_r2" ] },
279   "emit"      =>
280 '. cmp %S1, 0 /* compare Sel for CMov (%A2, %A3) */
281 . cmovne %D1, %S3 /* sel == true -> return %S3 */
282 '
283 },
284
285 # not commutative operations
286
287 "Sub" => {
288   "irn_flags" => "R",
289   "comment"   => "construct Sub: Sub(a, b) = a - b",
290   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
291   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
292   "emit"      => '. sub %ia32_emit_binop /* Sub(%A1, %A2) -> %D1 */',
293   "outs"      => [ "res", "M" ],
294 },
295
296 "DivMod" => {
297   "op_flags"  => "F|L",
298   "state"     => "exc_pinned",
299   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "eax in_r1", "edx in_r3" ] },
300   "attr"      => "ia32_op_flavour_t dm_flav",
301   "init_attr" => "  attr->data.op_flav = dm_flav;",
302   "cmp_attr"  => "  return attr_a->data.op_flav != attr_b->data.op_flav;\n",
303   "emit"      =>
304 '  if (mode_is_signed(get_irn_mode(n))) {
305 4.  idiv %S2 /* signed DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
306   }
307   else {
308 4.  div %S2 /* unsigned DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
309   }
310 ',
311   "outs"      => [ "div_res", "mod_res", "M" ],
312 },
313
314 "Shl" => {
315   "irn_flags" => "R",
316   "comment"   => "construct Shl: Shl(a, b) = a << b",
317   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
318   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
319   "emit"      => '. shl %ia32_emit_binop /* Shl(%A1, %A2) -> %D1 */',
320   "outs"      => [ "res", "M" ],
321 },
322
323 "Shr" => {
324   "irn_flags" => "R",
325   "comment"   => "construct Shr: Shr(a, b) = a >> b",
326   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
327   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
328   "emit"      => '. shr %ia32_emit_binop /* Shr(%A1, %A2) -> %D1 */',
329   "outs"      => [ "res", "M" ],
330 },
331
332 "Shrs" => {
333   "irn_flags" => "R",
334   "comment"   => "construct Shrs: Shrs(a, b) = a >> b",
335   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
336   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
337   "emit"      => '. sar %ia32_emit_binop /* Shrs(%A1, %A2) -> %D1 */',
338   "outs"      => [ "res", "M" ],
339 },
340
341 "RotR" => {
342   "irn_flags" => "R",
343   "comment"     => "construct RotR: RotR(a, b) = a ROTR b",
344   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
345   "reg_req"     => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
346   "emit"        => '. ror %ia32_emit_binop /* RotR(%A1, %A2) -> %D1 */',
347   "outs"      => [ "res", "M" ],
348 },
349
350 "RotL" => {
351   "irn_flags" => "R",
352   "comment"   => "construct RotL: RotL(a, b) = a ROTL b",
353   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
354   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
355   "emit"      => '. rol %ia32_emit_binop /* RotL(%A1, %A2) -> %D1 */',
356   "outs"      => [ "res", "M" ],
357 },
358
359 # unary operations
360
361 "Minus" => {
362   "irn_flags" => "R",
363   "comment"   => "construct Minus: Minus(a) = -a",
364   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
365   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
366   "emit"      => '. neg %ia32_emit_unop /* Neg(%A1) -> %D1, (%A1) */',
367   "outs"      => [ "res", "M" ],
368 },
369
370 "Inc" => {
371   "irn_flags" => "R",
372   "comment"   => "construct Increment: Inc(a) = a++",
373   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
374   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
375   "emit"      => '. inc %ia32_emit_unop /* Inc(%S1) -> %D1, (%A1) */',
376   "outs"      => [ "res", "M" ],
377 },
378
379 "Dec" => {
380   "irn_flags" => "R",
381   "comment"   => "construct Decrement: Dec(a) = a--",
382   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
383   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
384   "emit"      => '. dec %ia32_emit_unop /* Dec(%S1) -> %D1, (%A1) */',
385   "outs"      => [ "res", "M" ],
386 },
387
388 "Not" => {
389   "irn_flags" => "R",
390   "comment"   => "construct Not: Not(a) = !a",
391   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
392   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
393   "emit"      => '. not %ia32_emit_unop /* Not(%S1) -> %D1, (%A1) */',
394   "outs"      => [ "res", "M" ],
395 },
396
397 # other operations
398
399 "CondJmp" => {
400   "op_flags"  => "L|X|Y",
401   "comment"   => "construct conditional jump: CMP A, B && JMPxx LABEL",
402   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
403   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ] },
404   "outs"      => [ "false", "true" ],
405 },
406
407 "TestJmp" => {
408   "op_flags"  => "L|X|Y",
409   "comment"   => "construct conditional jump: TEST A, B && JMPxx LABEL",
410   "reg_req"  => { "in" => [ "gp", "gp" ] },
411   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
412   "outs"      => [ "false", "true" ],
413 },
414
415 "CJmpAM" => {
416   "op_flags"  => "L|X|Y",
417   "comment"   => "construct conditional jump without CMP (replaces CondJmp): JMPxx LABEL",
418   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
419   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "none", "none" ] },
420   "outs"      => [ "false", "true" ],
421 },
422
423 "CJmp" => {
424   "op_flags"  => "L|X|Y",
425   "comment"   => "construct conditional jump without CMP (replaces TestJmp): JMPxx LABEL",
426   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
427   "reg_req"   => { "in" => [ "gp", "gp" ] },
428 },
429
430 "SwitchJmp" => {
431   "op_flags"  => "L|X|Y",
432   "comment"   => "construct switch",
433   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
434   "reg_req"   => { "in" => [ "gp" ], "out" => [ "none" ] },
435 },
436
437 "Const" => {
438   "op_flags"  => "c",
439   "irn_flags" => "R",
440   "comment"   => "represents an integer constant",
441   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
442   "reg_req"   => { "in" => [ "none" ], "out" => [ "gp" ] },
443 },
444
445 "Cdq" => {
446   "irn_flags" => "R",
447   "comment"   => "construct CDQ: sign extend EAX -> EDX:EAX",
448   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax in_r1", "edx" ] },
449   "emit"      => '. cdq /* sign extend EAX -> EDX:EAX, (%A1) */',
450   "outs"      => [ "EAX", "EDX" ],
451 },
452
453 # Load / Store
454
455 "Load" => {
456   "op_flags"  => "L|F",
457   "irn_flags" => "R",
458   "state"     => "exc_pinned",
459   "comment"   => "construct Load: Load(ptr, mem) = LD ptr -> reg",
460   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
461   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "gp" ] },
462   "emit"      =>
463 '  if (get_mode_size_bits(get_ia32_ls_mode(n)) < 32) {
464 4.   mov%Mx %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
465   }
466   else {
467 4.   mov %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
468   }
469 ',
470   "outs"      => [ "res", "M" ],
471 },
472
473 "Store" => {
474   "op_flags"  => "L|F",
475   "state"     => "exc_pinned",
476   "comment"   => "construct Store: Store(ptr, val, mem) = ST ptr,val",
477   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
478   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ] },
479   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
480   "outs"      => [ "M" ],
481 },
482
483 "Store8Bit" => {
484   "op_flags"  => "L|F",
485   "state"     => "exc_pinned",
486   "comment"   => "construct 8Bit Store: Store(ptr, val, mem) = ST ptr,val",
487   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
488   "reg_req"   => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ] },
489   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */',
490   "outs"      => [ "M" ],
491 },
492
493 "Lea" => {
494   "irn_flags" => "R",
495   "comment"   => "construct Lea: Lea(a,b) = lea [a+b*const+offs] | res = a + b * const + offs with const = 0,1,2,4,8",
496   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
497   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
498   "emit"      => '. lea %D1, %ia32_emit_am /* LEA(%A1, %A2) */'
499 },
500
501 "Push" => {
502   "comment"   => "push a gp register on the stack",
503   "reg_req"   => { "in" => [ "esp", "gp", "none" ], "out" => [ "esp" ] },
504   "emit"      => '
505 if (get_ia32_id_cnst(n)) {
506         if (get_ia32_immop_type(n) == ia32_ImmConst) {
507 . push %C /* Push(%A2) */
508         } else {
509 . push OFFSET FLAT:%C /* Push(%A2) */
510         }
511 }
512 else {
513 . push %S2 /* Push(%A2) */
514 }
515 ',
516   "outs"      => [ "stack", "M" ],
517 },
518
519 "Pop" => {
520   "comment"   => "pop a gp register from the stack",
521   "reg_req"   => { "in" => [ "esp", "none" ], "out" => [ "gp", "esp" ] },
522   "emit"      => '. pop %D1 /* Pop -> %D1 */',
523   "outs"      => [ "res", "stack", "M" ],
524 },
525
526 "Enter" => {
527   "comment"   => "create stack frame",
528   "reg_req"   => { "in" => [ "esp" ], "out" => [ "ebp", "esp" ] },
529   "emit"      => '. enter /* Enter */',
530   "outs"      => [ "frame", "stack", "M" ],
531 },
532
533 "Leave" => {
534   "comment"   => "destroy stack frame",
535   "reg_req"   => { "in" => [ "esp", "ebp" ], "out" => [ "ebp", "esp" ] },
536   "emit"      => '. leave /* Leave */',
537   "outs"      => [ "frame", "stack", "M" ],
538 },
539
540 #-----------------------------------------------------------------------------#
541 #   _____ _____ ______    __ _             _                     _            #
542 #  / ____/ ____|  ____|  / _| |           | |                   | |           #
543 # | (___| (___ | |__    | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
544 #  \___ \\___ \|  __|   |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
545 #  ____) |___) | |____  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
546 # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
547 #-----------------------------------------------------------------------------#
548
549 # commutative operations
550
551 "xAdd" => {
552   "irn_flags" => "R",
553   "comment"   => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
554   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
555   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
556   "emit"      => '. adds%M %ia32_emit_binop /* SSE Add(%A3, %A4) -> %D1 */',
557   "outs"      => [ "res", "M" ],
558 },
559
560 "xMul" => {
561   "irn_flags" => "R",
562   "comment"   => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
563   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
564   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
565   "emit"      => '. muls%M %ia32_emit_binop /* SSE Mul(%A3, %A4) -> %D1 */',
566   "outs"      => [ "res", "M" ],
567 },
568
569 "xMax" => {
570   "irn_flags" => "R",
571   "comment"   => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
572   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
573   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
574   "emit"      => '. maxs%M %ia32_emit_binop /* SSE Max(%A3, %A4) -> %D1 */',
575   "outs"      => [ "res", "M" ],
576 },
577
578 "xMin" => {
579   "irn_flags" => "R",
580   "comment"   => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
581   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
582   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
583   "emit"      => '. mins%M %ia32_emit_binop /* SSE Min(%A3, %A4) -> %D1 */',
584   "outs"      => [ "res", "M" ],
585 },
586
587 "xAnd" => {
588   "irn_flags" => "R",
589   "comment"   => "construct SSE And: And(a, b) = a AND b",
590   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
591   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
592   "emit"      => '. andp%M %ia32_emit_binop /* SSE And(%A3, %A4) -> %D1 */',
593   "outs"      => [ "res", "M" ],
594 },
595
596 "xOr" => {
597   "irn_flags" => "R",
598   "comment"   => "construct SSE Or: Or(a, b) = a OR b",
599   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
600   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
601   "emit"      => '. orp%M %ia32_emit_binop /* SSE Or(%A3, %A4) -> %D1 */',
602   "outs"      => [ "res", "M" ],
603 },
604
605 "xEor" => {
606   "irn_flags" => "R",
607   "comment"   => "construct SSE Eor: Eor(a, b) = a XOR b",
608   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
609   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
610   "emit"      => '. xorp%M %ia32_emit_binop /* SSE Xor(%A3, %A4) -> %D1 */',
611   "outs"      => [ "res", "M" ],
612 },
613
614 # not commutative operations
615
616 "xSub" => {
617   "irn_flags" => "R",
618   "comment"   => "construct SSE Sub: Sub(a, b) = a - b",
619   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
620   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3" ] },
621   "emit"      => '. subs%M %ia32_emit_binop /* SSE Sub(%A1, %A2) -> %D1 */',
622   "outs"      => [ "res", "M" ],
623 },
624
625 "xDiv" => {
626   "irn_flags" => "R",
627   "comment"   => "construct SSE Div: Div(a, b) = a / b",
628   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
629   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "in_r3 !in_r4" ] },
630   "emit"      => '. divs%M %ia32_emit_binop /* SSE Div(%A1, %A2) -> %D1 */',
631   "outs"      => [ "res", "M" ],
632 },
633
634 # other operations
635
636 "xCondJmp" => {
637   "op_flags"  => "L|X|Y",
638   "comment"   => "construct conditional jump: UCOMIS A, B && JMPxx LABEL",
639   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
640   "reg_req"   => { "in" => [ "gp", "gp", "xmm", "xmm", "none" ], "out" => [ "none", "none" ] },
641   "outs"      => [ "false", "true" ],
642 },
643
644 "xConst" => {
645   "op_flags"  => "c",
646   "irn_flags" => "R",
647   "comment"   => "represents a SSE constant",
648   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
649   "reg_req"   => { "in" => [ "none" ], "out" => [ "xmm" ] },
650   "emit"      => '. mov%M %D1, %C /* Load fConst into register */',
651 },
652
653 # Load / Store
654
655 "xLoad" => {
656   "op_flags"  => "L|F",
657   "irn_flags" => "R",
658   "state"     => "exc_pinned",
659   "comment"   => "construct SSE Load: Load(ptr, mem) = LD ptr",
660   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
661   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "xmm" ] },
662   "emit"      => '. movs%M %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */',
663   "outs"      => [ "res", "M" ],
664 },
665
666 "xStore" => {
667   "op_flags" => "L|F",
668   "state"    => "exc_pinned",
669   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
670   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
671   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ] },
672   "emit"     => '. movs%M %ia32_emit_binop /* Store(%S3) -> (%A1) */',
673   "outs"      => [ "M" ],
674 },
675
676 # CopyB
677
678 "CopyB" => {
679   "op_flags" => "F|H",
680   "state"    => "pinned",
681   "comment"  => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
682   "reg_req"  => { "in" => [ "edi", "esi", "ecx", "none" ], "out" => [ "none" ] },
683 },
684
685 "CopyB_i" => {
686   "op_flags" => "F|H",
687   "state"    => "pinned",
688   "comment"  => "implements a memcopy: CopyB(dst, src, mem) == memcpy(dst, src, attr(size))",
689   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
690   "reg_req"  => { "in" => [ "edi", "esi", "none" ], "out" => [ "none" ] },
691 },
692
693 # Conversions
694
695 "Conv_I2I" => {
696   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3", "none" ] },
697   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
698   "comment"  => "construct Conv Int -> Int",
699   "outs"      => [ "res", "M" ],
700 },
701
702 "Conv_I2I8Bit" => {
703   "reg_req"  => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ], "out" => [ "in_r3", "none" ] },
704   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
705   "comment"  => "construct Conv Int -> Int",
706   "outs"      => [ "res", "M" ],
707 },
708
709 "Conv_I2FP" => {
710   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "xmm", "none" ] },
711   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
712   "comment"  => "construct Conv Int -> Floating Point",
713   "outs"      => [ "res", "M" ],
714 },
715
716 "Conv_FP2I" => {
717   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "gp", "none" ] },
718   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
719   "comment"  => "construct Conv Floating Point -> Int",
720   "outs"      => [ "res", "M" ],
721 },
722
723 "Conv_FP2FP" => {
724   "reg_req"  => { "in" => [ "gp", "gp", "xmm", "none" ], "out" => [ "xmm", "none" ] },
725   "cmp_attr"  => "  return ia32_compare_conv_attr(attr_a, attr_b);\n",
726   "comment"  => "construct Conv Floating Point -> Floating Point",
727   "outs"      => [ "res", "M" ],
728 },
729
730 #----------------------------------------------------------#
731 #        _      _               _    __ _             _    #
732 #       (_)    | |             | |  / _| |           | |   #
733 # __   ___ _ __| |_ _   _  __ _| | | |_| | ___   __ _| |_  #
734 # \ \ / / | '__| __| | | |/ _` | | |  _| |/ _ \ / _` | __| #
735 #  \ V /| | |  | |_| |_| | (_| | | | | | | (_) | (_| | |_  #
736 #   \_/ |_|_|   \__|\__,_|\__,_|_| |_| |_|\___/ \__,_|\__| #
737 #                 | |                                      #
738 #  _ __   ___   __| | ___  ___                             #
739 # | '_ \ / _ \ / _` |/ _ \/ __|                            #
740 # | | | | (_) | (_| |  __/\__ \                            #
741 # |_| |_|\___/ \__,_|\___||___/                            #
742 #----------------------------------------------------------#
743
744 "vfadd" => {
745   "irn_flags" => "R",
746   "comment"   => "virtual fp Add: Add(a, b) = Add(b, a) = a + b",
747   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
748   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
749   "outs"      => [ "res", "M" ],
750 },
751
752 "vfmul" => {
753   "irn_flags" => "R",
754   "comment"   => "virtual fp Mul: Mul(a, b) = Mul(b, a) = a + b",
755   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
756   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
757   "outs"      => [ "res", "M" ],
758 },
759
760 "vfsub" => {
761   "irn_flags" => "R",
762   "comment"   => "virtual fp Sub: Sub(a, b) = a - b",
763   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
764   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
765   "outs"      => [ "res", "M" ],
766 },
767
768 "vfdiv" => {
769   "comment"   => "virtual fp Div: Div(a, b) = a / b",
770   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
771   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "vfp" ] },
772   "outs"      => [ "res", "M" ],
773 },
774
775 "vfabs" => {
776   "irn_flags" => "R",
777   "comment"   => "virtual fp Abs: Abs(a) = |a|",
778   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
779 },
780
781 "vfchs" => {
782   "irn_flags" => "R",
783   "comment"   => "virtual fp Chs: Chs(a) = -a",
784   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
785 },
786
787 "vfsin" => {
788   "irn_flags" => "R",
789   "comment"   => "virtual fp Sin: Sin(a) = sin(a)",
790   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
791 },
792
793 "vfcos" => {
794   "irn_flags" => "R",
795   "comment"   => "virtual fp Cos: Cos(a) = cos(a)",
796   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
797 },
798
799 "vfsqrt" => {
800   "irn_flags" => "R",
801   "comment"   => "virtual fp Sqrt: Sqrt(a) = a ^ 0.5",
802   "reg_req"   => { "in" => [ "vfp"], "out" => [ "vfp" ] },
803 },
804
805 # virtual Load and Store
806
807 "vfld" => {
808   "op_flags"  => "L|F",
809   "irn_flags" => "R",
810   "state"     => "exc_pinned",
811   "comment"   => "virtual fp Load: Load(ptr, mem) = LD ptr -> reg",
812   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
813   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
814   "outs"      => [ "res", "M" ],
815 },
816
817 "vfst" => {
818   "op_flags"  => "L|F",
819   "state"     => "exc_pinned",
820   "comment"   => "virtual fp Store: Store(ptr, val, mem) = ST ptr,val",
821   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
822   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
823   "outs"      => [ "M" ],
824 },
825
826 # Conversions
827
828 "vfild" => {
829   "irn_flags" => "R",
830   "comment"   => "virtual fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
831   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
832   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "vfp", "none" ] },
833   "outs"      => [ "res", "M" ],
834 },
835
836 "vfist" => {
837   "comment"   => "virtual fp integer Store: Store(ptr, val, mem) = iST ptr,val",
838   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
839   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "none" ] },
840   "outs"      => [ "M" ],
841 },
842
843 # constants
844
845 "vfldz" => {
846   "irn_flags" => "R",
847   "comment"   => "virtual fp Load 0.0: Ld 0.0 -> reg",
848   "reg_req"   => { "out" => [ "vfp" ] },
849 },
850
851 "vfld1" => {
852   "irn_flags" => "R",
853   "comment"   => "virtual fp Load 1.0: Ld 1.0 -> reg",
854   "reg_req"   => { "out" => [ "vfp" ] },
855 },
856
857 "vfldpi" => {
858   "irn_flags" => "R",
859   "comment"   => "virtual fp Load pi: Ld pi -> reg",
860   "reg_req"   => { "out" => [ "vfp" ] },
861 },
862
863 "vfldln2" => {
864   "irn_flags" => "R",
865   "comment"   => "virtual fp Load ln 2: Ld ln 2 -> reg",
866   "reg_req"   => { "out" => [ "vfp" ] },
867 },
868
869 "vfldlg2" => {
870   "irn_flags" => "R",
871   "comment"   => "virtual fp Load lg 2: Ld lg 2 -> reg",
872   "reg_req"   => { "out" => [ "vfp" ] },
873 },
874
875 "vfldl2t" => {
876   "irn_flags" => "R",
877   "comment"   => "virtual fp Load ld 10: Ld ld 10 -> reg",
878   "reg_req"   => { "out" => [ "vfp" ] },
879 },
880
881 "vfldl2e" => {
882   "irn_flags" => "R",
883   "comment"   => "virtual fp Load ld e: Ld ld e -> reg",
884   "reg_req"   => { "out" => [ "vfp" ] },
885 },
886
887 "vfConst" => {
888   "op_flags"  => "c",
889   "irn_flags" => "R",
890   "comment"   => "represents a virtual floating point constant",
891   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
892   "reg_req"   => { "in" => [ "none" ], "out" => [ "vfp" ] },
893 },
894
895 # other
896
897 "vfCondJmp" => {
898   "op_flags"  => "L|X|Y",
899   "comment"   => "represents a virtual floating point compare",
900   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
901   "reg_req"   => { "in" => [ "gp", "gp", "vfp", "vfp", "none" ], "out" => [ "none", "none", "eax" ] },
902   "outs"      => [ "false", "true", "temp_reg_eax" ],
903 },
904
905 #------------------------------------------------------------------------#
906 #       ___ _____    __ _             _                     _            #
907 # __  _( _ )___  |  / _| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
908 # \ \/ / _ \  / /  | |_| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
909 #  >  < (_) |/ /   |  _| | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
910 # /_/\_\___//_/    |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
911 #------------------------------------------------------------------------#
912
913 "fadd" => {
914   "op_flags"  => "R",
915   "rd_constructor" => "NONE",
916   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
917   "reg_req"   => { },
918   "emit"      => '. fadd %ia32_emit_x87_binop /* x87 fadd(%A1, %A2) -> %D1 */',
919 },
920
921 "faddp" => {
922   "op_flags"  => "R",
923   "rd_constructor" => "NONE",
924   "comment"   => "x87 Add: Add(a, b) = Add(b, a) = a + b",
925   "reg_req"   => { },
926   "emit"      => '. faddp %ia32_emit_x87_binop /* x87 fadd(%A1, %A2) -> %D1 */',
927 },
928
929 "fmul" => {
930   "op_flags"  => "R",
931   "rd_constructor" => "NONE",
932   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
933   "reg_req"   => { },
934   "emit"      => '. fmul %ia32_emit_x87_binop /* x87 fmul(%A1, %A2) -> %D1 */',
935 },
936
937 "fmulp" => {
938   "op_flags"  => "R",
939   "rd_constructor" => "NONE",
940   "comment"   => "x87 fp Mul: Mul(a, b) = Mul(b, a) = a + b",
941   "reg_req"   => { },
942   "emit"      => '. fmulp %ia32_emit_x87_binop /* x87 fmul(%A1, %A2) -> %D1 */',,
943 },
944
945 "fsub" => {
946   "op_flags"  => "R",
947   "rd_constructor" => "NONE",
948   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
949   "reg_req"   => { },
950   "emit"      => '. fsub %ia32_emit_x87_binop /* x87 fsub(%A1, %A2) -> %D1 */',
951 },
952
953 "fsubp" => {
954   "op_flags"  => "R",
955   "rd_constructor" => "NONE",
956   "comment"   => "x87 fp Sub: Sub(a, b) = a - b",
957   "reg_req"   => { },
958   "emit"      => '. fsubp %ia32_emit_x87_binop /* x87 fsub(%A1, %A2) -> %D1 */',
959 },
960
961 "fsubr" => {
962   "op_flags"  => "R",
963   "rd_constructor" => "NONE",
964   "irn_flags" => "R",
965   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
966   "reg_req"   => { },
967   "emit"      => '. fsubr %ia32_emit_x87_binop /* x87 fsubr(%A1, %A2) -> %D1 */',
968 },
969
970 "fsubrp" => {
971   "op_flags"  => "R",
972   "rd_constructor" => "NONE",
973   "irn_flags" => "R",
974   "comment"   => "x87 fp SubR: SubR(a, b) = b - a",
975   "reg_req"   => { },
976   "emit"      => '. fsubrp %ia32_emit_x87_binop /* x87 fsubr(%A1, %A2) -> %D1 */',
977 },
978
979 "fdiv" => {
980   "op_flags"  => "R",
981   "rd_constructor" => "NONE",
982   "comment"   => "x87 fp Div: Div(a, b) = a / b",
983   "reg_req"   => { },
984   "emit"      => '. fdiv %ia32_emit_x87_binop /* x87 fdiv(%A1, %A2) -> %D1 */',
985 },
986
987 "fdivp" => {
988   "op_flags"  => "R",
989   "rd_constructor" => "NONE",
990   "comment"   => "x87 fp Div: Div(a, b) = a / b",
991   "reg_req"   => { },
992   "emit"      => '. fdivp %ia32_emit_x87_binop /* x87 fdiv(%A1, %A2) -> %D1 */',
993 },
994
995 "fdivr" => {
996   "op_flags"  => "R",
997   "rd_constructor" => "NONE",
998   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
999   "reg_req"   => { },
1000   "emit"      => '. fdivr %ia32_emit_x87_binop /* x87 fdivr(%A1, %A2) -> %D1 */',
1001 },
1002
1003 "fdivrp" => {
1004   "op_flags"  => "R",
1005   "rd_constructor" => "NONE",
1006   "comment"   => "x87 fp DivR: DivR(a, b) = b / a",
1007   "reg_req"   => { },
1008   "emit"      => '. fdivrp %ia32_emit_x87_binop /* x87 fdivr(%A1, %A2) -> %D1 */',
1009 },
1010
1011 "fabs" => {
1012   "op_flags"  => "R",
1013   "rd_constructor" => "NONE",
1014   "comment"   => "x87 fp Abs: Abs(a) = |a|",
1015   "reg_req"   => { },
1016   "emit"      => '. fabs /* x87 fabs(%S1) -> %D1 */',
1017 },
1018
1019 "fchs" => {
1020   "op_flags"  => "R",
1021   "rd_constructor" => "NONE",
1022   "comment"   => "x87 fp Chs: Chs(a) = -a",
1023   "reg_req"   => { },
1024   "emit"      => '. fchs /* x87 fchs(%S1) -> %D1 */',
1025 },
1026
1027 "fsin" => {
1028   "op_flags"  => "R",
1029   "rd_constructor" => "NONE",
1030   "comment"   => "x87 fp Sin: Sin(a) = sin(a)",
1031   "reg_req"   => { },
1032   "emit"      => '. fsin /* x87 sin(%S1) -> %D1 */',
1033 },
1034
1035 "fcos" => {
1036   "op_flags"  => "R",
1037   "rd_constructor" => "NONE",
1038   "comment"   => "x87 fp Cos: Cos(a) = cos(a)",
1039   "reg_req"   => { },
1040   "emit"      => '. fcos /* x87 cos(%S1) -> %D1 */',
1041 },
1042
1043 "fsqrt" => {
1044   "op_flags"  => "R",
1045   "rd_constructor" => "NONE",
1046   "comment"   => "x87 fp Sqrt: Sqrt(a) = a ^ 0.5",
1047   "reg_req"   => { },
1048   "emit"      => '. fsqrt $ /* x87 sqrt(%S1) -> %D1 */',
1049 },
1050
1051 # x87 Load and Store
1052
1053 "fld" => {
1054   "rd_constructor" => "NONE",
1055   "op_flags"  => "R|L|F",
1056   "state"     => "exc_pinned",
1057   "comment"   => "x87 fp Load: Load(ptr, mem) = LD ptr -> reg",
1058   "reg_req"   => { },
1059   "emit"      => '. fld %ia32_emit_am /* Load((%A1)) -> %D1 */',
1060 },
1061
1062 "fst" => {
1063   "rd_constructor" => "NONE",
1064   "op_flags"  => "R|L|F",
1065   "state"     => "exc_pinned",
1066   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1067   "reg_req"   => { },
1068   "emit"      => '. fst %ia32_emit_am /* Store(%A3) -> (%A1) */',
1069 },
1070
1071 "fstp" => {
1072   "rd_constructor" => "NONE",
1073   "op_flags"  => "R|L|F",
1074   "state"     => "exc_pinned",
1075   "comment"   => "x87 fp Store: Store(ptr, val, mem) = ST ptr,val",
1076   "reg_req"   => { },
1077   "emit"      => '. fstp %ia32_emit_am /* Store(%A3) -> (%A1) and pop */',
1078 },
1079
1080 # Conversions
1081
1082 "fild" => {
1083   "op_flags"  => "R",
1084   "irn_flags" => "R",
1085   "comment"   => "x87 fp integer Load: Load(ptr, mem) = iLD ptr -> reg",
1086   "reg_req"   => { },
1087   "emit"      => '. fild %ia32_emit_am /* integer Load((%A1)) -> %D1 */',
1088 },
1089
1090 "fist" => {
1091   "op_flags"  => "R",
1092   "rd_constructor" => "NONE",
1093   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1094   "reg_req"   => { },
1095   "emit"      => '. fist %ia32_emit_am /* integer Store(%A3) -> (%A1) */',
1096 },
1097
1098 "fistp" => {
1099   "op_flags"  => "R",
1100   "rd_constructor" => "NONE",
1101   "comment"   => "x87 fp integer Store: Store(ptr, val, mem) = iST ptr,val",
1102   "reg_req"   => { },
1103   "emit"      => '. fistp %ia32_emit_am /* integer Store(%A3) -> (%A1) and pop */',
1104 },
1105
1106 # constants
1107
1108 "fldz" => {
1109   "op_flags"  => "R",
1110   "rd_constructor" => "NONE",
1111   "comment"   => "x87 fp Load 0.0: Ld 0.0 -> reg",
1112   "reg_req"   => { },
1113   "emit"      => '. fldz /* x87 0.0 -> %D1 */',
1114 },
1115
1116 "fld1" => {
1117   "op_flags"  => "R",
1118   "rd_constructor" => "NONE",
1119   "comment"   => "x87 fp Load 1.0: Ld 1.0 -> reg",
1120   "reg_req"   => { },
1121   "emit"      => '. fld1 /* x87 1.0 -> %D1 */',
1122 },
1123
1124 "fldpi" => {
1125   "op_flags"  => "R",
1126   "rd_constructor" => "NONE",
1127   "comment"   => "x87 fp Load pi: Ld pi -> reg",
1128   "reg_req"   => { },
1129   "emit"      => '. fldpi /* x87 pi -> %D1 */',
1130 },
1131
1132 "fldln2" => {
1133   "op_flags"  => "R",
1134   "rd_constructor" => "NONE",
1135   "comment"   => "x87 fp Load ln 2: Ld ln 2 -> reg",
1136   "reg_req"   => { },
1137   "emit"      => '. fldln2 /* x87 ln(2) -> %D1 */',
1138 },
1139
1140 "fldlg2" => {
1141   "op_flags"  => "R",
1142   "rd_constructor" => "NONE",
1143   "comment"   => "x87 fp Load lg 2: Ld lg 2 -> reg",
1144   "reg_req"   => { },
1145   "emit"      => '. fldlg2 /* x87 log(2) -> %D1 */',
1146 },
1147
1148 "fldl2t" => {
1149   "op_flags"  => "R",
1150   "rd_constructor" => "NONE",
1151   "comment"   => "x87 fp Load ld 10: Ld ld 10 -> reg",
1152   "reg_req"   => { },
1153   "emit"      => '. fldll2t /* x87 ld(10) -> %D1 */',
1154 },
1155
1156 "fldl2e" => {
1157   "op_flags"  => "R",
1158   "rd_constructor" => "NONE",
1159   "comment"   => "x87 fp Load ld e: Ld ld e -> reg",
1160   "reg_req"   => { },
1161   "emit"      => '. fldl2e /* x87 ld(e) -> %D1 */',
1162 },
1163
1164 "fldConst" => {
1165   "op_flags"  => "R",
1166   "op_flags"  => "c",
1167   "irn_flags" => "R",
1168   "comment"   => "represents a x87 constant",
1169   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1170   "reg_req"   => { "out" => [ "st" ] },
1171   "emit"      => '. fld%M %C /* Load fConst into register -> %D1 */',
1172 },
1173
1174 # fxch, fpush, fpop
1175 # Note that it is NEVER allowed to do CSE on these nodes
1176
1177 "fxch" => {
1178   "op_flags"  => "R|K",
1179   "comment"   => "x87 stack exchange",
1180   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1181   "cmp_attr"  => "  return 1;\n",
1182   "emit"      => '. fxch %X1 /* x87 swap %X1, %X3 */',
1183 },
1184
1185 "fpush" => {
1186   "op_flags"  => "R",
1187   "comment"   => "x87 stack push",
1188   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1189   "cmp_attr"  => "  return 1;\n",
1190   "emit"      => '. fld %X1 /* x87 push %X1 */',
1191 },
1192
1193 "fpop" => {
1194   "op_flags"  => "R|K",
1195   "comment"   => "x87 stack pop",
1196   "reg_req"   => { "in" => [ "st"], "out" => [ "st" ] },
1197   "cmp_attr"  => "  return 1;\n",
1198   "emit"      => '. fstp %X1 /* x87 pop %X1 */',
1199 },
1200
1201 # compare
1202
1203 "fcomJmp" => {
1204   "op_flags"  => "L|X|Y",
1205   "comment"   => "floating point compare",
1206   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1207   "reg_req"   => { },
1208 },
1209
1210 "fcompJmp" => {
1211   "op_flags"  => "L|X|Y",
1212   "comment"   => "floating point compare and pop",
1213   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1214   "reg_req"   => { },
1215 },
1216
1217 "fcomppJmp" => {
1218   "op_flags"  => "L|X|Y",
1219   "comment"   => "floating point compare and pop twice",
1220   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1221   "reg_req"   => { },
1222 },
1223
1224 "fcomrJmp" => {
1225   "op_flags"  => "L|X|Y",
1226   "comment"   => "floating point compare reverse",
1227   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1228   "reg_req"   => { },
1229 },
1230
1231 "fcomrpJmp" => {
1232   "op_flags"  => "L|X|Y",
1233   "comment"   => "floating point compare reverse and pop",
1234   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1235   "reg_req"   => { },
1236 },
1237
1238 "fcomrppJmp" => {
1239   "op_flags"  => "L|X|Y",
1240   "comment"   => "floating point compare reverse and pop twice",
1241   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
1242   "reg_req"   => { },
1243 },
1244
1245 ); # end of %nodes