Skip to content

Commit 67eef7c

Browse files
committed
Bridge getSwiftMutableSpanDecl() and isBuiltinType()
1 parent a4c794d commit 67eef7c

File tree

8 files changed

+25
-0
lines changed

8 files changed

+25
-0
lines changed

SwiftCompilerSources/Sources/AST/Type.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ extension TypeProperties {
190190
public var hasLocalArchetype: Bool { rawType.bridged.hasLocalArchetype() }
191191
public var isEscapable: Bool { rawType.bridged.isEscapable() }
192192
public var isNoEscape: Bool { rawType.bridged.isNoEscape() }
193+
public var isBuiltinType: Bool { rawType.bridged.isBuiltinType() }
193194
public var archetypeRequiresClass: Bool { rawType.bridged.archetypeRequiresClass() }
194195

195196
public var representationOfMetatype: AST.`Type`.MetatypeRepresentation {

SwiftCompilerSources/Sources/Optimizer/PassManager/Context.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ struct FunctionPassContext : MutatingContext {
326326
_bridged.getSwiftArrayDecl().getAs(NominalTypeDecl.self)
327327
}
328328

329+
var swiftMutableSpan: NominalTypeDecl {
330+
_bridged.getSwiftMutableSpanDecl().getAs(NominalTypeDecl.self)
331+
}
332+
329333
func loadFunction(name: StaticString, loadCalleesRecursively: Bool) -> Function? {
330334
return name.withUTF8Buffer { (nameBuffer: UnsafeBufferPointer<UInt8>) in
331335
let nameStr = BridgedStringRef(data: nameBuffer.baseAddress, count: nameBuffer.count)

include/swift/AST/ASTBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3105,6 +3105,7 @@ struct BridgedASTType {
31053105
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getBuiltinVectorElementType() const;
31063106
BRIDGED_INLINE bool isBuiltinFixedWidthInteger(SwiftInt width) const;
31073107
BRIDGED_INLINE bool isOptional() const;
3108+
BRIDGED_INLINE bool isBuiltinType() const;
31083109
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getNominalOrBoundGenericNominal() const;
31093110
BRIDGED_INLINE TraitResult canBeClass() const;
31103111
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getAnyNominal() const;

include/swift/AST/ASTBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,10 @@ bool BridgedASTType::isUnownedStorageType() const {
556556
return unbridged()->is<swift::UnownedStorageType>();
557557
}
558558

559+
bool BridgedASTType::isBuiltinType() const {
560+
return unbridged()->isBuiltinType();
561+
}
562+
559563
OptionalBridgedDeclObj BridgedASTType::getNominalOrBoundGenericNominal() const {
560564
return {unbridged()->getNominalOrBoundGenericNominal()};
561565
}

include/swift/AST/KnownStdlibTypes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ KNOWN_STDLIB_TYPE_DECL(InlineArray, NominalTypeDecl, 2)
103103

104104
KNOWN_STDLIB_TYPE_DECL(SwiftSetting, NominalTypeDecl, 0)
105105

106+
KNOWN_STDLIB_TYPE_DECL(MutableSpan, NominalTypeDecl, 1)
107+
106108
#undef KNOWN_STDLIB_TYPE_DECL

include/swift/AST/Types.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,9 @@ class alignas(1 << TypeAlignInBits) TypeBase
10541054
bool is##NAME();
10551055
#include "swift/AST/KnownStdlibTypes.def"
10561056

1057+
/// Check if this type is from the Builtin module.
1058+
bool isBuiltinType();
1059+
10571060
/// Check if this type is equal to Builtin.IntN.
10581061
bool isBuiltinIntegerType(unsigned bitWidth);
10591062

@@ -8143,6 +8146,10 @@ inline GenericTypeDecl *TypeBase::getAnyGeneric() {
81438146
return getCanonicalType().getAnyGeneric();
81448147
}
81458148

8149+
inline bool TypeBase::isBuiltinType() {
8150+
return isa<BuiltinType>(getCanonicalType());
8151+
}
8152+
81468153
inline bool TypeBase::isBuiltinIntegerType(unsigned n) {
81478154
if (auto intTy = dyn_cast<BuiltinIntegerType>(getCanonicalType()))
81488155
return intTy->getWidth().isFixedWidth()

include/swift/SILOptimizer/OptimizerBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ struct BridgedPassContext {
216216
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDomTree getDomTree() const;
217217
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedPostDomTree getPostDomTree() const;
218218
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getSwiftArrayDecl() const;
219+
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getSwiftMutableSpanDecl() const;
219220

220221
// AST
221222

include/swift/SILOptimizer/OptimizerBridgingImpl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ BridgedDeclObj BridgedPassContext::getSwiftArrayDecl() const {
219219
return {mod->getASTContext().getArrayDecl()};
220220
}
221221

222+
BridgedDeclObj BridgedPassContext::getSwiftMutableSpanDecl() const {
223+
swift::SILModule *mod = invocation->getPassManager()->getModule();
224+
return {mod->getASTContext().getMutableSpanDecl()};
225+
}
226+
222227
// AST
223228

224229
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE

0 commit comments

Comments
 (0)