mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-05 12:31:46 +00:00
Must generate an instruction for GetElementPtr if single user is not
a memory instruction! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1238 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aa12a78a36
commit
671b16d055
@ -1819,16 +1819,26 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
|||||||
case 56: // reg: GetElemPtrIdx(reg,reg)
|
case 56: // reg: GetElemPtrIdx(reg,reg)
|
||||||
if (subtreeRoot->parent() != NULL)
|
if (subtreeRoot->parent() != NULL)
|
||||||
{
|
{
|
||||||
// Check if the parent was an array access.
|
// If the parent was a memory operation and not an array access,
|
||||||
// If so, we still need to generate this instruction.
|
// the parent will fold this instruction in so generate nothing.
|
||||||
MemAccessInst* memInst = (MemAccessInst*)
|
//
|
||||||
subtreeRoot->getInstruction();
|
Instruction* parent =
|
||||||
const PointerType* ptrType =
|
cast<Instruction>(subtreeRoot->parent()->getValue());
|
||||||
(const PointerType*) memInst->getPtrOperand()->getType();
|
if (parent->getOpcode() == Instruction::Load ||
|
||||||
if (! ptrType->getValueType()->isArrayType())
|
parent->getOpcode() == Instruction::Store ||
|
||||||
{// we don't need a separate instr
|
parent->getOpcode() == Instruction::GetElementPtr)
|
||||||
numInstr = 0; // don't forward operand!
|
{
|
||||||
break;
|
// Check if the parent is an array access,
|
||||||
|
// If so, we still need to generate this instruction.
|
||||||
|
GetElementPtrInst* getElemInst =
|
||||||
|
cast<GetElementPtrInst>(subtreeRoot->getInstruction());
|
||||||
|
const PointerType* ptrType =
|
||||||
|
(const PointerType*) getElemInst->getPtrOperand()->getType();
|
||||||
|
if (! ptrType->getValueType()->isArrayType())
|
||||||
|
{// we don't need a separate instr
|
||||||
|
numInstr = 0; // don't forward operand!
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else in all other cases we need to a separate ADD instruction
|
// else in all other cases we need to a separate ADD instruction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user