aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Translation/ControlFlowGraph.cs
diff options
context:
space:
mode:
authorFICTURE7 <FICTURE7@gmail.com>2020-09-20 03:00:24 +0400
committerGitHub <noreply@github.com>2020-09-19 20:00:24 -0300
commitf60033e0aaf546d7f56a4925b5aeec76709fb851 (patch)
treeaf6585403754a771dbab824b1739322ef04b3cd8 /ARMeilleure/Translation/ControlFlowGraph.cs
parent1eea35554c7505dbf521cf9f3cfeeaa0fc7e916f (diff)
Implement block placement (#1549)
* Implement block placement Implement a simple pass which re-orders cold blocks at the end of the list of blocks in the CFG. * Set PPTC version * Use Array.Resize Address gdkchan's feedback
Diffstat (limited to 'ARMeilleure/Translation/ControlFlowGraph.cs')
-rw-r--r--ARMeilleure/Translation/ControlFlowGraph.cs25
1 files changed, 18 insertions, 7 deletions
diff --git a/ARMeilleure/Translation/ControlFlowGraph.cs b/ARMeilleure/Translation/ControlFlowGraph.cs
index 34963534..ee1a245e 100644
--- a/ARMeilleure/Translation/ControlFlowGraph.cs
+++ b/ARMeilleure/Translation/ControlFlowGraph.cs
@@ -7,26 +7,37 @@ namespace ARMeilleure.Translation
{
class ControlFlowGraph
{
+ private BasicBlock[] _postOrderBlocks;
+ private int[] _postOrderMap;
+
public BasicBlock Entry { get; }
public IntrusiveList<BasicBlock> Blocks { get; }
- public BasicBlock[] PostOrderBlocks { get; }
- public int[] PostOrderMap { get; }
+ public BasicBlock[] PostOrderBlocks => _postOrderBlocks;
+ public int[] PostOrderMap => _postOrderMap;
public ControlFlowGraph(BasicBlock entry, IntrusiveList<BasicBlock> blocks)
{
Entry = entry;
Blocks = blocks;
- RemoveUnreachableBlocks(blocks);
+ Update(removeUnreachableBlocks: true);
+ }
+
+ public void Update(bool removeUnreachableBlocks)
+ {
+ if (removeUnreachableBlocks)
+ {
+ RemoveUnreachableBlocks(Blocks);
+ }
var visited = new HashSet<BasicBlock>();
var blockStack = new Stack<BasicBlock>();
- PostOrderBlocks = new BasicBlock[blocks.Count];
- PostOrderMap = new int[blocks.Count];
+ Array.Resize(ref _postOrderBlocks, Blocks.Count);
+ Array.Resize(ref _postOrderMap, Blocks.Count);
- visited.Add(entry);
- blockStack.Push(entry);
+ visited.Add(Entry);
+ blockStack.Push(Entry);
int index = 0;