|
45 | 45 |
|
46 | 46 | using namespace swift;
|
47 | 47 |
|
| 48 | +//===----------------------------------------------------------------------===// |
| 49 | +// ObjC -> Swift Bridging Cast Optimization |
| 50 | +//===----------------------------------------------------------------------===// |
| 51 | + |
48 | 52 | static SILFunction *
|
49 | 53 | getObjCToSwiftBridgingFunction(SILOptFunctionBuilder &funcBuilder,
|
50 | 54 | SILDynamicCastInst dynamicCast) {
|
@@ -358,6 +362,10 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
|
358 | 362 | return (newI) ? newI : AI;
|
359 | 363 | }
|
360 | 364 |
|
| 365 | +//===----------------------------------------------------------------------===// |
| 366 | +// Swift -> ObjC Bridging Cast Optimization |
| 367 | +//===----------------------------------------------------------------------===// |
| 368 | + |
361 | 369 | static bool canOptimizeCast(const swift::Type &BridgedTargetTy,
|
362 | 370 | swift::SILModule &M,
|
363 | 371 | swift::SILFunctionConventions &substConv) {
|
@@ -702,6 +710,10 @@ CastOptimizer::optimizeBridgedSwiftToObjCCast(SILDynamicCastInst dynamicCast) {
|
702 | 710 | return NewI;
|
703 | 711 | }
|
704 | 712 |
|
| 713 | +//===----------------------------------------------------------------------===// |
| 714 | +// Top Level Bridge Cast Optimization Entrypoint |
| 715 | +//===----------------------------------------------------------------------===// |
| 716 | + |
705 | 717 | /// Make use of the fact that some of these casts cannot fail. For
|
706 | 718 | /// example, if the ObjC type is exactly the expected _ObjectiveCType
|
707 | 719 | /// type, then it would always succeed for NSString, NSNumber, etc.
|
@@ -768,6 +780,10 @@ CastOptimizer::optimizeBridgedCasts(SILDynamicCastInst dynamicCast) {
|
768 | 780 | llvm_unreachable("Unknown kind of bridging");
|
769 | 781 | }
|
770 | 782 |
|
| 783 | +//===----------------------------------------------------------------------===// |
| 784 | +// Cast Optimizer Public API |
| 785 | +//===----------------------------------------------------------------------===// |
| 786 | + |
771 | 787 | SILInstruction *CastOptimizer::simplifyCheckedCastAddrBranchInst(
|
772 | 788 | CheckedCastAddrBranchInst *Inst) {
|
773 | 789 | if (auto *I = optimizeCheckedCastAddrBranchInst(Inst))
|
|
0 commit comments