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

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

12
13
binop = dict(
	abstract = True,
14
15
	ins      = [ "left", "right" ],
	op_index = 0,
16
17
),

18
19
20
21
#
# Real node types
#
Abs = dict(
22
23
	is_a     = "unop",
	flags    = "none",
24
25
),

26
Add = dict(
27
28
	is_a     = "binop",
	flags    = "commutative",
29
30
),

31
32
33
Alloc = dict(
	ins   = [ "mem", "size" ],
	outs  = [ "M", "X_regular", "X_except", "res" ],
34
	flags = "fragile, uses_memory",
35
36
37
38
39
40
41
42
43
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		),
		dict(
			name = "where",
			type = "ir_where_alloc"
		)
44
	],
45
	pinned      = "yes",
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
Anchor = dict(
54
55
56
57
58
	mode        = "mode_ANY",
	arity       = "variable",
	flags       = "dump_noblock",
	knownBlock  = True,
	singleton   = True,
59
60
),

61
And = dict(
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	is_a     = "binop",
	flags    = "commutative",
),

ASM = dict(
	mode          = "mode_T",
	arity         = "variable",
	flags         = "keep, uses_memory",
	attr_struct   = "asm_attr",
	pinned        = "memory",
	pinned_init   = "pinned",
	attrs = [
		dict(
			name = "input_constraints",
			type = "ir_asm_constraint*",
		),
		dict(
			name = "n_output_constraints",
			type = "int",
		),
		dict(
			name = "output_constraints",
			type = "ir_asm_constraint*",
		),
		dict(
			name = "n_clobbers",
			type = "int",
		),
		dict(
			name = "clobbers",
			type = "ident**",
		),
		dict(
			name = "text",
			type = "ident*",
		),
	],
	java_noconstr = True,
100
101
102
103
),

Bad = dict(
	mode       = "mode_Bad",
104
	flags      = "cfopcode, fragile, start_block, dump_noblock",
105
	knownBlock = True,
106
	singleton  = True,
107
108
109
),

Block = dict(
110
111
112
113
114
115
116
	mode        = "mode_BB",
	knownBlock  = True,
	block       = "NULL",
	optimize    = False,
	arity       = "variable",
	flags       = "labeled",
	attr_struct = "block_attr",
117
	java_noconstr = True,
Moritz Kroll's avatar
Moritz Kroll committed
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

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

138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
	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
159
160
	current_ir_graph->current_block = res;

161
162
163
	IRN_VRFY_IRG(res, current_ir_graph);
	''',

164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
	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);
184
185
186
187
188
189
	}

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

192
Borrow = dict(
193
194
	is_a     = "binop",
	flags    = "none",
195
196
),

197
Bound = dict(
198
199
	ins    = [ "mem", "index", "lower", "upper" ],
 	outs   = [ "M", "X_regular", "X_except", "res" ],
200
 	flags  = "fragile, highlevel",
201
202
	pinned = "exception",
	pinned_init = "pinned",
203
	attr_struct = "bound_attr",
204
205
206
207
208
209
210
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
	#endif
	'''
),

211
Break = dict(
212
213
	mode  = "mode_X",
	flags = "cfopcode",
214
215
),

216
217
Builtin = dict(
	ins      = [ "mem" ],
218
219
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
220
	flags    = "uses_memory",
221
	attrs    = [
222
223
224
225
		dict(
			type = "ir_builtin_kind",
			name = "kind"
		),
226
		dict(
227
228
229
			type = "ir_type*",
			name = "type"
		)
230
	],
231
232
233
	pinned      = "memory",
	pinned_init = "pinned",
	init   = '''
234
235
236
237
	assert((get_unknown_type() == type) || is_Method_type(type));
	'''

	# TODO: No firm_alloc_frag_arr??
238
239
),

