ir_spec.py 10.2 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
31
32
33
34
35
36
37
38
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"
		)
39
	],
40
41
	pinned      = "exception",
	pinned_init = "pinned",
42
43
44
45
46
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
	#endif
	'''
47
48
),

49
50
Anchor = dict(
	mode       = "mode_ANY",
51
	arity      = "variable",
52
53
	knownBlock = True,
	noconstr   = True
54
55
),

56
57
58
59
60
61
And = dict(
	is_a     = "binop"
),

Bad = dict(
	mode       = "mode_Bad",
62
63
64
65
	knownBlock = True,
),

Block = dict(
66
	mode       = "mode_BB",
67
	knownBlock = True,
68
	block      = "NULL",
69
	noconstr   = True,
Moritz Kroll's avatar
Moritz Kroll committed
70
	optimize   = False,
71
	arity      = "variable",
Moritz Kroll's avatar
Moritz Kroll committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

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

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
	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
113
114
	current_ir_graph->current_block = res;

115
116
117
	IRN_VRFY_IRG(res, current_ir_graph);
	''',

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
	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);
138
139
140
141
142
143
	}

	public boolean isBad() {
		return binding.is_Bad(ptr) != 0;
	}
	''',
144
145
),

146
147
Borrow = dict(
	is_a     = "binop"
148
149
),

150
Bound = dict(
151
152
153
154
	ins    = [ "mem", "index", "lower", "upper" ],
 	outs   = [ "M", "X_regular", "X_except", "res" ],
	pinned = "exception",
	pinned_init = "pinned",
155
156
157
158
159
160
161
162
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
	#endif
	'''
),


163
164
165
166
Break = dict(
	mode = "mode_X"
),

167
168
Builtin = dict(
	ins      = [ "mem" ],
169
170
171
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
	attrs    = [
172
173
174
175
		dict(
			type = "ir_builtin_kind",
			name = "kind"
		),
176
		dict(
177
178
179
			type = "ir_type*",
			name = "type"
		)
180
	],
181
182
183
	pinned      = "memory",
	pinned_init = "pinned",
	init   = '''
184
185
186
187
	assert((get_unknown_type() == type) || is_Method_type(type));
	'''

	# TODO: No firm_alloc_frag_arr??
188
189
),

190
191
Call = dict(
	ins      = [ "mem", "ptr" ],
192
193
194
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
	attrs    = [
195
196
197
		dict(
			type = "ir_type*",
			name = "type"
198
		)
199
	],
200
201
	pinned      = "memory",
	pinned_init = "pinned",
202
203
204
205
206
207
208
209
	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
	'''
210
211
212
213
214
215
),

Carry = dict(
	is_a     = "binop"
),

216
217
218
219
220
221
222
223
224
225
226
227
Cast = dict(
	ins      = [ "op" ],
	mode     = "get_irn_mode(irn_op)",
	attrs    = [
		dict(
			type = "ir_type*",
			name = "type"
		)
	],
	init     = "assert(is_atomic_type(type));"
),

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

233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
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"
		)
	]
253
254
),

255
256
257
258
259
260
261
262
263
Confirm = dict(
	ins      = [ "value", "bound" ],
	mode     = "get_irn_mode(irn_value)",
	attrs    = [
		dict(
			name = "cmp",
			type = "pn_Cmp"
		),
	],
264
265
),

266
267
268
269
270
271
272
273
274
275
Const = dict(
	mode       = "",
	knownBlock = True,
	attrs_name = "con",
	attrs      = [
		dict(
			type = "tarval*",
			name = "tarval",
		)
	],
276
277
),

278
279
280
281
282
283
284
285
286
287
288
289
290
Conv = dict(
	is_a     = "unop",
	attrs = [
		dict(
			name = "strict",
			type = "int",
			init = "0",
			special = dict(
				prefix = "strict",
				init = "1"
			)
		)
	]
291
292
),

293
294
295
CopyB = dict(
	ins   = [ "mem", "dst", "src" ],
	outs  = [ "M", "X_regular", "X_except" ],
296
297
	attrs = [
		dict(
298
299
			name = "type",
			type = "ir_type*"
300
		)
301
	],
302
303
	pinned      = "memory",
	pinned_init = "pinned",
304
305
306
307
308
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
	#endif
	'''
309
310
),

311
Div = dict(
312
	ins   = [ "mem", "left", "right" ],
313
	outs  = [ "M", "X_regular", "X_except", "res" ],
314
	attrs_name = "divmod",
315
316
317
318
319
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
Moritz Kroll's avatar
Moritz Kroll committed
320
321
322
323
324
325
326
327
		dict(
			name = "no_remainder",
			type = "int",
			init = "0",
			special = dict(
				suffix = "RL",
				init = "1"
			)
328
		)
329
	],
330
	pinned = "exception",
331
332
333
334
335
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
	#endif
	'''
336
337
338
),

DivMod = dict(
339
	ins   = [ "mem", "left", "right" ],
340
	outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
341
	attrs_name = "divmod",
342
343
344
345
346
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
347
	],
348
	pinned = "exception",
349
350
351
352
353
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
	#endif
	'''
354
355
),

356
357
358
End = dict(
	mode       = "mode_X",
	op_flags   = "cfopcode",
359
	pinned     = "yes",
360
361
362
363
364
365
366
367
368
	arity      = "dynamic",
	noconstr   = True,
	optimize   = False
),

Eor = dict(
	is_a     = "binop"
),

