ir_spec.py 8.04 KB
Newer Older
1
2
3
4
5
6
nodes = dict(
Start = dict(
	mode       = "mode_T",
	op_flags   = "cfopcode",
	state      = "pinned",
	noconstr   = True,
Moritz Kroll's avatar
Moritz Kroll committed
7
	optimize   = False
8
9
10
11
12
13
14
15
),

End = dict(
	mode       = "mode_X",
	op_flags   = "cfopcode",
	state      = "pinned",
	arity      = "dynamic",
	noconstr   = True,
Moritz Kroll's avatar
Moritz Kroll committed
16
	optimize   = False
17
18
),

19
20
21
22
Id = dict(
	ins = [ "pred" ]
),

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Phi = dict(
	noconstr = True,
	state    = "pinned",
	arity    = "variable",
),

Jmp = dict(
	mode     = "mode_X",
	op_flags = "cfopcode",
	state    = "pinned",
	ins      = [],
),

IJmp = dict(
	mode     = "mode_X",
	op_flags = "cfopcode",
	state    = "pinned",
	ins      = [ "target" ],
),

Const = dict(
	mode       = "",
	knownBlock = True,
Moritz Kroll's avatar
Moritz Kroll committed
46
	attrs_name = "con",
47
48
49
50
51
52
53
54
55
	attrs      = [
		dict(
			type = "tarval*",
			name = "tarval",
		)
	],
),

Block = dict(
56
	mode       = "mode_BB",
57
	knownBlock = True,
58
	block      = "NULL",
59
	noconstr   = True,
Moritz Kroll's avatar
Moritz Kroll committed
60
	optimize   = False,
61
	arity      = "variable",
Moritz Kroll's avatar
Moritz Kroll committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

	init = '''
	/* macroblock header */
	res->in[0] = res;

	res->attr.block.is_dead     = 0;
	res->attr.block.is_mb_head  = 1;
	res->attr.block.has_label   = 0;
	res->attr.block.irg         = irg;
	res->attr.block.backedge    = new_backedge_arr(irg->obst, arity);
	res->attr.block.in_cg       = NULL;
	res->attr.block.cg_backedge = NULL;
	res->attr.block.extblk      = NULL;
	res->attr.block.mb_depth    = 0;
	res->attr.block.label       = 0;

	set_Block_matured(res, 1);
	set_Block_block_visited(res, 0);
	''',

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
	d_pre = '''
	int i;
	int has_unknown = 0;
	''',

	d_post = '''
	/* Create and initialize array for Phi-node construction. */
	if (get_irg_phase_state(current_ir_graph) == phase_building) {
		res->attr.block.graph_arr = NEW_ARR_D(ir_node *, current_ir_graph->obst,
		                                      current_ir_graph->n_loc);
		memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
	}

	for (i = arity - 1; i >= 0; i--)
		if (is_Unknown(in[i])) {
			has_unknown = 1;
			break;
		}

	if (!has_unknown) res = optimize_node(res);

	IRN_VRFY_IRG(res, current_ir_graph);
	''',

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
	java_add   = '''
	public void addPred(Node node) {
		binding_cons.add_immBlock_pred(ptr, node.ptr);
	}

	public void mature() {
		binding_cons.mature_immBlock(ptr);
	}

	@Override
	public Block getBlock() {
		return null;
	}

	public boolean blockVisited() {
		return 0 != binding.Block_block_visited(ptr);
	}

	public void markBlockVisited() {
		binding.mark_Block_block_visited(ptr);
	}''',
),

SymConst = dict(
	mode       = "mode_P",
	knownBlock = True,
	noconstr   = True,
	attrs      = [
		dict(
			type = "ir_entity*",
			name = "entity"
		)
	],
),

# SymConst

Call = dict(
	ins      = [ "mem", "ptr" ],
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
	attrs    = [
		dict(
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
			type = "ir_type*",
			name = "type"
		)
	]
),

Builtin = dict(
	ins      = [ "mem" ],
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
	attrs    = [
		dict(
			type = "ir_builtin_kind",
			name = "kind"
		),
		dict(
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
			type = "ir_type*",
			name = "type"
		)
	]
),

binop = dict(
	abstract = True,
	ins      = [ "left", "right" ]
),

Add = dict(
	is_a     = "binop"
),

Carry = dict(
	is_a     = "binop"
),

Sub = dict(
	is_a     = "binop"
),

Borrow = dict(
	is_a     = "binop"
),

Mul = dict(
	is_a     = "binop"
),

Mulh = dict(
	is_a     = "binop"
),

Abs = dict(
	is_a     = "unop"
),

And = dict(
	is_a     = "binop"
),

Or = dict(
	is_a     = "binop"
),

Eor = dict(
	is_a     = "binop"
),

Not = dict(
	is_a     = "unop"
),

Shl = dict(
	is_a     = "binop"
),

Shr = dict(
	is_a     = "binop"
),

Shrs = dict(
	is_a     = "binop"
),

Rotl = dict(
	is_a     = "binop"
),

236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
Quot = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
		dict(
			name = "state",
			type = "op_pin_state"
		)
	]
),

