mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SILType] SILFunctionConventions API.
Separate formal lowered types from SIL types. The SIL type of an argument will depend on the SIL module's conventions. The module conventions are determined by the SIL stage and LangOpts. Almost NFC, but specialized manglings are broken incidentally as a result of fixes to the way passes handle book-keeping of aruments. The mangler is fixed in the subsequent commit. Otherwise, NFC is intended, but quite possible do to rewriting the logic in many places.
This commit is contained in:
@@ -35,9 +35,9 @@ using namespace Lowering;
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
SILGenFunction::SILGenFunction(SILGenModule &SGM, SILFunction &F)
|
||||
: SGM(SGM), F(F), StartOfPostmatter(F.end()), B(*this, createBasicBlock()),
|
||||
OpenedArchetypesTracker(F), CurrentSILLoc(F.getLocation()),
|
||||
Cleanups(*this) {
|
||||
: SGM(SGM), F(F), silConv(SGM.M), StartOfPostmatter(F.end()),
|
||||
B(*this, createBasicBlock()), OpenedArchetypesTracker(F),
|
||||
CurrentSILLoc(F.getLocation()), Cleanups(*this) {
|
||||
B.setCurrentDebugScope(F.getDebugScope());
|
||||
B.setOpenedArchetypesTracker(&OpenedArchetypesTracker);
|
||||
}
|
||||
@@ -540,6 +540,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
|
||||
auto UIApplicationMainFn = SGM.M.getOrCreateFunction(mainClass, mainRef,
|
||||
NotForDefinition);
|
||||
auto fnTy = UIApplicationMainFn->getLoweredFunctionType();
|
||||
SILFunctionConventions fnConv(fnTy, SGM.M);
|
||||
|
||||
// Get the class name as a string using NSStringFromClass.
|
||||
CanType mainClassTy = mainClass->getDeclaredInterfaceType()
|
||||
@@ -587,8 +588,8 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
|
||||
{}, metaTy);
|
||||
|
||||
// Fix up the string parameters to have the right type.
|
||||
SILType nameArgTy = fnTy->getSILArgumentType(3);
|
||||
assert(nameArgTy == fnTy->getSILArgumentType(2));
|
||||
SILType nameArgTy = fnConv.getSILArgumentType(3);
|
||||
assert(nameArgTy == fnConv.getSILArgumentType(2));
|
||||
auto managedName = ManagedValue::forUnmanaged(optName);
|
||||
SILValue nilValue;
|
||||
if (optName->getType() == nameArgTy) {
|
||||
@@ -607,7 +608,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
|
||||
}
|
||||
|
||||
// Fix up argv to have the right type.
|
||||
auto argvTy = fnTy->getSILArgumentType(1);
|
||||
auto argvTy = fnConv.getSILArgumentType(1);
|
||||
|
||||
SILType unwrappedTy = argvTy;
|
||||
if (Type innerTy = argvTy.getSwiftRValueType()->getAnyOptionalObjectType()){
|
||||
@@ -640,7 +641,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
|
||||
argc->getType(), {}, args);
|
||||
SILValue r = B.createIntegerLiteral(mainClass,
|
||||
SILType::getBuiltinIntegerType(32, ctx), 0);
|
||||
auto rType = F.getLoweredFunctionType()->getSingleResult().getSILType();
|
||||
auto rType = F.getConventions().getSingleSILResultType();
|
||||
if (r->getType() != rType)
|
||||
r = B.createStruct(mainClass, rType, r);
|
||||
|
||||
@@ -685,7 +686,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
|
||||
argc->getType(), {}, args);
|
||||
SILValue r = B.createIntegerLiteral(mainClass,
|
||||
SILType::getBuiltinIntegerType(32, getASTContext()), 0);
|
||||
auto rType = F.getLoweredFunctionType()->getSingleResult().getSILType();
|
||||
auto rType = F.getConventions().getSingleSILResultType();
|
||||
if (r->getType() != rType)
|
||||
r = B.createStruct(mainClass, rType, r);
|
||||
B.createReturn(mainClass, r);
|
||||
@@ -834,9 +835,9 @@ void SILGenFunction::emitCurryThunk(ValueDecl *vd,
|
||||
|
||||
SILValue toFn = getNextUncurryLevelRef(*this, vd, to, from.isDirectReference,
|
||||
curriedArgs, subs);
|
||||
SILType resultTy
|
||||
= SGM.getConstantType(from).castTo<SILFunctionType>()
|
||||
->getSingleResult().getSILType();
|
||||
SILFunctionConventions fromConv(
|
||||
SGM.getConstantType(from).castTo<SILFunctionType>(), SGM.M);
|
||||
SILType resultTy = fromConv.getSingleSILResultType();
|
||||
resultTy = F.mapTypeIntoContext(resultTy);
|
||||
auto toTy = toFn->getType();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user