@@ -814,3 +814,64 @@ void ObjectStage::print() const {
814814 llvm::errs () << " \t\t [" << un->index << " ] = " << un->value << " \n " ;
815815 }
816816}
817+
818+ /* **/
819+
820+ void ObjectStage::reset (ref<Expr> newDefault) {
821+ knownSymbolics->reset (std::move (newDefault));
822+ unflushedMask->reset (false );
823+ updates = UpdateList (nullptr , nullptr );
824+ }
825+
826+ void ObjectStage::reset (ref<Expr> updateForDefault, bool isAdd) {
827+ ref<Expr> oldDefault = knownSymbolics->defaultV ();
828+ ref<Expr> newDefault =
829+ isAdd ? OrExpr::create (oldDefault, updateForDefault)
830+ : AndExpr::create (oldDefault, NotExpr::create (updateForDefault));
831+ knownSymbolics->reset (std::move (newDefault));
832+ unflushedMask->reset (false );
833+ updates = UpdateList (nullptr , nullptr );
834+ }
835+
836+ ref<Expr> ObjectStage::combineAll () const {
837+ ref<Expr> result = knownSymbolics->defaultV ();
838+ for (auto [index, value] : knownSymbolics->storage ()) {
839+ result = OrExpr::create (result, value);
840+ }
841+ for (const auto *un = updates.head .get (); un; un = un->next .get ()) {
842+ result = OrExpr::create (result, un->value );
843+ }
844+ return result;
845+ }
846+
847+ void ObjectStage::updateAll (ref<Expr> updateExpr, bool isAdd) {
848+ std::vector<std::pair<size_t , ref<Expr>>> newKnownSymbolics;
849+ for (auto [index, value] : knownSymbolics->storage ()) {
850+ ref<Expr> newValue =
851+ isAdd ? OrExpr::create (value, updateExpr)
852+ : AndExpr::create (value, NotExpr::create (updateExpr));
853+ newKnownSymbolics.emplace_back (index, value);
854+ }
855+
856+ ref<Expr> oldDefault = knownSymbolics->defaultV ();
857+ ref<Expr> newDefault =
858+ isAdd ? OrExpr::create (oldDefault, updateExpr)
859+ : AndExpr::create (oldDefault, NotExpr::create (updateExpr));
860+ knownSymbolics->reset (std::move (newDefault));
861+
862+ for (auto [index, value] : newKnownSymbolics) {
863+ knownSymbolics->store (index, value);
864+ }
865+
866+ std::vector<std::pair<ref<Expr>, ref<Expr>>> newUpdates;
867+ for (auto *un = updates.head .get (); un; un = un->next .get ()) {
868+ ref<Expr> newValue =
869+ isAdd ? OrExpr::create (un->value , updateExpr)
870+ : AndExpr::create (un->value , NotExpr::create (updateExpr));
871+ newUpdates.emplace_back (un->index , newValue);
872+ }
873+ updates = UpdateList (nullptr , nullptr );
874+ for (auto [index, value] : newUpdates) {
875+ updates.extend (index, value);
876+ }
877+ }
0 commit comments