1 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
5 # The node description is done as a perl hash initializer with the
11 # arity => "0|1|2|3 ... |variable|dynamic|any", # optional
12 # state => "floats|pinned|mem_pinned|exc_pinned", # optional
14 # { type => "type 1", name => "name 1" },
15 # { type => "type 2", name => "name 2" },
18 # comment => "any comment for constructor", # optional
19 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
20 # cmp_attr => "c source code for comparing node attributes", # optional
21 # outs => { "out1", "out2" },# optional, creates pn_op_out1, ... consts
22 # ins => { "in1", "in2" }, # optional, creates n_op_in1, ... consts
23 # mode => "mode_Iu", # optional, predefines the mode
24 # emit => "emit code with templates", # optional for virtual nodes
25 # attr => "additional attribute arguments for constructor", # optional
26 # init_attr => "emit attribute initialization template", # optional
27 # rd_constructor => "c source code which constructs an ir_node", # optional
28 # hash_func => "name of the hash function for this operation", # optional, get the default hash function else
29 # latency => "latency of this operation (can be float)" # optional
30 # attr_type => "name of the attribute struct", # optional
33 # ... # (all nodes you need to describe)
35 # ); # close the %nodes initializer
37 # state: state of the operation, OPTIONAL (default is "floats")
39 # arity: arity of the operation, MUST NOT BE OMITTED
41 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
42 # are always the first 3 arguments and are always autmatically
44 # If this key is missing the following arguments will be created:
45 # for i = 1 .. arity: ir_node *op_i
48 # outs: if a node defines more than one output, the names of the projections
49 # nodes having outs having automatically the mode mode_T
51 # comment: OPTIONAL comment for the node constructor
54 $normal = 0; # no special type
55 $ignore = 1; # ignore (do not assign this register)
56 $arbitrary = 2; # emitter can choose an arbitrary register of this class
57 $virtual = 4; # the register is a virtual one
58 $state = 8; # register represents a state
59 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
62 { name => "rax", dwarf => 0 },
63 { name => "rcx", dwarf => 2 },
64 { name => "rdx", dwarf => 1 },
65 { name => "rsi", dwarf => 4 },
66 { name => "rdi", dwarf => 5 },
67 { name => "rbx", dwarf => 3 },
68 { name => "rbp", dwarf => 6 },
69 { name => "rsp", dwarf => 7, type => $ignore }, # stackpointer?
70 { name => "r8", dwarf => 8 },
71 { name => "r9", dwarf => 9 },
72 { name => "r10", dwarf => 10 },
73 { name => "r11", dwarf => 11 },
74 { name => "r12", dwarf => 12 },
75 { name => "r13", dwarf => 13 },
76 { name => "r14", dwarf => 14 },
77 { name => "r15", dwarf => 15 },
78 # { name => "gp_NOREG", type => $ignore }, # we need a dummy register for NoReg nodes
82 # { name => "xmm0", dwarf => 17 },
83 # { name => "xmm1", dwarf => 18 },
84 # { name => "xmm2", dwarf => 19 },
85 # { name => "xmm3", dwarf => 20 },
86 # { name => "xmm4", dwarf => 21 },
87 # { name => "xmm5", dwarf => 22 },
88 # { name => "xmm6", dwarf => 23 },
89 # { name => "xmm7", dwarf => 24 },
90 # { name => "xmm8", dwarf => 25 },
91 # { name => "xmm9", dwarf => 26 },
92 # { name => "xmm10", dwarf => 27 },
93 # { name => "xmm11", dwarf => 28 },
94 # { name => "xmm12", dwarf => 29 },
95 # { name => "xmm13", dwarf => 30 },
96 # { name => "xmm14", dwarf => 31 },
97 # { name => "xmm15", dwarf => 32 },
98 # { mode => "mode_D" }
101 { name => "eflags", dwarf => 49 },
102 { mode => "mode_Iu", flags => "manual_ra" }
106 $mode_gp = "mode_Lu";
107 $mode_flags = "mode_Iu";
109 sub amd64_custom_init_attr {
115 if(defined($node->{modified_flags})) {
116 $res .= "\tarch_add_irn_flags(res, arch_irn_flags_modify_flags);\n";
120 $custom_init_attr_func = \&amd64_custom_init_attr;
122 $default_copy_attr = "amd64_copy_attr";
125 S1 => "${arch}_emit_source_register(node, 0);",
126 S2 => "${arch}_emit_source_register(node, 1);",
127 S3 => "${arch}_emit_source_register(node, 2);",
128 S4 => "${arch}_emit_source_register(node, 3);",
129 S5 => "${arch}_emit_source_register(node, 4);",
130 S6 => "${arch}_emit_source_register(node, 5);",
131 D1 => "${arch}_emit_dest_register(node, 0);",
132 D2 => "${arch}_emit_dest_register(node, 1);",
133 D3 => "${arch}_emit_dest_register(node, 2);",
134 D4 => "${arch}_emit_dest_register(node, 3);",
135 D5 => "${arch}_emit_dest_register(node, 4);",
136 D6 => "${arch}_emit_dest_register(node, 5);",
137 C => "${arch}_emit_immediate(node);",
138 O => "${arch}_emit_fp_offset(node);",
143 "\tinit_amd64_attributes(res, irn_flags_, in_reqs, n_res);",
144 amd64_SymConst_attr_t =>
145 "\tinit_amd64_attributes(res, irn_flags_, in_reqs, n_res);"
146 . "\tinit_amd64_SymConst_attributes(res, entity);",
147 amd64_condcode_attr_t =>
148 "\tinit_amd64_attributes(res, irn_flags_, in_reqs, n_res);"
149 . "\tinit_amd64_condcode_attributes(res, pnc);",
153 amd64_attr_t => "cmp_amd64_attr",
154 amd64_SymConst_attr_t => "cmp_amd64_attr_SymConst",
155 amd64_condcode_attr_t => "cmp_amd64_attr_condcode",
160 state => "exc_pinned",
161 reg_req => { in => [ "gp", "gp", "none", "gp", "rsp" ], out => [ "rsp:I|S", "none" ] },
162 ins => [ "base", "index", "mem", "val", "stack" ],
163 emit => '. push %S1',
164 outs => [ "stack", "M" ],
165 am => "source,unary",
170 op_flags => [ "commutative" ],
171 irn_flags => [ "rematerializable" ],
172 state => "exc_pinned",
173 reg_req => { in => [ "gp", "gp" ],
175 in => [ "left", "right" ],
181 # we should not rematrialize this node. It produces 2 results and has
182 # very strict constraints
183 state => "exc_pinned",
184 reg_req => { in => [ "rax", "gp" ],
185 out => [ "rax rdx" ] },
186 ins => [ "left", "right" ],
190 am => "source,binary",
191 modified_flags => $status_flags
194 irn_flags => [ "rematerializable" ],
195 state => "exc_pinned",
196 reg_req => { in => [ "gp", "gp" ],
198 in => [ "left", "right" ],
204 irn_flags => [ "rematerializable" ],
205 reg_req => { in => [ "gp" ],
206 out => [ "in_r1", "flags" ] },
209 outs => [ "res", "flags" ],
211 modified_flags => $status_flags
214 op_flags => [ "constlike" ],
215 attr => "unsigned imm_value",
216 init_attr => "attr->ext.imm_value = imm_value;",
217 reg_req => { out => [ "gp" ] },
218 emit => '. mov %C, %D1',
222 op_flags => [ "constlike" ],
223 irn_flags => [ "rematerializable" ],
224 attr => "ir_entity *entity",
225 attr_type => "amd64_SymConst_attr_t",
226 reg_req => { out => [ "gp" ] },
231 state => "exc_pinned",
232 attr => "ir_mode *smaller_mode",
233 init_attr => "attr->ls_mode = smaller_mode;",
234 reg_req => { in => [ "gp" ], out => [ "gp" ] },
241 op_flags => [ "cfopcode" ],
242 reg_req => { out => [ "none" ] },
246 irn_flags => [ "rematerializable" ],
247 state => "exc_pinned",
248 reg_req => { in => [ "gp", "gp" ],
249 out => [ "flags" ] },
250 ins => [ "left", "right" ],
251 outs => [ "eflags" ],
252 emit => '. cmp %S1, %S2',
253 attr => "int ins_permuted, int cmp_unsigned",
254 init_attr => "attr->data.ins_permuted = ins_permuted;\n".
255 "\tattr->data.cmp_unsigned = cmp_unsigned;\n",
261 op_flags => [ "labeled", "cfopcode", "forking" ],
262 reg_req => { in => [ "eflags" ], out => [ "none", "none" ] },
264 outs => [ "false", "true" ],
265 attr => "ir_relation relation",
266 init_attr => "attr->ext.relation = relation;",
270 op_flags => [ "labeled" ],
271 state => "exc_pinned",
272 reg_req => { in => [ "gp", "none" ],
273 out => [ "gp", "none" ] },
274 ins => [ "ptr", "mem" ],
275 outs => [ "res", "M" ],
276 attr => "ir_entity *entity",
277 attr_type => "amd64_SymConst_attr_t",
278 emit => ". mov %O(%S1), %D1"
281 op_flags => [ "constlike" ],
282 irn_flags => [ "rematerializable" ],
283 reg_req => { in => [ "gp" ], out => [ "gp" ] },
285 attr => "ir_entity *entity",
286 attr_type => "amd64_SymConst_attr_t",
290 op_flags => [ "labeled" ],
291 state => "exc_pinned",
292 reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
293 ins => [ "ptr", "val", "mem" ],
295 attr => "ir_entity *entity",
296 attr_type => "amd64_SymConst_attr_t",
298 emit => ". mov %S2, %O(%S1)"
303 # op_flags => [ "constlike", "dump_noblcok", "dump_noinput" ],
304 # reg_req => { out => [ "gp_NOREG:I" ] },