TEMPLATE_spec.pl 7.36 KB
Newer Older
1
2
3
# the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
$arch = "TEMPLATE";

4
5
6
7
#
# Modes
#
$mode_gp  = "mode_Iu"; # mode used by general purpose registers
8
$mode_fp  = "mode_F";  # mode used by floatingpoint registers
9

10
11
12
13
14
15
# The node description is done as a perl hash initializer with the
# following structure:
#
# %nodes = (
#
# <op-name> => {
Matthias Braun's avatar
Matthias Braun committed
16
17
#   arity     => "0|1|2|3 ... |variable|dynamic|any",   # optional
#   state     => "floats|pinned|mem_pinned|exc_pinned", # optional
Matthias Braun's avatar
Matthias Braun committed
18
19
20
#   args      => [
#                    { type => "type 1", name => "name 1" },
#                    { type => "type 2", name => "name 2" },
Christian Würdig's avatar
Christian Würdig committed
21
22
#                    ...
#                  ],
Matthias Braun's avatar
Matthias Braun committed
23
#   comment   => "any comment for constructor",  # optional
Matthias Braun's avatar
Matthias Braun committed
24
#   reg_req   => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
25
26
27
#   outs      => { "out1", "out2" },# optional, creates pn_op_out1, ... consts
#   ins       => { "in1", "in2" },  # optional, creates n_op_in1, ... consts
#   mode      => "mode_Iu",         # optional, predefines the mode
Matthias Braun's avatar
Matthias Braun committed
28
#   emit      => "emit code with templates",   # optional for virtual nodes
29
#   attr      => "additional attribute arguments for constructor", # optional
30
31
32
33
34
#   init_attr => "emit attribute initialization template",         # optional
#   rd_constructor => "c source code which constructs an ir_node", # optional
#   hash_func => "name of the hash function for this operation",   # optional, get the default hash function else
#   latency   => "latency of this operation (can be float)"        # optional
#   attr_type => "name of the attribute struct",                   # optional
35
36
37
38
39
40
# },
#
# ... # (all nodes you need to describe)
#
# ); # close the %nodes initializer

Christian Würdig's avatar
Christian Würdig committed
41
# state: state of the operation, OPTIONAL (default is "floats")
42
43
44
45
46
47
48
49
50
51
#
# arity: arity of the operation, MUST NOT BE OMITTED
#
# args:  the OPTIONAL arguments of the node constructor (debug, irg and block
#        are always the first 3 arguments and are always autmatically
#        created)
#        If this key is missing the following arguments will be created:
#        for i = 1 .. arity: ir_node *op_i
#        ir_mode *mode
#
52
53
54
# outs:  if a node defines more than one output, the names of the projections
#        nodes having outs having automatically the mode mode_T
#
55
56
# comment: OPTIONAL comment for the node constructor
%reg_classes = (
57
	gp => [
58
59
60
61
62
63
64
65
66
67
68
69
70
71
		{ name => "r0" },
		{ name => "r1" },
		{ name => "r2" },
		{ name => "r3" },
		{ name => "r4" },
		{ name => "r5" },
		{ name => "r6" },
		{ name => "r7" },
		{ name => "r8" },
		{ name => "r9" },
		{ name => "r10" },
		{ name => "r11" },
		{ name => "r12" },
		{ name => "r13" },
72
73
		{ name => "sp"  }, # stackpointer
		{ name => "bp"  }, # basepointer
74
		{ mode => $mode_gp }
Matthias Braun's avatar
Matthias Braun committed
75
	],
76
	fp => [
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
		{ name => "f0" },
		{ name => "f1" },
		{ name => "f2" },
		{ name => "f3" },
		{ name => "f4" },
		{ name => "f5" },
		{ name => "f6" },
		{ name => "f7" },
		{ name => "f8" },
		{ name => "f9" },
		{ name => "f10" },
		{ name => "f11" },
		{ name => "f12" },
		{ name => "f13" },
		{ name => "f14" },
		{ name => "f15" },
93
		{ mode => $mode_fp }
Matthias Braun's avatar
Matthias Braun committed
94
	]
95
);
96

