llvm.org GIT mirror llvm / ff6f91e
[Attributor][NFC] Add merge/join/clamp operators to the IntegerState Differential Revision: https://reviews.llvm.org/D66146 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368925 91177308-0d34-0410-b5e6-96231b3b80d8 Johannes Doerfert a month ago
2 changed file(s) with 49 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
886886 this->getKnown() == R.getKnown();
887887 }
888888
889 /// Inequality for IntegerState.
890 bool operator!=(const IntegerState &R) const { return !(*this == R); }
891
892 /// "Clamp" this state with \p R. The result is the maximum of the known
893 /// information but the minimum of the assumed.
894 IntegerState operator^=(const IntegerState &R) {
895 takeKnownMaximum(R.Known);
896 takeAssumedMinimum(R.Assumed);
897 return *this;
898 }
899
900 /// Make this the minimum, known and assumed, of this state and \p R.
901 IntegerState operator&=(const IntegerState &R) {
902 Known = std::min(Known, R.Known);
903 Assumed = std::min(Assumed, R.Assumed);
904 return *this;
905 }
906
907 /// Make this the maximum, known and assumed, of this state and \p R.
908 IntegerState operator|=(const IntegerState &R) {
909 Known = std::max(Known, R.Known);
910 Assumed = std::max(Assumed, R.Assumed);
911 return *this;
912 }
913
889914 private:
890915 /// The known state encoding in an integer of type base_t.
891916 base_t Known = getWorstState();
16491649 return this->DerefBytesState == R.DerefBytesState &&
16501650 this->GlobalState == R.GlobalState;
16511651 }
1652
1653 /// Inequality for IntegerState.
1654 bool operator!=(const DerefState &R) { return !(*this == R); }
1655
1656 /// See IntegerState::operator^=
1657 DerefState operator^=(const DerefState &R) {
1658 DerefBytesState ^= R.DerefBytesState;
1659 GlobalState ^= R.GlobalState;
1660 return *this;
1661 }
1662
1663 /// See IntegerState::operator&=
1664 DerefState operator&=(const DerefState &R) {
1665 DerefBytesState &= R.DerefBytesState;
1666 GlobalState &= R.GlobalState;
1667 return *this;
1668 }
1669
1670 /// See IntegerState::operator|=
1671 DerefState operator|=(const DerefState &R) {
1672 DerefBytesState |= R.DerefBytesState;
1673 GlobalState |= R.GlobalState;
1674 return *this;
1675 }
16521676 };
16531677
16541678 struct AADereferenceableImpl : AADereferenceable, DerefState {