TEMPLATE_spec.pl 6.22 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
#   state     => "floats|pinned|mem_pinned|exc_pinned", # optional
#   comment   => "any comment for constructor",  # optional
18
#   in_reqs   => [ "reg_class|register" ] | "...",
19
#   out_reqs  => [ "reg_class|register|in_rX" ] | "...",
20
21
22
#   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
23
#   emit      => "emit code with templates",   # optional for virtual nodes
24
#   attr      => "additional attribute arguments for constructor", # optional
25
26
27
#   init_attr => "emit attribute initialization template",         # optional
#   hash_func => "name of the hash function for this operation",   # optional, get the default hash function else
#   attr_type => "name of the attribute struct",                   # optional
28
29
30
31
32
33
# },
#
# ... # (all nodes you need to describe)
#
# ); # close the %nodes initializer

Christian Würdig's avatar
Christian Würdig committed
34
# state: state of the operation, OPTIONAL (default is "floats")
35
36
37
#
# arity: arity of the operation, MUST NOT BE OMITTED
#
38
39
40
# outs:  if a node defines more than one output, the names of the projections
#        nodes having outs having automatically the mode mode_T
#
41
42
# comment: OPTIONAL comment for the node constructor
%reg_classes = (
43
	gp => [
44
45
46
47
48
49
50
51
52
53
54
55
56
57
		{ 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" },
58
59
		{ name => "sp"  }, # stackpointer
		{ name => "bp"  }, # basepointer
60
		{ mode => $mode_gp }
Matthias Braun's avatar
Matthias Braun committed
61
	],
62
	fp => [
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
		{ 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" },
79
		{ mode => $mode_fp }
Matthias Braun's avatar
Matthias Braun committed
80
	]
81
);
82

83
84
85
$default_attr_type = "TEMPLATE_attr_t";
$default_copy_attr = "TEMPLATE_copy_attr";

86
87
my $binop = {
	irn_flags => [ "rematerializable" ],
88
89
	in_reqs   => [ "gp", "gp" ],
	out_reqs  => [ "gp" ],
90
91
92
93
94
95
	mode      => $mode_gp,
};

my $constop = {
	op_flags   => [ "constlike" ],
	irn_flags  => [ "rematerializable" ],
96
	out_reqs   => [ "gp" ],
97
98
99
100
	mode       => $mode_gp,
};

my $fbinop = {
101
102
	in_reqs   => [ "fp", "fp" ],
	out_reqs  => [ "fp" ],
103
104
105
106
107
	mode      => $mode_fp,
};

my $unop = {
	irn_flags => [ "rematerializable" ],
108
109
	in_reqs   => [ "gp" ],
	out_reqs  => [ "gp" ],
110
111
112
	mode      => $mode_gp,
};

113
114
%nodes = (

115
# Integer nodes
116

Matthias Braun's avatar
Matthias Braun committed
117
Add => {
118
119
	template => $binop,
	emit     => '%D0 = add %S0, %S1',
120
121
},

Matthias Braun's avatar
Matthias Braun committed
122
Mul => {
123
124
	template => $binop,
	emit     => '%D0 = mul %S0, %S1',
125
126
},

Matthias Braun's avatar
Matthias Braun committed
127
And => {
128
129
	template => $binop,
	emit     => '%D0 = and %S0, %S1',
130
131
},

Matthias Braun's avatar
Matthias Braun committed
132
Or => {
133
134
	template => $binop,
	emit     => '%D0 = or %S0, %S1',
135
136
},

137
Xor => {
138
139
	template => $binop,
	emit     => '%D0 = xor %S0, %S1',
140
141
},

Matthias Braun's avatar
Matthias Braun committed
142
Sub => {
143
144
	template => $binop,
	emit     => '%D0 = sub %S0, %S1',
145
146
},

Matthias Braun's avatar
Matthias Braun committed
147
Shl => {
148
149
	template => $binop,
	emit     => '%D0 = shl %S0, %S1',
150
151
},

Matthias Braun's avatar
Matthias Braun committed
152
Shr => {
153
154
	template => $binop,
	emit     => '%D0 = shr %S0, %S1',
155
156
},

Matthias Braun's avatar
Matthias Braun committed
157
Minus => {
158
159
	template => $unop,
	emit     => '%D0 = neg %S0',
160
161
},

Matthias Braun's avatar
Matthias Braun committed
162
Not => {
163
164
	template => $unop,
	emit     => '%D0 = not %S0',
165
166
},

Matthias Braun's avatar
Matthias Braun committed
167
Const => {
168
	template   => $constop,
169
170
	attr       => "ir_entity *entity, ir_tarval *value",
	custominit => "set_TEMPLATE_value(res, entity, value);",
171
	emit       => '%D0 = const %I',
172
173
},

174
175
# Control Flow

176
Jmp => {
177
	state     => "pinned",
178
179
	op_flags  => [ "cfopcode" ],
	irn_flags => [ "simple_jump" ],
180
	out_reqs  => [ "none" ],
181
	mode      => "mode_X",
182
183
},

Matthias Braun's avatar
Matthias Braun committed
184
Start => {
185
	irn_flags => [ "schedule_first" ],
Matthias Braun's avatar
Matthias Braun committed
186
	state     => "pinned",
187
	out_reqs  => [ "sp:I", "r0", "r1", "r2", "r3", "none" ],
188
	outs      => [ "stack", "arg0", "arg1", "arg2", "arg3", "M" ],
Matthias Braun's avatar
Matthias Braun committed
189
190
191
192
193
194
	ins       => [],
},

Return => {
	state    => "pinned",
	op_flags => [ "cfopcode" ],
195
	in_reqs  => "...",
196
	out_reqs => [ "none" ],
197
	ins      => [ "mem", "stack", "first_result" ],
198
	outs     => [ "X" ],
Matthias Braun's avatar
Matthias Braun committed
199
200
201
	mode     => "mode_X",
},

202
203
# Load / Store

Matthias Braun's avatar
Matthias Braun committed
204
Load => {
205
	op_flags  => [ "uses_memory" ],
206
	irn_flags => [ "rematerializable" ],
207
	state     => "exc_pinned",
208
209
	in_reqs   => [ "none", "gp" ],
	out_reqs  => [ "gp", "none" ],
210
	ins       => [ "mem", "ptr" ],
Matthias Braun's avatar
Matthias Braun committed
211
	outs      => [ "res", "M" ],
212
	emit      => '%D0 = load (%S1)',
213
214
},

Matthias Braun's avatar
Matthias Braun committed
215
Store => {
216
	op_flags  => [ "uses_memory" ],
217
	irn_flags => [ "rematerializable" ],
218
	state     => "exc_pinned",
219
220
	in_reqs   => [ "none", "gp", "gp" ],
	out_reqs  => [ "none" ],
221
	ins       => [ "mem", "ptr", "val" ],
Matthias Braun's avatar
Matthias Braun committed
222
223
	outs      => [ "M" ],
	mode      => "mode_M",
224
	emit      => '(%S1) = store %S2',
225
226
},

227
# Floating Point operations
228

Matthias Braun's avatar
Matthias Braun committed
229
fAdd => {
230
	template  => $fbinop,
231
	irn_flags => [ "rematerializable" ],
232
	emit      => '%D0 = fadd %S0, %S1',
233
234
},

Matthias Braun's avatar
Matthias Braun committed
235
fMul => {
236
237
	template => $fbinop,
	emit     => '%D0 = fmul %S0, %S1',
238
239
},

Matthias Braun's avatar
Matthias Braun committed
240
fSub => {
241
	template  => $fbinop,
242
	irn_flags => [ "rematerializable" ],
243
	emit      => '%D0 = fsub %S0, %S1',
244
245
},

Matthias Braun's avatar
Matthias Braun committed
246
fDiv => {
247
248
	template => $fbinop,
	emit     => '%D0 = fdiv %S0, %S1',
249
250
},

Matthias Braun's avatar
Matthias Braun committed
251
fMinus => {
252
	irn_flags => [ "rematerializable" ],
253
254
	in_reqs   => [ "fp" ],
	out_reqs  => [ "fp" ],
255
	emit      => '%D0 = fneg %S0',
256
	mode      => $mode_fp,
257
258
},

Matthias Braun's avatar
Matthias Braun committed
259
fConst => {
260
261
	op_flags  => [ "constlike" ],
	irn_flags => [ "rematerializable" ],
262
	out_reqs  => [ "fp" ],
263
	emit      => '%D0 = fconst %I',
264
	mode      => $mode_fp,
265
266
267
268
},

# Load / Store

Matthias Braun's avatar
Matthias Braun committed
269
fLoad => {
270
	op_flags  => [ "uses_memory" ],
271
	irn_flags => [ "rematerializable" ],
272
	state     => "exc_pinned",
273
274
	in_reqs   => [ "none", "gp" ],
	out_reqs  => [ "fp", "none" ],
275
	ins       => [ "mem", "ptr" ],
Matthias Braun's avatar
Matthias Braun committed
276
	outs      => [ "res", "M" ],
277
	emit      => '%D0 = fload (%S1)',
Matthias Braun's avatar
Matthias Braun committed
278
279
280
},

fStore => {
281
	op_flags  => [ "uses_memory" ],
282
	irn_flags => [ "rematerializable" ],
283
	state     => "exc_pinned",
284
285
	in_reqs   => [ "none", "gp", "fp" ],
	out_reqs  => [ "none" ],
286
	ins       => [ "mem", "ptr", "val" ],
Matthias Braun's avatar
Matthias Braun committed
287
288
	outs      => [ "M" ],
	mode      => "mode_M",
289
	emit      => '(%S1) = fstore %S2',
Christian Würdig's avatar
Christian Würdig committed
290
},
291

292
);