[SIL] NFC: Remove TailAllocatedOperandList template
Please use InstructionBaseWithTrailingOperands template now. It is more type safe and more space efficient.
diff --git a/include/swift/SIL/SILValue.h b/include/swift/SIL/SILValue.h
index 44039a9..f66d8d4 100644
--- a/include/swift/SIL/SILValue.h
+++ b/include/swift/SIL/SILValue.h
@@ -412,7 +412,6 @@
friend class ValueBaseUseIterator;
friend class ValueUseIterator;
template <unsigned N> friend class FixedOperandList;
- template <unsigned N> friend class TailAllocatedOperandList;
friend class TrailingOperandsList;
};
@@ -590,176 +589,6 @@
const Operand &operator[](unsigned i) const { return asArray()[i]; }
};
-/// An operator list with a fixed number of known operands
-/// (possibly zero) and a dynamically-determined set of extra
-/// operands (also possibly zero). The number of dynamic operands
-/// is permanently set at initialization time.
-///
-/// 'N' is the number of static operands.
-///
-/// This class assumes that a number of bytes of extra storage have
-/// been allocated immediately after it. This means that this class
-/// must always be the final data member in a class.
-template <unsigned N> class TailAllocatedOperandList {
- unsigned NumExtra;
- Operand Buffer[N];
-
- TailAllocatedOperandList(const TailAllocatedOperandList &) = delete;
- TailAllocatedOperandList &operator=(const TailAllocatedOperandList &) =delete;
-
-public:
- /// Given the number of dynamic operands required, returns the
- /// number of bytes of extra storage to allocate.
- static size_t getExtraSize(unsigned numExtra) {
- return sizeof(Operand) * numExtra;
- }
-
- /// Initialize this operand list.
- ///
- /// The dynamic operands are actually out of order: logically they
- /// will placed after the fixed operands, not before them. But
- /// the variadic arguments have to come last.
- template <class... T>
- TailAllocatedOperandList(SILInstruction *user,
- ArrayRef<SILValue> dynamicArgs,
- T&&... fixedArgs)
- : NumExtra(dynamicArgs.size()),
- Buffer{ { user, std::forward<T>(fixedArgs) }... } {
- static_assert(sizeof...(fixedArgs) == N, "wrong number of initializers");
-
- Operand *dynamicSlot = Buffer + N;
- for (auto value : dynamicArgs) {
- new (dynamicSlot++) Operand(user, value);
- }
- }
-
- /// Initialize this operand list.
- ///
- /// The dynamic operands are actually out of order: logically they
- /// will placed after the fixed operands, not before them. But
- /// the variadic arguments have to come last.
- template <class... T>
- TailAllocatedOperandList(SILInstruction *user,
- ArrayRef<SILValue> dynamicArgs,
- ArrayRef<SILValue> additionalDynamicArgs,
- T&&... fixedArgs)
- : NumExtra(dynamicArgs.size() + additionalDynamicArgs.size()),
- Buffer{ { user, std::forward<T>(fixedArgs) }... } {
- static_assert(sizeof...(fixedArgs) == N, "wrong number of initializers");
-
- Operand *dynamicSlot = Buffer + N;
- for (auto value : dynamicArgs) {
- new (dynamicSlot++) Operand(user, value);
- }
-
- for (auto value : additionalDynamicArgs) {
- new (dynamicSlot++) Operand(user, value);
- }
- }
-
-
- ~TailAllocatedOperandList() {
- for (auto &op : getDynamicAsArray()) {
- op.~Operand();
- }
- }
-
- /// Returns the full list of operands.
- MutableArrayRef<Operand> asArray() {
- return MutableArrayRef<Operand>(Buffer, N+NumExtra);
- }
- ArrayRef<Operand> asArray() const {
- return ArrayRef<Operand>(Buffer, N+NumExtra);
- }
-
- /// Returns the full list of operand values.
- OperandValueArrayRef asValueArray() const {
- return OperandValueArrayRef(asArray());
- }
-
- /// Returns the list of the dynamic operands.
- MutableArrayRef<Operand> getDynamicAsArray() {
- return MutableArrayRef<Operand>(Buffer+N, NumExtra);
- }
- ArrayRef<Operand> getDynamicAsArray() const {
- return ArrayRef<Operand>(Buffer+N, NumExtra);
- }
-
- /// Returns the list of the dynamic operand values.
- OperandValueArrayRef getDynamicValuesAsArray() const {
- return OperandValueArrayRef(getDynamicAsArray());
- }
-
- unsigned size() const { return N+NumExtra; }
-
- /// Indexes into the full list of operands.
- Operand &operator[](unsigned i) { return asArray()[i]; }
- const Operand &operator[](unsigned i) const { return asArray()[i]; }
-};
-
-/// A specialization of TailAllocatedOperandList for zero static operands.
-template<> class TailAllocatedOperandList<0> {
- unsigned NumExtra;
- union { // suppress value semantics
- Operand Buffer[1];
- };
-
- TailAllocatedOperandList(const TailAllocatedOperandList &) = delete;
- TailAllocatedOperandList &operator=(const TailAllocatedOperandList &) =delete;
-
-public:
- static size_t getExtraSize(unsigned numExtra) {
- return sizeof(Operand) * (numExtra > 0 ? numExtra - 1 : 0);
- }
-
- TailAllocatedOperandList(SILInstruction *user, ArrayRef<SILValue> dynamicArgs)
- : NumExtra(dynamicArgs.size()) {
-
- Operand *dynamicSlot = Buffer;
- for (auto value : dynamicArgs) {
- new (dynamicSlot++) Operand(user, value);
- }
- }
-
- ~TailAllocatedOperandList() {
- for (auto &op : getDynamicAsArray()) {
- op.~Operand();
- }
- }
-
- /// Returns the full list of operands.
- MutableArrayRef<Operand> asArray() {
- return MutableArrayRef<Operand>(Buffer, NumExtra);
- }
- ArrayRef<Operand> asArray() const {
- return ArrayRef<Operand>(Buffer, NumExtra);
- }
-
- /// Returns the full list of operand values.
- OperandValueArrayRef asValueArray() const {
- return OperandValueArrayRef(asArray());
- }
-
- /// Returns the list of the dynamic operands.
- MutableArrayRef<Operand> getDynamicAsArray() {
- return MutableArrayRef<Operand>(Buffer, NumExtra);
- }
- ArrayRef<Operand> getDynamicAsArray() const {
- return ArrayRef<Operand>(Buffer, NumExtra);
- }
-
- /// Returns the list of the dynamic operand values.
- OperandValueArrayRef getDynamicValuesAsArray() const {
- return OperandValueArrayRef(getDynamicAsArray());
- }
-
- unsigned size() const { return NumExtra; }
-
- /// Indexes into the full list of operands.
- Operand &operator[](unsigned i) { return asArray()[i]; }
- const Operand &operator[](unsigned i) const { return asArray()[i]; }
-};
-
/// A helper class for initializing the list of trailing operands.
class TrailingOperandsList {
public: