Skip to content

Commit 4f8f5b6

Browse files
committed
[silgen] Add ManagedValue level APIs for creating CopyableToMoveOnlyWrapper and MarkMustCheck.
Just slimming down a larger commit.
1 parent c8c2b81 commit 4f8f5b6

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/SILGen/SILGenBuilder.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -921,3 +921,23 @@ ManagedValue SILGenBuilder::createGuaranteedMoveOnlyWrapperToCopyableValue(
921921
assert(mdi->getOperand()->getType().isObject() && "Expected an object?!");
922922
return ManagedValue::forUnmanaged(mdi);
923923
}
924+
925+
ManagedValue
926+
SILGenBuilder::createCopyableToMoveOnlyWrapperValue(SILLocation loc,
927+
ManagedValue value) {
928+
assert(value.isPlusOne(SGF) && "Argument must be at +1!");
929+
CleanupCloner cloner(*this, value);
930+
auto *mdi = SILBuilder::createCopyableToMoveOnlyWrapperValue(
931+
loc, value.forward(getSILGenFunction()));
932+
return cloner.clone(mdi);
933+
}
934+
935+
ManagedValue
936+
SILGenBuilder::createMarkMustCheckInst(SILLocation loc, ManagedValue value,
937+
MarkMustCheckInst::CheckKind kind) {
938+
assert(value.isPlusOne(SGF) && "Argument must be at +1!");
939+
CleanupCloner cloner(*this, value);
940+
auto *mdi = SILBuilder::createMarkMustCheckInst(
941+
loc, value.forward(getSILGenFunction()), kind);
942+
return cloner.clone(mdi);
943+
}

lib/SILGen/SILGenBuilder.h

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "RValue.h"
2929
#include "swift/Basic/ProfileCounter.h"
3030
#include "swift/SIL/SILBuilder.h"
31+
#include "swift/SIL/SILInstruction.h"
3132
#include "swift/SIL/SILLocation.h"
3233

3334
namespace swift {
@@ -414,6 +415,17 @@ class SILGenBuilder : public SILBuilder {
414415
ManagedValue
415416
createGuaranteedMoveOnlyWrapperToCopyableValue(SILLocation loc,
416417
ManagedValue value);
418+
419+
using SILBuilder::createCopyableToMoveOnlyWrapperValue;
420+
/// Create a copyable_to_moveonlywrapper. This expects a +1 value and returns
421+
/// a +1 value. Semantically though the two things are different entities so
422+
/// we are not forwarding ownership in the sense of the word.
423+
ManagedValue createCopyableToMoveOnlyWrapperValue(SILLocation loc,
424+
ManagedValue value);
425+
426+
using SILBuilder::createMarkMustCheckInst;
427+
ManagedValue createMarkMustCheckInst(SILLocation loc, ManagedValue value,
428+
MarkMustCheckInst::CheckKind kind);
417429
};
418430

419431
} // namespace Lowering

0 commit comments

Comments
 (0)