@@ -1823,6 +1823,49 @@ class InstructionBaseWithTrailingOperands
1823
1823
}
1824
1824
};
1825
1825
1826
+ // / A template base class for instructions that take no operands except
1827
+ // / for type-dependent operands. The operands are tail allocated after the
1828
+ // / instruction. Further trailing data can be allocated as well if
1829
+ // / TRAILING_TYPES are provided.
1830
+ template <SILInstructionKind Kind,
1831
+ typename Derived,
1832
+ typename Base,
1833
+ typename ... OtherTrailingTypes>
1834
+ class NullaryInstructionWithTypeDependentOperandsBase
1835
+ : public InstructionBaseWithTrailingOperands<Kind, Derived, Base,
1836
+ OtherTrailingTypes...> {
1837
+ protected:
1838
+ friend InstructionBaseWithTrailingOperands<Kind, Derived, Operand,
1839
+ OtherTrailingTypes...>;
1840
+
1841
+ using TrailingObjects =
1842
+ InstructionBaseWithTrailingOperands<Kind, Derived, Operand,
1843
+ OtherTrailingTypes...>;
1844
+
1845
+ template <typename ... Args>
1846
+ NullaryInstructionWithTypeDependentOperandsBase (SILDebugLocation debugLoc,
1847
+ ArrayRef<SILValue> typeDependentOperands,
1848
+ Args &&...args)
1849
+ : InstructionBaseWithTrailingOperands<Kind, Derived, Base,
1850
+ OtherTrailingTypes...>(
1851
+ typeDependentOperands,
1852
+ debugLoc,
1853
+ std::forward<Args>(args)...) {}
1854
+
1855
+ public:
1856
+ unsigned getNumTypeDependentOperands () const {
1857
+ return this ->getAllOperands ().size ();
1858
+ }
1859
+
1860
+ ArrayRef<Operand> getTypeDependentOperands () const {
1861
+ return this ->getAllOperands ();
1862
+ }
1863
+
1864
+ MutableArrayRef<Operand> getTypeDependentOperands () {
1865
+ return this ->getAllOperands ();
1866
+ }
1867
+ };
1868
+
1826
1869
// / A template base class for instructions that take a single regular SILValue
1827
1870
// / operand, a set of type dependent operands and has no result
1828
1871
// / or a single value result. The operands are tail allocated after the
@@ -2351,7 +2394,7 @@ class AllocRefDynamicInst final
2351
2394
// / is an address pointing to the contained element. The contained
2352
2395
// / element is uninitialized.
2353
2396
class AllocBoxInst final
2354
- : public InstructionBaseWithTrailingOperands <
2397
+ : public NullaryInstructionWithTypeDependentOperandsBase <
2355
2398
SILInstructionKind::AllocBoxInst,
2356
2399
AllocBoxInst, AllocationInst, char >
2357
2400
{
@@ -2392,14 +2435,6 @@ class AllocBoxInst final
2392
2435
Optional<SILDebugVariable> getVarInfo () const {
2393
2436
return VarInfo.get (getDecl (), getTrailingObjects<char >());
2394
2437
};
2395
-
2396
- ArrayRef<Operand> getTypeDependentOperands () const {
2397
- return getAllOperands ();
2398
- }
2399
-
2400
- MutableArrayRef<Operand> getTypeDependentOperands () {
2401
- return getAllOperands ();
2402
- }
2403
2438
};
2404
2439
2405
2440
// / This represents the allocation of a heap box for an existential container.
@@ -2408,7 +2443,7 @@ class AllocBoxInst final
2408
2443
// / is an address pointing to the contained element. The contained
2409
2444
// / value is uninitialized.
2410
2445
class AllocExistentialBoxInst final
2411
- : public InstructionBaseWithTrailingOperands <
2446
+ : public NullaryInstructionWithTypeDependentOperandsBase <
2412
2447
SILInstructionKind::AllocExistentialBoxInst,
2413
2448
AllocExistentialBoxInst, AllocationInst> {
2414
2449
friend SILBuilder;
@@ -2420,7 +2455,8 @@ class AllocExistentialBoxInst final
2420
2455
ArrayRef<ProtocolConformanceRef> Conformances,
2421
2456
ArrayRef<SILValue> TypeDependentOperands,
2422
2457
SILFunction *Parent)
2423
- : InstructionBaseWithTrailingOperands(TypeDependentOperands, DebugLoc,
2458
+ : NullaryInstructionWithTypeDependentOperandsBase(DebugLoc,
2459
+ TypeDependentOperands,
2424
2460
ExistentialType.getObjectType()),
2425
2461
ConcreteType (ConcreteType), Conformances(Conformances) {}
2426
2462
@@ -2437,14 +2473,6 @@ class AllocExistentialBoxInst final
2437
2473
ArrayRef<ProtocolConformanceRef> getConformances () const {
2438
2474
return Conformances;
2439
2475
}
2440
-
2441
- ArrayRef<Operand> getTypeDependentOperands () const {
2442
- return getAllOperands ();
2443
- }
2444
-
2445
- MutableArrayRef<Operand> getTypeDependentOperands () {
2446
- return getAllOperands ();
2447
- }
2448
2476
};
2449
2477
2450
2478
// / GenericSpecializationInformation - provides information about a generic
@@ -6660,28 +6688,19 @@ class SelectValueInst final
6660
6688
// / MetatypeInst - Represents the production of an instance of a given metatype
6661
6689
// / named statically.
6662
6690
class MetatypeInst final
6663
- : public InstructionBaseWithTrailingOperands <
6691
+ : public NullaryInstructionWithTypeDependentOperandsBase <
6664
6692
SILInstructionKind::MetatypeInst,
6665
6693
MetatypeInst, SingleValueInstruction> {
6666
6694
friend SILBuilder;
6667
6695
6668
6696
// / Constructs a MetatypeInst
6669
6697
MetatypeInst (SILDebugLocation DebugLoc, SILType Metatype,
6670
6698
ArrayRef<SILValue> TypeDependentOperands)
6671
- : InstructionBaseWithTrailingOperands(TypeDependentOperands, DebugLoc,
6672
- Metatype) {}
6699
+ : NullaryInstructionWithTypeDependentOperandsBase( DebugLoc,
6700
+ TypeDependentOperands, Metatype) {}
6673
6701
6674
6702
static MetatypeInst *create (SILDebugLocation DebugLoc, SILType Metatype,
6675
6703
SILFunction *F);
6676
-
6677
- public:
6678
- ArrayRef<Operand> getTypeDependentOperands () const {
6679
- return getAllOperands ();
6680
- }
6681
-
6682
- MutableArrayRef<Operand> getTypeDependentOperands () {
6683
- return getAllOperands ();
6684
- }
6685
6704
};
6686
6705
6687
6706
// / Represents loading a dynamic metatype from a value.
@@ -7029,7 +7048,7 @@ class ObjCSuperMethodInst
7029
7048
// / and a protocol method constant, extracts the implementation of that method
7030
7049
// / for the type.
7031
7050
class WitnessMethodInst final
7032
- : public InstructionBaseWithTrailingOperands <
7051
+ : public NullaryInstructionWithTypeDependentOperandsBase <
7033
7052
SILInstructionKind::WitnessMethodInst,
7034
7053
WitnessMethodInst, MethodInst> {
7035
7054
friend SILBuilder;
@@ -7040,8 +7059,8 @@ class WitnessMethodInst final
7040
7059
WitnessMethodInst (SILDebugLocation DebugLoc, CanType LookupType,
7041
7060
ProtocolConformanceRef Conformance, SILDeclRef Member,
7042
7061
SILType Ty, ArrayRef<SILValue> TypeDependentOperands)
7043
- : InstructionBaseWithTrailingOperands(TypeDependentOperands ,
7044
- DebugLoc , Ty, Member),
7062
+ : NullaryInstructionWithTypeDependentOperandsBase(DebugLoc ,
7063
+ TypeDependentOperands , Ty, Member),
7045
7064
LookupType (LookupType), Conformance(Conformance) {}
7046
7065
7047
7066
// / Create a witness method call of a protocol requirement, passing in a lookup
@@ -7068,14 +7087,6 @@ class WitnessMethodInst final
7068
7087
}
7069
7088
7070
7089
ProtocolConformanceRef getConformance () const { return Conformance; }
7071
-
7072
- ArrayRef<Operand> getTypeDependentOperands () const {
7073
- return getAllOperands ();
7074
- }
7075
-
7076
- MutableArrayRef<Operand> getTypeDependentOperands () {
7077
- return getAllOperands ();
7078
- }
7079
7090
};
7080
7091
7081
7092
// / Access allowed to the opened value by the open_existential_addr instruction.
@@ -7420,7 +7431,7 @@ class DeinitExistentialValueInst
7420
7431
// / the pack type parameters, and the requirements on the pack type
7421
7432
// / parameters.
7422
7433
class OpenPackElementInst final
7423
- : public InstructionBaseWithTrailingOperands <
7434
+ : public UnaryInstructionWithTypeDependentOperandsBase <
7424
7435
SILInstructionKind::OpenPackElementInst,
7425
7436
OpenPackElementInst,
7426
7437
SingleValueInstruction> {
@@ -7460,7 +7471,8 @@ class OpenPackElementInst final
7460
7471
GenericEnvironment *Env;
7461
7472
7462
7473
OpenPackElementInst (SILDebugLocation debugLoc,
7463
- ArrayRef<SILValue> allOperands,
7474
+ SILValue packIndexOperand,
7475
+ ArrayRef<SILValue> typeDependentOperands,
7464
7476
SILType type,
7465
7477
GenericEnvironment *env);
7466
7478
@@ -7481,14 +7493,6 @@ class OpenPackElementInst final
7481
7493
SILValue getIndexOperand () const {
7482
7494
return getAllOperands ()[0 ].get ();
7483
7495
}
7484
-
7485
- ArrayRef<Operand> getTypeDependentOperands () const {
7486
- return getAllOperands ().slice (1 );
7487
- }
7488
-
7489
- MutableArrayRef<Operand> getTypeDependentOperands () {
7490
- return getAllOperands ().slice (1 );
7491
- }
7492
7496
};
7493
7497
7494
7498
// / Projects the capture storage address from a @block_storage address.
0 commit comments