summaryrefslogtreecommitdiff
path: root/src/analysis/lattices/bool.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-10-25 21:30:31 +0200
committerGitHub <noreply@github.com>2023-10-25 21:30:31 +0200
commit6ba0f3d282714fa60be2634fbdf48a8ab5a3997d (patch)
tree45d873c2a38a9e50641254628a59b15d068f49ba /src/analysis/lattices/bool.h
parenta09ea699d69ed54741d95b9b5fa2247bdcf28152 (diff)
downloadbinaryen-6ba0f3d282714fa60be2634fbdf48a8ab5a3997d.tar.gz
binaryen-6ba0f3d282714fa60be2634fbdf48a8ab5a3997d.tar.bz2
binaryen-6ba0f3d282714fa60be2634fbdf48a8ab5a3997d.zip
[analysis] Add a FullLattice concept and Inverted lattice (#6038)
The FullLattice concept extends the base Lattice with `getTop` and `meet` operations. The `Inverted` lattice uses these operations to reverse the order of an arbitrary full lattice, for example to create a lattice of integers ordered by `>` rather than by `<`.
Diffstat (limited to 'src/analysis/lattices/bool.h')
-rw-r--r--src/analysis/lattices/bool.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/analysis/lattices/bool.h b/src/analysis/lattices/bool.h
index 31094fb7d..c905d69f4 100644
--- a/src/analysis/lattices/bool.h
+++ b/src/analysis/lattices/bool.h
@@ -26,6 +26,7 @@ namespace wasm::analysis {
struct Bool {
using Element = bool;
Element getBottom() const noexcept { return false; }
+ Element getTop() const noexcept { return true; }
LatticeComparison compare(Element a, Element b) const noexcept {
return a > b ? GREATER : a == b ? EQUAL : LESS;
}
@@ -36,6 +37,13 @@ struct Bool {
}
return false;
}
+ bool meet(Element& self, Element other) const noexcept {
+ if (self && !other) {
+ self = other;
+ return true;
+ }
+ return false;
+ }
};
#if __cplusplus >= 202002L