@@ -8126,23 +8126,20 @@ class DynamicMethodBranchInst
81268126};
81278127
81288128// / The base class for cast instructions which are terminators.
8129- class CastBranchInstBase : public TermInst {
8129+ template < typename BaseTy> class CastBranchInstBase : public BaseTy {
81308130 std::array<SILSuccessor, 2 > DestBBs;
81318131
81328132public:
8133-
8133+ template < typename ... ArgTys>
81348134 CastBranchInstBase (SILInstructionKind K, SILDebugLocation DebugLoc,
81358135 SILBasicBlock *SuccessBB, SILBasicBlock *FailureBB,
8136- ProfileCounter Target1Count = ProfileCounter(),
8137- ProfileCounter Target2Count = ProfileCounter()) :
8138- TermInst (K, DebugLoc),
8139- DestBBs{{{this , SuccessBB, Target1Count},
8140- {this , FailureBB, Target2Count}}}
8141- {}
8136+ ProfileCounter Target1Count, ProfileCounter Target2Count,
8137+ ArgTys &&... args)
8138+ : BaseTy(K, DebugLoc, std::forward<ArgTys>(args)...),
8139+ DestBBs{{{this , SuccessBB, Target1Count},
8140+ {this , FailureBB, Target2Count}}} {}
81428141
8143- SuccessorListTy getSuccessors () {
8144- return DestBBs;
8145- }
8142+ TermInst::SuccessorListTy getSuccessors () { return DestBBs; }
81468143
81478144 SILBasicBlock *getSuccessBB () { return DestBBs[0 ]; }
81488145 const SILBasicBlock *getSuccessBB () const { return DestBBs[0 ]; }
@@ -8157,7 +8154,7 @@ class CastBranchInstBase : public TermInst {
81578154
81588155// / The base class for cast instructions which are terminators and have a
81598156// / CastConsumptionKind.
8160- class CastBranchWithConsumptionKindBase : public CastBranchInstBase {
8157+ class CastBranchWithConsumptionKindBase : public CastBranchInstBase <TermInst> {
81618158 CastConsumptionKind ConsumptionKind;
81628159
81638160public:
@@ -8250,11 +8247,10 @@ class AddrCastInstBase
82508247// / Perform a checked cast operation and branch on whether the cast succeeds.
82518248// / The success branch destination block receives the cast result as a BB
82528249// / argument.
8253- class CheckedCastBranchInst final :
8254- public UnaryInstructionWithTypeDependentOperandsBase<
8255- SILInstructionKind::CheckedCastBranchInst,
8256- CheckedCastBranchInst,
8257- CastBranchInstBase> {
8250+ class CheckedCastBranchInst final
8251+ : public UnaryInstructionWithTypeDependentOperandsBase<
8252+ SILInstructionKind::CheckedCastBranchInst, CheckedCastBranchInst,
8253+ CastBranchInstBase<OwnershipForwardingTermInst>> {
82588254 friend SILBuilder;
82598255
82608256 SILType DestLoweredTy;
@@ -8266,12 +8262,12 @@ class CheckedCastBranchInst final:
82668262 ArrayRef<SILValue> TypeDependentOperands,
82678263 SILType DestLoweredTy, CanType DestFormalTy,
82688264 SILBasicBlock *SuccessBB, SILBasicBlock *FailureBB,
8269- ProfileCounter Target1Count, ProfileCounter Target2Count)
8270- : UnaryInstructionWithTypeDependentOperandsBase(DebugLoc, Operand,
8271- TypeDependentOperands,
8272- SuccessBB, FailureBB, Target1Count, Target2Count) ,
8273- DestLoweredTy (DestLoweredTy ),
8274- DestFormalTy(DestFormalTy),
8265+ ProfileCounter Target1Count,
8266+ ProfileCounter Target2Count)
8267+ : UnaryInstructionWithTypeDependentOperandsBase(
8268+ DebugLoc, Operand, TypeDependentOperands, SuccessBB, FailureBB ,
8269+ Target1Count, Target2Count, Operand.getOwnershipKind() ),
8270+ DestLoweredTy (DestLoweredTy), DestFormalTy(DestFormalTy),
82758271 IsExact(IsExact) {}
82768272
82778273 static CheckedCastBranchInst *
@@ -8297,23 +8293,23 @@ class CheckedCastBranchInst final:
82978293class CheckedCastValueBranchInst final
82988294 : public UnaryInstructionWithTypeDependentOperandsBase<
82998295 SILInstructionKind::CheckedCastValueBranchInst,
8300- CheckedCastValueBranchInst,
8301- CastBranchInstBase> {
8296+ CheckedCastValueBranchInst, CastBranchInstBase<TermInst>> {
83028297 friend SILBuilder;
83038298
83048299 CanType SourceFormalTy;
83058300 SILType DestLoweredTy;
83068301 CanType DestFormalTy;
83078302
8308- CheckedCastValueBranchInst (SILDebugLocation DebugLoc,
8309- SILValue Operand, CanType SourceFormalTy,
8303+ CheckedCastValueBranchInst (SILDebugLocation DebugLoc, SILValue Operand,
8304+ CanType SourceFormalTy,
83108305 ArrayRef<SILValue> TypeDependentOperands,
83118306 SILType DestLoweredTy, CanType DestFormalTy,
83128307 SILBasicBlock *SuccessBB, SILBasicBlock *FailureBB)
8313- : UnaryInstructionWithTypeDependentOperandsBase(DebugLoc, Operand,
8314- TypeDependentOperands, SuccessBB, FailureBB),
8315- SourceFormalTy (SourceFormalTy),
8316- DestLoweredTy(DestLoweredTy), DestFormalTy(DestFormalTy) {}
8308+ : UnaryInstructionWithTypeDependentOperandsBase(
8309+ DebugLoc, Operand, TypeDependentOperands, SuccessBB, FailureBB,
8310+ ProfileCounter (), ProfileCounter()),
8311+ SourceFormalTy(SourceFormalTy), DestLoweredTy(DestLoweredTy),
8312+ DestFormalTy(DestFormalTy) {}
83178313
83188314 static CheckedCastValueBranchInst *
83198315 create (SILDebugLocation DebugLoc,
0 commit comments