Add mangling support for partial specializations.

This commit is contained in:
Roman Levenstein
2017-02-06 19:00:01 -08:00
parent 26c963f27b
commit 2b9444e03a
3 changed files with 89 additions and 13 deletions

View File

@@ -55,7 +55,7 @@ static void mangleSubstitution(Mangler &M, Substitution Sub) {
void GenericSpecializationMangler::mangleSpecialization() {
Mangler &M = getMangler();
// This is a full specialization.
SILFunctionType *FTy = Function->getLoweredFunctionType();
CanGenericSignature Sig = FTy->getGenericSignature();
@@ -73,6 +73,25 @@ void GenericSpecializationMangler::mangleSpecialization() {
assert(idx == Subs.size() && "subs not parallel to dependent types");
}
void PartialSpecializationMangler::mangleSpecialization() {
Mangler &M = getMangler();
// If the only change to the generic signature during specialization is
// addition of new same-type requirements, which happens in case of a
// full specialization, it would be enough to mangle only the substitutions.
//
// If the types of function arguments have not changed, but some new
// conformances were added to the generic parameters, e.g. in case of
// a pre-specialization, then it would be enough to mangle only the new
// generic signature.
//
// If the types of function arguments have changed as a result of a partial
// specialization, we need to mangle the entire new function type.
// This is a partial specialization.
M.mangleType(SpecializedFnTy, 0);
M.append("_");
}
//===----------------------------------------------------------------------===//
// Function Signature Optimizations
//===----------------------------------------------------------------------===//