[sil] Add support for UnsafeRawPointer to SILType and ASTSynthesis.

I am going to be using this type in some of the Builtins that I am adding. Just
chopping off part of the patch before I commit anything.
This commit is contained in:
Michael Gottesman
2025-10-30 13:00:17 -07:00
parent 5cb2409ba6
commit 1711ef2e62
3 changed files with 17 additions and 6 deletions

View File

@@ -52,13 +52,14 @@ enum SingletonTypeSynthesizer {
_rawUnsafeContinuation,
_void,
_word,
_swiftInt, // Swift.Int
_serialExecutor, // the '_Concurrency.SerialExecutor' protocol
_taskExecutor, // the '_Concurrency.TaskExecutor' protocol
_actor, // the '_Concurrency.Actor' protocol
_distributedActor, // the 'Distributed.DistributedActor' protocol
_swiftInt, // Swift.Int
_serialExecutor, // the '_Concurrency.SerialExecutor' protocol
_taskExecutor, // the '_Concurrency.TaskExecutor' protocol
_actor, // the '_Concurrency.Actor' protocol
_distributedActor, // the 'Distributed.DistributedActor' protocol
_unsafeRawBufferPointer, // UnsafeRawBufferPointer
_unconstrainedAny, // any ~Copyable & ~Escapable
_unconstrainedAny, // any ~Copyable & ~Escapable
_unsafeRawPointer, // UnsafeRawPointer
};
inline Type synthesizeType(SynthesisContext &SC,
SingletonTypeSynthesizer kind) {
@@ -93,6 +94,8 @@ inline Type synthesizeType(SynthesisContext &SC,
->getDeclaredInterfaceType();
case _unsafeRawBufferPointer:
return SC.Context.getUnsafeRawBufferPointerType();
case _unsafeRawPointer:
return SC.Context.getUnsafeRawPointerType();
case _copyable:
return SC.Context.getProtocol(KnownProtocolKind::Copyable)
->getDeclaredInterfaceType();

View File

@@ -1067,6 +1067,9 @@ public:
/// Return Builtin.ImplicitActor.
static SILType getBuiltinImplicitActorType(const ASTContext &ctx);
/// Return UnsafeRawPointer.
static SILType getUnsafeRawPointer(const ASTContext &ctx);
//
// Utilities for treating SILType as a pointer-like type.
//

View File

@@ -136,6 +136,11 @@ SILType SILType::getBuiltinImplicitActorType(const ASTContext &ctx) {
return getPrimitiveObjectType(ctx.TheImplicitActorType->getCanonicalType());
}
SILType SILType::getUnsafeRawPointer(const ASTContext &ctx) {
return getPrimitiveObjectType(
ctx.getUnsafeRawPointerType()->getCanonicalType());
}
bool SILType::isTrivial(const SILFunction &F) const {
auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this;