6701cd414f1013f77de3c8ac489bf0c0c1ba17e2
[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
7 $arch = "ia32";
8
9 # The node description is done as a perl hash initializer with the
10 # following structure:
11 #
12 # %nodes = (
13 #
14 # <op-name> => {
15 #   "op_flags" => "N|L|C|X|I|F|Y|H|c",
16 #   "arity"    => "0|1|2|3|variable|dynamic|all",
17 #   "state"    => "floats|pinned",
18 #   "args"     => [
19 #                   { "type" => "type 1", "name" => "name 1" },
20 #                   { "type" => "type 2", "name" => "name 2" },
21 #                   ...
22 #                 ],
23 #   "comment"  => "any comment for constructor",
24 #   "rd_constructor" => "c source code which constructs an ir_node"
25 # },
26 #
27 # ... # (all nodes you need to describe)
28 #
29 # ); # close the %nodes initializer
30
31 # the op_flags correspond to the firm irop_flags:
32 #   N   irop_flag_none
33 #   L   irop_flag_labeled
34 #   C   irop_flag_commutative
35 #   X   irop_flag_cfopcode
36 #   I   irop_flag_ip_cfopcode
37 #   F   irop_flag_fragile
38 #   Y   irop_flag_forking
39 #   H   irop_flag_highlevel
40 #   c   irop_flag_constlike
41 #
42 # op_flags: flags for the operation, OPTIONAL (default is "N")
43 #
44 # state: state of the operation, OPTIONAL (default is "pinned")
45 #
46 # arity: arity of the operation, MUST NOT BE OMITTED
47 #
48 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
49 #        are always the first 3 arguments and are always autmatically
50 #        created)
51 #        If this key is missing the following arguments will be created:
52 #        for i = 1 .. arity: ir_node *op_i
53 #        ir_mode *mode
54 #
55 # comment: OPTIONAL comment for the node constructor
56 #
57 # rd_constructor: for every operation there will be a
58 #      new_rd_<arch>_<op-name> function with the arguments from above
59 #      which creates the ir_node corresponding to the defined operation
60 #      you can either put the complete source code of this function here
61 #
62 #      This key is OPTIONAL. If omitted, the following constructor will
63 #      be created:
64 #      if (!op_<arch>_<op-name>) assert(0);
65 #      for i = 1 to arity
66 #         set in[i] = op_i
67 #      done
68 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
69 #      return res
70 #
71 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
72
73 # register types:
74 #   0 - no special type
75 #   1 - write invariant (writes to this register doesn't change it's content)
76 #   2 - caller save (register must be saved by the caller of a function)
77 #   3 - callee save (register must be saved by the called function)
78 #   4 - ignore (do not assign this register)
79 # NOTE: Make sure to list the registers returning the call-result at first and
80 #       in the correct order, otherwise it will break the magic!
81 %reg_classes = (
82   "general_purpose" => [
83                          { "name" => "eax", "type" => 2 },
84                          { "name" => "edx", "type" => 2 },
85                          { "name" => "ebx", "type" => 3 },
86                          { "name" => "ecx", "type" => 2 },
87                          { "name" => "edi", "type" => 2 },
88                          { "name" => "esi", "type" => 3 },
89                          { "name" => "ebp", "type" => 3 }
90                        ],
91   "floating_point"  => [
92                          { "name" => "xmm0", "type" => 2 },
93                          { "name" => "xmm1", "type" => 2 },
94                          { "name" => "xmm2", "type" => 2 },
95                          { "name" => "xmm3", "type" => 2 },
96                          { "name" => "xmm4", "type" => 2 },
97                          { "name" => "xmm5", "type" => 2 },
98                          { "name" => "xmm6", "type" => 2 },
99                          { "name" => "xmm7", "type" => 2 },
100                        ]
101 ); # %reg_classes
102
103 #--------------------------------------------------#
104 #                        _                         #
105 #                       (_)                        #
106 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
107 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
108 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
109 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
110 #                                      | |         #
111 #                                      |_|         #
112 #--------------------------------------------------#
113
114 %nodes = (
115
116 #-----------------------------------------------------------------#
117 #  _       _                                         _            #
118 # (_)     | |                                       | |           #
119 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
120 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
121 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
122 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
123 #                   __/ |                                         #
124 #                  |___/                                          #
125 #-----------------------------------------------------------------#
126
127 # commutative operations
128
129 "Add" => {
130   "op_flags"    => "C",
131   "arity"       => 2,
132   "remat"       => 1,
133   "comment"     => "construct Add: Add(a, b) = Add(b, a) = a + b",
134   "check_inout" => 1,
135   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
136   "emit"        => '. addl %S2, %D1\t\t\t/* Add(%S1, %S2) -> %D1, (%A1, %A2) */'
137 },
138
139 "Add_i" => {
140   "arity"       => 1,
141   "remat"       => 1,
142   "comment"     => "construct Add: Add(a, const) = Add(const, a) = a + const",
143   "check_inout" => 1,
144   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
145   "emit"        => '. addl %C, %D1\t\t\t/* Add(%C, %S1) -> %D1, (%A1, const) */'
146 },
147
148 "Mul" => {
149   "op_flags"    => "C",
150   "arity"       => 2,
151   "comment"     => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
152   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "eax in_r1", "edx in_r2" ] },
153   "emit"        =>
154 '  if (mode_is_signed(get_irn_mode(n))) {
155 4. imull %S2\t\t\t/* signed Mul(%S1, %S2) -> %D1, (%A1, %A2) */
156   }
157   else {
158 4. mull %S2\t\t\t/* unsigned Mul(%S1, %S2) -> %D1, (%A1, %A2) */
159   }
160 '
161 },
162
163 "Mul_i" => {
164   "state"       => "pinned",
165   "arity"       => 1,
166   "comment"     => "construct Mul: Mul(a, const) = Mul(const, a) = a * const",
167   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "eax in_r1", "edx" ] },
168   "emit"        =>
169 '  if (mode_is_signed(get_irn_mode(n))) {
170 4. imull %C\t\t\t/* signed Mul(%C, %S1) -> %D1, (%A1, const) */
171   }
172   else {
173 4. mull %C\t\t\t/* unsigned Mul(%C, %S1) -> %D1, (%A1, const) */
174   }
175 '
176 },
177
178 "And" => {
179   "op_flags"    => "C",
180   "arity"       => 2,
181   "remat"       => 1,
182   "comment"     => "construct And: And(a, b) = And(b, a) = a AND b",
183   "check_inout" => 1,
184   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
185   "emit"        => '. andl %S2, %D1\t\t\t/* And(%S1, %S2) -> %D1, (%A1, %A2) */'
186 },
187
188 "And_i" => {
189   "arity"       => 1,
190   "remat"       => 1,
191   "comment"     => "construct And: And(a, const) = And(const, a) = a AND const",
192   "check_inout" => 1,
193   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
194   "emit"        => '. andl %C, %D1\t\t\t/* And(%C, %S1) -> %D1, (%A1, const) */'
195 },
196
197 "Or" => {
198   "op_flags"    => "C",
199   "arity"       => 2,
200   "remat"       => 1,
201   "comment"     => "construct Or: Or(a, b) = Or(b, a) = a OR b",
202   "check_inout" => 1,
203   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
204   "emit"        => '. orl %S2, %D1\t\t\t/* Or(%S1, %S2) -> %D1, (%A1, %A2) */'
205 },
206
207 "Or_i" => {
208   "arity"       => 1,
209   "remat"       => 1,
210   "comment"     => "construct Or: Or(a, const) = Or(const, a) = a OR const",
211   "check_inout" => 1,
212   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
213   "emit"        => '. orl %C, %D1\t\t\t/* Or(%C, %S1) -> %D1, (%A1, const) */'
214 },
215
216 "Eor" => {
217   "op_flags"    => "C",
218   "arity"       => 2,
219   "remat"       => 1,
220   "comment"     => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
221   "check_inout" => 1,
222   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
223   "emit"        => '. xorl %S2, %D1\t\t\t/* Xor(%S1, %S2) -> %D1, (%A1, %A2) */'
224 },
225
226 "Eor_i" => {
227   "arity"       => 1,
228   "remat"       => 1,
229   "comment"     => "construct Eor: Eor(a, const) = Eor(const, a) = a EOR const",
230   "check_inout" => 1,
231   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
232   "emit"        => '. xorl %C, %D1\t\t\t/* Xor(%C, %S1) -> %D1, (%A1, const) */'
233 },
234
235 "Max" => {
236   "op_flags"    => "C",
237   "arity"       => 2,
238   "remat"       => 1,
239   "comment"     => "construct Max: Max(a, b) = Max(b, a) = a > b ? a : b",
240   "check_inout" => 1,
241   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
242   "emit"        =>
243 '2. cmpl %S2, %S1\t\t\t/* prepare Max (%S1 should be %D1), (%A1, %A2) */
244   if (mode_is_signed(get_irn_mode(n))) {
245 4.  cmovl %S2, %D1\t\t\t/* %S1 is less %S2 */
246   }
247   else {
248 4.  cmovb %S2, %D1\t\t\t/* %S1 is below %S2 */
249   }
250 '
251 },
252
253 "Min" => {
254   "op_flags"    => "C",
255   "arity"       => 2,
256   "remat"       => 1,
257   "comment"     => "construct Min: Min(a, b) = Min(b, a) = a < b ? a : b",
258   "check_inout" => 1,
259   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
260   "emit"        =>
261 '2. cmpl %S2, %S1\t\t\t/* prepare Min (%S1 should be %D1), (%A1, %A2) */
262   if (mode_is_signed(get_irn_mode(n))) {
263 2.  cmovg %S2, %D1\t\t\t/* %S1 is greater %S2 */
264   }
265   else {
266 2.  cmova %S2, %D1\t\t\t/* %S1 is above %S2 */
267   }
268 '
269 },
270
271 # not commutative operations
272
273 "Sub" => {
274   "arity"       => 2,
275   "remat"       => 1,
276   "comment"     => "construct Sub: Sub(a, b) = a - b",
277   "check_inout" => 1,
278   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
279   "emit"        => '. subl %S2, %D1\t\t\t/* Sub(%S1, %S2) -> %D1, (%A1, %A2) */'
280 },
281
282 "Sub_i" => {
283   "arity"       => 1,
284   "remat"       => 1,
285   "comment"     => "construct Sub: Sub(a, const) = a - const",
286   "check_inout" => 1,
287   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
288   "emit"        => '. subl %C, %D1\t\t\t/* Sub(%S1, %C) -> %D1, (%A1, const) */'
289 },
290
291 "DivMod" => {
292   "op_flags"    => "F|L",
293   "state"       => "exc_pinned",
294   "arity"       => 4,
295   "reg_req"     => { "in" => [ "general_purpose", "general_purpose", "general_purpose", "none" ], "out" => [ "eax in_r1", "edx in_r3" ] },
296   "emit"        =>
297 '  if (mode_is_signed(get_irn_mode(n))) {
298 4.  idivl %S2\t\t\t/* signed DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
299   }
300   else {
301 4.  divl %S2\t\t\t/* unsigned DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
302   }
303 '
304 },
305
306 "Shl" => {
307   "arity"       => 2,
308   "remat"       => 1,
309   "comment"     => "construct Shl: Shl(a, b) = a << b",
310   "check_inout" => 1,
311   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
312   "emit"        => '. shll %S2, %D1\t\t\t/* Shl(%S1, %S2) -> %D1, (%A1, %A2) */'
313 },
314
315 "Shl_i" => {
316   "arity"       => 1,
317   "remat"       => 1,
318   "comment"     => "construct Shl: Shl(a, const) = a << const",
319   "check_inout" => 1,
320   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
321   "emit"        => '. shll %C, %D1\t\t\t/* Shl(%S1, %C) -> %D1, (%A1, const) */'
322 },
323
324 "Shr" => {
325   "arity"       => 2,
326   "remat"       => 1,
327   "comment"     => "construct Shr: Shr(a, b) = a >> b",
328   "check_inout" => 1,
329   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
330   "emit"        => '. shrl %S2, %D1\t\t\t/* Shr(%S1, %S2) -> %D1, (%A1, %A2) */'
331 },
332
333 "Shr_i" => {
334   "arity"       => 1,
335   "remat"       => 1,
336   "comment"     => "construct Shr: Shr(a, const) = a >> const",
337   "check_inout" => 1,
338   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
339   "emit"        => '. shrl %C, %D1\t\t\t/* Shr(%S1, %C) -> %D1, (%A1, const) */'
340 },
341
342 "Shrs" => {
343   "arity"       => 2,
344   "remat"       => 1,
345   "comment"     => "construct Shrs: Shrs(a, b) = a >> b",
346   "check_inout" => 1,
347   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
348   "emit"        => '. sarl %S2, %D1\t\t\t/* Shrs(%S1, %S2) -> %D1, (%A1, %A2) */'
349 },
350
351 "Shrs_i" => {
352   "arity"       => 1,
353   "remat"       => 1,
354   "comment"     => "construct Shrs: Shrs(a, const) = a >> const",
355   "check_inout" => 1,
356   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
357   "emit"        => '. sarl %C, %D1\t\t\t/* Shrs(%S1, %C) -> %D1, (%A1, const) */'
358 },
359
360 "RotR" => {
361   "arity"       => 2,
362   "remat"       => 1,
363   "comment"     => "construct RotR: RotR(a, b) = a ROTR b",
364   "check_inout" => 1,
365   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
366   "emit"        => '. rorl %S2, %D1\t\t\t/* RotR(%S1, %S2) -> %D1, (%A1, %A2) */'
367 },
368
369 "RotL" => {
370   "arity"       => 2,
371   "remat"       => 1,
372   "comment"     => "construct RotL: RotL(a, b) = a ROTL b",
373   "check_inout" => 1,
374   "reg_req"     => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "in_r1" ] },
375   "emit"        => '. roll %S2, %D1\t\t\t/* RotL(%S1, %S2) -> %D1, (%A1, %A2) */'
376 },
377
378 "RotL_i" => {
379   "arity"       => 1,
380   "remat"       => 1,
381   "comment"     => "construct RotL: RotL(a, const) = a ROTL const",
382   "check_inout" => 1,
383   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
384   "emit"        => '. roll %C, %D1\t\t\t/* RotL(%S1, %C) -> %D1, (%A1, const) */'
385 },
386
387 "Minus" => {
388   "arity"       => 1,
389   "remat"       => 1,
390   "comment"     => "construct Minus: Minus(a) = -a",
391   "check_inout" => 1,
392   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
393   "emit"        => '. negl %D1\t\t\t/* Neg(%S1) -> %D1, (%A1) */'
394 },
395
396 "Inc" => {
397   "arity"       => 1,
398   "remat"       => 1,
399   "comment"     => "construct Increment: Inc(a) = a++",
400   "check_inout" => 1,
401   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
402   "emit"        => '. incl %D1\t\t\t/* Inc(%S1) -> %D1, (%A1) */'
403 },
404
405 "Dec" => {
406   "arity"       => 1,
407   "remat"       => 1,
408   "comment"     => "construct Decrement: Dec(a) = a--",
409   "check_inout" => 1,
410   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
411   "emit"        => '. decl %D1\t\t\t/* Dec(%S1) -> %D1, (%A1) */'
412 },
413
414 "Not" => {
415   "arity"       => 1,
416   "remat"       => 1,
417   "comment"     => "construct Not: Not(a) = !a",
418   "check_inout" => 1,
419   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
420   "emit"        => '. notl %D1\t\t\t/* Not(%S1) -> %D1, (%A1) */'
421 },
422
423 # other operations
424
425 "Conv" => {
426   "arity"    => 1,
427   "reg_req"  => { "in" => [ "general_purpose" ], "out" => [ "in_r1" ] },
428   "comment"  => "construct Conv: Conv(a) = (conv)a"
429 },
430
431 "CondJmp" => {
432   "op_flags" => "C|L|X|Y",
433   "arity"    => 2,
434   "comment"  => "construct conditional jump: CMP A, B && JMPxx LABEL",
435   "reg_req"  => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "none", "none" ] },
436 },
437
438 "CondJmp_i" => {
439   "op_flags" => "L|X|Y",
440   "arity"    => 1,
441   "comment"  => "construct conditional jump: CMP A, const && JMPxx LABEL",
442   "reg_req"  => { "in" => [ "general_purpose" ], "out" => [ "none", "none" ] },
443 },
444
445 "SwitchJmp" => {
446   "op_flags" => "L|X|Y",
447   "arity"    => 1,
448   "comment"  => "construct switch",
449   "reg_req"  => { "in" => [ "general_purpose" ], "out" => [ "none" ] },
450 },
451
452 "Const" => {
453   "op_flags" => "c",
454   "arity"    => "0",
455   "remat"    => 1,
456   "comment"  => "represents an integer constant",
457   "reg_req"  => { "out" => [ "general_purpose" ] },
458   "emit"     => '. movl %C, %D1\t\t\t/* Mov Const into register */',
459   "cmp_attr" =>
460 '
461   if (attr_a->tp == attr_b->tp) {
462     if (attr_a->tp == asmop_SymConst) {
463       if (attr_a->old_ir == NULL || attr_b->old_ir == NULL)
464         return 1;
465       else
466         return strcmp(get_sc_name(attr_a->old_ir), get_sc_name(attr_b->old_ir));
467     }
468     else {
469       if (attr_a->old_ir == NULL || attr_b->old_ir == NULL)
470         return 1;
471
472       if (tarval_cmp(attr_a->tv, attr_b->tv) == pn_Cmp_Eq)
473         return 0;
474       else
475         return 1;
476     }
477   }
478   else
479     return 1;
480 '
481 },
482
483 "Cltd" => {
484   "arity"       => 1,
485   "remat"       => 1,
486   "comment"     => "construct Cltd: sign extend EAX -> EDX:EAX",
487   "reg_req"     => { "in" => [ "general_purpose" ], "out" => [ "eax in_r1", "edx" ] },
488   "emit"        => '. cltd\t\t\t/* sign extend EAX -> EDX:EAX, (%A1) */'
489 },
490
491 # Load / Store
492
493 "Load" => {
494   "op_flags" => "L|F",
495   "state"    => "exc_pinned",
496   "arity"    => 2,
497   "remat"    => 1,
498   "comment"  => "construct Load: Load(ptr, mem) = LD ptr -> reg",
499   "reg_req"  => { "in" => [ "general_purpose", "none" ], "out" => [ "general_purpose" ] },
500   "emit"     => '. movl (%S1), %D1\t\t\t/* Load((%S1)) -> %D1, (%A1) */'
501 },
502
503 "Store" => {
504   "op_flags" => "L|F",
505   "state"    => "exc_pinned",
506   "arity"    => 3,
507   "remat"    => 1,
508   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
509   "reg_req"  => { "in" => [ "general_purpose", "general_purpose", "none" ] },
510   "emit"     => '. movl %S2, (%S1)\t\t\t/* Store(%S2) -> (%S1), (%A1, %A2) */'
511 },
512
513 "Lea" => {
514   "arity"    => 2,
515   "comment"  => "construct Lea: Lea(a,b) = lea offs(a,b,const) | res = a + b * const + offs with const = 0,1,2,4,8",
516   "reg_req"  => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "general_purpose" ] },
517   "emit"     => '. leal %O(%S1, %S2, %C), %D1\t\t/* %D1 = %S1 + %S2 << %C + %O, (%A1, %A2) */'
518 },
519
520 "Lea_i" => {
521   "arity"    => 1,
522   "comment"  => "construct Lea: Lea(a) = lea offs(a) | res = a + offs",
523   "reg_req"  => { "in" => [ "general_purpose" ], "out" => [ "general_purpose" ] },
524   "emit"     => '. leal %C(%S1), %D1\t\t\t/* %D1 = %S1 + %C, (%A1)*/'
525 },
526
527 "RegParam" => {
528   "arity"    => 1,
529   "comment"  => "constructs a Register Parameter to cover parameters passed in register",
530   "reg_req"  => { "in" => [ "none" ], "out" => [ "none" ] },
531   "cmp_attr" =>
532 '
533   return (attr_a->pn_code != attr_b->pn_code);
534 '
535 },
536
537 "StackParam" => {
538   "arity"    => 1,
539   "comment"  => "constructs a Stack Parameter to retrieve a parameter from Stack",
540   "reg_req"  => { "in" => [ "none" ], "out" => [ "general_purpose" ] },
541   "cmp_attr" =>
542 '
543   return (attr_a->pn_code != attr_b->pn_code);
544 '
545 },
546
547 "StackArg" => {
548   "arity"    => 2,
549   "comment"  => "constructs a Stack Argument to pass an argument on Stack",
550   "reg_req"  => { "in" => [ "none", "general_purpose" ], "out" => [ "none" ] },
551   "cmp_attr" =>
552 '
553   return (attr_a->pn_code != attr_b->pn_code);
554 '
555 },
556
557 #--------------------------------------------------------#
558 #    __ _             _                     _            #
559 #   / _| |           | |                   | |           #
560 #  | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
561 #  |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
562 #  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
563 #  |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
564 #--------------------------------------------------------#
565
566 # commutative operations
567
568 "fAdd" => {
569   "op_flags"    => "C",
570   "arity"       => 2,
571   "remat"       => 1,
572   "check_inout" => 1,
573   "comment"     => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
574   "reg_req"     => { "in" => [ "floating_point", "floating_point" ], "out" => [ "in_r1" ] },
575   "emit"        => '. add%M %S2, %D1\t\t\t/* SSE Add(%S1, %S2) -> %D1 */'
576 },
577
578 "fMul" => {
579   "op_flags"    => "C",
580   "arity"       => 2,
581   "check_inout" => 1,
582   "comment"     => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
583   "reg_req"     => { "in" => [ "floating_point", "floating_point" ], "out" => [ "in_r1" ] },
584   "emit"        =>'. muls%M %S2, %D1\t\t\t/* SSE Mul(%S1, %S2) -> %D1 */'
585 },
586
587 "fMax" => {
588   "op_flags"    => "C",
589   "arity"       => 2,
590   "remat"       => 1,
591   "check_inout" => 1,
592   "comment"     => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
593   "reg_req"     => { "in" => [ "floating_point", "floating_point" ], "out" => [ "in_r1" ] },
594   "emit"        =>'. maxs%M %S2, %D1\t\t\t/* SSE Max(%S1, %S2) -> %D1 */'
595 },
596
597 "fMin" => {
598   "op_flags"    => "C",
599   "arity"       => 2,
600   "remat"       => 1,
601   "check_inout" => 1,
602   "comment"     => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
603   "reg_req"     => { "in" => [ "floating_point", "floating_point" ], "out" => [ "in_r1" ] },
604   "emit"        =>'. mins%M %S2, %D1\t\t\t/* SSE Min(%S1, %S2) -> %D1 */'
605 },
606
607 # not commutative operations
608
609 "fSub" => {
610   "arity"       => 2,
611   "remat"       => 1,
612   "check_inout" => 1,
613   "comment"     => "construct SSE Sub: Sub(a, b) = a - b",
614   "reg_req"     => { "in" => [ "floating_point", "floating_point" ], "out" => [ "in_r1" ] },
615   "emit"        => '. subs%M %S2, %D1\t\t\t/* SSE Sub(%S1, %S2) -> %D1 */'
616 },
617
618 "fDiv" => {
619   "arity"       => 2,
620   "remat"       => 1,
621   "check_inout" => 1,
622   "comment"     => "construct SSE Div: Div(a, b) = a / b",
623   "reg_req"     => { "in" => [ "floating_point", "floating_point" ], "out" => [ "in_r1" ] },
624   "emit"        => '. divs%M %S2, %D1\t\t\t/* SSE Div(%S1, %S2) -> %D1 */'
625 },
626
627 "fMinus" => {
628   "arity"       => 1,
629   "remat"       => 1,
630   "check_inout" => 1,
631   "comment"     => "construct SSE Minus: Minus(a) = -a",
632   "reg_req"     => { "in" => [ "floating_point" ], "out" => [ "in_r1" ] },
633   "emit"        => '. xorp%M c %D1\t\t\t/* SSE Minus(%S1) -> %D1 */'
634 },
635
636 # other operations
637
638 "fConv" => {
639   "arity"    => 1,
640   "reg_req"  => { "in" => [ "floating_point" ], "out" => [ "general_purpose" ] },
641   "comment"  => "construct Conv: Conv(a) = (conv)a"
642 },
643
644 "fCondJmp" => {
645   "op_flags" => "C|L|X|Y",
646   "arity"    => 2,
647   "comment"  => "construct conditional jump: CMP A, B && JMPxx LABEL",
648   "reg_req"  => { "in" => [ "general_purpose", "general_purpose" ], "out" => [ "none", "none" ] },
649 },
650
651 "fConst" => {
652   "op_flags" => "c",
653   "arity"    => "0",
654   "remat"    => 1,
655   "comment"  => "represents a SSE constant",
656   "reg_req"  => { "out" => [ "floating_point" ] },
657   "emit"     => '. mov%M %C, %D1\t\t\t/* Mov fConst into register */',
658   "cmp_attr" =>
659 '
660   if (attr_a->tp == attr_b->tp) {
661     if (attr_a->tp == asmop_SymConst) {
662       if (attr_a->old_ir == NULL || attr_b->old_ir == NULL)
663         return 1;
664       else
665         return strcmp(get_sc_name(attr_a->old_ir), get_sc_name(attr_b->old_ir));
666     }
667     else {
668       if (attr_a->old_ir == NULL || attr_b->old_ir == NULL)
669         return 1;
670
671       if (tarval_cmp(attr_a->tv, attr_b->tv) == pn_Cmp_Eq)
672         return 0;
673       else
674         return 1;
675     }
676   }
677   else
678     return 1;
679 '
680 },
681
682 # Load / Store
683
684 "fLoad" => {
685   "op_flags" => "L|F",
686   "state"    => "exc_pinned",
687   "arity"    => 2,
688   "remat"    => 1,
689   "comment"  => "construct SSE Load: Load(ptr, mem) = LD ptr",
690   "reg_req"  => { "in" => [ "general_purpose", "none" ], "out" => [ "floating_point" ] },
691   "emit"     => '. movl (%S1), %D1\t\t\t/* Load((%S1)) -> %D1 */'
692 },
693
694 "fStore" => {
695   "op_flags" => "L|F",
696   "state"    => "exc_pinned",
697   "arity"    => 3,
698   "remat"    => 1,
699   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
700   "reg_req"  => { "in" => [ "general_purpose", "floating_point", "none" ] },
701   "emit"     => '. movl %S2, (%S1)\t\t\t/* Store(%S2) -> (%S1), (%A1, %A2) */'
702 },
703
704 "fStackParam" => {
705   "arity"    => 1,
706   "comment"  => "constructs a Stack Parameter to retrieve a SSE parameter from Stack",
707   "reg_req"  => { "in" => [ "none" ], "out" => [ "floating_point" ] },
708   "cmp_attr" =>
709 '
710   return (attr_a->pn_code != attr_b->pn_code);
711 '
712 },
713
714 "fStackArg" => {
715   "arity"    => 2,
716   "comment"  => "constructs a Stack Argument to pass an argument on Stack",
717   "reg_req"  => { "in" => [ "none", "floating_point" ], "out" => [ "none" ] },
718   "cmp_attr" =>
719 '
720   return (attr_a->pn_code != attr_b->pn_code);
721 '
722 },
723
724 # Call
725
726 "Call" => {
727   "op_flags" => "L|F",
728   "state"    => "mem_pinned",
729   "arity"    => "variable",
730   "spill"    => 0,
731   "comment"  => "construct Call: Call(...)",
732   "args"     => [
733                   { "type" => "int",        "name" => "n" },
734                   { "type" => "ir_node **", "name" => "in" }
735                 ],
736   "rd_constructor" =>
737 "  if (!op_ia32_Call) assert(0);
738   return new_ir_node(db, irg, block, op_ia32_Call, mode_T, n, in);
739 "
740 }
741
742 ); # end of %nodes