summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/InstructionReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-08 23:22:50 +0000
committerChris Lattner <sabre@nondot.org>2001-07-08 23:22:50 +0000
commit62ecb4a13712cd2e844d24cd07dc6497b234e458 (patch)
tree0edb8a7d2989da239a0419d384dd110f978a3eaf /llvm/lib/Bytecode/Reader/InstructionReader.cpp
parent31feae855069992ad3806d44873e6b54c2f88e3e (diff)
downloadbcm5719-llvm-62ecb4a13712cd2e844d24cd07dc6497b234e458.tar.gz
bcm5719-llvm-62ecb4a13712cd2e844d24cd07dc6497b234e458.zip
Implementation of Store & GetElementPtr
llvm-svn: 164
Diffstat (limited to 'llvm/lib/Bytecode/Reader/InstructionReader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/InstructionReader.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Reader/InstructionReader.cpp b/llvm/lib/Bytecode/Reader/InstructionReader.cpp
index 9dc5c6fc3da..3af40f2d813 100644
--- a/llvm/lib/Bytecode/Reader/InstructionReader.cpp
+++ b/llvm/lib/Bytecode/Reader/InstructionReader.cpp
@@ -242,7 +242,8 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
Res = new FreeInst(V);
return false;
- case Instruction::Load: {
+ case Instruction::Load:
+ case Instruction::GetElementPtr: {
vector<ConstPoolVal*> Idx;
switch (Raw.NumOperands) {
case 0: cerr << "Invalid load encountered!\n"; return true;
@@ -271,7 +272,39 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
delete Raw.VarArgs;
break;
}
- Res = new LoadInst(getValue(Raw.Ty, Raw.Arg1), Idx);
+ if (Raw.Opcode == Instruction::Load)
+ Res = new LoadInst(getValue(Raw.Ty, Raw.Arg1), Idx);
+ else if (Raw.Opcode == Instruction::GetElementPtr)
+ Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx);
+ else
+ abort();
+ return false;
+ }
+ case Instruction::Store: {
+ vector<ConstPoolVal*> Idx;
+ switch (Raw.NumOperands) {
+ case 0:
+ case 1: cerr << "Invalid store encountered!\n"; return true;
+ case 2: break;
+ case 3: V = getValue(Type::UByteTy, Raw.Arg3);
+ if (!V->isConstant()) return true;
+ Idx.push_back(V->castConstant());
+ break;
+ default:
+ vector<unsigned> &args = *Raw.VarArgs;
+ for (unsigned i = 0, E = args.size(); i != E; ++i) {
+ V = getValue(Type::UByteTy, args[i]);
+ if (!V->isConstant()) return true;
+ Idx.push_back(V->castConstant());
+ }
+ delete Raw.VarArgs;
+ break;
+ }
+
+ const Type *ElType = StoreInst::getIndexedType(Raw.Ty, Idx);
+ if (ElType == 0) return true;
+ Res = new StoreInst(getValue(ElType, Raw.Arg1), getValue(Raw.Ty, Raw.Arg2),
+ Idx);
return false;
}
} // end switch(Raw.Opcode)
OpenPOWER on IntegriCloud