251
252
253
254
255
256
257
258
259
260
261
Div = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
		dict(
			name = "state",
			type = "op_pin_state"
Moritz Kroll's avatar
Moritz Kroll committed
262
263
264
265
266
267
268
269
270
		),
		dict(
			name = "no_remainder",
			type = "int",
			init = "0",
			special = dict(
				suffix = "RL",
				init = "1"
			)
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
		)
	]
),

DivMod = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
		dict(
			name = "state",
			type = "op_pin_state"
		)
	]
),

290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
Mod = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
		dict(
			name = "state",
			type = "op_pin_state"
		)
	]
),

305
306
307
308
309
310
311
312
313
314
315
316
Load = dict(
	ins      = [ "mem", "ptr" ],
	outs     = [ "M", "X_regular", "X_except", "res" ],
	attrs    = [
		dict(
			type = "ir_mode*",
			name = "mode",
			java_name = "load_mode"
		),
	],
	constructor_args = [
		dict(
Moritz Kroll's avatar
Moritz Kroll committed
317
			type = "ir_cons_flags",
318
319
320
			name = "flags",
		),
	],
321
322
323
324
325
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
#endif
	'''
326
327
328
329
330
331
332
),

Store = dict(
	ins      = [ "mem", "ptr", "value" ],
	outs     = [ "M", "X_regular", "X_except" ],
	constructor_args = [
		dict(
Moritz Kroll's avatar
Moritz Kroll committed
333
			type = "ir_cons_flags",
334
335
336
			name = "flags",
		),
	],
337
338
339
340
341
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
#endif
	'''
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
),

Anchor = dict(
	mode       = "mode_ANY",
	ins        = [ "end_block", "start_block", "end", "start",
	               "end_reg", "end_except", "initial_exec",
				   "frame", "tls", "initial_mem", "args",
				   "bad", "no_mem" ],
	knownBlock = True,
	noconstr   = True
),

NoMem = dict(
	mode       = "mode_M",
	knownBlock = True,
),

Bad = dict(
	mode       = "mode_Bad",
	knownBlock = True,
),

Pin = dict(
	ins      = [ "op" ],
366
	mode     = "get_irn_mode(irn_op)"
367
368
369
370
371
372
373
),

Proj = dict(
	ins      = [ "pred" ],
	attrs    = [
		dict(
			type = "long",
374
375
			name = "proj",
			initname = ""
376
377
378
379
380
381
382
		)
	]
),

Sel = dict(
	ins    = [ "mem", "ptr" ],
	arity  = "variable",
383
	mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
384
385
386
387
388
389
390
391
392
393
	attrs    = [
		dict(
			type = "ir_entity*",
			name = "entity"
		)
	]
),

Sync = dict(
	mode     = "mode_M",
Moritz Kroll's avatar
Moritz Kroll committed
394
	optimize = False,
395
396
397
398
399
400
401
402
403
	arity    = "dynamic"
),

Tuple = dict(
	arity    = "variable",
	mode     = "mode_T",
),

Unknown = dict(
404
405
406
	knownBlock = True,
	block      = "get_irg_start_block(irg)",
	nodbginfo  = True
407
408
409
410
),

Confirm = dict(
	ins      = [ "value", "bound" ],
411
	mode     = "get_irn_mode(irn_value)",
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
	attrs    = [
		dict(
			name = "cmp",
			type = "pn_Cmp"
		),
	],
),

Return = dict(
	ins      = [ "mem" ],
	arity    = "variable",
	mode     = "mode_X"
),

unop = dict(
	abstract = True,
	ins      = [ "op" ]
),

Minus = dict(
	is_a     = "unop"
),

Mux = dict(
	ins      = [ "sel", "false", "true" ]
),

Cond = dict(
	ins      = [ "selector" ],
	outs     = [ "false", "true" ],
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
	attrs    = [
		dict(
			name = "kind",
			type = "cond_kind",
			init = "dense"
		),
		dict(
			name = "default_proj",
			type = "long",
			init = "0"
		),
		dict(
			name = "jmp_pred",
			type = "cond_jmp_predicate",
			init = "COND_JMP_PRED_NONE"
		)
	]
459
460
461
462
463
464
465
466
),

Cmp = dict(
	is_a     = "binop",
	outs     = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ],
),

Conv = dict(
467
468
469
470
471
472
473
474
475
476
477
478
	is_a     = "unop",
	attrs = [
		dict(
			name = "strict",
			type = "int",
			init = "0",
			special = dict(
				prefix = "strict",
				init = "1"
			)
		)
	]
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
),

Alloc = dict(
	ins   = [ "mem", "size" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		),
		dict(
			name = "where",
			type = "ir_where_alloc"
		)
	]
),

Free = dict(
	ins   = [ "mem", "ptr", "size" ],
	mode  = "mode_M",
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		),
		dict(
			name = "where",
			type = "ir_where_alloc"
		)
	]
),
Moritz Kroll's avatar
Moritz Kroll committed
510
511
512
513
514
515
516
517
518
519
520

CopyB = dict(
	ins   = [ "mem", "dst", "src" ],
	outs  = [ "M", "X_regular", "X_except" ],
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		)
	]
),
521
)