[OperandBundles] Refactor; NFCI
authorSanjoy Das <sanjoy@playingwithpointers.com>
Wed, 4 Nov 2015 04:31:06 +0000 (04:31 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Wed, 4 Nov 2015 04:31:06 +0000 (04:31 +0000)
Intended to make later changes simpler.  Exposes
`getBundleOperandsStartIndex` and `getBundleOperandsEndIndex`, and uses
them for the computation in `getNumTotalBundleOperands`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252037 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/InstrTypes.h

index 191061148800121a7f9d4366e892d7c3e91b5f08..55f50d43b5fe7ba1d69d6eb59cecc4a2b303a3c6 100644 (file)
@@ -1196,18 +1196,29 @@ public:
   /// \brief Return true if this User has any operand bundles.
   bool hasOperandBundles() const { return getNumOperandBundles() != 0; }
 
+  /// \brief Return the index of the first bundle operand in the Use array.
+  unsigned getBundleOperandsStartIndex() const {
+    assert(hasOperandBundles() && "Don't call otherwise!");
+    return bundle_op_info_begin()->Begin;
+  }
+
+  /// \brief Return the index of the last bundle operand in the Use array.
+  unsigned getBundleOperandsEndIndex() const {
+    assert(hasOperandBundles() && "Don't call otherwise!");
+    return bundle_op_info_end()[-1].End;
+  }
+
   /// \brief Return the total number operands (not operand bundles) used by
   /// every operand bundle in this OperandBundleUser.
   unsigned getNumTotalBundleOperands() const {
     if (!hasOperandBundles())
       return 0;
 
-    auto *Begin = bundle_op_info_begin();
-    auto *Back = bundle_op_info_end() - 1;
-
-    assert(Begin <= Back && "hasOperandBundles() returned true!");
+    unsigned Begin = getBundleOperandsStartIndex();
+    unsigned End = getBundleOperandsEndIndex();
 
-    return Back->End - Begin->Begin;
+    assert(Begin <= End && "Should be!");
+    return End - Begin;
   }
 
   /// \brief Return the operand bundle at a specific index.