[PATCH] D66146: [Attributor][NFC] Add merge/join/clamp operators to the
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 09:11:02 PDT 2019
jdoerfert created this revision.
Herald added subscribers: llvm-commits, bollu, hiraditya.
Herald added a project: LLVM.
Define operators to allow more concise operations on (common) abstract states.
https://reviews.llvm.org/D66146
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1651,6 +1651,30 @@
return this->DerefBytesState == R.DerefBytesState &&
this->GlobalState == R.GlobalState;
}
+
+ /// Inequality for IntegerState.
+ bool operator!=(const DerefState &R) { return !(*this == R); }
+
+ /// See IntegerState::operator^=
+ DerefState operator^=(const DerefState &R) {
+ DerefBytesState ^= R.DerefBytesState;
+ GlobalState ^= R.GlobalState;
+ return *this;
+ }
+
+ /// See IntegerState::operator&=
+ DerefState operator&=(const DerefState &R) {
+ DerefBytesState &= R.DerefBytesState;
+ GlobalState &= R.GlobalState;
+ return *this;
+ }
+
+ /// See IntegerState::operator|=
+ DerefState operator|=(const DerefState &R) {
+ DerefBytesState |= R.DerefBytesState;
+ GlobalState |= R.GlobalState;
+ return *this;
+ }
};
struct AADereferenceableImpl : AADereferenceable, DerefState {
Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -884,6 +884,31 @@
this->getKnown() == R.getKnown();
}
+ /// Inequality for IntegerState.
+ bool operator!=(const IntegerState &R) const { return !(*this == R); }
+
+ /// "Clamp" this state with the one of \p R, hat is the maximum of the known
+ /// information but the minimum of the assumed.
+ IntegerState operator^=(const IntegerState &R) {
+ takeKnownMaximum(R.Known);
+ takeAssumedMinimum(R.Assumed);
+ return *this;
+ }
+
+ /// Make this the minimum, known and assumed, between this state and \p R.
+ IntegerState operator&=(const IntegerState &R) {
+ Known = std::min(Known, R.Known);
+ Assumed = std::min(Assumed, R.Assumed);
+ return *this;
+ }
+
+ /// Make this the maximum, known and assumed, between this state and \p R.
+ IntegerState operator|=(const IntegerState &R) {
+ Known = std::max(Known, R.Known);
+ Assumed = std::max(Assumed, R.Assumed);
+ return *this;
+ }
+
private:
/// The known state encoding in an integer of type base_t.
base_t Known = getWorstState();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66146.214850.patch
Type: text/x-patch
Size: 2343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190813/d01d3489/attachment.bin>
More information about the llvm-commits
mailing list