mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add a convenience function to map a CanType+StructDecl to the mapped
CanType. This doesn't really fit on SILBuilder, but until StructType and BoundGenericStructType are merged, this will do. Swift SVN r9336
This commit is contained in:
@@ -30,13 +30,6 @@ class SILBuilder {
|
|||||||
/// instruction is recorded in this list.
|
/// instruction is recorded in this list.
|
||||||
SmallVectorImpl<SILInstruction*> *InsertedInstrs = nullptr;
|
SmallVectorImpl<SILInstruction*> *InsertedInstrs = nullptr;
|
||||||
public:
|
public:
|
||||||
static SILType getTupleElementType(SILType Ty, unsigned EltNo,
|
|
||||||
SILValueCategory Cat);
|
|
||||||
static SILType getStructFieldType(SILType Ty, VarDecl *Field,
|
|
||||||
SILValueCategory Cat);
|
|
||||||
static SILType getPartialApplyResultType(SILType Ty, unsigned ArgCount,
|
|
||||||
SILModule &M);
|
|
||||||
|
|
||||||
SILBuilder(SILFunction &F) : F(F), BB(0) {}
|
SILBuilder(SILFunction &F) : F(F), BB(0) {}
|
||||||
|
|
||||||
explicit SILBuilder(SILInstruction *I,
|
explicit SILBuilder(SILInstruction *I,
|
||||||
@@ -118,6 +111,18 @@ public:
|
|||||||
return InsertedInstrs;
|
return InsertedInstrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// Type remapping
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
static SILType getTupleElementType(SILType Ty, unsigned EltNo,
|
||||||
|
SILValueCategory Cat);
|
||||||
|
static SILType getStructFieldType(SILType Ty, VarDecl *Field,
|
||||||
|
SILValueCategory Cat);
|
||||||
|
static CanType getStructFieldType(CanType Ty, VarDecl *Field);
|
||||||
|
static SILType getPartialApplyResultType(SILType Ty, unsigned ArgCount,
|
||||||
|
SILModule &M);
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// CFG Manipulation
|
// CFG Manipulation
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ using namespace swift;
|
|||||||
// SILBuilder Implementation
|
// SILBuilder Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
CanType SILBuilder::getStructFieldType(CanType Ty, VarDecl *Field) {
|
||||||
|
return Ty->getTypeOfMember(Field->getModuleContext(), Field, nullptr)
|
||||||
|
->getCanonicalType();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SILType SILBuilder::getTupleElementType(SILType Ty, unsigned EltNo,
|
SILType SILBuilder::getTupleElementType(SILType Ty, unsigned EltNo,
|
||||||
SILValueCategory Cat) {
|
SILValueCategory Cat) {
|
||||||
TupleType *TT = Ty.getAs<TupleType>();
|
TupleType *TT = Ty.getAs<TupleType>();
|
||||||
@@ -27,9 +33,7 @@ SILType SILBuilder::getTupleElementType(SILType Ty, unsigned EltNo,
|
|||||||
SILType SILBuilder::getStructFieldType(SILType Ty, VarDecl *Field,
|
SILType SILBuilder::getStructFieldType(SILType Ty, VarDecl *Field,
|
||||||
SILValueCategory Cat) {
|
SILValueCategory Cat) {
|
||||||
assert(Field->getDeclContext() == Ty.getStructOrBoundGenericStruct());
|
assert(Field->getDeclContext() == Ty.getStructOrBoundGenericStruct());
|
||||||
auto FieldTy = Ty.getSwiftRValueType()
|
auto FieldTy = getStructFieldType(Ty.getSwiftRValueType(), Field);
|
||||||
->getTypeOfMember(Field->getModuleContext(), Field, nullptr)
|
|
||||||
->getCanonicalType();
|
|
||||||
return SILType::getPrimitiveType(FieldTy, Cat);
|
return SILType::getPrimitiveType(FieldTy, Cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user