97
98
99
$default_attr_type = "TEMPLATE_attr_t";
$default_copy_attr = "TEMPLATE_copy_attr";

100
101
%nodes = (

102
# Integer nodes
103

Matthias Braun's avatar
Matthias Braun committed
104
Add => {
105
	irn_flags => [ "rematerializable" ],
106
	reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
107
	emit      => 'add %S1, %S2, %D1',
108
	mode      => $mode_gp,
109
110
},

Matthias Braun's avatar
Matthias Braun committed
111
Mul => {
112
	irn_flags => [ "rematerializable" ],
113
	reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
114
	emit      =>'mul %S1, %S2, %D1',
115
	mode      => $mode_gp,
116
117
},

Matthias Braun's avatar
Matthias Braun committed
118
And => {
119
	irn_flags => [ "rematerializable" ],
120
	reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
121
	emit      => 'and %S1, %S2, %D1',
122
	mode      => $mode_gp,
123
124
},

Matthias Braun's avatar
Matthias Braun committed
125
Or => {
126
	irn_flags => [ "rematerializable" ],
127
	reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
128
	emit      => 'or %S1, %S2, %D1',
129
	mode      => $mode_gp,
130
131
},

132
Xor => {
133
	irn_flags => [ "rematerializable" ],
134
	reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
135
	emit      => 'xor %S1, %S2, %D1',
136
	mode      => $mode_gp,
137
138
},

Matthias Braun's avatar
Matthias Braun committed
139
Sub => {
140
	irn_flags => [ "rematerializable" ],
141
	reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
142
	emit      => 'sub %S1, %S2, %D1',
143
	mode      => $mode_gp,
144
145
},

Matthias Braun's avatar
Matthias Braun committed
146
Shl => {
147
	irn_flags => [ "rematerializable" ],
148
	reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
149
	emit      => 'shl %S1, %S2, %D1',
150
	mode      => $mode_gp,
151
152
},

Matthias Braun's avatar
Matthias Braun committed
153
Shr => {
154
	irn_flags => [ "rematerializable" ],
155
	reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
Matthias Braun's avatar
Matthias Braun committed
156
	emit      => 'shr %S2, %D1',
157
	mode      => $mode_gp,
158
159
},

Matthias Braun's avatar
Matthias Braun committed
160
Minus => {
161
	irn_flags => [ "rematerializable" ],
162
	reg_req   => { in => [ "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
163
	emit      => 'neg %S1, %D1',
164
	mode      => $mode_gp,
165
166
},

Matthias Braun's avatar
Matthias Braun committed
167
Not => {
168
169
170
	arity   => 1,
	remat   => 1,
	reg_req => { in => [ "gp" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
171
	emit    => 'not %S1, %D1',
172
	mode    => $mode_gp,
173
174
},

Matthias Braun's avatar
Matthias Braun committed
175
Const => {
176
177
	op_flags   => [ "constlike" ],
	irn_flags  => [ "rematerializable" ],
Matthias Braun's avatar
Matthias Braun committed
178
	attr       => "ir_tarval *value",
179
180
	custominit => "set_TEMPLATE_value(res, value);",
	reg_req    => { out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
181
	emit       => 'mov %I, %D1',
182
	mode       => $mode_gp,
183
184
},

185
186
# Control Flow

187
Jmp => {
188
	state     => "pinned",
189
190
	op_flags  => [ "cfopcode" ],
	irn_flags => [ "simple_jump" ],
191
192
	reg_req   => { out => [ "none" ] },
	mode      => "mode_X",
193
194
},

Matthias Braun's avatar
Matthias Braun committed
195
Start => {
196
	irn_flags => [ "schedule_first" ],
Matthias Braun's avatar
Matthias Braun committed
197
198
199
200
201
202
203
204
205
	state     => "pinned",
	reg_req   => { in => [], out => [ "sp:I|S", "none" ] },
	outs      => [ "stack", "M" ],
	ins       => [],
},

Return => {
	state    => "pinned",
	op_flags => [ "cfopcode" ],
206
207
	# This is fixed to 1 result in a gp register
	ins      => [ "result", "stack", "mem" ],
208
	outs     => [ "X" ],
209
	reg_req  => { in => [ "gp", "sp", "none", ], out => [ "none" ] },
Matthias Braun's avatar
Matthias Braun committed
210
211
212
	mode     => "mode_X",
},

213
214
# Load / Store

Matthias Braun's avatar
Matthias Braun committed
215
Load => {
216
	op_flags  => [ "uses_memory" ],
217
	irn_flags => [ "rematerializable" ],
218
	state     => "exc_pinned",
219
	reg_req   => { in => [ "gp", "none" ], out => [ "gp" ] },
Matthias Braun's avatar
Matthias Braun committed
220
	emit      => 'mov (%S1), %D1',
221
222
},

Matthias Braun's avatar
Matthias Braun committed
223
Store => {
224
	op_flags  => [ "uses_memory" ],
225
	irn_flags => [ "rematerializable" ],
226
	state     => "exc_pinned",
227
	reg_req   => { in => [ "gp", "gp", "none" ] },
Matthias Braun's avatar
Matthias Braun committed
228
	emit      => 'movl %S2, (%S1)',
229
230
},

231
# Floating Point operations
232

Matthias Braun's avatar
Matthias Braun committed
233
fAdd => {
234
	irn_flags => [ "rematerializable" ],
235
	reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
Matthias Braun's avatar
Matthias Braun committed
236
	emit      => 'fadd %S1, %S2, %D1',
237
	mode    => $mode_fp,
238
239
},

Matthias Braun's avatar
Matthias Braun committed
240
fMul => {
241
	reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
Matthias Braun's avatar
Matthias Braun committed
242
	emit      =>'fmul %S1, %S2, %D1',
243
	mode      => $mode_fp,
244
245
},

Matthias Braun's avatar
Matthias Braun committed
246
fSub => {
247
	irn_flags => [ "rematerializable" ],
248
	reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
Matthias Braun's avatar
Matthias Braun committed
249
	emit      => 'fsub %S1, %S2, %D1',
250
	mode      => $mode_fp,
251
252
},

Matthias Braun's avatar
Matthias Braun committed
253
fDiv => {
254
	reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
Matthias Braun's avatar
Matthias Braun committed
255
	emit      => 'fdiv %S1, %S2, %D1',
256
	mode      => $mode_fp,
257
258
},

Matthias Braun's avatar
Matthias Braun committed
259
fMinus => {
260
	irn_flags => [ "rematerializable" ],
261
	reg_req   => { in => [ "fp" ], out => [ "fp" ] },
Matthias Braun's avatar
Matthias Braun committed
262
	emit      => 'fneg %S1, %D1',
263
	mode      => $mode_fp,
264
265
},

Matthias Braun's avatar
Matthias Braun committed
266
fConst => {
267
268
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
269
	reg_req   => { out => [ "fp" ] },
Matthias Braun's avatar
Matthias Braun committed
270
	emit      => 'fmov %I, %D1',
271
	mode      => $mode_fp,
272
273
274
275
},

# Load / Store

Matthias Braun's avatar
Matthias Braun committed
276
fLoad => {
277
	op_flags  => [ "uses_memory" ],
278
	irn_flags => [ "rematerializable" ],
279
	state     => "exc_pinned",
280
	reg_req   => { in => [ "gp", "none" ], out => [ "fp" ] },
Matthias Braun's avatar
Matthias Braun committed
281
	emit      => 'fmov (%S1), %D1',
Matthias Braun's avatar
Matthias Braun committed
282
283
284
},

fStore => {
285
	op_flags  => [ "uses_memory" ],
286
	irn_flags => [ "rematerializable" ],
287
	state     => "exc_pinned",
288
	reg_req   => { in => [ "gp", "fp", "none" ] },
Matthias Braun's avatar
Matthias Braun committed
289
	emit      => 'fmov %S2, (%S1)',
Christian Würdig's avatar
Christian Würdig committed
290
},
291

292
);