mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[silgen] Add RValue::isPlus{One,Zero} to distinguish +0 from +1 rvalues.
I already in a previous commit forced all rvalues to have consistent cleanups and consistent value ownership kinds. Now that we know all constructed RValues are consistent, we can safely query that information. rdar://33358110
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "Initialization.h"
|
||||
#include "SILGenFunction.h"
|
||||
#include "swift/AST/CanTypeVisitor.h"
|
||||
#include "swift/Basic/STLExtras.h"
|
||||
#include "swift/SIL/AbstractionPattern.h"
|
||||
#include "swift/SIL/SILArgument.h"
|
||||
|
||||
@@ -784,3 +785,21 @@ void RValue::verifyConsistentOwnership() const {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RValue::isPlusOne(SILGenFunction &SGF) const & {
|
||||
return llvm::none_of(values, [&SGF](ManagedValue mv) -> bool {
|
||||
if (mv.getType().isTrivial(SGF.F.getModule()) ||
|
||||
mv.getOwnershipKind() == ValueOwnershipKind::Trivial)
|
||||
return false;
|
||||
return !mv.hasCleanup();
|
||||
});
|
||||
}
|
||||
|
||||
bool RValue::isPlusZero(SILGenFunction &SGF) const & {
|
||||
return llvm::none_of(values, [&SGF](ManagedValue mv) -> bool {
|
||||
if (mv.getType().isTrivial(SGF.F.getModule()) ||
|
||||
mv.getOwnershipKind() == ValueOwnershipKind::Trivial)
|
||||
return false;
|
||||
return mv.hasCleanup();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user