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