Move the logic for folding type casts using statically known protocol conformances into DynamicCasts.cpp.

The logic for different special cases of type casting is spread over multiple places currently. This patch simply re-factors some of that  code (folding of of type casts using statically known protocol conformances) and moves it into one central place, which makes it easier to maintain. Plus, it allows other clients of DynamicCasts benefit from it as well, e.g. the inliner can use this now. NFC.

Swift SVN r25486
This commit is contained in:
Roman Levenstein
2015-02-23 21:30:48 +00:00
parent 3d23935d39
commit c97f748fb9
4 changed files with 154 additions and 107 deletions

View File

@@ -44,7 +44,9 @@ enum class DynamicCastFeasibility {
/// types should be unlowered formal types.
DynamicCastFeasibility classifyDynamicCast(Module *context,
CanType sourceType,
CanType targetType);
CanType targetType,
bool isSourceTypeExact = false,
bool isWholdModuleOpts = false);
SILValue emitSuccessfulScalarUnconditionalCast(SILBuilder &B, Module *M,
SILLocation loc, SILValue value,