240
241
Call = dict(
	ins      = [ "mem", "ptr" ],
242
243
	arity    = "variable",
	outs     = [ "M_regular", "X_regular", "X_except", "T_result", "M_except", "P_value_res_base" ],
244
	flags    = "fragile, uses_memory",
245
	attrs    = [
246
247
248
		dict(
			type = "ir_type*",
			name = "type"
249
		)
250
	],
251
	attr_struct = "call_attr",
252
253
	pinned      = "memory",
	pinned_init = "pinned",
254
255
256
257
258
259
260
261
	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
	'''
262
263
),

264
265
266
267
268
269
270
271
272
273
274
275
CallBegin = dict(
	ins   = [ "ptr" ],
	outs  = [ "" ], # TODO
	flags         = "cfopcode, ip_cfopcode",
	# TODO: attribute with call...
	attr_struct   = "callbegin_attr",
	java_noconstr = True,
	init = '''
	res->attr.callbegin.call = call;
	''',
),

276
Carry = dict(
277
278
	is_a     = "binop",
	flags    = "commutative",
279
280
),

281
282
283
Cast = dict(
	ins      = [ "op" ],
	mode     = "get_irn_mode(irn_op)",
284
	flags    = "highlevel",
285
286
287
288
289
290
	attrs    = [
		dict(
			type = "ir_type*",
			name = "type"
		)
	],
291
	attr_struct = "cast_attr",
292
293
294
	init     = "assert(is_atomic_type(type));"
),

295
296
297
Cmp = dict(
	is_a     = "binop",
	outs     = [ "False", "Eq", "Lt", "Le", "Gt", "Ge", "Lg", "Leg", "Uo", "Ue", "Ul", "Ule", "Ug", "Uge", "Ne", "True" ],
298
	flags    = "none",
299
300
),

301
302
303
Cond = dict(
	ins      = [ "selector" ],
	outs     = [ "false", "true" ],
304
	flags    = "cfopcode, forking",
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
	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"
		)
321
322
	],
	attr_struct = "cond_attr"
323
324
),

325
326
327
Confirm = dict(
	ins      = [ "value", "bound" ],
	mode     = "get_irn_mode(irn_value)",
328
	flags    = "highlevel",
329
330
331
332
333
334
	attrs    = [
		dict(
			name = "cmp",
			type = "pn_Cmp"
		),
	],
335
	attr_struct = "confirm_attr",
336
337
),

338
339
Const = dict(
	mode       = "",
340
	flags      = "constlike, start_block",
341
342
343
344
345
346
347
348
	knownBlock = True,
	attrs_name = "con",
	attrs      = [
		dict(
			type = "tarval*",
			name = "tarval",
		)
	],
349
	attr_struct = "const_attr",
350
351
),

352
353
Conv = dict(
	is_a     = "unop",
354
	flags    = "none",
355
356
357
358
359
360
361
362
363
364
	attrs = [
		dict(
			name = "strict",
			type = "int",
			init = "0",
			special = dict(
				prefix = "strict",
				init = "1"
			)
		)
365
366
	],
	attr_struct = "conv_attr",
367
368
),

369
370
371
CopyB = dict(
	ins   = [ "mem", "dst", "src" ],
	outs  = [ "M", "X_regular", "X_except" ],
372
	flags = "fragile, highlevel, uses_memory",
373
374
	attrs = [
		dict(
375
376
			name = "type",
			type = "ir_type*"
377
		)
378
	],
379
	attr_struct = "copyb_attr",
380
381
	pinned      = "memory",
	pinned_init = "pinned",
382
383
384
385
386
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
	#endif
	'''
387
388
),

389
Div = dict(
390
	ins   = [ "mem", "left", "right" ],
391
	outs  = [ "M", "X_regular", "X_except", "res" ],
392
	flags = "fragile, uses_memory",
393
	attrs_name = "divmod",
394
395
396
397
398
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
Moritz Kroll's avatar
Moritz Kroll committed
399
400
401
402
403
404
405
406
		dict(
			name = "no_remainder",
			type = "int",
			init = "0",
			special = dict(
				suffix = "RL",
				init = "1"
			)
407
		)
408
	],
409
	attr_struct = "divmod_attr",
410
411
	pinned      = "exception",
	op_index    = 1,
412
413
414
415
416
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
	#endif
	'''
417
418
419
),

DivMod = dict(
420
	ins   = [ "mem", "left", "right" ],
421
	outs  = [ "M", "X_regular", "X_except", "res_div", "res_mod" ],
422
	flags = "fragile, uses_memory",
423
	attrs_name = "divmod",
424
425
426
427
428
	attrs = [
		dict(
			type = "ir_mode*",
			name = "resmode"
		),
429
	],
430
	attr_struct = "divmod_attr",
431
432
	pinned      = "exception",
	op_index    = 1,
433
434
435
436
437
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
	#endif
	'''
438
439
),

