@@ -8126,23 +8126,20 @@ class DynamicMethodBranchInst
8126
8126
};
8127
8127
8128
8128
// / The base class for cast instructions which are terminators.
8129
- class CastBranchInstBase : public TermInst {
8129
+ template < typename BaseTy> class CastBranchInstBase : public BaseTy {
8130
8130
std::array<SILSuccessor, 2 > DestBBs;
8131
8131
8132
8132
public:
8133
-
8133
+ template < typename ... ArgTys>
8134
8134
CastBranchInstBase (SILInstructionKind K, SILDebugLocation DebugLoc,
8135
8135
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}}} {}
8142
8141
8143
- SuccessorListTy getSuccessors () {
8144
- return DestBBs;
8145
- }
8142
+ TermInst::SuccessorListTy getSuccessors () { return DestBBs; }
8146
8143
8147
8144
SILBasicBlock *getSuccessBB () { return DestBBs[0 ]; }
8148
8145
const SILBasicBlock *getSuccessBB () const { return DestBBs[0 ]; }
@@ -8157,7 +8154,7 @@ class CastBranchInstBase : public TermInst {
8157
8154
8158
8155
// / The base class for cast instructions which are terminators and have a
8159
8156
// / CastConsumptionKind.
8160
- class CastBranchWithConsumptionKindBase : public CastBranchInstBase {
8157
+ class CastBranchWithConsumptionKindBase : public CastBranchInstBase <TermInst> {
8161
8158
CastConsumptionKind ConsumptionKind;
8162
8159
8163
8160
public:
@@ -8250,11 +8247,10 @@ class AddrCastInstBase
8250
8247
// / Perform a checked cast operation and branch on whether the cast succeeds.
8251
8248
// / The success branch destination block receives the cast result as a BB
8252
8249
// / 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>> {
8258
8254
friend SILBuilder;
8259
8255
8260
8256
SILType DestLoweredTy;
@@ -8266,12 +8262,12 @@ class CheckedCastBranchInst final:
8266
8262
ArrayRef<SILValue> TypeDependentOperands,
8267
8263
SILType DestLoweredTy, CanType DestFormalTy,
8268
8264
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),
8275
8271
IsExact(IsExact) {}
8276
8272
8277
8273
static CheckedCastBranchInst *
@@ -8297,23 +8293,23 @@ class CheckedCastBranchInst final:
8297
8293
class CheckedCastValueBranchInst final
8298
8294
: public UnaryInstructionWithTypeDependentOperandsBase<
8299
8295
SILInstructionKind::CheckedCastValueBranchInst,
8300
- CheckedCastValueBranchInst,
8301
- CastBranchInstBase> {
8296
+ CheckedCastValueBranchInst, CastBranchInstBase<TermInst>> {
8302
8297
friend SILBuilder;
8303
8298
8304
8299
CanType SourceFormalTy;
8305
8300
SILType DestLoweredTy;
8306
8301
CanType DestFormalTy;
8307
8302
8308
- CheckedCastValueBranchInst (SILDebugLocation DebugLoc,
8309
- SILValue Operand, CanType SourceFormalTy,
8303
+ CheckedCastValueBranchInst (SILDebugLocation DebugLoc, SILValue Operand,
8304
+ CanType SourceFormalTy,
8310
8305
ArrayRef<SILValue> TypeDependentOperands,
8311
8306
SILType DestLoweredTy, CanType DestFormalTy,
8312
8307
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) {}
8317
8313
8318
8314
static CheckedCastValueBranchInst *
8319
8315
create (SILDebugLocation DebugLoc,
0 commit comments