5bb89517b0e4693759d799b03ab2b0e415702ec4
[libfirm] / ir / be / ia32 / ia32_spec.pl
1 # Creation: 2005/10/19
2 # $Id$
3 # This is the specification for the ia32 assembler Firm-operations
4
5 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
6
7 $arch = "ia32";
8
9 # The node description is done as a perl hash initializer with the
10 # following structure:
11 #
12 # %nodes = (
13 #
14 # <op-name> => {
15 #   "op_flags" => "N|L|C|X|I|F|Y|H|c",
16 #   "arity"    => "0|1|2|3|variable|dynamic|all",
17 #   "state"    => "floats|pinned",
18 #   "args"     => "DEFAULT"
19 #                 or
20 #                 [
21 #                   { "type" => "type 1", "name" => "name 1" },
22 #                   { "type" => "type 2", "name" => "name 2" },
23 #                   ...
24 #                 ],
25 #   "comment"  => "any comment for constructor",
26 #   "rd_constructor" => "DEFAULT"
27 #                       or
28 #                       "c source code which constructs an ir_node"
29 # },
30 #
31 # ... # (all nodes you need to describe)
32 #
33 # ); # close the %nodes initializer
34
35 # the op_flags correspond to the firm irop_flags:
36 #   N   irop_flag_none
37 #   L   irop_flag_labeled
38 #   C   irop_flag_commutative
39 #   X   irop_flag_cfopcode
40 #   I   irop_flag_ip_cfopcode
41 #   F   irop_flag_fragile
42 #   Y   irop_flag_forking
43 #   H   irop_flag_highlevel
44 #   c   irop_flag_constlike
45 #
46 # arity: arity of the operation
47 # args:  the arguments of the node constructor (debug, irg and block
48 #        are always the first 3 arguments and are always autmatically
49 #        created)
50 #        or DEFAULT
51 #        DEFAULT will create the following arguments:
52 #        for i = 1 .. arity: ir_node *op_i
53 #        ir_mode *mode
54 # comment: optional comment for the node constructor
55 # rd_constructor: for every operation there will be a
56 #      new_rd_<arch>_<op-name> function with the arguments from above
57 #      which creates the ir_node corresponding to the defined operation
58 #      you can either put the complete source code of this function here
59 #      or use DEFAULT
60 #      DEFAULT creates the following constructor:
61 #
62 #      if (!op_<arch>_<op-name>) assert(0);
63 #      for i = 1 to arity
64 #         set in[i] = op_i
65 #      done
66 #      res = new_ir_node(dbg, irg, block, op_<arch>_<op-name>, mode, in)
67 #      res = optimize_node(res)
68 #      IRN_VRFY_IRG(res, irg)
69 #      return res
70 #
71 # NOTE: You can use DEFAULT if and only if arity is 0,1,2 or 3
72
73 #--------------------------------------------------#
74 #                        _                         #
75 #                       (_)                        #
76 #  _ __   _____      __  _ _ __    ___  _ __  ___  #
77 # | '_ \ / _ \ \ /\ / / | | '__|  / _ \| '_ \/ __| #
78 # | | | |  __/\ V  V /  | | |    | (_) | |_) \__ \ #
79 # |_| |_|\___| \_/\_/   |_|_|     \___/| .__/|___/ #
80 #                                      | |         #
81 #                                      |_|         #
82 #--------------------------------------------------#
83
84 %nodes = (
85
86 # arithmetic operations
87
88 # commutative operations
89
90 "Add" => {
91   "op_flags" => "C",
92   "state"    => "pinned",
93   "arity"    => 2,
94   "args"     => "DEFAULT",
95   "comment"  => "construct Add: Add(a, b) = Add(b, a) = a + b",
96   "rd_constructor" => "DEFAULT"
97 },
98
99 "Add_i" => {
100   "op_flags" => "N",
101   "state"    => "pinned",
102   "arity"    => 1,
103   "args"     => "DEFAULT",
104   "comment"  => "construct Add: Add(a, const) = Add(const, a) = a + const",
105   "rd_constructor" => "DEFAULT"
106 },
107
108 "Mul" => {
109   "op_flags" => "C",
110   "state"    => "pinned",
111   "arity"    => 2,
112   "args"     => "DEFAULT",
113   "comment"  => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
114   "rd_constructor" => "DEFAULT"
115 },
116
117 "Mul_i" => {
118   "op_flags" => "N",
119   "state"    => "pinned",
120   "arity"    => 1,
121   "args"     => "DEFAULT",
122   "comment"  => "construct Mul: Mul(a, const) = Mul(const, a) = a * const",
123   "rd_constructor" => "DEFAULT"
124 },
125
126 "And" => {
127   "op_flags" => "C",
128   "state"    => "pinned",
129   "arity"    => 2,
130   "args"     => "DEFAULT",
131   "comment"  => "construct And: And(a, b) = And(b, a) = a AND b",
132   "rd_constructor" => "DEFAULT"
133 },
134
135 "And_i" => {
136   "op_flags" => "N",
137   "state"    => "pinned",
138   "arity"    => 1,
139   "args"     => "DEFAULT",
140   "comment"  => "construct And: And(a, const) = And(const, a) = a AND const",
141   "rd_constructor" => "DEFAULT"
142 },
143
144 "Or" => {
145   "op_flags" => "C",
146   "state"    => "pinned",
147   "arity"    => 2,
148   "args"     => "DEFAULT",
149   "comment"  => "construct Or: Or(a, b) = Or(b, a) = a OR b",
150   "rd_constructor" => "DEFAULT"
151 },
152
153 "Or_i" => {
154   "op_flags" => "N",
155   "state"    => "pinned",
156   "arity"    => 1,
157   "args"     => "DEFAULT",
158   "comment"  => "construct Or: Or(a, const) = Or(const, a) = a OR const",
159   "rd_constructor" => "DEFAULT"
160 },
161
162 "Eor" => {
163   "op_flags" => "C",
164   "state"    => "pinned",
165   "arity"    => 2,
166   "args"     => "DEFAULT",
167   "comment"  => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
168   "rd_constructor" => "DEFAULT"
169 },
170
171 "Eor_i" => {
172   "op_flags" => "N",
173   "state"    => "pinned",
174   "arity"    => 1,
175   "args"     => "DEFAULT",
176   "comment"  => "construct Eor: Eor(a, const) = Eor(const, a) = a EOR const",
177   "rd_constructor" => "DEFAULT"
178 },
179
180 # not commutative operations
181
182 "Sub" => {
183   "op_flags" => "N",
184   "state"    => "pinned",
185   "arity"    => 2,
186   "args"     => "DEFAULT",
187   "comment"  => "construct Sub: Sub(a, b) = a - b",
188   "rd_constructor" => "DEFAULT"
189 },
190
191 "Sub_i" => {
192   "op_flags" => "N",
193   "state"    => "pinned",
194   "arity"    => 1,
195   "args"     => "DEFAULT",
196   "comment"  => "construct Sub: Sub(a, const) = a - const",
197   "rd_constructor" => "DEFAULT"
198 },
199
200 "Mod" => {
201   "op_flags" => "N",
202   "state"    => "pinned",
203   "arity"    => 2,
204   "args"     => "DEFAULT",
205   "comment"  => "construct Mod: Mod(a, b) = a % b",
206   "rd_constructor" => "DEFAULT"
207 },
208
209 "Mod_i" => {
210   "op_flags" => "N",
211   "state"    => "pinned",
212   "arity"    => 1,
213   "args"     => "DEFAULT",
214   "comment"  => "construct Mod: Mod(a, const) = a % const",
215   "rd_constructor" => "DEFAULT"
216 },
217
218 "Shl" => {
219   "op_flags" => "N",
220   "state"    => "pinned",
221   "arity"    => 2,
222   "args"     => "DEFAULT",
223   "comment"  => "construct Shl: Shl(a, b) = a << b",
224   "rd_constructor" => "DEFAULT"
225 },
226
227 "Shl_i" => {
228   "op_flags" => "N",
229   "state"    => "pinned",
230   "arity"    => 1,
231   "args"     => "DEFAULT",
232   "comment"  => "construct Shl: Shl(a, const) = a << const",
233   "rd_constructor" => "DEFAULT"
234 },
235
236 "Shr" => {
237   "op_flags" => "N",
238   "state"    => "pinned",
239   "arity"    => 2,
240   "args"     => "DEFAULT",
241   "comment"  => "construct Shr: Shr(a, b) = a >> b",
242   "rd_constructor" => "DEFAULT"
243 },
244
245 "Shr_i" => {
246   "op_flags" => "N",
247   "state"    => "pinned",
248   "arity"    => 1,
249   "args"     => "DEFAULT",
250   "comment"  => "construct Shr: Shr(a, const) = a >> const",
251   "rd_constructor" => "DEFAULT"
252 },
253
254 "Shrs" => {
255   "op_flags" => "N",
256   "state"    => "pinned",
257   "arity"    => 2,
258   "args"     => "DEFAULT",
259   "comment"  => "construct Shrs: Shrs(a, b) = a >> b",
260   "rd_constructor" => "DEFAULT"
261 },
262
263 "Shrs_i" => {
264   "op_flags" => "N",
265   "state"    => "pinned",
266   "arity"    => 1,
267   "args"     => "DEFAULT",
268   "comment"  => "construct Shrs: Shrs(a, const) = a >> const",
269   "rd_constructor" => "DEFAULT"
270 },
271
272 "Rot" => {
273   "op_flags" => "N",
274   "state"    => "pinned",
275   "arity"    => 2,
276   "args"     => "DEFAULT",
277   "comment"  => "construct Rot: Rot(a, b) = a ROT b",
278   "rd_constructor" => "DEFAULT"
279 },
280
281 "Rot_i" => {
282   "op_flags" => "N",
283   "state"    => "pinned",
284   "arity"    => 1,
285   "args"     => "DEFAULT",
286   "comment"  => "construct Rot: Rot(a, const) = a ROT const",
287   "rd_constructor" => "DEFAULT"
288 },
289
290 "Minus" => {
291   "op_flags" => "N",
292   "state"    => "pinned",
293   "arity"    => 1,
294   "args"     => "DEFAULT",
295   "comment"  => "construct Minus: Minus(a) = -a",
296   "rd_constructor" => "DEFAULT"
297 },
298
299 # other operations
300
301 "Conv" => {
302   "op_flags" => "N",
303   "state"    => "pinned",
304   "arity"    => 1,
305   "args"     => "DEFAULT",
306   "comment"  => "construct Conv: Conv(a) = (conv)a",
307   "rd_constructor" => "DEFAULT"
308 },
309
310 "Cmp" => {
311   "op_flags" => "C",
312   "state"    => "pinned",
313   "arity"    => 2,
314   "args"     => "DEFAULT",
315   "comment"  => "construct Cmp: Cmp(a, b) = a CMP b",
316   "rd_constructor" => "DEFAULT"
317 },
318
319 "Cmp_i" => {
320   "op_flags" => "N",
321   "state"    => "pinned",
322   "arity"    => 1,
323   "args"     => "DEFAULT",
324   "comment"  => "construct Cmp: Cmp(a, const) = Cmp(const, a) = a CMP const",
325   "rd_constructor" => "DEFAULT"
326 },
327
328 # Load / Store
329
330 "Load" => {
331   "op_flags" => "N",
332   "state"    => "pinned",
333   "arity"    => 2,
334   "args"     => "DEFAULT",
335   "comment"  => "construct Load: Load(mem-edge, ptr) = LD ptr",
336   "rd_constructor" => "DEFAULT"
337 },
338
339 "Store" => {
340   "op_flags" => "N",
341   "state"    => "pinned",
342   "arity"    => 3,
343   "args"     => "DEFAULT",
344   "comment"  => "construct Store: Store(mem-edge, ptr, val) = ST ptr,val",
345   "rd_constructor" => "DEFAULT"
346 }
347
348 ); # end of %nodes