Skip to content

Commit 1a89813

Browse files
committed
AST: Introduce Builtin.RawUnsafeContinuation type
This is otherwise identical to Builtin.RawPointer, but has the spare bits of a heap object pointer.
1 parent 3e38655 commit 1a89813

21 files changed

+84
-7
lines changed

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ Types
498498
type ::= 'BO' // Builtin.UnknownObject (no longer a distinct type, but still used for AnyObject)
499499
type ::= 'Bo' // Builtin.NativeObject
500500
type ::= 'Bp' // Builtin.RawPointer
501+
type ::= 'Bc' // Builtin.RawUnsafeContinuation
501502
type ::= 'Bt' // Builtin.SILToken
502503
type ::= type 'Bv' NATURAL '_' // Builtin.Vec<n>x<type>
503504
type ::= 'Bw' // Builtin.Word

include/swift/AST/ASTContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ class ASTContext final {
751751
const CanType TheNativeObjectType; /// Builtin.NativeObject
752752
const CanType TheBridgeObjectType; /// Builtin.BridgeObject
753753
const CanType TheRawPointerType; /// Builtin.RawPointer
754+
const CanType TheRawUnsafeContinuationType; /// Builtin.RawUnsafeContinuation
754755
const CanType TheUnsafeValueBufferType; /// Builtin.UnsafeValueBuffer
755756
const CanType TheSILTokenType; /// Builtin.SILToken
756757
const CanType TheIntegerLiteralType; /// Builtin.IntegerLiteralType

include/swift/AST/TypeDifferenceVisitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class CanTypeDifferenceVisitor : public CanTypePairVisitor<Impl, bool> {
113113
}
114114
SINGLETON_TYPE(BuiltinIntegerLiteralType)
115115
SINGLETON_TYPE(BuiltinRawPointerType)
116+
SINGLETON_TYPE(BuiltinRawUnsafeContinuationType)
116117
SINGLETON_TYPE(BuiltinNativeObjectType)
117118
SINGLETON_TYPE(BuiltinBridgeObjectType)
118119
SINGLETON_TYPE(BuiltinUnsafeValueBufferType)

include/swift/AST/TypeMatcher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class TypeMatcher {
105105
TRIVIAL_CASE(BuiltinIntegerLiteralType)
106106
TRIVIAL_CASE(BuiltinFloatType)
107107
TRIVIAL_CASE(BuiltinRawPointerType)
108+
TRIVIAL_CASE(BuiltinRawUnsafeContinuationType)
108109
TRIVIAL_CASE(BuiltinNativeObjectType)
109110
TRIVIAL_CASE(BuiltinBridgeObjectType)
110111
TRIVIAL_CASE(BuiltinUnsafeValueBufferType)

include/swift/AST/TypeNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ ABSTRACT_TYPE(Builtin, Type)
9797
TYPE_RANGE(AnyBuiltinInteger, BuiltinInteger, BuiltinIntegerLiteral)
9898
BUILTIN_TYPE(BuiltinFloat, BuiltinType)
9999
BUILTIN_TYPE(BuiltinRawPointer, BuiltinType)
100+
BUILTIN_TYPE(BuiltinRawUnsafeContinuation, BuiltinType)
100101
BUILTIN_TYPE(BuiltinNativeObject, BuiltinType)
101102
BUILTIN_TYPE(BuiltinBridgeObject, BuiltinType)
102103
BUILTIN_TYPE(BuiltinUnsafeValueBuffer, BuiltinType)

include/swift/AST/Types.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,20 @@ class BuiltinRawPointerType : public BuiltinType {
13911391
};
13921392
DEFINE_EMPTY_CAN_TYPE_WRAPPER(BuiltinRawPointerType, BuiltinType);
13931393

1394+
/// BuiltinRawContinuationType - The builtin raw unsafe continuation type.
1395+
/// This pointer is completely unmanaged, but is lowered with the same
1396+
/// spare bits as an opaque object-pointer type.
1397+
class BuiltinRawUnsafeContinuationType : public BuiltinType {
1398+
friend class ASTContext;
1399+
BuiltinRawUnsafeContinuationType(const ASTContext &C)
1400+
: BuiltinType(TypeKind::BuiltinRawUnsafeContinuation, C) {}
1401+
public:
1402+
static bool classof(const TypeBase *T) {
1403+
return T->getKind() == TypeKind::BuiltinRawUnsafeContinuation;
1404+
}
1405+
};
1406+
DEFINE_EMPTY_CAN_TYPE_WRAPPER(BuiltinRawUnsafeContinuationType, BuiltinType);
1407+
13941408
/// BuiltinNativeObjectType - The builtin opaque object-pointer type.
13951409
/// Useful for keeping an object alive when it is otherwise being
13961410
/// manipulated via an unsafe pointer type.

include/swift/Strings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_BRIDGEOBJECT = {
110110
/// The name of the Builtin type for RawPointer
111111
constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_RAWPOINTER = {
112112
"Builtin.RawPointer"};
113+
/// The name of the Builtin type for RawUnsafeContinuation
114+
constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_RAWUNSAFECONTINUATION = {
115+
"Builtin.RawUnsafeContinuation"};
113116
/// The name of the Builtin type for UnsafeValueBuffer
114117
constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER =
115118
{"Builtin.UnsafeValueBuffer"};

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ ASTContext::ASTContext(LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
595595
BuiltinBridgeObjectType(*this)),
596596
TheRawPointerType(new (*this, AllocationArena::Permanent)
597597
BuiltinRawPointerType(*this)),
598+
TheRawUnsafeContinuationType(new (*this, AllocationArena::Permanent)
599+
BuiltinRawUnsafeContinuationType(*this)),
598600
TheUnsafeValueBufferType(new (*this, AllocationArena::Permanent)
599601
BuiltinUnsafeValueBufferType(*this)),
600602
TheSILTokenType(new (*this, AllocationArena::Permanent)

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,6 +3561,7 @@ namespace {
35613561

35623562
TRIVIAL_TYPE_PRINTER(BuiltinIntegerLiteral, builtin_integer_literal)
35633563
TRIVIAL_TYPE_PRINTER(BuiltinRawPointer, builtin_raw_pointer)
3564+
TRIVIAL_TYPE_PRINTER(BuiltinRawUnsafeContinuation, builtin_raw_unsafe_continuation)
35643565
TRIVIAL_TYPE_PRINTER(BuiltinNativeObject, builtin_native_object)
35653566
TRIVIAL_TYPE_PRINTER(BuiltinBridgeObject, builtin_bridge_object)
35663567
TRIVIAL_TYPE_PRINTER(BuiltinUnsafeValueBuffer, builtin_unsafe_value_buffer)

lib/AST/ASTMangler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ void ASTMangler::appendType(Type type, const ValueDecl *forDecl) {
975975
return appendOperator("BI");
976976
case TypeKind::BuiltinRawPointer:
977977
return appendOperator("Bp");
978+
case TypeKind::BuiltinRawUnsafeContinuation:
979+
return appendOperator("Bc");
978980
case TypeKind::BuiltinNativeObject:
979981
return appendOperator("Bo");
980982
case TypeKind::BuiltinBridgeObject:

0 commit comments

Comments
 (0)