const vector<ConstPoolVal*> &Indices,
bool AllowStructLeaf = false);
- const vector<ConstPoolVal*>& getIndexVec() const { return indexVec; }
+ const vector<ConstPoolVal*> &getIndices() const { return indexVec; }
inline bool hasIndices() const { return !indexVec.empty(); }
- virtual Value* getPtrOperand() = 0;
+ virtual Value *getPtrOperand() = 0;
- virtual int getFirstOffsetIdx() const = 0;
+ virtual int getFirstOffsetIdx() const = 0;
};
//===----------------------------------------------------------------------===//
class LoadInst : public MemAccessInst {
- LoadInst(const LoadInst &LI) : MemAccessInst(LI.getType(), Load, LI.getIndexVec()) {
+ LoadInst(const LoadInst &LI) : MemAccessInst(LI.getType(), Load,
+ LI.getIndices()) {
Operands.reserve(LI.Operands.size());
for (unsigned i = 0, E = LI.Operands.size(); i != E; ++i)
Operands.push_back(Use(LI.Operands[i], this));
const string &Name = "");
LoadInst(Value *Ptr, const string &Name = "");
- virtual Instruction* clone() const { return new LoadInst(*this); }
- virtual const char* getOpcodeName() const { return "load"; }
- virtual Value* getPtrOperand() { return this->getOperand(0); }
- virtual int getFirstOffsetIdx() const { return (this->getNumOperands() > 1)? 1 : -1;}
+ virtual Instruction *clone() const { return new LoadInst(*this); }
+ virtual const char *getOpcodeName() const { return "load"; }
+ virtual Value *getPtrOperand() { return this->getOperand(0); }
+ virtual int getFirstOffsetIdx() const { return (this->getNumOperands() > 1)? 1 : -1; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const LoadInst *) { return true; }
//===----------------------------------------------------------------------===//
class StoreInst : public MemAccessInst {
- StoreInst(const StoreInst &SI) : MemAccessInst(SI.getType(), Store, SI.getIndexVec()) {
+ StoreInst(const StoreInst &SI) : MemAccessInst(SI.getType(), Store,
+ SI.getIndices()) {
Operands.reserve(SI.Operands.size());
for (unsigned i = 0, E = SI.Operands.size(); i != E; ++i)
Operands.push_back(Use(SI.Operands[i], this));
virtual const char *getOpcodeName() const { return "store"; }
virtual bool hasSideEffects() const { return true; }
- virtual Value* getPtrOperand() { return this->getOperand(1); }
+ virtual Value *getPtrOperand() { return this->getOperand(1); }
virtual int getFirstOffsetIdx() const { return (this->getNumOperands() > 2)? 2 : -1;}
// Methods for support type inquiry through isa, cast, and dyn_cast:
class GetElementPtrInst : public MemAccessInst {
GetElementPtrInst(const GetElementPtrInst &EPI)
- : MemAccessInst(EPI.getType(), GetElementPtr, EPI.getIndexVec()) {
+ : MemAccessInst(EPI.getType(), GetElementPtr, EPI.getIndices()) {
Operands.reserve(EPI.Operands.size());
for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i)
Operands.push_back(Use(EPI.Operands[i], this));
const string &Name = "");
virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
virtual const char *getOpcodeName() const { return "getelementptr"; }
- virtual Value* getPtrOperand() { return this->getOperand(0); }
+ virtual Value *getPtrOperand() { return this->getOperand(0); }
virtual int getFirstOffsetIdx() const { return (this->getNumOperands() > 1)? 1 : -1;}
inline bool isArraySelector() const { return !isStructSelector(); }
// Initialize return values from the incoming instruction
Value* ptrVal = getElemInst->getPtrOperand();
- chainIdxVec = getElemInst->getIndexVec(); // copies index vector values
+ chainIdxVec = getElemInst->getIndices(); // copies index vector values
// Now chase the chain of getElementInstr instructions, if any
InstrTreeNode* ptrChild = getElemInstrNode->leftChild();
// Child is a GetElemPtr instruction
getElemInst = (MemAccessInst*)
((InstructionNode*) ptrChild)->getInstruction();
- const vector<ConstPoolVal*>& idxVec = getElemInst->getIndexVec();
+ const vector<ConstPoolVal*>& idxVec = getElemInst->getIndices();
// Get the pointer value out of ptrChild and *prepend* its index vector
ptrVal = getElemInst->getPtrOperand();
// Initialize return values from the incoming instruction
Value* ptrVal = getElemInst->getPtrOperand();
- chainIdxVec = getElemInst->getIndexVec(); // copies index vector values
+ chainIdxVec = getElemInst->getIndices(); // copies index vector values
// Now chase the chain of getElementInstr instructions, if any
InstrTreeNode* ptrChild = getElemInstrNode->leftChild();
// Child is a GetElemPtr instruction
getElemInst = (MemAccessInst*)
((InstructionNode*) ptrChild)->getInstruction();
- const vector<ConstPoolVal*>& idxVec = getElemInst->getIndexVec();
+ const vector<ConstPoolVal*>& idxVec = getElemInst->getIndices();
// Get the pointer value out of ptrChild and *prepend* its index vector
ptrVal = getElemInst->getPtrOperand();
// index array. If there are, check to see if removing them causes us to
// get to the right type...
//
- vector<ConstPoolVal*> Indices = GEP->getIndexVec();
+ vector<ConstPoolVal*> Indices = GEP->getIndices();
const Type *BaseType = GEP->getPtrOperand()->getType();
while (Indices.size() &&
// index array. If there are, check to see if removing them causes us to
// get to the right type...
//
- vector<ConstPoolVal*> Indices = GEP->getIndexVec();
+ vector<ConstPoolVal*> Indices = GEP->getIndices();
const Type *BaseType = GEP->getPtrOperand()->getType();
const Type *PVTy = cast<PointerType>(Ty)->getValueType();
Res = 0;
PRINT_PEEPHOLE2("gep-store:in", GEP, SI);
ReplaceInstWithInst(BB->getInstList(), BI,
SI = new StoreInst(Val, GEP->getPtrOperand(),
- GEP->getIndexVec()));
+ GEP->getIndices()));
PRINT_PEEPHOLE1("gep-store:out", SI);
return true;
}
PRINT_PEEPHOLE2("gep-load:in", GEP, LI);
ReplaceInstWithInst(BB->getInstList(), BI,
LI = new LoadInst(GEP->getPtrOperand(),
- GEP->getIndexVec()));
+ GEP->getIndices()));
PRINT_PEEPHOLE1("gep-load:out", LI);
return true;
}