[llvm] r249510 - [OperandBundles] Add an accessor to get an operand bundle by tag
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 19:39:24 PDT 2015
Author: sanjoy
Date: Tue Oct 6 21:39:24 2015
New Revision: 249510
URL: http://llvm.org/viewvc/llvm-project?rev=249510&view=rev
Log:
[OperandBundles] Add an accessor to get an operand bundle by tag
Not used at the moment, but will be used in a later change to
RewriteStatepointsForGC.
Modified:
llvm/trunk/include/llvm/IR/CallSite.h
llvm/trunk/include/llvm/IR/InstrTypes.h
Modified: llvm/trunk/include/llvm/IR/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/CallSite.h?rev=249510&r1=249509&r2=249510&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/CallSite.h (original)
+++ llvm/trunk/include/llvm/IR/CallSite.h Tue Oct 6 21:39:24 2015
@@ -333,6 +333,10 @@ public:
CALLSITE_DELEGATE_GETTER(getOperandBundle(Index));
}
+ Optional<OperandBundleUse> getOperandBundle(StringRef Name) const {
+ CALLSITE_DELEGATE_GETTER(getOperandBundle(Name));
+ }
+
#undef CALLSITE_DELEGATE_GETTER
#undef CALLSITE_DELEGATE_SETTER
Modified: llvm/trunk/include/llvm/IR/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/InstrTypes.h?rev=249510&r1=249509&r2=249510&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/IR/InstrTypes.h Tue Oct 6 21:39:24 2015
@@ -16,6 +16,7 @@
#ifndef LLVM_IR_INSTRTYPES_H
#define LLVM_IR_INSTRTYPES_H
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instruction.h"
@@ -1204,6 +1205,34 @@ public:
return OperandBundleUse(BOI->Tag->getKey(), Inputs);
}
+ /// \brief Return the number of operand bundles with the tag Name attached to
+ /// this instruction.
+ unsigned countOperandBundlesOfType(StringRef Name) const {
+ unsigned Count = 0;
+ for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i)
+ if (getOperandBundle(i).Tag == Name)
+ Count++;
+
+ return Count;
+ }
+
+ /// \brief Return an operand bundle by name, if present.
+ ///
+ /// It is an error to call this for operand bundle types that may have
+ /// multiple instances of them on the same instruction.
+ Optional<OperandBundleUse> getOperandBundle(StringRef Name) const {
+ assert(countOperandBundlesOfType(Name) < 2 && "Precondition violated!");
+
+ for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i) {
+ OperandBundleUse U = getOperandBundle(i);
+ if (U.Tag == Name)
+ return U;
+ }
+
+ return None;
+ }
+
+
protected:
/// \brief Used to keep track of an operand bundle. See the main comment on
/// OperandBundleUser above.
More information about the llvm-commits
mailing list