1 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
7 $mode_gp = "mode_Iu"; # mode used by general purpose registers
8 $mode_fp = "mode_F"; # mode used by floatingpoint registers
10 # The node description is done as a perl hash initializer with the
11 # following structure:
16 # arity => "0|1|2|3 ... |variable|dynamic|any", # optional
17 # state => "floats|pinned|mem_pinned|exc_pinned", # optional
19 # { type => "type 1", name => "name 1" },
20 # { type => "type 2", name => "name 2" },
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
38 # ... # (all nodes you need to describe)
40 # ); # close the %nodes initializer
42 # state: state of the operation, OPTIONAL (default is "floats")
44 # arity: arity of the operation, MUST NOT BE OMITTED
46 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
47 # are always the first 3 arguments and are always autmatically
49 # If this key is missing the following arguments will be created:
50 # for i = 1 .. arity: ir_node *op_i
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
56 # comment: OPTIONAL comment for the node constructor
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
81 { name => "sp", realname => "r14", type => 1 }, # stackpointer
82 { name => "bp", realname => "r15", type => 1 }, # basepointer
106 $default_attr_type = "TEMPLATE_attr_t";
107 $default_copy_attr = "TEMPLATE_copy_attr";
114 op_flags => [ "commutative" ],
115 irn_flags => [ "rematerializable" ],
116 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
117 emit => 'add %S1, %S2, %D1',
122 op_flags => [ "commutative" ],
123 irn_flags => [ "rematerializable" ],
124 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
125 emit =>'mul %S1, %S2, %D1',
130 op_flags => [ "commutative" ],
131 irn_flags => [ "rematerializable" ],
132 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
133 emit => 'and %S1, %S2, %D1',
138 op_flags => [ "commutative" ],
139 irn_flags => [ "rematerializable" ],
140 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
141 emit => 'or %S1, %S2, %D1',
146 op_flags => [ "commutative" ],
147 irn_flags => [ "rematerializable" ],
148 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
149 emit => 'xor %S1, %S2, %D1',
154 irn_flags => [ "rematerializable" ],
155 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
156 emit => 'sub %S1, %S2, %D1',
161 irn_flags => [ "rematerializable" ],
162 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
163 emit => 'shl %S1, %S2, %D1',
168 irn_flags => [ "rematerializable" ],
169 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
170 emit => 'shr %S2, %D1',
175 irn_flags => [ "rematerializable" ],
176 reg_req => { in => [ "gp" ], out => [ "gp" ] },
177 emit => 'neg %S1, %D1',
184 reg_req => { in => [ "gp" ], out => [ "gp" ] },
185 emit => 'not %S1, %D1',
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',
198 /* TODO: compare Const attributes */
208 op_flags => [ "cfopcode" ],
209 irn_flags => [ "simple_jump" ],
210 reg_req => { out => [ "none" ] },
217 op_flags => [ "uses_memory" ],
218 irn_flags => [ "rematerializable" ],
219 state => "exc_pinned",
220 reg_req => { in => [ "gp", "none" ], out => [ "gp" ] },
221 emit => 'mov (%S1), %D1',
225 op_flags => [ "uses_memory" ],
226 irn_flags => [ "rematerializable" ],
227 state => "exc_pinned",
228 reg_req => { in => [ "gp", "gp", "none" ] },
229 emit => 'movl %S2, (%S1)',
232 # Floating Point operations
235 op_flags => [ "commutative" ],
236 irn_flags => [ "rematerializable" ],
237 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
238 emit => 'fadd %S1, %S2, %D1',
243 op_flags => [ "commutative" ],
244 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
245 emit =>'fmul %S1, %S2, %D1',
250 irn_flags => [ "rematerializable" ],
251 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
252 emit => 'fsub %S1, %S2, %D1',
257 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
258 emit => 'fdiv %S1, %S2, %D1',
263 irn_flags => [ "rematerializable" ],
264 reg_req => { in => [ "fp" ], out => [ "fp" ] },
265 emit => 'fneg %S1, %D1',
270 op_flags => [ "constlike" ],
271 irn_flags => [ "rematerializable" ],
272 reg_req => { out => [ "fp" ] },
273 emit => 'fmov %I, %D1',
276 /* TODO: compare fConst attributes */
285 op_flags => [ "uses_memory" ],
286 irn_flags => [ "rematerializable" ],
287 state => "exc_pinned",
288 reg_req => { in => [ "gp", "none" ], out => [ "fp" ] },
289 emit => 'fmov (%S1), %D1',
293 op_flags => [ "uses_memory" ],
294 irn_flags => [ "rematerializable" ],
295 state => "exc_pinned",
296 reg_req => { in => [ "gp", "fp", "none" ] },
297 emit => 'fmov %S2, (%S1)',