From: Sanjoy Das Date: Wed, 4 Nov 2015 04:31:06 +0000 (+0000) Subject: [OperandBundles] Refactor; NFCI X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2d37340ead9438eb7a14170ca8c199e8d68b7825;p=oota-llvm.git [OperandBundles] Refactor; NFCI 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 --- diff --git a/include/llvm/IR/InstrTypes.h b/include/llvm/IR/InstrTypes.h index 19106114880..55f50d43b5f 100644 --- a/include/llvm/IR/InstrTypes.h +++ b/include/llvm/IR/InstrTypes.h @@ -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.