heur4: Avoid unnecessary bitset operations when the node is not limited.
[libfirm] / ir / be / TEMPLATE / TEMPLATE_spec.pl
1 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
2 $arch = "TEMPLATE";
3
4 #
5 # Modes
6 #
7 $mode_gp  = "mode_Iu"; # mode used by general purpose registers
8 $mode_fp  = "mode_F";  # mode used by floatingpoint registers
9
10 # The node description is done as a perl hash initializer with the
11 # following structure:
12 #
13 # %nodes = (
14 #
15 # <op-name> => {
16 #   arity     => "0|1|2|3 ... |variable|dynamic|any",   # optional
17 #   state     => "floats|pinned|mem_pinned|exc_pinned", # optional
18 #   args      => [
19 #                    { type => "type 1", name => "name 1" },
20 #                    { type => "type 2", name => "name 2" },
21 #                    ...
22 #                  ],
23 #   comment   => "any comment for constructor",  # optional
24 #   reg_req   => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
25 #   cmp_attr  => "c source code for comparing node attributes", # optional
26 #   outs      => { "out1", "out2" },# optional, creates pn_op_out1, ... consts
27 #   ins       => { "in1", "in2" },  # optional, creates n_op_in1, ... consts
28 #   mode      => "mode_Iu",         # optional, predefines the mode
29 #   emit      => "emit code with templates",   # optional for virtual nodes
30 #   attr      => "additional attribute arguments for constructor", # optional
31 #   init_attr => "emit attribute initialization template",         # optional
32 #   rd_constructor => "c source code which constructs an ir_node", # optional
33 #   hash_func => "name of the hash function for this operation",   # optional, get the default hash function else
34 #   latency   => "latency of this operation (can be float)"        # optional
35 #   attr_type => "name of the attribute struct",                   # optional
36 # },
37 #
38 # ... # (all nodes you need to describe)
39 #
40 # ); # close the %nodes initializer
41
42 # state: state of the operation, OPTIONAL (default is "floats")
43 #
44 # arity: arity of the operation, MUST NOT BE OMITTED
45 #
46 # args:  the OPTIONAL arguments of the node constructor (debug, irg and block
47 #        are always the first 3 arguments and are always autmatically
48 #        created)
49 #        If this key is missing the following arguments will be created:
50 #        for i = 1 .. arity: ir_node *op_i
51 #        ir_mode *mode
52 #
53 # outs:  if a node defines more than one output, the names of the projections
54 #        nodes having outs having automatically the mode mode_T
55 #
56 # comment: OPTIONAL comment for the node constructor
57 #
58 # register types:
59 #   0 - no special type
60 #   1 - ignore (do not assign this register)
61 #   2 - emitter can choose an arbitrary register of this class
62 #   4 - the register is a virtual one
63 #   8 - register represents a state
64 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
65 %reg_classes = (
66         gp => [
67                 { name => "r0" },
68                 { name => "r1" },
69                 { name => "r2" },
70                 { name => "r3" },
71                 { name => "r4" },
72                 { name => "r5" },
73                 { name => "r6" },
74                 { name => "r7" },
75                 { name => "r8" },
76                 { name => "r9" },
77                 { name => "r10" },
78                 { name => "r11" },
79                 { name => "r12" },
80                 { name => "r13" },
81                 { name => "sp", realname => "r14", type => 1 },  # stackpointer
82                 { name => "bp", realname => "r15", type => 1 },  # basepointer
83                 { mode => $mode_gp }
84         ],
85         fp => [
86                 { name => "f0" },
87                 { name => "f1" },
88                 { name => "f2" },
89                 { name => "f3" },
90                 { name => "f4" },
91                 { name => "f5" },
92                 { name => "f6" },
93                 { name => "f7" },
94                 { name => "f8" },
95                 { name => "f9" },
96                 { name => "f10" },
97                 { name => "f11" },
98                 { name => "f12" },
99                 { name => "f13" },
100                 { name => "f14" },
101                 { name => "f15" },
102                 { mode => $mode_fp }
103         ]
104 );
105
106 $default_attr_type = "TEMPLATE_attr_t";
107 $default_copy_attr = "TEMPLATE_copy_attr";
108
109 %nodes = (
110
111 # Integer nodes
112
113 Add => {
114         op_flags  => [ "commutative" ],
115         irn_flags => [ "rematerializable" ],
116         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
117         emit      => 'add %S1, %S2, %D1',
118         mode      => $mode_gp,
119 },
120
121 Mul => {
122         op_flags  => [ "commutative" ],
123         irn_flags => [ "rematerializable" ],
124         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
125         emit      =>'mul %S1, %S2, %D1',
126         mode      => $mode_gp,
127 },
128
129 And => {
130         op_flags  => [ "commutative" ],
131         irn_flags => [ "rematerializable" ],
132         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
133         emit      => 'and %S1, %S2, %D1',
134         mode      => $mode_gp,
135 },
136
137 Or => {
138         op_flags  => [ "commutative" ],
139         irn_flags => [ "rematerializable" ],
140         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
141         emit      => 'or %S1, %S2, %D1',
142         mode      => $mode_gp,
143 },
144
145 Xor => {
146         op_flags  => [ "commutative" ],
147         irn_flags => [ "rematerializable" ],
148         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
149         emit      => 'xor %S1, %S2, %D1',
150         mode      => $mode_gp,
151 },
152
153 Sub => {
154         irn_flags => [ "rematerializable" ],
155         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
156         emit      => 'sub %S1, %S2, %D1',
157         mode      => $mode_gp,
158 },
159
160 Shl => {
161         irn_flags => [ "rematerializable" ],
162         reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
163         emit      => 'shl %S1, %S2, %D1',
164         mode      => $mode_gp,
165 },
166
167 Shr => {
168         irn_flags => [ "rematerializable" ],
169         reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
170         emit      => 'shr %S2, %D1',
171         mode      => $mode_gp,
172 },
173
174 Minus => {
175         irn_flags => [ "rematerializable" ],
176         reg_req   => { in => [ "gp" ], out => [ "gp" ] },
177         emit      => 'neg %S1, %D1',
178         mode      => $mode_gp,
179 },
180
181 Not => {
182         arity   => 1,
183         remat   => 1,
184         reg_req => { in => [ "gp" ], out => [ "gp" ] },
185         emit    => 'not %S1, %D1',
186         mode    => $mode_gp,
187 },
188
189 Const => {
190         op_flags   => [ "constlike" ],
191         irn_flags  => [ "rematerializable" ],
192         attr       => "ir_tarval *value",
193         custominit => "set_TEMPLATE_value(res, value);",
194         reg_req    => { out => [ "gp" ] },
195         emit       => 'mov %I, %D1',
196         cmp_attr   =>
197 '
198         /* TODO: compare Const attributes */
199     return 1;
200 ',
201         mode    => $mode_gp,
202 },
203
204 # Control Flow
205
206 Jmp => {
207         state     => "pinned",
208         op_flags  => [ "cfopcode" ],
209         irn_flags => [ "simple_jump" ],
210         reg_req   => { out => [ "none" ] },
211         mode      => "mode_X",
212 },
213
214 Start => {
215         state     => "pinned",
216         reg_req   => { in => [], out => [ "sp:I|S", "none" ] },
217         outs      => [ "stack", "M" ],
218         ins       => [],
219 },
220
221 Return => {
222         state    => "pinned",
223         op_flags => [ "cfopcode" ],
224         ins      => [ "stack", "mem" ],
225         reg_req  => { in => [ "sp", "none", ], out => [] },
226         mode     => "mode_X",
227 },
228
229 # Load / Store
230
231 Load => {
232         op_flags  => [ "uses_memory" ],
233         irn_flags => [ "rematerializable" ],
234         state     => "exc_pinned",
235         reg_req   => { in => [ "gp", "none" ], out => [ "gp" ] },
236         emit      => 'mov (%S1), %D1',
237 },
238
239 Store => {
240         op_flags  => [ "uses_memory" ],
241         irn_flags => [ "rematerializable" ],
242         state     => "exc_pinned",
243         reg_req   => { in => [ "gp", "gp", "none" ] },
244         emit      => 'movl %S2, (%S1)',
245 },
246
247 # Floating Point operations
248
249 fAdd => {
250         op_flags  => [ "commutative" ],
251         irn_flags => [ "rematerializable" ],
252         reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
253         emit      => 'fadd %S1, %S2, %D1',
254         mode    => $mode_fp,
255 },
256
257 fMul => {
258         op_flags  => [ "commutative" ],
259         reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
260         emit      =>'fmul %S1, %S2, %D1',
261         mode      => $mode_fp,
262 },
263
264 fSub => {
265         irn_flags => [ "rematerializable" ],
266         reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
267         emit      => 'fsub %S1, %S2, %D1',
268         mode      => $mode_fp,
269 },
270
271 fDiv => {
272         reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
273         emit      => 'fdiv %S1, %S2, %D1',
274         mode      => $mode_fp,
275 },
276
277 fMinus => {
278         irn_flags => [ "rematerializable" ],
279         reg_req   => { in => [ "fp" ], out => [ "fp" ] },
280         emit      => 'fneg %S1, %D1',
281         mode      => $mode_fp,
282 },
283
284 fConst => {
285         op_flags  => [ "constlike" ],
286         irn_flags => [ "rematerializable" ],
287         reg_req   => { out => [ "fp" ] },
288         emit      => 'fmov %I, %D1',
289         cmp_attr  =>
290 '
291         /* TODO: compare fConst attributes */
292         return 1;
293 ',
294         mode      => $mode_fp,
295 },
296
297 # Load / Store
298
299 fLoad => {
300         op_flags  => [ "uses_memory" ],
301         irn_flags => [ "rematerializable" ],
302         state     => "exc_pinned",
303         reg_req   => { in => [ "gp", "none" ], out => [ "fp" ] },
304         emit      => 'fmov (%S1), %D1',
305 },
306
307 fStore => {
308         op_flags  => [ "uses_memory" ],
309         irn_flags => [ "rematerializable" ],
310         state     => "exc_pinned",
311         reg_req   => { in => [ "gp", "fp", "none" ] },
312         emit      => 'fmov %S2, (%S1)',
313 },
314
315 );