4 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
11 $mode_gp = "mode_Iu"; # mode used by general purpose registers
12 $mode_fp = "mode_F"; # mode used by floatingpoint registers
14 # The node description is done as a perl hash initializer with the
15 # following structure:
20 # arity => "0|1|2|3 ... |variable|dynamic|any", # optional
21 # state => "floats|pinned|mem_pinned|exc_pinned", # optional
23 # { type => "type 1", name => "name 1" },
24 # { type => "type 2", name => "name 2" },
27 # comment => "any comment for constructor", # optional
28 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
29 # cmp_attr => "c source code for comparing node attributes", # optional
30 # outs => { "out1", "out2" },# optional, creates pn_op_out1, ... consts
31 # ins => { "in1", "in2" }, # optional, creates n_op_in1, ... consts
32 # mode => "mode_Iu", # optional, predefines the mode
33 # emit => "emit code with templates", # optional for virtual nodes
34 # attr => "additional attribute arguments for constructor", # optional
35 # init_attr => "emit attribute initialization template", # optional
36 # rd_constructor => "c source code which constructs an ir_node", # optional
37 # hash_func => "name of the hash function for this operation", # optional, get the default hash function else
38 # latency => "latency of this operation (can be float)" # optional
39 # attr_type => "name of the attribute struct", # optional
42 # ... # (all nodes you need to describe)
44 # ); # close the %nodes initializer
46 # state: state of the operation, OPTIONAL (default is "floats")
48 # arity: arity of the operation, MUST NOT BE OMITTED
50 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
51 # are always the first 3 arguments and are always autmatically
53 # If this key is missing the following arguments will be created:
54 # for i = 1 .. arity: ir_node *op_i
57 # outs: if a node defines more than one output, the names of the projections
58 # nodes having outs having automatically the mode mode_T
60 # comment: OPTIONAL comment for the node constructor
64 # 1 - ignore (do not assign this register)
65 # 2 - emitter can choose an arbitrary register of this class
66 # 4 - the register is a virtual one
67 # 8 - register represents a state
68 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
85 { name => "sp", realname => "r14", type => 1 }, # stackpointer
86 { name => "bp", realname => "r15", type => 1 }, # basepointer
111 S1 => "${arch}_emit_source_register(node, 0);",
112 S2 => "${arch}_emit_source_register(node, 1);",
113 S3 => "${arch}_emit_source_register(node, 2);",
114 S4 => "${arch}_emit_source_register(node, 3);",
115 S5 => "${arch}_emit_source_register(node, 4);",
116 S6 => "${arch}_emit_source_register(node, 5);",
117 D1 => "${arch}_emit_dest_register(node, 0);",
118 D2 => "${arch}_emit_dest_register(node, 1);",
119 D3 => "${arch}_emit_dest_register(node, 2);",
120 D4 => "${arch}_emit_dest_register(node, 3);",
121 D5 => "${arch}_emit_dest_register(node, 4);",
122 D6 => "${arch}_emit_dest_register(node, 5);",
123 C => "${arch}_emit_immediate(node);"
126 $default_attr_type = "TEMPLATE_attr_t";
127 $default_copy_attr = "TEMPLATE_copy_attr";
134 op_flags => [ "commutative" ],
135 irn_flags => [ "rematerializable" ],
136 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
137 emit => '. add %S1, %S2, %D1',
142 op_flags => [ "commutative" ],
143 irn_flags => [ "rematerializable" ],
144 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
145 emit =>'. mul %S1, %S2, %D1',
150 op_flags => [ "commutative" ],
151 irn_flags => [ "rematerializable" ],
152 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
153 emit => '. and %S1, %S2, %D1',
158 op_flags => [ "commutative" ],
159 irn_flags => [ "rematerializable" ],
160 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
161 emit => '. or %S1, %S2, %D1',
166 op_flags => [ "commutative" ],
167 irn_flags => [ "rematerializable" ],
168 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
169 emit => '. xor %S1, %S2, %D1',
174 irn_flags => [ "rematerializable" ],
175 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
176 emit => '. sub %S1, %S2, %D1',
181 irn_flags => [ "rematerializable" ],
182 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
183 emit => '. shl %S1, %S2, %D1',
188 irn_flags => [ "rematerializable" ],
189 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
190 emit => '. shr %S2, %D1',
195 irn_flags => [ "rematerializable" ],
196 reg_req => { in => [ "gp" ], out => [ "gp" ] },
197 emit => '. neg %S1, %D1',
204 reg_req => { in => [ "gp" ], out => [ "gp" ] },
205 emit => '. not %S1, %D1',
210 op_flags => [ "constlike" ],
211 irn_flags => [ "rematerializable" ],
212 attr => "ir_tarval *value",
213 custominit => "set_TEMPLATE_value(res, value);",
214 reg_req => { out => [ "gp" ] },
215 emit => '. mov %C, %D1',
218 /* TODO: compare Const attributes */
228 op_flags => [ "cfopcode" ],
229 irn_flags => [ "simple_jump" ],
230 reg_req => { out => [ "none" ] },
237 op_flags => [ "labeled" ],
238 irn_flags => [ "rematerializable" ],
239 state => "exc_pinned",
240 reg_req => { in => [ "gp", "none" ], out => [ "gp" ] },
241 emit => '. mov (%S1), %D1',
245 op_flags => [ "labeled" ],
246 irn_flags => [ "rematerializable" ],
247 state => "exc_pinned",
248 reg_req => { in => [ "gp", "gp", "none" ] },
249 emit => '. movl %S2, (%S1)',
252 # Floating Point operations
255 op_flags => [ "commutative" ],
256 irn_flags => [ "rematerializable" ],
257 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
258 emit => '. fadd %S1, %S2, %D1',
263 op_flags => [ "commutative" ],
264 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
265 emit =>'. fmul %S1, %S2, %D1',
270 irn_flags => [ "rematerializable" ],
271 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
272 emit => '. fsub %S1, %S2, %D1',
277 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
278 emit => '. fdiv %S1, %S2, %D1',
283 irn_flags => [ "rematerializable" ],
284 reg_req => { in => [ "fp" ], out => [ "fp" ] },
285 emit => '. fneg %S1, %D1',
290 op_flags => [ "constlike" ],
291 irn_flags => [ "rematerializable" ],
292 reg_req => { out => [ "fp" ] },
293 emit => '. fmov %C, %D1',
296 /* TODO: compare fConst attributes */
305 op_flags => [ "labeled" ],
306 irn_flags => [ "rematerializable" ],
307 state => "exc_pinned",
308 reg_req => { in => [ "gp", "none" ], out => [ "fp" ] },
309 emit => '. fmov (%S1), %D1',
313 op_flags => [ "labeled" ],
314 irn_flags => [ "rematerializable" ],
315 state => "exc_pinned",
316 reg_req => { in => [ "gp", "fp", "none" ] },
317 emit => '. fmov %S2, (%S1)',