-
Notifications
You must be signed in to change notification settings - Fork 1
/
IRBasicBlock.cs
50 lines (37 loc) · 1.32 KB
/
IRBasicBlock.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Text;
using NIR.Instructions;
namespace NIR
{
public class IRBasicBlock
{
public List<IROp> Operations { get; set; } = new List<IROp>();
public List<IRBasicBlock> Parents { get; set; } = new List<IRBasicBlock>();
public List<IRBasicBlock> Children { get; set; } = new List<IRBasicBlock>();
public int OValue { get; set; }
public Stack<bool> Marked { get; set; } = new Stack<bool>();
public List<IRBasicBlock> DominanceFrontier { get; set; }
= new List<IRBasicBlock>();
public List<IRName> LiveIn { get; set; } = new List<IRName>();
public List<IRName> LiveOut { get; set; } = new List<IRName>();
public override string ToString() => OValue.ToString();
public void InsertOp(int index, IROp op)
{
op.Block = this;
Operations.Insert(index, op);
}
public void ReplaceAt(int index, IROp op)
{
op.Block = this;
Operations[index] = op;
}
public void Unlink()
{
foreach (IRBasicBlock parent in Parents)
parent.Children.Remove(this);
foreach (IRBasicBlock child in Children)
child.Parents.Remove(this);
}
}
}