Add a Name parameter to two of the init methods of GetElementPointer to make the name setting more consistent.

llvm-svn: 51945
This commit is contained in:
Matthijs Kooijman 2008-06-04 16:14:12 +00:00
parent c0b54901f4
commit 76d8dec5db
2 changed files with 12 additions and 12 deletions

View File

@ -379,8 +379,8 @@ static inline const Type *checkType(const Type *Ty) {
/// ///
class GetElementPtrInst : public Instruction { class GetElementPtrInst : public Instruction {
GetElementPtrInst(const GetElementPtrInst &GEPI); GetElementPtrInst(const GetElementPtrInst &GEPI);
void init(Value *Ptr, Value* const *Idx, unsigned NumIdx); void init(Value *Ptr, Value* const *Idx, unsigned NumIdx, const std::string &Name);
void init(Value *Ptr, Value *Idx); void init(Value *Ptr, Value *Idx, const std::string &Name);
template<typename InputIterator> template<typename InputIterator>
void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd, void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
@ -392,14 +392,12 @@ class GetElementPtrInst : public Instruction {
if (NumIdx > 0) { if (NumIdx > 0) {
// This requires that the iterator points to contiguous memory. // This requires that the iterator points to contiguous memory.
init(Ptr, &*IdxBegin, NumIdx); // FIXME: for the general case init(Ptr, &*IdxBegin, NumIdx, Name); // FIXME: for the general case
// we have to build an array here // we have to build an array here
} }
else { else {
init(Ptr, 0, NumIdx); init(Ptr, 0, NumIdx, Name);
} }
setName(Name);
} }
/// getIndexedType - Returns the type of the element that would be loaded with /// getIndexedType - Returns the type of the element that would be loaded with

View File

@ -992,20 +992,24 @@ static unsigned retrieveAddrSpace(const Value *Val) {
return cast<PointerType>(Val->getType())->getAddressSpace(); return cast<PointerType>(Val->getType())->getAddressSpace();
} }
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) { void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx, const std::string &Name) {
assert(NumOperands == 1+NumIdx && "NumOperands not initialized?"); assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
Use *OL = OperandList; Use *OL = OperandList;
OL[0] = Ptr; OL[0] = Ptr;
for (unsigned i = 0; i != NumIdx; ++i) for (unsigned i = 0; i != NumIdx; ++i)
OL[i+1] = Idx[i]; OL[i+1] = Idx[i];
setName(Name);
} }
void GetElementPtrInst::init(Value *Ptr, Value *Idx) { void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) {
assert(NumOperands == 2 && "NumOperands not initialized?"); assert(NumOperands == 2 && "NumOperands not initialized?");
Use *OL = OperandList; Use *OL = OperandList;
OL[0] = Ptr; OL[0] = Ptr;
OL[1] = Idx; OL[1] = Idx;
setName(Name);
} }
GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
@ -1026,8 +1030,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
GetElementPtr, GetElementPtr,
OperandTraits<GetElementPtrInst>::op_end(this) - 2, OperandTraits<GetElementPtrInst>::op_end(this) - 2,
2, InBe) { 2, InBe) {
init(Ptr, Idx); init(Ptr, Idx, Name);
setName(Name);
} }
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
@ -1037,8 +1040,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
GetElementPtr, GetElementPtr,
OperandTraits<GetElementPtrInst>::op_end(this) - 2, OperandTraits<GetElementPtrInst>::op_end(this) - 2,
2, IAE) { 2, IAE) {
init(Ptr, Idx); init(Ptr, Idx, Name);
setName(Name);
} }
// getIndexedType - Returns the type of the element that would be loaded with // getIndexedType - Returns the type of the element that would be loaded with