Skip to content

Commit 1711ef2

Browse files
committed
[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.
1 parent 5cb2409 commit 1711ef2

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

include/swift/AST/ASTSynthesis.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ enum SingletonTypeSynthesizer {
5252
_rawUnsafeContinuation,
5353
_void,
5454
_word,
55-
_swiftInt, // Swift.Int
56-
_serialExecutor, // the '_Concurrency.SerialExecutor' protocol
57-
_taskExecutor, // the '_Concurrency.TaskExecutor' protocol
58-
_actor, // the '_Concurrency.Actor' protocol
59-
_distributedActor, // the 'Distributed.DistributedActor' protocol
55+
_swiftInt, // Swift.Int
56+
_serialExecutor, // the '_Concurrency.SerialExecutor' protocol
57+
_taskExecutor, // the '_Concurrency.TaskExecutor' protocol
58+
_actor, // the '_Concurrency.Actor' protocol
59+
_distributedActor, // the 'Distributed.DistributedActor' protocol
6060
_unsafeRawBufferPointer, // UnsafeRawBufferPointer
61-
_unconstrainedAny, // any ~Copyable & ~Escapable
61+
_unconstrainedAny, // any ~Copyable & ~Escapable
62+
_unsafeRawPointer, // UnsafeRawPointer
6263
};
6364
inline Type synthesizeType(SynthesisContext &SC,
6465
SingletonTypeSynthesizer kind) {
@@ -93,6 +94,8 @@ inline Type synthesizeType(SynthesisContext &SC,
9394
->getDeclaredInterfaceType();
9495
case _unsafeRawBufferPointer:
9596
return SC.Context.getUnsafeRawBufferPointerType();
97+
case _unsafeRawPointer:
98+
return SC.Context.getUnsafeRawPointerType();
9699
case _copyable:
97100
return SC.Context.getProtocol(KnownProtocolKind::Copyable)
98101
->getDeclaredInterfaceType();

include/swift/SIL/SILType.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,9 @@ class SILType {
10671067
/// Return Builtin.ImplicitActor.
10681068
static SILType getBuiltinImplicitActorType(const ASTContext &ctx);
10691069

1070+
/// Return UnsafeRawPointer.
1071+
static SILType getUnsafeRawPointer(const ASTContext &ctx);
1072+
10701073
//
10711074
// Utilities for treating SILType as a pointer-like type.
10721075
//

lib/SIL/IR/SILType.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ SILType SILType::getBuiltinImplicitActorType(const ASTContext &ctx) {
136136
return getPrimitiveObjectType(ctx.TheImplicitActorType->getCanonicalType());
137137
}
138138

139+
SILType SILType::getUnsafeRawPointer(const ASTContext &ctx) {
140+
return getPrimitiveObjectType(
141+
ctx.getUnsafeRawPointerType()->getCanonicalType());
142+
}
143+
139144
bool SILType::isTrivial(const SILFunction &F) const {
140145
auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this;
141146

0 commit comments

Comments
 (0)