mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-26 05:27:43 +00:00
add a GEP helper function
llvm-svn: 36515
This commit is contained in:
parent
54544c8835
commit
9bfe8f4517
@ -441,6 +441,12 @@ public:
|
||||
/// zeros. If so, the result pointer and the first operand have the same
|
||||
/// value, just potentially different types.
|
||||
bool hasAllZeroIndices() const;
|
||||
|
||||
/// hasAllConstantIndices - Return true if all of the indices of this GEP are
|
||||
/// constant integers. If so, the result pointer and the first operand have
|
||||
/// a constant offset between them.
|
||||
bool hasAllConstantIndices() const;
|
||||
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static inline bool classof(const GetElementPtrInst *) { return true; }
|
||||
|
@ -1043,6 +1043,17 @@ bool GetElementPtrInst::hasAllZeroIndices() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// hasAllConstantIndices - Return true if all of the indices of this GEP are
|
||||
/// constant integers. If so, the result pointer and the first operand have
|
||||
/// a constant offset between them.
|
||||
bool GetElementPtrInst::hasAllConstantIndices() const {
|
||||
for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {
|
||||
if (!isa<ConstantInt>(getOperand(i)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ExtractElementInst Implementation
|
||||
|
Loading…
Reference in New Issue
Block a user