[llvm] r252037 - [OperandBundles] Refactor; NFCI
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 3 20:31:07 PST 2015
Author: sanjoy
Date: Tue Nov 3 22:31:06 2015
New Revision: 252037
URL: http://llvm.org/viewvc/llvm-project?rev=252037&view=rev
Log:
[OperandBundles] Refactor; NFCI
Intended to make later changes simpler. Exposes
`getBundleOperandsStartIndex` and `getBundleOperandsEndIndex`, and uses
them for the computation in `getNumTotalBundleOperands`.
Modified:
llvm/trunk/include/llvm/IR/InstrTypes.h
Modified: llvm/trunk/include/llvm/IR/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/InstrTypes.h?rev=252037&r1=252036&r2=252037&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/IR/InstrTypes.h Tue Nov 3 22:31:06 2015
@@ -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.
More information about the llvm-commits
mailing list