mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-20 12:31:40 +00:00
Emit an obnoxious warning message for bytecode that includes load/store
instructions that use indexing. Convert them transparently into a pair of instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3431 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
64339f681a
commit
352eef717d
@ -116,7 +116,8 @@ bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
|
|
||||||
|
|
||||||
bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
||||||
Instruction *&Res) {
|
Instruction *&Res,
|
||||||
|
BasicBlock *BB /*HACK*/) {
|
||||||
RawInst Raw;
|
RawInst Raw;
|
||||||
if (ParseRawInst(Buf, EndBuf, Raw))
|
if (ParseRawInst(Buf, EndBuf, Raw))
|
||||||
return true;
|
return true;
|
||||||
@ -388,9 +389,18 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Raw.Opcode == Instruction::Load) {
|
if (Raw.Opcode == Instruction::Load) {
|
||||||
assert(MemAccessInst::getIndexedType(Raw.Ty, Idx) &&
|
Value *Src = getValue(Raw.Ty, Raw.Arg1);
|
||||||
"Bad indices for Load!");
|
if (!Idx.empty()) {
|
||||||
Res = new LoadInst(getValue(Raw.Ty, Raw.Arg1), Idx);
|
cerr << "WARNING: Bytecode contains load instruction with indices. "
|
||||||
|
<< "Replacing with getelementptr/load pair\n";
|
||||||
|
assert(MemAccessInst::getIndexedType(Raw.Ty, Idx) &&
|
||||||
|
"Bad indices for Load!");
|
||||||
|
Src = new GetElementPtrInst(Src, Idx);
|
||||||
|
// FIXME: Remove this compatibility code and the BB parameter to this
|
||||||
|
// method.
|
||||||
|
BB->getInstList().push_back(cast<Instruction>(Src));
|
||||||
|
}
|
||||||
|
Res = new LoadInst(Src);
|
||||||
} else if (Raw.Opcode == Instruction::GetElementPtr)
|
} else if (Raw.Opcode == Instruction::GetElementPtr)
|
||||||
Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx);
|
Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx);
|
||||||
else
|
else
|
||||||
@ -429,10 +439,22 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type *ElType = StoreInst::getIndexedType(Raw.Ty, Idx);
|
Value *Ptr = getValue(Raw.Ty, Raw.Arg2);
|
||||||
if (ElType == 0) return true;
|
if (!Idx.empty()) {
|
||||||
Res = new StoreInst(getValue(ElType, Raw.Arg1), getValue(Raw.Ty, Raw.Arg2),
|
cerr << "WARNING: Bytecode contains load instruction with indices. "
|
||||||
Idx);
|
<< "Replacing with getelementptr/load pair\n";
|
||||||
|
|
||||||
|
const Type *ElType = StoreInst::getIndexedType(Raw.Ty, Idx);
|
||||||
|
if (ElType == 0) return true;
|
||||||
|
|
||||||
|
Ptr = new GetElementPtrInst(Ptr, Idx);
|
||||||
|
// FIXME: Remove this compatibility code and the BB parameter to this
|
||||||
|
// method.
|
||||||
|
BB->getInstList().push_back(cast<Instruction>(Ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
const Type *ValTy = cast<PointerType>(Ptr->getType())->getElementType();
|
||||||
|
Res = new StoreInst(getValue(ValTy, Raw.Arg1), Ptr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // end switch(Raw.Opcode)
|
} // end switch(Raw.Opcode)
|
||||||
|
@ -168,7 +168,8 @@ bool BytecodeParser::ParseBasicBlock(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
|
|
||||||
while (Buf < EndBuf) {
|
while (Buf < EndBuf) {
|
||||||
Instruction *Inst;
|
Instruction *Inst;
|
||||||
if (ParseInstruction(Buf, EndBuf, Inst)) {
|
if (ParseInstruction(Buf, EndBuf, Inst,
|
||||||
|
/*HACK*/BB)) {
|
||||||
delete BB;
|
delete BB;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,8 @@ private:
|
|||||||
bool ParseSymbolTable (const uchar *&Buf, const uchar *End, SymbolTable *);
|
bool ParseSymbolTable (const uchar *&Buf, const uchar *End, SymbolTable *);
|
||||||
bool ParseMethod (const uchar *&Buf, const uchar *End, Module *);
|
bool ParseMethod (const uchar *&Buf, const uchar *End, Module *);
|
||||||
bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&);
|
bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&);
|
||||||
bool ParseInstruction (const uchar *&Buf, const uchar *End, Instruction *&);
|
bool ParseInstruction (const uchar *&Buf, const uchar *End, Instruction *&,
|
||||||
|
BasicBlock *BB /*HACK*/);
|
||||||
bool ParseRawInst (const uchar *&Buf, const uchar *End, RawInst &);
|
bool ParseRawInst (const uchar *&Buf, const uchar *End, RawInst &);
|
||||||
|
|
||||||
bool ParseConstantPool(const uchar *&Buf, const uchar *EndBuf,
|
bool ParseConstantPool(const uchar *&Buf, const uchar *EndBuf,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user