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