ir_spec.py 9.76 KB
Newer Older
1
nodes = dict(
2
3
4
5
6
7
8

#
# Abstract node types
#
unop = dict(
	abstract = True,
	ins      = [ "op" ]
9
10
),

11
12
13
binop = dict(
	abstract = True,
	ins      = [ "left", "right" ]
14
15
),

16
17
18
19
20
#
# Real node types
#
Abs = dict(
	is_a     = "unop"
21
22
),

23
24
Add = dict(
	is_a     = "binop"
25
26
),

27
28
29
30
Alloc = dict(
	ins   = [ "mem", "size" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
	attrs = [
31
32
33
34
35
36
		dict(
			name = "state",
			type = "op_pin_state",
			initname = ".exc.pin_state",
			init = "op_pin_state_pinned"
		),
37
38
39
40
41
42
43
44
		dict(
			name = "type",
			type = "ir_type*"
		),
		dict(
			name = "where",
			type = "ir_where_alloc"
		)
45
46
47
48
49
50
	],
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
	#endif
	'''
51
52
),

53
54
55
56
57
58
59
60
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
61
62
),

63
64
65
66
67
68
And = dict(
	is_a     = "binop"
),

Bad = dict(
	mode       = "mode_Bad",
69
70
71
72
	knownBlock = True,
),

Block = dict(
73
	mode       = "mode_BB",
74
	knownBlock = True,
75
	block      = "NULL",
76
	noconstr   = True,
Moritz Kroll's avatar
Moritz Kroll committed
77
	optimize   = False,
78
	arity      = "variable",
Moritz Kroll's avatar
Moritz Kroll committed
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

	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);
	''',

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
	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);

Moritz Kroll's avatar
Moritz Kroll committed
120
121
	current_ir_graph->current_block = res;

122
123
124
	IRN_VRFY_IRG(res, current_ir_graph);
	''',

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
	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);
	}''',
),

148
149
Borrow = dict(
	is_a     = "binop"
150
151
),

152
153
Builtin = dict(
	ins      = [ "mem" ],
154
155
156
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
	attrs    = [
157
158
159
160
161
162
		dict(
			name = "state",
			type = "op_pin_state",
			initname = ".exc.pin_state",
			init = "op_pin_state_pinned"
		),
163
164
165
166
		dict(
			type = "ir_builtin_kind",
			name = "kind"
		),
167
		dict(
168
169
170
			type = "ir_type*",
			name = "type"
		)
171
172
173
174
175
176
	],
	init = '''
	assert((get_unknown_type() == type) || is_Method_type(type));
	'''

	# TODO: No firm_alloc_frag_arr??
177
178
),

179
180
Call = dict(
	ins      = [ "mem", "ptr" ],
181
182
183
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
	attrs    = [
184
185
186
187
188
		dict(
			name = "state",
			type = "op_pin_state",
			initname = ".exc.pin_state",
			init = "op_pin_state_pinned"
189
190
191
192
		),
		dict(
			type = "ir_type*",
			name = "type"
193
		)
194
195
196
197
198
199
200
201
202
	],
	init = '''
	assert((get_unknown_type() == type) || is_Method_type(type));
	''',
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
	#endif
	'''
203
204
205
206
207
208
),

Carry = dict(
	is_a     = "binop"
),

209
210
211
212
213
214
215
216
217
218
219
220
Cast = dict(
	ins      = [ "op" ],
	mode     = "get_irn_mode(irn_op)",
	attrs    = [
		dict(
			type = "ir_type*",
			name = "type"
		)
	],
	init     = "assert(is_atomic_type(type));"
),

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

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
Cond = dict(
	ins      = [ "selector" ],
	outs     = [ "false", "true" ],
	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"
		)
	]
246
247
),

248
249
250
251
252
253
254
255
256
Confirm = dict(
	ins      = [ "value", "bound" ],
	mode     = "get_irn_mode(irn_value)",
	attrs    = [
		dict(
			name = "cmp",
			type = "pn_Cmp"
		),
	],
257
258
),

259
260
261
262
263
264
265
266
267
268
Const = dict(
	mode       = "",
	knownBlock = True,
	attrs_name = "con",
	attrs      = [
		dict(
			type = "tarval*",
			name = "tarval",
		)
	],
269
270
),

271
272
273
274
275
276
277
278
279
280
281
282
283
Conv = dict(
	is_a     = "unop",
	attrs = [
		dict(
			name = "strict",
			type = "int",
			init = "0",
			special = dict(
				prefix = "strict",
				init = "1"
			)
		)
	]
284
285
),

286
287
288
CopyB = dict(
	ins   = [ "mem", "dst", "src" ],
	outs  = [ "M", "X_regular", "X_except" ],
289
290
	attrs = [
		dict(
291
292
			name = "type",
			type = "ir_type*"
293
294
295
296
		)
	]
),

297
298
299
Div = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
300
	attrs_name = "divmod",
301
302
303
304
305
306
307
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
		dict(
			name = "state",
308
309
			type = "op_pin_state",
			initname = ".exc.pin_state"
Moritz Kroll's avatar
Moritz Kroll committed
310
311
312
313
314
315
316
317
318
		),
		dict(
			name = "no_remainder",
			type = "int",
			init = "0",
			special = dict(
				suffix = "RL",
				init = "1"
			)
319
		)
320
321
322
323
324
325
	],
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
	#endif
	'''
326
327
328
329
330
),

DivMod = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
331
	attrs_name = "divmod",
332
333
334
335
336
337
338
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
		dict(
			name = "state",
339
340
			type = "op_pin_state",
			initname = ".exc.pin_state"
341
		)
342
343
344
345
346
347
	],
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
	#endif
	'''
348
349
),

350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
End = dict(
	mode       = "mode_X",
	op_flags   = "cfopcode",
	state      = "pinned",
	arity      = "dynamic",
	noconstr   = True,
	optimize   = False
),

Eor = dict(
	is_a     = "binop"
),

Free = dict(
	ins   = [ "mem", "ptr", "size" ],
	mode  = "mode_M",
366
367
	attrs = [
		dict(
368
369
			name = "type",
			type = "ir_type*"
370
371
		),
		dict(
372
373
			name = "where",
			type = "ir_where_alloc"
374
375
376
377
		)
	]
),

378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
Id = dict(
	ins = [ "pred" ]
),

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

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

396
397
398
399
400
401
402
403
404
405
406
407
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
408
			type = "ir_cons_flags",
409
410
411
			name = "flags",
		),
	],
412
413
414
415
416
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
#endif
	'''
