@@ -412,7 +412,6 @@ class Operand {
412
412
friend class ValueBaseUseIterator ;
413
413
friend class ValueUseIterator ;
414
414
template <unsigned N> friend class FixedOperandList ;
415
- template <unsigned N> friend class TailAllocatedOperandList ;
416
415
friend class TrailingOperandsList ;
417
416
};
418
417
@@ -590,176 +589,6 @@ template <unsigned N> class FixedOperandList {
590
589
const Operand &operator [](unsigned i) const { return asArray ()[i]; }
591
590
};
592
591
593
- // / An operator list with a fixed number of known operands
594
- // / (possibly zero) and a dynamically-determined set of extra
595
- // / operands (also possibly zero). The number of dynamic operands
596
- // / is permanently set at initialization time.
597
- // /
598
- // / 'N' is the number of static operands.
599
- // /
600
- // / This class assumes that a number of bytes of extra storage have
601
- // / been allocated immediately after it. This means that this class
602
- // / must always be the final data member in a class.
603
- template <unsigned N> class TailAllocatedOperandList {
604
- unsigned NumExtra;
605
- Operand Buffer[N];
606
-
607
- TailAllocatedOperandList (const TailAllocatedOperandList &) = delete ;
608
- TailAllocatedOperandList &operator =(const TailAllocatedOperandList &) =delete ;
609
-
610
- public:
611
- // / Given the number of dynamic operands required, returns the
612
- // / number of bytes of extra storage to allocate.
613
- static size_t getExtraSize (unsigned numExtra) {
614
- return sizeof (Operand) * numExtra;
615
- }
616
-
617
- // / Initialize this operand list.
618
- // /
619
- // / The dynamic operands are actually out of order: logically they
620
- // / will placed after the fixed operands, not before them. But
621
- // / the variadic arguments have to come last.
622
- template <class ... T>
623
- TailAllocatedOperandList (SILInstruction *user,
624
- ArrayRef<SILValue> dynamicArgs,
625
- T&&... fixedArgs)
626
- : NumExtra(dynamicArgs.size()),
627
- Buffer{ { user, std::forward<T>(fixedArgs) }... } {
628
- static_assert (sizeof ...(fixedArgs) == N, " wrong number of initializers" );
629
-
630
- Operand *dynamicSlot = Buffer + N;
631
- for (auto value : dynamicArgs) {
632
- new (dynamicSlot++) Operand (user, value);
633
- }
634
- }
635
-
636
- // / Initialize this operand list.
637
- // /
638
- // / The dynamic operands are actually out of order: logically they
639
- // / will placed after the fixed operands, not before them. But
640
- // / the variadic arguments have to come last.
641
- template <class ... T>
642
- TailAllocatedOperandList (SILInstruction *user,
643
- ArrayRef<SILValue> dynamicArgs,
644
- ArrayRef<SILValue> additionalDynamicArgs,
645
- T&&... fixedArgs)
646
- : NumExtra(dynamicArgs.size() + additionalDynamicArgs.size()),
647
- Buffer{ { user, std::forward<T>(fixedArgs) }... } {
648
- static_assert (sizeof ...(fixedArgs) == N, " wrong number of initializers" );
649
-
650
- Operand *dynamicSlot = Buffer + N;
651
- for (auto value : dynamicArgs) {
652
- new (dynamicSlot++) Operand (user, value);
653
- }
654
-
655
- for (auto value : additionalDynamicArgs) {
656
- new (dynamicSlot++) Operand (user, value);
657
- }
658
- }
659
-
660
-
661
- ~TailAllocatedOperandList () {
662
- for (auto &op : getDynamicAsArray ()) {
663
- op.~Operand ();
664
- }
665
- }
666
-
667
- // / Returns the full list of operands.
668
- MutableArrayRef<Operand> asArray () {
669
- return MutableArrayRef<Operand>(Buffer, N+NumExtra);
670
- }
671
- ArrayRef<Operand> asArray () const {
672
- return ArrayRef<Operand>(Buffer, N+NumExtra);
673
- }
674
-
675
- // / Returns the full list of operand values.
676
- OperandValueArrayRef asValueArray () const {
677
- return OperandValueArrayRef (asArray ());
678
- }
679
-
680
- // / Returns the list of the dynamic operands.
681
- MutableArrayRef<Operand> getDynamicAsArray () {
682
- return MutableArrayRef<Operand>(Buffer+N, NumExtra);
683
- }
684
- ArrayRef<Operand> getDynamicAsArray () const {
685
- return ArrayRef<Operand>(Buffer+N, NumExtra);
686
- }
687
-
688
- // / Returns the list of the dynamic operand values.
689
- OperandValueArrayRef getDynamicValuesAsArray () const {
690
- return OperandValueArrayRef (getDynamicAsArray ());
691
- }
692
-
693
- unsigned size () const { return N+NumExtra; }
694
-
695
- // / Indexes into the full list of operands.
696
- Operand &operator [](unsigned i) { return asArray ()[i]; }
697
- const Operand &operator [](unsigned i) const { return asArray ()[i]; }
698
- };
699
-
700
- // / A specialization of TailAllocatedOperandList for zero static operands.
701
- template <> class TailAllocatedOperandList <0 > {
702
- unsigned NumExtra;
703
- union { // suppress value semantics
704
- Operand Buffer[1 ];
705
- };
706
-
707
- TailAllocatedOperandList (const TailAllocatedOperandList &) = delete ;
708
- TailAllocatedOperandList &operator =(const TailAllocatedOperandList &) =delete ;
709
-
710
- public:
711
- static size_t getExtraSize (unsigned numExtra) {
712
- return sizeof (Operand) * (numExtra > 0 ? numExtra - 1 : 0 );
713
- }
714
-
715
- TailAllocatedOperandList (SILInstruction *user, ArrayRef<SILValue> dynamicArgs)
716
- : NumExtra(dynamicArgs.size()) {
717
-
718
- Operand *dynamicSlot = Buffer;
719
- for (auto value : dynamicArgs) {
720
- new (dynamicSlot++) Operand (user, value);
721
- }
722
- }
723
-
724
- ~TailAllocatedOperandList () {
725
- for (auto &op : getDynamicAsArray ()) {
726
- op.~Operand ();
727
- }
728
- }
729
-
730
- // / Returns the full list of operands.
731
- MutableArrayRef<Operand> asArray () {
732
- return MutableArrayRef<Operand>(Buffer, NumExtra);
733
- }
734
- ArrayRef<Operand> asArray () const {
735
- return ArrayRef<Operand>(Buffer, NumExtra);
736
- }
737
-
738
- // / Returns the full list of operand values.
739
- OperandValueArrayRef asValueArray () const {
740
- return OperandValueArrayRef (asArray ());
741
- }
742
-
743
- // / Returns the list of the dynamic operands.
744
- MutableArrayRef<Operand> getDynamicAsArray () {
745
- return MutableArrayRef<Operand>(Buffer, NumExtra);
746
- }
747
- ArrayRef<Operand> getDynamicAsArray () const {
748
- return ArrayRef<Operand>(Buffer, NumExtra);
749
- }
750
-
751
- // / Returns the list of the dynamic operand values.
752
- OperandValueArrayRef getDynamicValuesAsArray () const {
753
- return OperandValueArrayRef (getDynamicAsArray ());
754
- }
755
-
756
- unsigned size () const { return NumExtra; }
757
-
758
- // / Indexes into the full list of operands.
759
- Operand &operator [](unsigned i) { return asArray ()[i]; }
760
- const Operand &operator [](unsigned i) const { return asArray ()[i]; }
761
- };
762
-
763
592
// / A helper class for initializing the list of trailing operands.
764
593
class TrailingOperandsList {
765
594
public:
0 commit comments