Skip to content

Commit 09535c3

Browse files
committed
IRGen: Stub out TypeConverter support for PackType
1 parent aae0355 commit 09535c3

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

lib/IRGen/GenType.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ const TypeInfo *TypeConverter::convertType(CanType ty) {
20992099
case TypeKind::Error: {
21002100
// We might see error types if type checking has failed.
21012101
// Try to do something graceful and return an zero sized type.
2102-
auto &ctx = ty->getASTContext();
2102+
auto &ctx = IGM.Context;
21032103
return convertTupleType(cast<TupleType>(ctx.TheEmptyTupleType));
21042104
}
21052105
#define UNCHECKED_TYPE(id, parent) \
@@ -2172,7 +2172,6 @@ const TypeInfo *TypeConverter::convertType(CanType ty) {
21722172
case TypeKind::PrimaryArchetype:
21732173
case TypeKind::OpenedArchetype:
21742174
case TypeKind::OpaqueTypeArchetype:
2175-
case TypeKind::PackArchetype:
21762175
case TypeKind::ElementArchetype:
21772176
return convertArchetypeType(cast<ArchetypeType>(ty));
21782177
case TypeKind::Class:
@@ -2213,11 +2212,24 @@ const TypeInfo *TypeConverter::convertType(CanType ty) {
22132212
return convertBlockStorageType(cast<SILBlockStorageType>(ty));
22142213
case TypeKind::SILBox:
22152214
return convertBoxType(cast<SILBoxType>(ty));
2215+
case TypeKind::Pack:
2216+
return convertPackType(cast<PackType>(ty));
2217+
case TypeKind::PackArchetype: {
2218+
// FIXME: This is the wrong place for this kind of wrapping
2219+
SmallVector<Type> elts;
2220+
auto archetypeTy = cast<PackArchetypeType>(ty);
2221+
elts.push_back(PackExpansionType::get(archetypeTy,
2222+
archetypeTy->getReducedShape()));
2223+
return convertPackType(PackType::get(IGM.Context, elts));
2224+
}
2225+
case TypeKind::PackExpansion: {
2226+
// FIXME: This is the wrong place for this kind of wrapping
2227+
SmallVector<Type> elts;
2228+
elts.push_back(ty);
2229+
return convertPackType(PackType::get(IGM.Context, elts));
2230+
}
22162231
case TypeKind::SILToken:
22172232
llvm_unreachable("should not be asking for representation of a SILToken");
2218-
case TypeKind::Pack:
2219-
case TypeKind::PackExpansion:
2220-
llvm_unreachable("Unimplemented!");
22212233
}
22222234
}
22232235
llvm_unreachable("bad type kind");
@@ -2233,6 +2245,12 @@ const TypeInfo *TypeConverter::convertInOutType(InOutType *T) {
22332245
IGM.getPointerAlignment());
22342246
}
22352247

2248+
const TypeInfo *TypeConverter::convertPackType(PackType *pack) {
2249+
return new RawPointerTypeInfo(IGM.Int8PtrTy,
2250+
IGM.getPointerSize(),
2251+
IGM.getPointerAlignment());
2252+
}
2253+
22362254
/// Convert a reference storage type. The implementation here depends on the
22372255
/// underlying reference type. The type may be optional.
22382256
#define REF_STORAGE(Name, ...) \

lib/IRGen/GenType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class TypeConverter {
168168
const TypeInfo *convertProtocolCompositionType(ProtocolCompositionType *T);
169169
const TypeInfo *convertParameterizedProtocolType(ParameterizedProtocolType *T);
170170
const TypeInfo *convertExistentialType(ExistentialType *T);
171+
const TypeInfo *convertPackType(PackType *T);
171172
const LoadableTypeInfo *convertBuiltinNativeObject();
172173
const LoadableTypeInfo *convertBuiltinUnknownObject();
173174
const LoadableTypeInfo *convertBuiltinBridgeObject();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-ir -primary-file %s -enable-experimental-feature VariadicGenerics | %FileCheck %s
2+
3+
// Because of -enable-experimental-feature VariadicGenerics
4+
// REQUIRES: asserts
5+
6+
// REQUIRES: PTRSIZE=64
7+
8+
// CHECK-LABEL: define hidden swiftcc void @"$s26variadic_generic_functions2f11tyxxQp_tlF"(i8** noalias nocapture dereferenceable(8) %0, i64 %1, %swift.type* %T)
9+
func f1<T...>(t: T...) {}
10+
11+
// CHECK-LABEL: define hidden swiftcc void @"$s26variadic_generic_functions2f21t1uyxxQp_q_q_Qptr0_lF"(i8** noalias nocapture dereferenceable(8) %0, i8** noalias nocapture dereferenceable(8) %1, i64 %2, i64 %3, %swift.type* %T, %swift.type* %U)
12+
func f2<T..., U...>(t: T..., u: U...) {}
13+
14+
// CHECK-LABEL: define hidden swiftcc void @"$s26variadic_generic_functions2f31t1uyxxQp_q_q_Qptq_Rhzr0_lF"(i8** noalias nocapture dereferenceable(8) %0, i8** noalias nocapture dereferenceable(8) %1, i64 %2, %swift.type* %T, %swift.type* %U)
15+
func f3<T..., U...>(t: T..., u: U...) where ((T, U)...): Any {}

0 commit comments

Comments
 (0)