417
418
),

419
420
421
422
423
424
425
Minus = dict(
	is_a     = "unop"
),

Mod = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
426
	attrs_name = "divmod",
427
	attrs = [
428
		dict(
429
430
			type = "ir_mode*",
			name = "resmode"
431
		),
432
433
		dict(
			name = "state",
434
435
			type = "op_pin_state",
			initname = ".exc.pin_state"
436
		)
437
438
439
440
441
442
	],
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
	#endif
	'''
443
444
),

445
446
447
448
449
450
451
452
453
454
Mul = dict(
	is_a     = "binop"
),

Mulh = dict(
	is_a     = "binop"
),

Mux = dict(
	ins      = [ "sel", "false", "true" ]
455
456
457
458
459
460
461
),

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

462
463
464
465
466
467
468
469
470
471
472
473
Not = dict(
	is_a     = "unop"
),

Or = dict(
	is_a     = "binop"
),

Phi = dict(
	noconstr = True,
	state    = "pinned",
	arity    = "variable",
474
475
476
477
),

Pin = dict(
	ins      = [ "op" ],
478
	mode     = "get_irn_mode(irn_op)"
479
480
481
482
483
484
485
),

Proj = dict(
	ins      = [ "pred" ],
	attrs    = [
		dict(
			type = "long",
486
487
			name = "proj",
			initname = ""
488
489
490
491
		)
	]
),

492
493
494
Quot = dict(
	ins   = [ "mem", "dividend", "divisor" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
495
	attrs_name = "divmod",
496
	attrs = [
497
		dict(
498
499
500
501
502
			type = "ir_mode*",
			name = "resmode"
		),
		dict(
			name = "state",
503
504
			type = "op_pin_state",
			initname = ".exc.pin_state"
505
		)
506
507
508
509
510
511
	],
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
	#endif
	'''
512
513
),

514
515
Return = dict(
	ins      = [ "mem" ],
516
	arity    = "variable",
517
	mode     = "mode_X"
518
519
),

520
521
Rotl = dict(
	is_a     = "binop"
522
523
),

524
525
526
527
Sel = dict(
	ins    = [ "mem", "ptr" ],
	arity  = "variable",
	mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
528
529
	attrs    = [
		dict(
530
531
532
533
			type = "ir_entity*",
			name = "entity"
		)
	]
534
535
),

536
537
Shl = dict(
	is_a     = "binop"
538
539
),

540
541
Shr = dict(
	is_a     = "binop"
542
543
),

544
545
Shrs = dict(
	is_a     = "binop"
546
547
),

548
549
550
551
552
553
Start = dict(
	mode       = "mode_T",
	op_flags   = "cfopcode",
	state      = "pinned",
	noconstr   = True,
	optimize   = False
554
555
),

556
557
558
559
Store = dict(
	ins      = [ "mem", "ptr", "value" ],
	outs     = [ "M", "X_regular", "X_except" ],
	constructor_args = [
560
		dict(
561
562
			type = "ir_cons_flags",
			name = "flags",
563
		),
564
565
566
567
568
569
	],
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
#endif
	'''
570
571
),

572
573
Sub = dict(
	is_a     = "binop"
574
575
),

576
577
578
579
580
SymConst = dict(
	mode       = "mode_P",
	knownBlock = True,
	noconstr   = True,
	attrs      = [
581
		dict(
582
583
			type = "ir_entity*",
			name = "entity"
584
		)
585
	],
586
587
),

588
589
590
591
Sync = dict(
	mode     = "mode_M",
	optimize = False,
	arity    = "dynamic"
592
593
),

594
595
596
Tuple = dict(
	arity    = "variable",
	mode     = "mode_T",
597
),
Moritz Kroll's avatar
Moritz Kroll committed
598

599
600
601
602
Unknown = dict(
	knownBlock = True,
	block      = "get_irg_start_block(irg)",
	nodbginfo  = True
Moritz Kroll's avatar
Moritz Kroll committed
603
),
604
)