mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[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. llvm-svn: 249510
This commit is contained in:
parent
01d951e9b2
commit
a9789b67ff
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user