440
441
442
443
444
445
446
Dummy = dict(
	ins   = [],
	flags = "cfopcode, fragile, start_block, constlike, dump_noblock",
	knownBlock = True,
	block      = "get_irg_start_block(irg)",
),

447
448
End = dict(
	mode       = "mode_X",
449
	pinned     = "yes",
450
	arity      = "dynamic",
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
	flags      = "cfopcode",
	singleton  = True,
),

EndExcept = dict(
	mode      = "mode_X",
	pinned    = "yes",
	arity     = "dynamic",
	flags     = "cfopcode, ip_cfopcode",
	singleton = True
),

EndReg = dict(
	mode      = "mode_X",
	pinned    = "yes",
	arity     = "dynamic",
	flags     = "cfopcode, ip_cfopcode",
	singleton = True
469
470
471
),

Eor = dict(
472
473
	is_a     = "binop",
	flags    = "commutative",
474
475
),

476
477
Filter = dict(
	ins   = [ "pred" ],
478
	flags = "none",
479
480
481
482
483
	attrs = [
		dict(
			name = "proj",
			type = "long"
		)
484
485
486
	],
	attr_struct = "filter_attr",
	java_noconstr = True
487
488
489
490
491
492

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

493
494
495
Free = dict(
	ins   = [ "mem", "ptr", "size" ],
	mode  = "mode_M",
496
	flags = "uses_memory",
497
498
	attrs = [
		dict(
499
500
			name = "type",
			type = "ir_type*"
501
502
		),
		dict(
503
504
			name = "where",
			type = "ir_where_alloc"
505
		)
506
507
	],
	attr_struct = "free_attr",
508
509
),

510
Id = dict(
511
512
	ins   = [ "pred" ],
	flags = "none",
513
514
515
516
),

IJmp = dict(
	mode     = "mode_X",
517
	pinned   = "yes",
518
	ins      = [ "target" ],
519
	flags    = "cfopcode, forking, keep",
520
521
),

522
InstOf = dict(
523
	ins   = [ "store", "obj" ],
524
	outs  = [ "M", "X_regular", "X_except", "res", "M_except" ],
525
	flags = "highlevel",
526
527
528
529
530
	attrs = [
		dict(
			name = "type",
			type = "ir_type*"
		)
531
	],
532
	attr_struct = "io_attr",
533
534
	pinned      = "memory",
	pinned_init = "floats",
535
536
),

537
538
Jmp = dict(
	mode     = "mode_X",
539
	pinned   = "yes",
540
	ins      = [],
541
	flags    = "cfopcode",
542
543
),

544
545
546
Load = dict(
	ins      = [ "mem", "ptr" ],
	outs     = [ "M", "X_regular", "X_except", "res" ],
547
	flags    = "fragile, uses_memory",
548
549
550
551
552
553
554
	attrs    = [
		dict(
			type = "ir_mode*",
			name = "mode",
			java_name = "load_mode"
		),
	],
555
	attr_struct = "load_attr",
556
557
	constructor_args = [
		dict(
Moritz Kroll's avatar
Moritz Kroll committed
558
			type = "ir_cons_flags",
559
560
561
			name = "flags",
		),
	],
562
563
564
565
566
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
#endif
	'''
567
568
),

569
Minus = dict(
570
571
	is_a     = "unop",
	flags    = "none",
572
573
574
),

Mod = dict(
575
	ins   = [ "mem", "left", "right" ],
576
	outs  = [ "M", "X_regular", "X_except", "res" ],
577
	flags = "fragile, uses_memory",
578
	attrs_name = "divmod",
579
	attrs = [
580
		dict(
581
582
			type = "ir_mode*",
			name = "resmode"
583
		),
584
	],
585
	attr_struct = "divmod_attr",
586
587
	pinned      = "exception",
	op_index    = 1,
588
589
590
591
592
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
	#endif
	'''
593
594
),

595
Mul = dict(
596
597
	is_a     = "binop",
	flags    = "commutative",
598
599
600
),

Mulh = dict(
601
602
	is_a     = "binop",
	flags    = "commutative",
603
604
605
),

Mux = dict(
606
607
	ins   = [ "sel", "false", "true" ],
	flags = "none",
608
609
610
611
),

NoMem = dict(
	mode       = "mode_M",
612
	flags      = "dump_noblock, dump_noinput",
613
	knownBlock = True,
614
	singleton  = True,
615
616
),

617
Not = dict(
618
619
	is_a     = "unop",
	flags    = "none",
620
621
622
),

Or = dict(
623
624
	is_a     = "binop",
	flags    = "commutative",
625
626
627
),

Phi = dict(
628
629
630
631
632
633
	pinned      = "yes",
	arity       = "variable",
	flags       = "none",
	attr_struct = "phi_attr",
	custom_is   = True,
	java_noconstr = True,
634
635
636
637
),

Pin = dict(
	ins      = [ "op" ],
638
639
	mode     = "get_irn_mode(irn_op)",
	flags    = "highlevel",
640
641
642
643
),

Proj = dict(
	ins      = [ "pred" ],
644
	flags    = "none",
645
646
647
	attrs    = [
		dict(
			type = "long",
648
649
			name = "proj",
			initname = ""
650
		)
651
652
653
	],
	attr_struct = "long",
	custom_is   = True,
654
655
),

656
Quot = dict(
657
	ins   = [ "mem", "left", "right" ],
658
	outs  = [ "M", "X_regular", "X_except", "res" ],
659
	flags = "fragile, uses_memory",
660
	attrs_name = "divmod",
661
	attrs = [
662
		dict(
663
664
665
			type = "ir_mode*",
			name = "resmode"
		),
666
	],
667
	attr_struct = "divmod_attr",
668
669
	pinned      = "exception",
	op_index    = 1,
670
671
672
673
674
	d_post = '''
	#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
	#endif
	'''
675
676
),

677
678
Raise = dict(
	ins   = [ "mem", "exo_ptr" ],
679
680
	outs  = [ "M", "X" ],
	flags = "highlevel, cfopcode",
681
682
),

683
684
Return = dict(
	ins      = [ "mem" ],
685
	arity    = "variable",
686
687
	mode     = "mode_X",
	flags    = "cfopcode",
688
689
),

690
Rotl = dict(
691
692
	is_a     = "binop",
	flags    = "none",
693
694
),

695
696
697
Sel = dict(
	ins    = [ "mem", "ptr" ],
	arity  = "variable",
698
	flags  = "none",
699
	mode   = "is_Method_type(get_entity_type(entity)) ? mode_P_code : mode_P_data",
700
701
	attrs    = [
		dict(
702
703
704
			type = "ir_entity*",
			name = "entity"
		)
705
706
	],
	attr_struct = "sel_attr",
707
708
),

709
Shl = dict(
710
711
	is_a     = "binop",
	flags    = "none",
712
713
),

714
Shr = dict(
715
716
	is_a     = "binop",
	flags    = "none",
717
718
),

719
Shrs = dict(
720
721
	is_a     = "binop",
	flags    = "none",
722
723
),

724
725
Start = dict(
	mode       = "mode_T",
726
	pinned     = "yes",
727
728
	flags      = "cfopcode",
	singleton  = True,
729
730
),

731
732
733
Store = dict(
	ins      = [ "mem", "ptr", "value" ],
	outs     = [ "M", "X_regular", "X_except" ],
734
735
	flags    = "fragile, uses_memory",
	attr_struct = "store_attr",
736
	constructor_args = [
737
		dict(
738
739
			type = "ir_cons_flags",
			name = "flags",
740
		),
741
742
743
744
745
746
	],
	d_post = '''
#if PRECISE_EXC_CONTEXT
	firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
#endif
	'''
747
748
),

749
Sub = dict(
750
751
	is_a     = "binop",
	flags    = "none",
752
753
),

754
755
SymConst = dict(
	mode       = "mode_P",
756
	flags      = "constlike, start_block",
757
758
	knownBlock = True,
	attrs      = [
759
		dict(
760
761
			type = "ir_entity*",
			name = "entity"
762
		)
763
	],
764
765
	attr_struct = "symconst_attr",
	java_noconstr = True,
766
767
),

768
769
Sync = dict(
	mode     = "mode_M",
770
	flags    = "none",
771
772
	optimize = False,
	arity    = "dynamic"
773
774
),

775
Tuple = dict(
776
777
778
779
	arity = "variable",
	mode  = "mode_T",
	flags = "labeled",
	java_noconstr = True
780
),
Moritz Kroll's avatar
Moritz Kroll committed
781

782
783
784
Unknown = dict(
	knownBlock = True,
	block      = "get_irg_start_block(irg)",
785
	flags      = "cfopcode, fragile, start_block, constlike, dump_noblock",
Moritz Kroll's avatar
Moritz Kroll committed
786
),
787
)