@@ -1009,6 +1009,19 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
1009
1009
node->getKind () <= SILNodeKind::Last_##ID; \
1010
1010
}
1011
1011
1012
+ // / Abstract base class which defines the source and destination operand numbers
1013
+ // / for copy-like instructions, like store, assign, copy_addr and cast
1014
+ // / instructions.
1015
+ class CopyLikeInstruction {
1016
+ public:
1017
+ enum {
1018
+ // / The source operand index.
1019
+ Src,
1020
+ // / The destination operand index.
1021
+ Dest
1022
+ };
1023
+ };
1024
+
1012
1025
// / Abstract base class used for isa checks on instructions to determine if they
1013
1026
// / forward ownership and to verify that the set of ownership instructions and
1014
1027
// / the ownership utilities stay in sync via assertions.
@@ -3823,7 +3836,8 @@ static_assert(2 == SILNode::NumStoreOwnershipQualifierBits, "Size mismatch");
3823
3836
// / StoreInst - Represents a store from a memory location.
3824
3837
class StoreInst
3825
3838
: public InstructionBase<SILInstructionKind::StoreInst,
3826
- NonValueInstruction> {
3839
+ NonValueInstruction>,
3840
+ public CopyLikeInstruction {
3827
3841
friend SILBuilder;
3828
3842
3829
3843
private:
@@ -3833,13 +3847,6 @@ class StoreInst
3833
3847
StoreOwnershipQualifier Qualifier);
3834
3848
3835
3849
public:
3836
- enum {
3837
- // / the value being stored
3838
- Src,
3839
- // / the lvalue being stored to
3840
- Dest
3841
- };
3842
-
3843
3850
SILValue getSrc () const { return Operands[Src].get (); }
3844
3851
SILValue getDest () const { return Operands[Dest].get (); }
3845
3852
@@ -3915,17 +3922,10 @@ inline auto BeginBorrowInst::getEndBorrows() const -> EndBorrowRange {
3915
3922
// / address. Must be paired with an end_borrow in its use-def list.
3916
3923
class StoreBorrowInst
3917
3924
: public InstructionBase<SILInstructionKind::StoreBorrowInst,
3918
- SingleValueInstruction> {
3925
+ SingleValueInstruction>,
3926
+ public CopyLikeInstruction {
3919
3927
friend class SILBuilder ;
3920
3928
3921
- public:
3922
- enum {
3923
- // / The source of the value being borrowed.
3924
- Src,
3925
- // / The destination of the borrowed value.
3926
- Dest
3927
- };
3928
-
3929
3929
private:
3930
3930
FixedOperandList<2 > Operands;
3931
3931
StoreBorrowInst (SILDebugLocation DebugLoc, SILValue Src, SILValue Dest);
@@ -4326,7 +4326,8 @@ static_assert(2 == SILNode::NumAssignOwnershipQualifierBits, "Size mismatch");
4326
4326
4327
4327
template <SILInstructionKind Kind, int NumOps>
4328
4328
class AssignInstBase
4329
- : public InstructionBase<Kind, NonValueInstruction> {
4329
+ : public InstructionBase<Kind, NonValueInstruction>,
4330
+ public CopyLikeInstruction {
4330
4331
4331
4332
protected:
4332
4333
FixedOperandList<NumOps> Operands;
@@ -4337,13 +4338,6 @@ class AssignInstBase
4337
4338
Operands (this , std::forward<T>(args)...) { }
4338
4339
4339
4340
public:
4340
- enum {
4341
- // / the value being stored
4342
- Src,
4343
- // / the lvalue being stored to
4344
- Dest
4345
- };
4346
-
4347
4341
SILValue getSrc () const { return Operands[Src].get (); }
4348
4342
SILValue getDest () const { return Operands[Dest].get (); }
4349
4343
@@ -4663,18 +4657,10 @@ class Store##Name##Inst \
4663
4657
// / but a copy instruction must be used for address-only types.
4664
4658
class CopyAddrInst
4665
4659
: public InstructionBase<SILInstructionKind::CopyAddrInst,
4666
- NonValueInstruction> {
4660
+ NonValueInstruction>,
4661
+ public CopyLikeInstruction {
4667
4662
friend SILBuilder;
4668
4663
4669
- public:
4670
- enum {
4671
- // / The lvalue being loaded from.
4672
- Src,
4673
-
4674
- // / The lvalue being stored to.
4675
- Dest
4676
- };
4677
-
4678
4664
private:
4679
4665
FixedOperandList<2 > Operands;
4680
4666
@@ -8657,7 +8643,8 @@ template<SILInstructionKind Kind,
8657
8643
typename Base>
8658
8644
class AddrCastInstBase
8659
8645
: public InstructionBaseWithTrailingOperands<Kind, Derived,
8660
- TypesForAddrCasts<Base>> {
8646
+ TypesForAddrCasts<Base>>,
8647
+ public CopyLikeInstruction {
8661
8648
protected:
8662
8649
friend InstructionBaseWithTrailingOperands<Kind, Derived, Operand>;
8663
8650
@@ -8688,13 +8675,6 @@ class AddrCastInstBase
8688
8675
return this ->getAllOperands ().slice (2 );
8689
8676
}
8690
8677
8691
- enum {
8692
- // / the value being stored
8693
- Src,
8694
- // / the lvalue being stored to
8695
- Dest
8696
- };
8697
-
8698
8678
SILValue getSrc () const { return this ->getAllOperands ()[Src].get (); }
8699
8679
SILValue getDest () const { return this ->getAllOperands ()[Dest].get (); }
8700
8680
0 commit comments