aboutsummaryrefslogtreecommitdiffstats
path: root/ControlFlowGraph.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-05 23:45:58 +0800
committerchriseth <c@ethdev.com>2015-05-06 18:55:18 +0800
commitbebe76828a6c8ccfc3e61a066a43530f715aeee9 (patch)
treef585130864b832c2b1fedefe5eac3f1851854c3e /ControlFlowGraph.h
parent85673ff00cc8c0c21209080fb327c7deda69883a (diff)
downloaddexon-solidity-bebe76828a6c8ccfc3e61a066a43530f715aeee9.tar
dexon-solidity-bebe76828a6c8ccfc3e61a066a43530f715aeee9.tar.gz
dexon-solidity-bebe76828a6c8ccfc3e61a066a43530f715aeee9.tar.bz2
dexon-solidity-bebe76828a6c8ccfc3e61a066a43530f715aeee9.tar.lz
dexon-solidity-bebe76828a6c8ccfc3e61a066a43530f715aeee9.tar.xz
dexon-solidity-bebe76828a6c8ccfc3e61a066a43530f715aeee9.tar.zst
dexon-solidity-bebe76828a6c8ccfc3e61a066a43530f715aeee9.zip
CFG returns vector of blocks instead of assembly items.
Diffstat (limited to 'ControlFlowGraph.h')
-rw-r--r--ControlFlowGraph.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/ControlFlowGraph.h b/ControlFlowGraph.h
index 4310d664..3366dc45 100644
--- a/ControlFlowGraph.h
+++ b/ControlFlowGraph.h
@@ -35,6 +35,7 @@ namespace eth
{
class KnownState;
+using KnownStatePointer = std::shared_ptr<KnownState>;
/**
* Identifier for a block, coincides with the tag number of an AssemblyItem but adds a special
@@ -81,19 +82,22 @@ struct BasicBlock
/// Knowledge about the state when this block is entered. Intersection of all possible ways
/// to enter this block.
- std::shared_ptr<KnownState> startState;
+ KnownStatePointer startState;
/// Knowledge about the state at the end of this block.
- std::shared_ptr<KnownState> endState;
+ KnownStatePointer endState;
};
+using BasicBlocks = std::vector<BasicBlock>;
+
class ControlFlowGraph
{
public:
/// Initializes the control flow graph.
/// @a _items has to persist across the usage of this class.
ControlFlowGraph(AssemblyItems const& _items): m_items(_items) {}
- /// @returns the collection of optimised items, should be called only once.
- AssemblyItems optimisedItems();
+ /// @returns vector of basic blocks in the order they should be used in the final code.
+ /// Should be called only once.
+ BasicBlocks optimisedBlocks();
private:
void findLargestTag();
@@ -102,7 +106,7 @@ private:
void removeUnusedBlocks();
void gatherKnowledge();
void setPrevLinks();
- AssemblyItems rebuildCode();
+ BasicBlocks rebuildCode();
/// @returns the corresponding BlockId if _id is a pushed jump tag,
/// and an invalid BlockId otherwise.