369
370
371
372
373
374
375
376
377
378
379
380
381
382
Filter = dict(
	ins   = [ "pred" ],
	attrs = [
		dict(
			name = "proj",
			type = "long"
		)
	]

	# TODO: Broken asserts in original:
	# assert(get_Proj_pred(res));
	# assert(get_nodes_block(get_Proj_pred(res)));
),

383
384
385
Free = dict(
	ins   = [ "mem", "ptr", "size" ],
	mode  = "mode_M",
386
387
	attrs = [
		dict(
388
389
			name = "type",
			type = "ir_type*"
390
391
		),
		dict(
392
393
			name = "where",
			type = "ir_where_alloc"
394
395
396
397
		)
	]
),

398
399
400
401
402
403
404
Id = dict(
	ins = [ "pred" ]
),

IJmp = dict(
	mode     = "mode_X",
	op_flags = "cfopcode",
405
	pinned   = "yes",
406
407
408
	ins      = [ "target" ],
),

409
InstOf = dict(
410
	ins   = [ "store", "obj" ],
411
412
413
414
415
416
	outs  = [ "M", "X_regular", "X_except", "res", "M_except" ],
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		)
417
418
419
	],
	pinned      = "memory",
	pinned_init = "floats",
420
421
),

422
423
424
Jmp = dict(
	mode     = "mode_X",
	op_flags = "cfopcode",
425
	pinned   = "yes",
426
427
428
	ins      = [],
),

429
430
431
432
433
434
435
436
437
438
439
440
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
441
			type = "ir_cons_flags",
442
443
444
			name = "flags",
		),
	],
445
446
447
448
449
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
#endif
	'''
450
451
),

452
453
454
455
456
Minus = dict(
	is_a     = "unop"
),

Mod = dict(
457
	ins   = [ "mem", "left", "right" ],
458
	outs  = [ "M", "X_regular", "X_except", "res" ],
459
	attrs_name = "divmod",
460
	attrs = [
461
		dict(
462
463
			type = "ir_mode*",
			name = "resmode"
464
		),
465
	],
466
	pinned = "exception",
467
468
469
470
471
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
	#endif
	'''
472
473
),

474
475
476
477
478
479
480
481
482
483
Mul = dict(
	is_a     = "binop"
),

Mulh = dict(
	is_a     = "binop"
),

Mux = dict(
	ins      = [ "sel", "false", "true" ]
484
485
486
487
488
489
490
),

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

491
492
493
494
495
496
497
498
499
500
Not = dict(
	is_a     = "unop"
),

Or = dict(
	is_a     = "binop"
),

Phi = dict(
	noconstr = True,
501
	pinned   = "yes",
502
	arity    = "variable",
503
504
505
506
),

Pin = dict(
	ins      = [ "op" ],
507
	mode     = "get_irn_mode(irn_op)"
508
509
510
511
512
513
514
),

Proj = dict(
	ins      = [ "pred" ],
	attrs    = [
		dict(
			type = "long",
515
516
			name = "proj",
			initname = ""
517
518
519
520
		)
	]
),

521
Quot = dict(
522
	ins   = [ "mem", "left", "right" ],
523
	outs  = [ "M", "X_regular", "X_except", "res" ],
524
	attrs_name = "divmod",
525
	attrs = [
526
		dict(
527
528
529
			type = "ir_mode*",
			name = "resmode"
		),
530
	],
531
	pinned = "exception",
532
533
534
535
536
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
	#endif
	'''
537
538
),

539
540
541
542
543
Raise = dict(
	ins   = [ "mem", "exo_ptr" ],
	outs  = [ "M", "X" ]
),

544
545
Return = dict(
	ins      = [ "mem" ],
546
	arity    = "variable",
547
	mode     = "mode_X"
548
549
),

550
551
Rotl = dict(
	is_a     = "binop"
552
553
),

554
555
556
557
Sel = dict(
	ins    = [ "mem", "ptr" ],
	arity  = "variable",
	mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
558
559
	attrs    = [
		dict(
560
561
562
563
			type = "ir_entity*",
			name = "entity"
		)
	]
564
565
),

566
567
Shl = dict(
	is_a     = "binop"
568
569
),

570
571
Shr = dict(
	is_a     = "binop"
572
573
),

574
575
Shrs = dict(
	is_a     = "binop"
576
577
),

578
579
580
Start = dict(
	mode       = "mode_T",
	op_flags   = "cfopcode",
581
	pinned     = "yes",
582
583
	noconstr   = True,
	optimize   = False
584
585
),

586
587
588
589
Store = dict(
	ins      = [ "mem", "ptr", "value" ],
	outs     = [ "M", "X_regular", "X_except" ],
	constructor_args = [
590
		dict(
591
592
			type = "ir_cons_flags",
			name = "flags",
593
		),
594
595
596
597
598
599
	],
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
#endif
	'''
600
601
),

602
603
Sub = dict(
	is_a     = "binop"
604
605
),

606
607
608
609
610
SymConst = dict(
	mode       = "mode_P",
	knownBlock = True,
	noconstr   = True,
	attrs      = [
611
		dict(
612
613
			type = "ir_entity*",
			name = "entity"
614
		)
615
	],
616
617
),

618
619
620
621
Sync = dict(
	mode     = "mode_M",
	optimize = False,
	arity    = "dynamic"
622
623
),

624
625
626
Tuple = dict(
	arity    = "variable",
	mode     = "mode_T",
627
),
Moritz Kroll's avatar
Moritz Kroll committed
628

629
630
631
632
Unknown = dict(
	knownBlock = True,
	block      = "get_irg_start_block(irg)",
	nodbginfo  = True
Moritz Kroll's avatar
Moritz Kroll committed
633
),
634
)