mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 03:32:10 +00:00
Add pointer indexing support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1460 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f7a551fd92
commit
b024ef5e62
@ -350,8 +350,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
case Instruction::GetElementPtr: {
|
case Instruction::GetElementPtr: {
|
||||||
vector<Value*> Idx;
|
vector<Value*> Idx;
|
||||||
if (!isa<PointerType>(Raw.Ty)) return failure(true);
|
if (!isa<PointerType>(Raw.Ty)) return failure(true);
|
||||||
const CompositeType *TopTy =
|
const CompositeType *TopTy = dyn_cast<CompositeType>(Raw.Ty);
|
||||||
dyn_cast<CompositeType>(cast<PointerType>(Raw.Ty)->getElementType());
|
|
||||||
|
|
||||||
switch (Raw.NumOperands) {
|
switch (Raw.NumOperands) {
|
||||||
case 0: cerr << "Invalid load encountered!\n"; return failure(true);
|
case 0: cerr << "Invalid load encountered!\n"; return failure(true);
|
||||||
@ -366,7 +365,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
Idx.push_back(V = getValue(TopTy->getIndexType(), Raw.Arg2));
|
Idx.push_back(V = getValue(TopTy->getIndexType(), Raw.Arg2));
|
||||||
if (!V) return failure(true);
|
if (!V) return failure(true);
|
||||||
|
|
||||||
const Type *ETy = MemAccessInst::getIndexedType(Raw.Ty, Idx, true);
|
const Type *ETy = MemAccessInst::getIndexedType(TopTy, Idx, true);
|
||||||
const CompositeType *ElTy = dyn_cast_or_null<CompositeType>(ETy);
|
const CompositeType *ElTy = dyn_cast_or_null<CompositeType>(ETy);
|
||||||
if (!ElTy) return failure(true);
|
if (!ElTy) return failure(true);
|
||||||
|
|
||||||
@ -404,8 +403,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
case Instruction::Store: {
|
case Instruction::Store: {
|
||||||
vector<Value*> Idx;
|
vector<Value*> Idx;
|
||||||
if (!isa<PointerType>(Raw.Ty)) return failure(true);
|
if (!isa<PointerType>(Raw.Ty)) return failure(true);
|
||||||
const CompositeType *TopTy =
|
const CompositeType *TopTy = dyn_cast<CompositeType>(Raw.Ty);
|
||||||
dyn_cast<CompositeType>(cast<PointerType>(Raw.Ty)->getElementType());
|
|
||||||
|
|
||||||
switch (Raw.NumOperands) {
|
switch (Raw.NumOperands) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -418,13 +416,18 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vector<unsigned> &args = *Raw.VarArgs;
|
vector<unsigned> &args = *Raw.VarArgs;
|
||||||
for (unsigned i = 0, E = args.size(); i != E; ++i) {
|
const CompositeType *ElTy = TopTy;
|
||||||
const Type *ETy = MemAccessInst::getIndexedType(Raw.Ty, Idx, true);
|
unsigned i, E;
|
||||||
const CompositeType *ElTy = dyn_cast_or_null<CompositeType>(ETy);
|
for (i = 0, E = args.size(); ElTy && i != E; ++i) {
|
||||||
if (!ElTy) return failure(true);
|
|
||||||
Idx.push_back(V = getValue(ElTy->getIndexType(), args[i]));
|
Idx.push_back(V = getValue(ElTy->getIndexType(), args[i]));
|
||||||
if (!V) return failure(true);
|
if (!V) return failure(true);
|
||||||
|
|
||||||
|
const Type *ETy = MemAccessInst::getIndexedType(Raw.Ty, Idx, true);
|
||||||
|
ElTy = dyn_cast_or_null<CompositeType>(ETy);
|
||||||
}
|
}
|
||||||
|
if (i != E)
|
||||||
|
return failure(true); // didn't use up all of the indices!
|
||||||
|
|
||||||
delete Raw.VarArgs;
|
delete Raw.VarArgs;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user