[PATCH] D59979: [Attributor][NFC] Add helper functions to deal wit bit-encodings
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 23:35:22 PDT 2019
jdoerfert created this revision.
jdoerfert added a reviewer: llvm-commits.
Herald added subscribers: bollu, hiraditya.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59979
Files:
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
@@ -100,6 +100,35 @@
BaseTy getAssumed() const { return Assumed; }
protected:
+ /// Copy the bits set in \p BitsEncoding from \p From to \p To.
+ static void copyBits(BaseTy &To, const BaseTy From, BaseTy BitsEncoding) {
+ BaseTy UnaffectedBits = To & (~BitsEncoding);
+ BaseTy AffectedBits = From & BitsEncoding;
+ To = UnaffectedBits | AffectedBits;
+ }
+
+ /// Set the bits of \p Target also set in \p BitsEncoding.
+ static void setBits(BaseTy &Target, BaseTy BitsEncoding) {
+ Target = Target | BitsEncoding;
+ }
+
+ /// Unset the bits of \p Target also set in \p BitsEncoding.
+ static BaseTy &unsetBits(BaseTy &Target, BaseTy BitsEncoding) {
+ Target = Target & ~BitsEncoding;
+ return Target;
+ }
+
+ /// Intersect the bits of \p Target also set in \p BitsEncoding.
+ static BaseTy &intersectBits(BaseTy &Target, BaseTy BitsEncoding) {
+ Target = Target & BitsEncoding;
+ return Target;
+ }
+
+ /// Return true if the bits set in \p BitsEncoding are set in \p Source.
+ static bool testBits(BaseTy Source, BaseTy BitsEncoding) {
+ return (Source & BitsEncoding) == BitsEncoding;
+ }
+
/// The known state encoding in an integer of type BaseTy.
BaseTy Known;
@@ -691,17 +720,17 @@
/// See AANoCapture::isAssumedNoCapture(...).
bool isAssumedNoCapture() const override {
- return getAssumed() == BEST_STATE;
+ return testBits(getAssumed(), NOT_CAPTURED | NOT_RETURNED);
}
/// See AANoCapture::isKnownNoCaptureMaybeReturned(...).
bool isKnownNoCaptureMaybeReturned() const override {
- return getKnown() & NOT_CAPTURED;
+ return testBits(getKnown(), NOT_CAPTURED);
}
/// See AANoCapture::isAssumedNoCaptureMaybeReturned(...).
bool isAssumedNoCaptureMaybeReturned() const override {
- return getAssumed() & NOT_CAPTURED;
+ return testBits(getAssumed(), NOT_CAPTURED);
}
/// see AbstractAttribute::isAssumedNoCaptureMaybeReturned(...).
@@ -926,7 +955,7 @@
if (!AssumedNoCapture)
indicateFixpoint(/* Optimistic */ false);
else if (MaybeReturned)
- Assumed = Known | (Assumed & ~NOT_RETURNED);
+ setBits(unsetBits(Assumed, NOT_RETURNED), Known);
return (AssumedState == getAssumed()) ? ChangeStatus::UNCHANGED
: ChangeStatus::CHANGED;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59979.192780.patch
Type: text/x-patch
Size: 2511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190329/160c9c5b/attachment.bin>
More information about the llvm-commits
mailing list