#ifndef wasm_analysis_lattice_h #define wasm_analysis_lattice_h #include "wasm.h" #include #include namespace wasm::analysis { enum LatticeComparison { NO_RELATION, EQUAL, LESS, GREATER }; template constexpr bool has_compare = std::is_invocable_r::value; template constexpr bool has_getLeastUpperBound = std:: is_invocable_r::value; template constexpr bool has_isTop = std::is_invocable_r::value; template constexpr bool has_isBottom = std::is_invocable_r::value; template constexpr bool is_lattice = has_compare&& has_getLeastUpperBound&& has_isTop&& has_isBottom; // Represents a powerset lattice element (i.e. a set) as a bitvector. A true // means that an element is present in the set. template struct BitsetPowersetLattice { std::bitset value; static BitsetPowersetLattice getBottom(); static bool isTop(const BitsetPowersetLattice& element); static bool isBottom(const BitsetPowersetLattice& element); // Compares two lattice elements and returns a result indicating the // left element's relation to the right element. static LatticeComparison compare(const BitsetPowersetLattice& left, const BitsetPowersetLattice& right); // Calculates the LUB of this current (left) lattice element with some right // element. It then updates this current lattice element to the LUB in place. void getLeastUpperBound(const BitsetPowersetLattice& right); // Prints out the bits in the bitvector for a lattice element. void print(std::ostream& os); }; } // namespace wasm::analysis #include "powerset-lattice-impl.h" #endif // wasm_analysis_lattice_h