mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-23 00:20:25 +00:00
add direct support for making GEP instrs with one index
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21665 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -603,6 +603,13 @@ void GetElementPtrInst::init(Value *Ptr, Value *Idx0, Value *Idx1) {
|
||||
OL[2].init(Idx1, this);
|
||||
}
|
||||
|
||||
void GetElementPtrInst::init(Value *Ptr, Value *Idx) {
|
||||
NumOperands = 2;
|
||||
Use *OL = OperandList = new Use[2];
|
||||
OL[0].init(Ptr, this);
|
||||
OL[1].init(Idx, this);
|
||||
}
|
||||
|
||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
|
||||
const std::string &Name, Instruction *InBe)
|
||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
||||
@@ -619,6 +626,20 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
|
||||
init(Ptr, Idx);
|
||||
}
|
||||
|
||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
||||
const std::string &Name, Instruction *InBe)
|
||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx))),
|
||||
GetElementPtr, 0, 0, Name, InBe) {
|
||||
init(Ptr, Idx);
|
||||
}
|
||||
|
||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
||||
const std::string &Name, BasicBlock *IAE)
|
||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx))),
|
||||
GetElementPtr, 0, 0, Name, IAE) {
|
||||
init(Ptr, Idx);
|
||||
}
|
||||
|
||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
|
||||
const std::string &Name, Instruction *InBe)
|
||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
|
||||
@@ -700,6 +721,16 @@ const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, Value *Idx) {
|
||||
const PointerType *PTy = dyn_cast<PointerType>(Ptr);
|
||||
if (!PTy) return 0; // Type isn't a pointer type!
|
||||
|
||||
// Check the pointer index.
|
||||
if (!PTy->indexValid(Idx)) return 0;
|
||||
|
||||
return PTy;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// BinaryOperator Class
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user