2 # $Id: amd64_spec.pl 26673 2009-10-01 16:43:13Z matze $
4 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
8 # The node description is done as a perl hash initializer with the
14 # arity => "0|1|2|3 ... |variable|dynamic|any", # optional
15 # state => "floats|pinned|mem_pinned|exc_pinned", # optional
17 # { type => "type 1", name => "name 1" },
18 # { type => "type 2", name => "name 2" },
21 # comment => "any comment for constructor", # optional
22 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
23 # cmp_attr => "c source code for comparing node attributes", # optional
24 # outs => { "out1", "out2" },# optional, creates pn_op_out1, ... consts
25 # ins => { "in1", "in2" }, # optional, creates n_op_in1, ... consts
26 # mode => "mode_Iu", # optional, predefines the mode
27 # emit => "emit code with templates", # optional for virtual nodes
28 # attr => "additional attribute arguments for constructor", # optional
29 # init_attr => "emit attribute initialization template", # optional
30 # rd_constructor => "c source code which constructs an ir_node", # optional
31 # hash_func => "name of the hash function for this operation", # optional, get the default hash function else
32 # latency => "latency of this operation (can be float)" # optional
33 # attr_type => "name of the attribute struct", # optional
36 # ... # (all nodes you need to describe)
38 # ); # close the %nodes initializer
40 # state: state of the operation, OPTIONAL (default is "floats")
42 # arity: arity of the operation, MUST NOT BE OMITTED
44 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
45 # are always the first 3 arguments and are always autmatically
47 # If this key is missing the following arguments will be created:
48 # for i = 1 .. arity: ir_node *op_i
51 # outs: if a node defines more than one output, the names of the projections
52 # nodes having outs having automatically the mode mode_T
54 # comment: OPTIONAL comment for the node constructor
57 $normal = 0; # no special type
58 $ignore = 1; # ignore (do not assign this register)
59 $arbitrary = 2; # emitter can choose an arbitrary register of this class
60 $virtual = 4; # the register is a virtual one
61 $state = 8; # register represents a state
62 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
72 { name => "rsp", type => $ignore }, # stackpointer?
81 # { name => "gp_NOREG", type => $ignore }, # we need a dummy register for NoReg nodes
95 # { name => "xmm10" },
96 # { name => "xmm11" },
97 # { name => "xmm12" },
98 # { name => "xmm13" },
99 # { name => "xmm14" },
100 # { name => "xmm15" },
101 # { mode => "mode_D" }
104 { name => "eflags" },
105 { mode => "mode_Iu", flags => "manual_ra" }
109 $mode_gp = "mode_Lu";
110 $mode_flags = "mode_Iu";
112 sub amd64_custom_init_attr {
118 if(defined($node->{modified_flags})) {
119 $res .= "\tarch_add_irn_flags(res, arch_irn_flags_modify_flags);\n";
123 $custom_init_attr_func = \&amd64_custom_init_attr;
125 $default_copy_attr = "amd64_copy_attr";
128 S1 => "${arch}_emit_source_register(node, 0);",
129 S2 => "${arch}_emit_source_register(node, 1);",
130 S3 => "${arch}_emit_source_register(node, 2);",
131 S4 => "${arch}_emit_source_register(node, 3);",
132 S5 => "${arch}_emit_source_register(node, 4);",
133 S6 => "${arch}_emit_source_register(node, 5);",
134 D1 => "${arch}_emit_dest_register(node, 0);",
135 D2 => "${arch}_emit_dest_register(node, 1);",
136 D3 => "${arch}_emit_dest_register(node, 2);",
137 D4 => "${arch}_emit_dest_register(node, 3);",
138 D5 => "${arch}_emit_dest_register(node, 4);",
139 D6 => "${arch}_emit_dest_register(node, 5);",
140 C => "${arch}_emit_immediate(node);",
141 O => "${arch}_emit_fp_offset(node);",
146 "\tinit_amd64_attributes(res, irn_flags_, in_reqs, n_res);",
147 amd64_SymConst_attr_t =>
148 "\tinit_amd64_attributes(res, irn_flags_, in_reqs, n_res);"
149 . "\tinit_amd64_SymConst_attributes(res, entity);",
150 amd64_condcode_attr_t =>
151 "\tinit_amd64_attributes(res, irn_flags_, in_reqs, n_res);"
152 . "\tinit_amd64_condcode_attributes(res, pnc);",
156 amd64_attr_t => "cmp_amd64_attr",
157 amd64_SymConst_attr_t => "cmp_amd64_attr_SymConst",
158 amd64_condcode_attr_t => "cmp_amd64_attr_condcode",
163 state => "exc_pinned",
164 reg_req => { in => [ "gp", "gp", "none", "gp", "rsp" ], out => [ "rsp:I|S", "none" ] },
165 ins => [ "base", "index", "mem", "val", "stack" ],
166 emit => '. push %S1',
167 outs => [ "stack", "M" ],
168 am => "source,unary",
173 op_flags => [ "commutative" ],
174 irn_flags => [ "rematerializable" ],
175 state => "exc_pinned",
176 reg_req => { in => [ "gp", "gp" ],
178 in => [ "left", "right" ],
184 # we should not rematrialize this node. It produces 2 results and has
185 # very strict constraints
186 state => "exc_pinned",
187 reg_req => { in => [ "rax", "gp" ],
188 out => [ "rax rdx" ] },
189 ins => [ "left", "right" ],
193 am => "source,binary",
194 modified_flags => $status_flags
197 irn_flags => [ "rematerializable" ],
198 state => "exc_pinned",
199 reg_req => { in => [ "gp", "gp" ],
201 in => [ "left", "right" ],
207 irn_flags => [ "rematerializable" ],
208 reg_req => { in => [ "gp" ],
209 out => [ "in_r1", "flags" ] },
212 outs => [ "res", "flags" ],
214 modified_flags => $status_flags
217 op_flags => [ "constlike" ],
218 attr => "unsigned imm_value",
219 init_attr => "attr->ext.imm_value = imm_value;",
220 reg_req => { out => [ "gp" ] },
221 emit => '. mov %C, %D1',
225 op_flags => [ "constlike" ],
226 irn_flags => [ "rematerializable" ],
227 attr => "ir_entity *entity",
228 attr_type => "amd64_SymConst_attr_t",
229 reg_req => { out => [ "gp" ] },
234 state => "exc_pinned",
235 attr => "ir_mode *smaller_mode",
236 init_attr => "attr->ls_mode = smaller_mode;",
237 reg_req => { in => [ "gp" ], out => [ "gp" ] },
244 op_flags => [ "cfopcode" ],
245 reg_req => { out => [ "none" ] },
249 irn_flags => [ "rematerializable" ],
250 state => "exc_pinned",
251 reg_req => { in => [ "gp", "gp" ],
252 out => [ "flags" ] },
253 ins => [ "left", "right" ],
254 outs => [ "eflags" ],
255 emit => '. cmp %S1, %S2',
256 attr => "int ins_permuted, int cmp_unsigned",
257 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
258 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
264 op_flags => [ "labeled", "cfopcode", "forking" ],
265 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
267 outs => [ "false", "true" ],
268 attr => "ir_relation relation",
269 init_attr => "attr->ext.relation = relation;",
273 op_flags => [ "labeled" ],
274 state => "exc_pinned",
275 reg_req => { in => [ "gp", "none" ],
276 out => [ "gp", "none" ] },
277 ins => [ "ptr", "mem" ],
278 outs => [ "res", "M" ],
279 attr => "ir_entity *entity",
280 attr_type => "amd64_SymConst_attr_t",
281 emit => ". mov %O(%S1), %D1"
284 op_flags => [ "constlike" ],
285 irn_flags => [ "rematerializable" ],
286 reg_req => { in => [ "gp" ], out => [ "gp" ] },
288 attr => "ir_entity *entity",
289 attr_type => "amd64_SymConst_attr_t",
293 op_flags => [ "labeled" ],
294 state => "exc_pinned",
295 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
296 ins => [ "ptr", "val", "mem" ],
298 attr => "ir_entity *entity",
299 attr_type => "amd64_SymConst_attr_t",
301 emit => ". mov %S2, %O(%S1)"
306 # op_flags => [ "constlike", "dump_noblcok", "dump_noinput" ],
307 # reg_req => { out => [ "gp_NOREG:I" ] },