mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Eliminated the MemAccessInst class, folding contents into GEP class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3488 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cc63f1c674
commit
3bb8ad27a8
@ -54,7 +54,7 @@ class Module;
|
|||||||
|
|
||||||
// Forward declare the intermediate types...
|
// Forward declare the intermediate types...
|
||||||
class TerminatorInst; class BinaryOperator;
|
class TerminatorInst; class BinaryOperator;
|
||||||
class AllocationInst; class MemAccessInst;
|
class AllocationInst;
|
||||||
|
|
||||||
|
|
||||||
#define DELEGATE(CLASS_TO_VISIT) \
|
#define DELEGATE(CLASS_TO_VISIT) \
|
||||||
@ -166,7 +166,7 @@ struct InstVisitor {
|
|||||||
RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); }
|
RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitLoadInst(LoadInst &I) { DELEGATE(Instruction); }
|
RetTy visitLoadInst(LoadInst &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitStoreInst(StoreInst &I) { DELEGATE(Instruction); }
|
RetTy visitStoreInst(StoreInst &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitGetElementPtrInst(GetElementPtrInst &I){ DELEGATE(MemAccessInst); }
|
RetTy visitGetElementPtrInst(GetElementPtrInst &I){ DELEGATE(Instruction); }
|
||||||
RetTy visitPHINode(PHINode &I) { DELEGATE(Instruction); }
|
RetTy visitPHINode(PHINode &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitCastInst(CastInst &I) { DELEGATE(Instruction); }
|
RetTy visitCastInst(CastInst &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitCallInst(CallInst &I) { DELEGATE(Instruction); }
|
RetTy visitCallInst(CallInst &I) { DELEGATE(Instruction); }
|
||||||
@ -179,7 +179,6 @@ struct InstVisitor {
|
|||||||
RetTy visitTerminatorInst(TerminatorInst &I) { DELEGATE(Instruction); }
|
RetTy visitTerminatorInst(TerminatorInst &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitBinaryOperator(BinaryOperator &I) { DELEGATE(Instruction); }
|
RetTy visitBinaryOperator(BinaryOperator &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitAllocationInst(AllocationInst &I) { DELEGATE(Instruction); }
|
RetTy visitAllocationInst(AllocationInst &I) { DELEGATE(Instruction); }
|
||||||
RetTy visitMemAccessInst (MemAccessInst &I) { DELEGATE(Instruction); }
|
|
||||||
|
|
||||||
// If the user wants a 'default' case, they can choose to override this
|
// If the user wants a 'default' case, they can choose to override this
|
||||||
// function. If this function is not overloaded in the users subclass, then
|
// function. If this function is not overloaded in the users subclass, then
|
||||||
|
@ -101,7 +101,7 @@ namespace {
|
|||||||
// getSubscriptedNode - Perform the basic getelementptr functionality that
|
// getSubscriptedNode - Perform the basic getelementptr functionality that
|
||||||
// must be factored out of gep, load and store while they are all MAI's.
|
// must be factored out of gep, load and store while they are all MAI's.
|
||||||
//
|
//
|
||||||
DSNode *getSubscriptedNode(MemAccessInst &MAI, DSNode *Ptr);
|
DSNode *getSubscriptedNode(GetElementPtrInst &GEP, DSNode *Ptr);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,16 +218,15 @@ DSNode *GraphBuilder::getLink(DSNode *Node, unsigned Link) {
|
|||||||
// getSubscriptedNode - Perform the basic getelementptr functionality that must
|
// getSubscriptedNode - Perform the basic getelementptr functionality that must
|
||||||
// be factored out of gep, load and store while they are all MAI's.
|
// be factored out of gep, load and store while they are all MAI's.
|
||||||
//
|
//
|
||||||
DSNode *GraphBuilder::getSubscriptedNode(MemAccessInst &MAI, DSNode *Ptr) {
|
DSNode *GraphBuilder::getSubscriptedNode(GetElementPtrInst &GEP, DSNode *Ptr) {
|
||||||
for (unsigned i = MAI.getFirstIndexOperandNumber(), e = MAI.getNumOperands();
|
for (unsigned i = 1, e = GEP.getNumOperands(); i != e; ++i)
|
||||||
i != e; ++i)
|
if (GEP.getOperand(i)->getType() == Type::UIntTy)
|
||||||
if (MAI.getOperand(i)->getType() == Type::UIntTy)
|
|
||||||
Ptr = getLink(Ptr, 0);
|
Ptr = getLink(Ptr, 0);
|
||||||
else if (MAI.getOperand(i)->getType() == Type::UByteTy)
|
else if (GEP.getOperand(i)->getType() == Type::UByteTy)
|
||||||
Ptr = getLink(Ptr, cast<ConstantUInt>(MAI.getOperand(i))->getValue());
|
Ptr = getLink(Ptr, cast<ConstantUInt>(GEP.getOperand(i))->getValue());
|
||||||
|
|
||||||
if (MAI.getFirstIndexOperandNumber() == MAI.getNumOperands())
|
if (GEP.getNumOperands() == 1)
|
||||||
Ptr = getLink(Ptr, 0); // All MAI's have an implicit 0 if nothing else.
|
Ptr = getLink(Ptr, 0); // All GEP's have an implicit 0 if nothing else.
|
||||||
|
|
||||||
return Ptr;
|
return Ptr;
|
||||||
}
|
}
|
||||||
|
@ -963,7 +963,8 @@ SetOperandsForMemInstr(vector<MachineInstr*>& mvec,
|
|||||||
const InstructionNode* vmInstrNode,
|
const InstructionNode* vmInstrNode,
|
||||||
const TargetMachine& target)
|
const TargetMachine& target)
|
||||||
{
|
{
|
||||||
MemAccessInst* memInst = (MemAccessInst*) vmInstrNode->getInstruction();
|
GetElementPtrInst* memInst =
|
||||||
|
cast<GetElementPtrInst>(vmInstrNode->getInstruction());
|
||||||
|
|
||||||
// Variables to hold the index vector and ptr value.
|
// Variables to hold the index vector and ptr value.
|
||||||
// The major work here is to extract these for all 3 instruction types
|
// The major work here is to extract these for all 3 instruction types
|
||||||
@ -982,7 +983,7 @@ SetOperandsForMemInstr(vector<MachineInstr*>& mvec,
|
|||||||
: vmInstrNode->leftChild());
|
: vmInstrNode->leftChild());
|
||||||
|
|
||||||
// Check if all indices are constant for this instruction
|
// Check if all indices are constant for this instruction
|
||||||
for (MemAccessInst::op_iterator OI=memInst->idx_begin(),OE=memInst->idx_end();
|
for (User::op_iterator OI=memInst->idx_begin(),OE=memInst->idx_end();
|
||||||
allConstantIndices && OI != OE; ++OI)
|
allConstantIndices && OI != OE; ++OI)
|
||||||
if (! isa<Constant>(*OI))
|
if (! isa<Constant>(*OI))
|
||||||
allConstantIndices = false;
|
allConstantIndices = false;
|
||||||
@ -1024,7 +1025,8 @@ SetMemOperands_Internal(vector<MachineInstr*>& mvec,
|
|||||||
bool allConstantIndices,
|
bool allConstantIndices,
|
||||||
const TargetMachine& target)
|
const TargetMachine& target)
|
||||||
{
|
{
|
||||||
MemAccessInst* memInst = (MemAccessInst*) vmInstrNode->getInstruction();
|
GetElementPtrInst* memInst =
|
||||||
|
cast<GetElementPtrInst>(vmInstrNode->getInstruction());
|
||||||
|
|
||||||
// Initialize so we default to storing the offset in a register.
|
// Initialize so we default to storing the offset in a register.
|
||||||
int64_t smallConstOffset = 0;
|
int64_t smallConstOffset = 0;
|
||||||
@ -1035,7 +1037,7 @@ SetMemOperands_Internal(vector<MachineInstr*>& mvec,
|
|||||||
// Check if there is an index vector and if so, compute the
|
// Check if there is an index vector and if so, compute the
|
||||||
// right offset for structures and for arrays
|
// right offset for structures and for arrays
|
||||||
//
|
//
|
||||||
if (idxVec.size() > 0)
|
if (!idxVec.empty())
|
||||||
{
|
{
|
||||||
const PointerType* ptrType = cast<PointerType>(ptrVal->getType());
|
const PointerType* ptrType = cast<PointerType>(ptrVal->getType());
|
||||||
|
|
||||||
|
@ -413,15 +413,9 @@ void MutateStructTypes::transformFunction(Function *m) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Instruction::Load:
|
case Instruction::Load:
|
||||||
assert(cast<MemAccessInst>(I).idx_begin() ==
|
|
||||||
cast<MemAccessInst>(I).idx_end() &&
|
|
||||||
"Indexing loads not supported!");
|
|
||||||
NewI = new LoadInst(ConvertValue(I.getOperand(0)));
|
NewI = new LoadInst(ConvertValue(I.getOperand(0)));
|
||||||
break;
|
break;
|
||||||
case Instruction::Store:
|
case Instruction::Store:
|
||||||
assert(cast<MemAccessInst>(I).idx_begin() ==
|
|
||||||
cast<MemAccessInst>(I).idx_end() &&
|
|
||||||
"Indexing loads not supported!");
|
|
||||||
NewI = new StoreInst(ConvertValue(I.getOperand(0)),
|
NewI = new StoreInst(ConvertValue(I.getOperand(0)),
|
||||||
ConvertValue(I.getOperand(1)));
|
ConvertValue(I.getOperand(1)));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user