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