4 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
11 $mode_gp = "mode_Iu"; # mode used by general purpose registers
12 $mode_fp = "mode_E"; # mode used by floatingpoint registers
14 # The node description is done as a perl hash initializer with the
15 # following structure:
20 # op_flags => "N|L|C|X|I|F|Y|H|c|K", # optional
21 # irn_flags => "R|N|I" # optional
22 # arity => "0|1|2|3 ... |variable|dynamic|any", # optional
23 # state => "floats|pinned|mem_pinned|exc_pinned", # optional
25 # { type => "type 1", name => "name 1" },
26 # { type => "type 2", name => "name 2" },
29 # comment => "any comment for constructor", # optional
30 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
31 # cmp_attr => "c source code for comparing node attributes", # optional
32 # outs => { "out1", "out2" },# optional, creates pn_op_out1, ... consts
33 # ins => { "in1", "in2" }, # optional, creates n_op_in1, ... consts
34 # mode => "mode_Iu", # optional, predefines the mode
35 # emit => "emit code with templates", # optional for virtual nodes
36 # attr => "additional attribute arguments for constructor", # optional
37 # init_attr => "emit attribute initialization template", # optional
38 # rd_constructor => "c source code which constructs an ir_node", # optional
39 # hash_func => "name of the hash function for this operation", # optional, get the default hash function else
40 # latency => "latency of this operation (can be float)" # optional
41 # attr_type => "name of the attribute struct", # optional
44 # ... # (all nodes you need to describe)
46 # ); # close the %nodes initializer
48 # op_flags: flags for the operation, OPTIONAL (default is "N")
49 # the op_flags correspond to the firm irop_flags:
52 # C irop_flag_commutative
53 # X irop_flag_cfopcode
54 # I irop_flag_ip_cfopcode
57 # H irop_flag_highlevel
58 # c irop_flag_constlike
61 # irn_flags: special node flags, OPTIONAL (default is 0)
62 # following irn_flags are supported:
65 # I ignore for register allocation
67 # state: state of the operation, OPTIONAL (default is "floats")
69 # arity: arity of the operation, MUST NOT BE OMITTED
71 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
72 # are always the first 3 arguments and are always autmatically
74 # If this key is missing the following arguments will be created:
75 # for i = 1 .. arity: ir_node *op_i
78 # outs: if a node defines more than one output, the names of the projections
79 # nodes having outs having automatically the mode mode_T
81 # comment: OPTIONAL comment for the node constructor
83 # rd_constructor: for every operation there will be a
84 # new_rd_<arch>_<op-name> function with the arguments from above
85 # which creates the ir_node corresponding to the defined operation
86 # you can either put the complete source code of this function here
88 # This key is OPTIONAL. If omitted, the following constructor will
90 # if (!op_<arch>_<op-name>) assert(0);
94 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
100 # 0 - no special type
101 # 1 - caller save (register must be saved by the caller of a function)
102 # 2 - callee save (register must be saved by the called function)
103 # 4 - ignore (do not assign this register)
104 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
107 { name => "r0", type => 1 },
108 { name => "r1", type => 1 },
109 { name => "r2", type => 1 },
110 { name => "r3", type => 1 },
111 { name => "r4", type => 1 },
112 { name => "r5", type => 1 },
113 { name => "r6", type => 1 },
114 { name => "r7", type => 2 },
115 { name => "r8", type => 2 },
116 { name => "r9", type => 2 },
117 { name => "r10", type => 2 },
118 { name => "r11", type => 2 },
119 { name => "r12", type => 2 },
120 { name => "r13", type => 2 },
121 { name => "sp", realname => "r14", type => 4 }, # stackpointer
122 { name => "bp", realname => "r15", type => 4 }, # basepointer
126 { name => "f0", type => 1 },
127 { name => "f1", type => 1 },
128 { name => "f2", type => 1 },
129 { name => "f3", type => 1 },
130 { name => "f4", type => 1 },
131 { name => "f5", type => 1 },
132 { name => "f6", type => 1 },
133 { name => "f7", type => 1 },
134 { name => "f8", type => 1 },
135 { name => "f9", type => 1 },
136 { name => "f10", type => 1 },
137 { name => "f11", type => 1 },
138 { name => "f12", type => 1 },
139 { name => "f13", type => 1 },
140 { name => "f14", type => 1 },
141 { name => "f15", type => 1 },
147 S1 => "${arch}_emit_source_register(node, 0);",
148 S2 => "${arch}_emit_source_register(node, 1);",
149 S3 => "${arch}_emit_source_register(node, 2);",
150 S4 => "${arch}_emit_source_register(node, 3);",
151 S5 => "${arch}_emit_source_register(node, 4);",
152 S6 => "${arch}_emit_source_register(node, 5);",
153 D1 => "${arch}_emit_dest_register(node, 0);",
154 D2 => "${arch}_emit_dest_register(node, 1);",
155 D3 => "${arch}_emit_dest_register(node, 2);",
156 D4 => "${arch}_emit_dest_register(node, 3);",
157 D5 => "${arch}_emit_dest_register(node, 4);",
158 D6 => "${arch}_emit_dest_register(node, 5);",
159 C => "${arch}_emit_immediate(node);"
167 op_flags => [ "commutative" ],
168 irn_flags => [ "rematerializable" ],
169 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
170 emit => '. add %S1, %S2, %D1',
175 op_flags => [ "commutative" ],
176 irn_flags => [ "rematerializable" ],
177 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
178 emit =>'. mul %S1, %S2, %D1',
183 op_flags => [ "commutative" ],
184 irn_flags => [ "rematerializable" ],
185 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
186 emit => '. and %S1, %S2, %D1',
191 op_flags => [ "commutative" ],
192 irn_flags => [ "rematerializable" ],
193 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
194 emit => '. or %S1, %S2, %D1',
199 op_flags => [ "commutative" ],
200 irn_flags => [ "rematerializable" ],
201 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
202 emit => '. xor %S1, %S2, %D1',
207 irn_flags => [ "rematerializable" ],
208 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
209 emit => '. sub %S1, %S2, %D1',
214 irn_flags => [ "rematerializable" ],
215 reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
216 emit => '. shl %S1, %S2, %D1',
221 irn_flags => [ "rematerializable" ],
222 reg_req => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
223 emit => '. shr %S2, %D1',
228 irn_flags => [ "rematerializable" ],
229 reg_req => { in => [ "gp" ], out => [ "gp" ] },
230 emit => '. neg %S1, %D1',
237 reg_req => { in => [ "gp" ], out => [ "gp" ] },
238 emit => '. not %S1, %D1',
243 op_flags => [ "constlike" ],
244 irn_flags => [ "rematerializable" ],
245 attr => "tarval *value",
246 custominit => "set_TEMPLATE_value(res, value);",
247 reg_req => { out => [ "gp" ] },
248 emit => '. mov %C, %D1',
251 /* TODO: compare Const attributes */
261 op_flags => [ "cfopcode" ],
262 irn_flags => [ "simple_jump" ],
263 reg_req => { out => [ "none" ] },
270 op_flags => [ "labeled", "fragile" ],
271 irn_flags => [ "rematerializable" ],
272 state => "exc_pinned",
273 reg_req => { in => [ "gp", "none" ], out => [ "gp" ] },
274 emit => '. mov (%S1), %D1',
278 op_flags => [ "labeled", "fragile" ],
279 irn_flags => [ "rematerializable" ],
280 state => "exc_pinned",
281 reg_req => { in => [ "gp", "gp", "none" ] },
282 emit => '. movl %S2, (%S1)',
285 # Floating Point operations
288 op_flags => [ "commutative" ],
289 irn_flags => [ "rematerializable" ],
290 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
291 emit => '. fadd %S1, %S2, %D1',
296 op_flags => [ "commutative" ],
297 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
298 emit =>'. fmul %S1, %S2, %D1',
303 irn_flags => [ "rematerializable" ],
304 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
305 emit => '. fsub %S1, %S2, %D1',
310 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
311 emit => '. fdiv %S1, %S2, %D1',
316 irn_flags => [ "rematerializable" ],
317 reg_req => { in => [ "fp" ], out => [ "fp" ] },
318 emit => '. fneg %S1, %D1',
323 op_flags => [ "constlike" ],
324 irn_flags => [ "rematerializable" ],
325 reg_req => { out => [ "fp" ] },
326 emit => '. fmov %C, %D1',
329 /* TODO: compare fConst attributes */
338 op_flags => [ "labeled", "fragile" ],
339 irn_flags => [ "rematerializable" ],
340 state => "exc_pinned",
341 reg_req => { in => [ "gp", "none" ], out => [ "fp" ] },
342 emit => '. fmov (%S1), %D1',
346 op_flags => [ "labeled", "fragile" ],
347 irn_flags => [ "rematerializable" ],
348 state => "exc_pinned",
349 reg_req => { in => [ "gp", "fp", "none" ] },
350 emit => '. fmov %S2, (%S1)',