changed ia32 attribute structure and switched to idents
[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 #   "rd_constructor" => "c source code which constructs an ir_node"
34 # },
35 #
36 # ... # (all nodes you need to describe)
37 #
38 # ); # close the %nodes initializer
39
40 # op_flags: flags for the operation, OPTIONAL (default is "N")
41 # the op_flags correspond to the firm irop_flags:
42 #   N   irop_flag_none
43 #   L   irop_flag_labeled
44 #   C   irop_flag_commutative
45 #   X   irop_flag_cfopcode
46 #   I   irop_flag_ip_cfopcode
47 #   F   irop_flag_fragile
48 #   Y   irop_flag_forking
49 #   H   irop_flag_highlevel
50 #   c   irop_flag_constlike
51 #   K   irop_flag_keep
52 #
53 # irn_flags: special node flags, OPTIONAL (default is 0)
54 # following irn_flags are supported:
55 #   R   rematerializeable
56 #   N   not spillable
57 #   I   ignore for register allocation
58 #
59 # state: state of the operation, OPTIONAL (default is "floats")
60 #
61 # arity: arity of the operation, MUST NOT BE OMITTED
62 #
63 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
64 #        are always the first 3 arguments and are always autmatically
65 #        created)
66 #        If this key is missing the following arguments will be created:
67 #        for i = 1 .. arity: ir_node *op_i
68 #        ir_mode *mode
69 #
70 # comment: OPTIONAL comment for the node constructor
71 #
72 # rd_constructor: for every operation there will be a
73 #      new_rd_<arch>_<op-name> function with the arguments from above
74 #      which creates the ir_node corresponding to the defined operation
75 #      you can either put the complete source code of this function here
76 #
77 #      This key is OPTIONAL. If omitted, the following constructor will
78 #      be created:
79 #      if (!op_<arch>_<op-name>) assert(0);
80 #      for i = 1 to arity
81 #         set in[i] = op_i
82 #      done
83 #      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
84 #      return res
85 #
86 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
87
88 # register types:
89 #   0 - no special type
90 #   1 - caller save (register must be saved by the caller of a function)
91 #   2 - callee save (register must be saved by the called function)
92 #   4 - ignore (do not assign this register)
93 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
94 %reg_classes = (
95   "gp" => [
96             { "name" => "eax", "type" => 1 },
97             { "name" => "edx", "type" => 1 },
98             { "name" => "ebx", "type" => 2 },
99             { "name" => "ecx", "type" => 1 },
100             { "name" => "esi", "type" => 2 },
101             { "name" => "edi", "type" => 2 },
102             { "name" => "ebp", "type" => 2 },
103             { "name" => "esp", "type" => 4 },
104             { "name" => "xxx", "type" => 6 },  # we need a dummy register for NoReg and Unknown nodes
105                         { "mode" => "mode_P" }
106           ],
107   "fp" => [
108             { "name" => "xmm0", "type" => 1 },
109             { "name" => "xmm1", "type" => 1 },
110             { "name" => "xmm2", "type" => 1 },
111             { "name" => "xmm3", "type" => 1 },
112             { "name" => "xmm4", "type" => 1 },
113             { "name" => "xmm5", "type" => 1 },
114             { "name" => "xmm6", "type" => 1 },
115             { "name" => "xmm7", "type" => 1 },
116             { "name" => "xxxx", "type" => 6 },  # we need a dummy register for NoReg and Unknown nodes
117                         { "mode" => "mode_D" }
118           ]
119 ); # %reg_classes
120
121 #--------------------------------------------------#
122 #                        _                         #
123 #                       (_)                        #
124 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
125 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
126 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
127 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
128 #                                      | |         #
129 #                                      |_|         #
130 #--------------------------------------------------#
131
132 %nodes = (
133
134 #-----------------------------------------------------------------#
135 #  _       _                                         _            #
136 # (_)     | |                                       | |           #
137 #  _ _ __ | |_ ___  __ _  ___ _ __   _ __   ___   __| | ___  ___  #
138 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
139 # | | | | | ||  __/ (_| |  __/ |    | | | | (_) | (_| |  __/\__ \ #
140 # |_|_| |_|\__\___|\__, |\___|_|    |_| |_|\___/ \__,_|\___||___/ #
141 #                   __/ |                                         #
142 #                  |___/                                          #
143 #-----------------------------------------------------------------#
144
145 # commutative operations
146
147 # NOTE:
148 # All nodes supporting Addressmode have 5 INs:
149 # 1 - base    r1 == NoReg in case of no AM or no base
150 # 2 - index   r2 == NoReg in case of no AM or no index
151 # 3 - op1     r3 == always present
152 # 4 - op2     r4 == NoReg in case of immediate operation
153 # 5 - mem     NoMem in case of no AM otherwise it takes the mem from the Load
154
155 "Add" => {
156   "irn_flags" => "R",
157   "comment"   => "construct Add: Add(a, b) = Add(b, a) = a + b",
158   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
159   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
160   "emit"      => '. add %ia32_emit_binop /* Add(%A1, %A2) -> %D1 */',
161 },
162
163 "Mul" => {
164   "irn_flags" => "A",
165   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
166   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
167   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
168   "emit"      => '. imul %ia32_emit_binop /* Mul(%A1, %A2) -> %D1 */'
169 },
170
171 # Mulh is an exception from the 4 INs with AM because the target is always EAX:EDX
172 "Mulh" => {
173   "comment"   => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
174   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
175   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "eax in_r3", "edx in_r4" ] },
176   "emit"      => '. imul %ia32_emit_unop /* Mulh(%A1, %A2) -> %D1 */'
177 },
178
179 "And" => {
180   "irn_flags" => "R",
181   "comment"   => "construct And: And(a, b) = And(b, a) = a AND b",
182   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
183   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
184   "emit"      => '. and %ia32_emit_binop /* And(%A1, %A2) -> %D1 */'
185 },
186
187 "Or" => {
188   "irn_flags" => "R",
189   "comment"   => "construct Or: Or(a, b) = Or(b, a) = a OR b",
190   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
191   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
192   "emit"      => '. or %ia32_emit_binop /* Or(%A1, %A2) -> %D1 */'
193 },
194
195 "Eor" => {
196   "irn_flags" => "R",
197   "comment"   => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
198   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
199   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
200   "emit"      => '. xor %ia32_emit_binop /* Xor(%A1, %A2) -> %D1 */'
201 },
202
203 "Max" => {
204   "irn_flags" => "R",
205   "comment"   => "construct Max: Max(a, b) = Max(b, a) = a > b ? a : b",
206   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
207   "emit"      =>
208 '2. cmp %S1, %S2 /* prepare Max (%S1 - %S2), (%A1, %A2) */
209   if (mode_is_signed(get_irn_mode(n))) {
210 4.  cmovl %D1, %S2 /* %S1 is less %S2 */
211   }
212   else {
213 4.  cmovb %D1, %S2 /* %S1 is below %S2 */
214   }
215 '
216 },
217
218 "Min" => {
219   "irn_flags" => "R",
220   "comment"   => "construct Min: Min(a, b) = Min(b, a) = a < b ? a : b",
221   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
222   "emit"      =>
223 '2. cmp %S1, %S2 /* prepare Min (%S1 - %S2), (%A1, %A2) */
224   if (mode_is_signed(get_irn_mode(n))) {
225 2.  cmovg %D1, %S2 /* %S1 is greater %S2 */
226   }
227   else {
228 2.  cmova %D1, %S2, %D1 /* %S1 is above %S2 */
229   }
230 '
231 },
232
233 "CMov" => {
234   "irn_flags" => "R",
235   "comment"   => "construct Mux: Mux(sel, a, b) == sel ? a : b",
236   "reg_req"   => { "in" => [ "gp", "gp", "gp" ], "out" => [ "in_r2" ] },
237   "emit"      =>
238 '. cmp %S1, 0 /* compare Sel for CMov (%A2, %A3) */
239 . cmovne %D1, %S3 /* sel == true -> return %S3 */
240 '
241 },
242
243 # not commutative operations
244
245 "Sub" => {
246   "irn_flags" => "R",
247   "comment"   => "construct Sub: Sub(a, b) = a - b",
248   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
249   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
250   "emit"      => '. sub %ia32_emit_binop /* Sub(%A1, %A2) -> %D1 */'
251 },
252
253 "DivMod" => {
254   "op_flags" => "F|L",
255   "state"    => "exc_pinned",
256   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "eax in_r1", "edx in_r3" ] },
257   "emit"     =>
258 '  if (mode_is_signed(get_irn_mode(n))) {
259 4.  idiv %S2 /* signed DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
260   }
261   else {
262 4.  div %S2 /* unsigned DivMod(%S1, %S2) -> %D1, (%A1, %A2, %A3) */
263   }
264 '
265 },
266
267 "Shl" => {
268   "irn_flags" => "R",
269   "comment"   => "construct Shl: Shl(a, b) = a << b",
270   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
271   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
272   "emit"      => '. shl %ia32_emit_binop /* Shl(%A1, %A2) -> %D1 */'
273 },
274
275 "Shr" => {
276   "irn_flags" => "R",
277   "comment"   => "construct Shr: Shr(a, b) = a >> b",
278   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
279   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
280   "emit"      => '. shr %ia32_emit_binop /* Shr(%A1, %A2) -> %D1 */'
281 },
282
283 "Shrs" => {
284   "irn_flags" => "R",
285   "comment"   => "construct Shrs: Shrs(a, b) = a >> b",
286   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
287   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
288   "emit"      => '. sar %ia32_emit_binop /* Shrs(%A1, %A2) -> %D1 */'
289 },
290
291 "RotR" => {
292   "irn_flags" => "R",
293   "comment"     => "construct RotR: RotR(a, b) = a ROTR b",
294   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
295   "reg_req"     => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
296   "emit"        => '. ror %ia32_emit_binop /* RotR(%A1, %A2) -> %D1 */'
297 },
298
299 "RotL" => {
300   "irn_flags" => "R",
301   "comment"   => "construct RotL: RotL(a, b) = a ROTL b",
302   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
303   "reg_req"   => { "in" => [ "gp", "gp", "gp", "ecx", "none" ], "out" => [ "in_r3 !in_r4" ] },
304   "emit"      => '. rol %ia32_emit_binop /* RotL(%A1, %A2) -> %D1 */'
305 },
306
307 # unary operations
308
309 "Minus" => {
310   "irn_flags" => "R",
311   "comment"   => "construct Minus: Minus(a) = -a",
312   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
313   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
314   "emit"      => '. neg %ia32_emit_unop /* Neg(%A1) -> %D1, (%A1) */'
315 },
316
317 "Inc" => {
318   "irn_flags" => "R",
319   "comment"   => "construct Increment: Inc(a) = a++",
320   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
321   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
322   "emit"      => '. inc %ia32_emit_unop /* Inc(%S1) -> %D1, (%A1) */'
323 },
324
325 "Dec" => {
326   "irn_flags" => "R",
327   "comment"   => "construct Decrement: Dec(a) = a--",
328   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
329   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
330   "emit"      => '. dec %ia32_emit_unop /* Dec(%S1) -> %D1, (%A1) */'
331 },
332
333 "Not" => {
334   "irn_flags" => "R",
335   "comment"   => "construct Not: Not(a) = !a",
336   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
337   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3" ] },
338   "emit"      => '. not %ia32_emit_unop /* Not(%S1) -> %D1, (%A1) */'
339 },
340
341 # other operations
342
343 "CondJmp" => {
344   "op_flags"  => "L|X|Y",
345   "comment"   => "construct conditional jump: CMP A, B && JMPxx LABEL",
346   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
347   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ] },
348 },
349
350 "TestJmp" => {
351   "op_flags"  => "L|X|Y",
352   "comment"   => "construct conditional jump: TEST A, B && JMPxx LABEL",
353   "reg_req"  => { "in" => [ "gp", "gp" ] },
354   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
355 },
356
357 "CJmpAM" => {
358   "op_flags"  => "L|X|Y",
359   "comment"   => "construct conditional jump without CMP (replaces CondJmp): JMPxx LABEL",
360   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
361   "reg_req"   => { "in" => [ "gp", "gp", "gp", "gp", "none" ], "out" => [ "none", "none" ] },
362 },
363
364 "CJmp" => {
365   "op_flags"  => "L|X|Y",
366   "comment"   => "construct conditional jump without CMP (replaces TestJmp): JMPxx LABEL",
367   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
368   "reg_req"   => { "in" => [ "gp", "gp" ] },
369 },
370
371 "SwitchJmp" => {
372   "op_flags"  => "L|X|Y",
373   "comment"   => "construct switch",
374   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
375   "reg_req"   => { "in" => [ "gp" ], "out" => [ "none" ] },
376 },
377
378 "Const" => {
379   "op_flags"  => "c",
380   "irn_flags" => "R",
381   "comment"   => "represents an integer constant",
382   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
383   "reg_req"   => { "out" => [ "gp" ] },
384   "emit"      =>
385 '  if (get_ia32_Immop_tarval(n) == get_tarval_null(get_irn_mode(n))) {
386 4.   sub %D1, %D1 /* optimized mov 0 to register */
387   }
388   else {
389     if (get_ia32_op_type(n) == ia32_SymConst) {
390 6.    mov %D1, OFFSET FLAT:%C /* Move address of SymConst into register */
391     }
392         else {
393 6.    mov %D1, %C /* Mov Const into register */
394         }
395   }
396 ',
397 },
398
399 "Cdq" => {
400   "irn_flags" => "R",
401   "comment"   => "construct CDQ: sign extend EAX -> EDX:EAX",
402   "reg_req"   => { "in" => [ "gp" ], "out" => [ "eax in_r1", "edx" ] },
403   "emit"      => '. cdq /* sign extend EAX -> EDX:EAX, (%A1) */'
404 },
405
406 # Load / Store
407
408 "Load" => {
409   "op_flags"  => "L|F",
410   "irn_flags" => "R",
411   "state"     => "exc_pinned",
412   "comment"   => "construct Load: Load(ptr, mem) = LD ptr -> reg",
413   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
414   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "gp" ] },
415   "emit"      =>
416 '  if (get_mode_size_bits(get_ia32_ls_mode(n)) < 32) {
417 4.   mov%Mx %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
418   }
419   else {
420 4.   mov %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */
421   }
422 '
423 },
424
425 "Store" => {
426   "op_flags"  => "L|F",
427   "state"     => "exc_pinned",
428   "comment"   => "construct Store: Store(ptr, val, mem) = ST ptr,val",
429   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
430   "reg_req"   => { "in" => [ "gp", "gp", "gp", "none" ] },
431   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */'
432 },
433
434 "Store8Bit" => {
435   "op_flags"  => "L|F",
436   "state"     => "exc_pinned",
437   "comment"   => "construct 8Bit Store: Store(ptr, val, mem) = ST ptr,val",
438   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
439   "reg_req"   => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ] },
440   "emit"      => '. mov %ia32_emit_binop /* Store(%A3) -> (%A1) */'
441 },
442
443 "Lea" => {
444   "irn_flags" => "R",
445   "comment"   => "construct Lea: Lea(a,b) = lea [a+b*const+offs] | res = a + b * const + offs with const = 0,1,2,4,8",
446   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
447   "reg_req"   => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
448   "emit"      => '. lea %D1, %ia32_emit_am /* LEA(%A1, %A2) */'
449 },
450
451 #--------------------------------------------------------#
452 #    __ _             _                     _            #
453 #   / _| |           | |                   | |           #
454 #  | |_| | ___   __ _| |_   _ __   ___   __| | ___  ___  #
455 #  |  _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
456 #  | | | | (_) | (_| | |_  | | | | (_) | (_| |  __/\__ \ #
457 #  |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
458 #--------------------------------------------------------#
459
460 # commutative operations
461
462 "fAdd" => {
463   "irn_flags" => "R",
464   "comment"   => "construct SSE Add: Add(a, b) = Add(b, a) = a + b",
465   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
466   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
467   "emit"      => '. adds%M %ia32_emit_binop /* SSE Add(%A3, %A4) -> %D1 */'
468 },
469
470 "fMul" => {
471   "irn_flags" => "R",
472   "comment"   => "construct SSE Mul: Mul(a, b) = Mul(b, a) = a * b",
473   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
474   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
475   "emit"      => '. muls%M %ia32_emit_binop /* SSE Mul(%A3, %A4) -> %D1 */'
476 },
477
478 "fMax" => {
479   "irn_flags" => "R",
480   "comment"   => "construct SSE Max: Max(a, b) = Max(b, a) = a > b ? a : b",
481   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
482   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
483   "emit"      => '. maxs%M %ia32_emit_binop /* SSE Max(%A3, %A4) -> %D1 */'
484 },
485
486 "fMin" => {
487   "irn_flags" => "R",
488   "comment"   => "construct SSE Min: Min(a, b) = Min(b, a) = a < b ? a : b",
489   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
490   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
491   "emit"      => '. mins%M %ia32_emit_binop /* SSE Min(%A3, %A4) -> %D1 */'
492 },
493
494 "fAnd" => {
495   "irn_flags" => "R",
496   "comment"   => "construct SSE And: And(a, b) = a AND b",
497   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
498   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
499   "emit"      => '. andp%M %ia32_emit_binop /* SSE And(%A3, %A4) -> %D1 */'
500 },
501
502 "fOr" => {
503   "irn_flags" => "R",
504   "comment"   => "construct SSE Or: Or(a, b) = a OR b",
505   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
506   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
507   "emit"      => '. orp%M %ia32_emit_binop /* SSE Or(%A3, %A4) -> %D1 */'
508 },
509
510 "fEor" => {
511   "irn_flags" => "R",
512   "comment"   => "construct SSE Eor: Eor(a, b) = a XOR b",
513   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
514   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
515   "emit"      => '. xorp%M %ia32_emit_binop /* SSE Xor(%A3, %A4) -> %D1 */'
516 },
517
518 # not commutative operations
519
520 "fSub" => {
521   "irn_flags" => "R",
522   "comment"   => "construct SSE Sub: Sub(a, b) = a - b",
523   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
524   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3" ] },
525   "emit"      => '. subs%M %ia32_emit_binop /* SSE Sub(%A1, %A2) -> %D1 */'
526 },
527
528 "fDiv" => {
529   "irn_flags" => "R",
530   "comment"   => "construct SSE Div: Div(a, b) = a / b",
531   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
532   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "in_r3 !in_r4" ] },
533   "emit"      => '. divs%M %ia32_emit_binop /* SSE Div(%A1, %A2) -> %D1 */'
534 },
535
536 # other operations
537
538 "fCondJmp" => {
539   "op_flags"  => "L|X|Y",
540   "comment"   => "construct conditional jump: UCOMIS A, B && JMPxx LABEL",
541   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
542   "reg_req"   => { "in" => [ "gp", "gp", "fp", "fp", "none" ], "out" => [ "none", "none" ] },
543 },
544
545 "fConst" => {
546   "op_flags"  => "c",
547   "irn_flags" => "R",
548   "comment"   => "represents a SSE constant",
549   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
550   "reg_req"   => { "out" => [ "fp" ] },
551   "emit"      => '. mov%M %D1, %C /* Load fConst into register */',
552 },
553
554 # Load / Store
555
556 "fLoad" => {
557   "op_flags"  => "L|F",
558   "irn_flags" => "R",
559   "state"     => "exc_pinned",
560   "comment"   => "construct SSE Load: Load(ptr, mem) = LD ptr",
561   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
562   "reg_req"   => { "in" => [ "gp", "gp", "none" ], "out" => [ "fp" ] },
563   "emit"      => '. movs%M %D1, %ia32_emit_am /* Load((%A1)) -> %D1 */'
564 },
565
566 "fStore" => {
567   "op_flags" => "L|F",
568   "state"    => "exc_pinned",
569   "comment"  => "construct Store: Store(ptr, val, mem) = ST ptr,val",
570   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
571   "reg_req"  => { "in" => [ "gp", "gp", "fp", "none" ] },
572   "emit"     => '. movs%M %ia32_emit_binop /* Store(%S3) -> (%A1) */'
573 },
574
575 # CopyB
576
577 "CopyB" => {
578   "op_flags" => "F|H",
579   "state"    => "pinned",
580   "comment"  => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
581   "reg_req"  => { "in" => [ "edi", "esi", "ecx", "none" ], "out" => [ "none" ] },
582 },
583
584 "CopyB_i" => {
585   "op_flags" => "F|H",
586   "state"    => "pinned",
587   "comment"  => "implements a memcopy: CopyB(dst, src, mem) == memcpy(dst, src, attr(size))",
588   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
589   "reg_req"  => { "in" => [ "edi", "esi", "none" ], "out" => [ "none" ] },
590 },
591
592 # Conversions
593
594 "Conv_I2I" => {
595   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "in_r3", "none" ] },
596   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
597   "comment"  => "construct Conv Int -> Int"
598 },
599
600 "Conv_I2I8Bit" => {
601   "reg_req"  => { "in" => [ "gp", "gp", "eax ebx ecx edx", "none" ], "out" => [ "in_r3", "none" ] },
602   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
603   "comment"  => "construct Conv Int -> Int"
604 },
605
606 "Conv_I2FP" => {
607   "reg_req"  => { "in" => [ "gp", "gp", "gp", "none" ], "out" => [ "fp", "none" ] },
608   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
609   "comment"  => "construct Conv Int -> Floating Point"
610 },
611
612 "Conv_FP2I" => {
613   "reg_req"  => { "in" => [ "gp", "gp", "fp", "none" ], "out" => [ "gp", "none" ] },
614   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
615   "comment"  => "construct Conv Floating Point -> Int"
616 },
617
618 "Conv_FP2FP" => {
619   "reg_req"  => { "in" => [ "gp", "gp", "fp", "none" ], "out" => [ "fp", "none" ] },
620   "cmp_attr"  => "  return ia32_compare_immop_attr(attr_a, attr_b);\n",
621   "comment"  => "construct Conv Floating Point -> Floating Point",
622 },
623
624 ); # end of %nodes