diff options
author | Bruce He <44327446+zm2he@users.noreply.github.com> | 2023-07-06 20:02:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 16:02:07 -0400 |
commit | eb185f5d0706927db5917bf111afa73c6989b249 (patch) | |
tree | 13420bc642ab2d1524ff98e7b16bc923cc6282d9 /test/gtest | |
parent | 73f24c0af330578e9fa01e3d5fc6391619baaa9e (diff) | |
download | binaryen-eb185f5d0706927db5917bf111afa73c6989b249.tar.gz binaryen-eb185f5d0706927db5917bf111afa73c6989b249.tar.bz2 binaryen-eb185f5d0706927db5917bf111afa73c6989b249.zip |
Make the Transfer Function a Generic, Interchangeable Type for the Monotone Analyzer (#5794)
This change makes the transfer function an object separate from the monotone analyzer. The transfer function class type is a generic template of the monotone analyzer, and an instance of the transfer function is instantiated and then passed into the monotone analyzer via its constructor. The API of the transfer function is enforced by a static assertion.
This change also introduces LivenessTransferFunction as a transfer function for liveness analysis as an example.
Diffstat (limited to 'test/gtest')
-rw-r--r-- | test/gtest/cfg.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/test/gtest/cfg.cpp b/test/gtest/cfg.cpp index ae1b9215e..65b449745 100644 --- a/test/gtest/cfg.cpp +++ b/test/gtest/cfg.cpp @@ -2,6 +2,7 @@ #include "analysis/cfg.h" #include "analysis/lattice.h" +#include "analysis/liveness-transfer-function.h" #include "analysis/monotone-analyzer.h" #include "print-test.h" #include "wasm.h" @@ -111,9 +112,8 @@ TEST_F(CFGTest, LinearLiveness) { )wasm"; auto analyzerText = R"analyzer(CFG Analyzer -State Block: 0 -Beginning State: 000 -End State: 000 +CFG Block: 0 +Input State: 000 Predecessors: Successors: Intermediate States (reverse order): @@ -148,8 +148,10 @@ End CFG cfg = CFG::fromFunction(wasm.getFunction("bar")); FinitePowersetLattice lattice(wasm.getFunction("bar")->getNumLocals()); - MonotoneCFGAnalyzer<FinitePowersetLattice> analyzer(lattice); - analyzer.fromCFG(&cfg); + LivenessTransferFunction transferFunction; + + MonotoneCFGAnalyzer<FinitePowersetLattice, LivenessTransferFunction> analyzer( + lattice, transferFunction, cfg); analyzer.evaluate(); std::stringstream ss; @@ -184,9 +186,8 @@ TEST_F(CFGTest, NonlinearLiveness) { )wasm"; auto analyzerText = R"analyzer(CFG Analyzer -State Block: 0 -Beginning State: 00 -End State: 10 +CFG Block: 0 +Input State: 10 Predecessors: Successors: 1 2 Intermediate States (reverse order): @@ -201,9 +202,8 @@ local.set $0 00 i32.const 1 00 -State Block: 1 -Beginning State: 00 -End State: 00 +CFG Block: 1 +Input State: 00 Predecessors: 0 Successors: 3 Intermediate States (reverse order): @@ -212,9 +212,8 @@ local.set $1 00 i32.const 4 00 -State Block: 2 -Beginning State: 10 -End State: 00 +CFG Block: 2 +Input State: 00 Predecessors: 0 Successors: 3 Intermediate States (reverse order): @@ -223,9 +222,8 @@ drop 00 local.get $0 10 -State Block: 3 -Beginning State: 00 -End State: 00 +CFG Block: 3 +Input State: 00 Predecessors: 2 1 Successors: Intermediate States (reverse order): @@ -240,8 +238,10 @@ End CFG cfg = CFG::fromFunction(wasm.getFunction("bar")); FinitePowersetLattice lattice(wasm.getFunction("bar")->getNumLocals()); - MonotoneCFGAnalyzer<FinitePowersetLattice> analyzer(lattice); - analyzer.fromCFG(&cfg); + LivenessTransferFunction transferFunction; + + MonotoneCFGAnalyzer<FinitePowersetLattice, LivenessTransferFunction> analyzer( + lattice, transferFunction, cfg); analyzer.evaluate(); std::stringstream ss; |