summaryrefslogtreecommitdiff
path: root/src/analysis/monotone-analyzer-impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/monotone-analyzer-impl.h')
-rw-r--r--src/analysis/monotone-analyzer-impl.h41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/analysis/monotone-analyzer-impl.h b/src/analysis/monotone-analyzer-impl.h
index 8599bccf2..a87ba4282 100644
--- a/src/analysis/monotone-analyzer-impl.h
+++ b/src/analysis/monotone-analyzer-impl.h
@@ -10,14 +10,12 @@ namespace wasm::analysis {
// All states are set to the bottom lattice element using the lattice in this
// constructor.
-template<typename Lattice>
-inline BlockState<Lattice>::BlockState(const BasicBlock* underlyingBlock,
- Lattice& lattice)
+template<Lattice L>
+inline BlockState<L>::BlockState(const BasicBlock* underlyingBlock, L& lattice)
: cfgBlock(underlyingBlock), inputState(lattice.getBottom()) {}
// Prints out inforamtion about a CFG node's state, but not intermediate states.
-template<typename Lattice>
-inline void BlockState<Lattice>::print(std::ostream& os) {
+template<Lattice L> inline void BlockState<L>::print(std::ostream& os) {
os << "CFG Block: " << cfgBlock->getIndex() << std::endl;
os << "Input State: ";
inputState.print(os);
@@ -32,9 +30,9 @@ inline void BlockState<Lattice>::print(std::ostream& os) {
os << std::endl;
}
-template<typename Lattice, typename TransferFunction>
-inline MonotoneCFGAnalyzer<Lattice, TransferFunction>::MonotoneCFGAnalyzer(
- Lattice& lattice, TransferFunction& transferFunction, CFG& cfg)
+template<Lattice L, typename TransferFunction>
+inline MonotoneCFGAnalyzer<L, TransferFunction>::MonotoneCFGAnalyzer(
+ L& lattice, TransferFunction& transferFunction, CFG& cfg)
: lattice(lattice), transferFunction(transferFunction), cfg(cfg) {
// Construct BlockStates for each BasicBlock.
@@ -43,30 +41,28 @@ inline MonotoneCFGAnalyzer<Lattice, TransferFunction>::MonotoneCFGAnalyzer(
}
}
-template<typename Lattice, typename TransferFunction>
-inline void
-MonotoneCFGAnalyzer<Lattice, TransferFunction>::evaluateFunctionEntry(
+template<Lattice L, typename TransferFunction>
+inline void MonotoneCFGAnalyzer<L, TransferFunction>::evaluateFunctionEntry(
Function* func) {
transferFunction.evaluateFunctionEntry(func, stateBlocks[0].inputState);
}
-template<typename Lattice, typename TransferFunction>
-inline void MonotoneCFGAnalyzer<Lattice, TransferFunction>::evaluate() {
+template<Lattice L, typename TransferFunction>
+inline void MonotoneCFGAnalyzer<L, TransferFunction>::evaluate() {
std::queue<const BasicBlock*> worklist;
// Transfer function enqueues the work in some order which is efficient.
transferFunction.enqueueWorklist(cfg, worklist);
while (!worklist.empty()) {
- BlockState<Lattice>& currBlockState =
- stateBlocks[worklist.front()->getIndex()];
+ BlockState<L>& currBlockState = stateBlocks[worklist.front()->getIndex()];
worklist.pop();
// For each expression, applies the transfer function, using the expression,
// on the state of the expression it depends upon (here the next expression)
// to arrive at the expression's state. The beginning and end states of the
// CFG block will be updated.
- typename Lattice::Element outputState = currBlockState.inputState;
+ typename L::Element outputState = currBlockState.inputState;
transferFunction.transfer(currBlockState.cfgBlock, outputState);
// Propagate state to dependents of currBlockState.
@@ -81,10 +77,10 @@ inline void MonotoneCFGAnalyzer<Lattice, TransferFunction>::evaluate() {
}
}
-template<typename Lattice, typename TransferFunction>
-inline void MonotoneCFGAnalyzer<Lattice, TransferFunction>::collectResults() {
+template<Lattice L, typename TransferFunction>
+inline void MonotoneCFGAnalyzer<L, TransferFunction>::collectResults() {
for (BlockState currBlockState : stateBlocks) {
- typename Lattice::Element inputStateCopy = currBlockState.inputState;
+ typename L::Element inputStateCopy = currBlockState.inputState;
// The transfer function generates the final set of states and uses it to
// produce useful information. For example, in reaching definitions
@@ -96,13 +92,12 @@ inline void MonotoneCFGAnalyzer<Lattice, TransferFunction>::collectResults() {
// Currently prints both the basic information and intermediate states of each
// BlockState.
-template<typename Lattice, typename TransferFunction>
-inline void
-MonotoneCFGAnalyzer<Lattice, TransferFunction>::print(std::ostream& os) {
+template<Lattice L, typename TransferFunction>
+inline void MonotoneCFGAnalyzer<L, TransferFunction>::print(std::ostream& os) {
os << "CFG Analyzer" << std::endl;
for (auto state : stateBlocks) {
state.print(os);
- typename Lattice::Element temp = state.inputState;
+ typename L::Element temp = state.inputState;
transferFunction.print(os, state.cfgBlock, temp);
}
os << "End" << std::endl;