Add convenience functions for creating inbounds GEPs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78695 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-08-11 17:57:01 +00:00
parent 7cd0118c36
commit e2574d3215
7 changed files with 164 additions and 6 deletions

View File

@ -493,6 +493,44 @@ public:
return new(2) GetElementPtrInst(Ptr, Idx, NameStr, InsertAtEnd);
}
/// Create an "inbounds" getelementptr. See the documentation for the
/// "inbounds" flag in LangRef.html for details.
template<typename InputIterator>
static GetElementPtrInst *CreateInBounds(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd,
const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
GetElementPtrInst *GEP = Create(Ptr, IdxBegin, IdxEnd,
NameStr, InsertBefore);
cast<GEPOperator>(GEP)->setIsInBounds(true);
return GEP;
}
template<typename InputIterator>
static GetElementPtrInst *CreateInBounds(Value *Ptr,
InputIterator IdxBegin,
InputIterator IdxEnd,
const Twine &NameStr,
BasicBlock *InsertAtEnd) {
GetElementPtrInst *GEP = Create(Ptr, IdxBegin, IdxEnd,
NameStr, InsertAtEnd);
cast<GEPOperator>(GEP)->setIsInBounds(true);
return GEP;
}
static GetElementPtrInst *CreateInBounds(Value *Ptr, Value *Idx,
const Twine &NameStr = "",
Instruction *InsertBefore = 0) {
GetElementPtrInst *GEP = Create(Ptr, Idx, NameStr, InsertBefore);
cast<GEPOperator>(GEP)->setIsInBounds(true);
return GEP;
}
static GetElementPtrInst *CreateInBounds(Value *Ptr, Value *Idx,
const Twine &NameStr,
BasicBlock *InsertAtEnd) {
GetElementPtrInst *GEP = Create(Ptr, Idx, NameStr, InsertAtEnd);
cast<GEPOperator>(GEP)->setIsInBounds(true);
return GEP;
}
virtual GetElementPtrInst *clone(LLVMContext &Context) const;
/// Transparently provide more efficient getOperand methods.