diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-08 18:04:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-08 18:04:16 +0000 |
commit | 09bd0257623e115f06ccc4b732f30418c879ee19 (patch) | |
tree | c41690211a6a060e3ac6863403eaf762e5de88e7 /lib/Bytecode | |
parent | 0fe56f42ab5b1035b20714a55da5cebdd95a3c25 (diff) |
Remove a gross hack that was there to support bytecode files that are over a year old.
If you still have these suckers laying around, you have GOT to rebuild them. geeze.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r-- | lib/Bytecode/Reader/InstructionReader.cpp | 73 | ||||
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 2 | ||||
-rw-r--r-- | lib/Bytecode/Reader/ReaderInternals.h | 2 |
3 files changed, 12 insertions, 65 deletions
diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index 4ce940db99..2ae21683b5 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -116,8 +116,7 @@ bool BytecodeParser::ParseRawInst(const unsigned char *&Buf, bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, const unsigned char *EndBuf, - Instruction *&Res, - BasicBlock *BB /*HACK*/) { + Instruction *&Res) { RawInst Raw; if (ParseRawInst(Buf, EndBuf, Raw)) return true; @@ -359,14 +358,13 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, Res = new FreeInst(V); return false; - case Instruction::Load: case Instruction::GetElementPtr: { std::vector<Value*> Idx; if (!isa<PointerType>(Raw.Ty)) return true; const CompositeType *TopTy = dyn_cast<CompositeType>(Raw.Ty); switch (Raw.NumOperands) { - case 0: std::cerr << "Invalid load encountered!\n"; return true; + case 0: std::cerr << "Invalid getelementptr encountered!\n"; return true; case 1: break; case 2: if (!TopTy) return true; @@ -403,71 +401,20 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, break; } - if (Raw.Opcode == Instruction::Load) { - Value *Src = getValue(Raw.Ty, Raw.Arg1); - if (!Idx.empty()) { - std::cerr << "WARNING: Bytecode contains load instruction with indices." - << " Replacing with getelementptr/load pair\n"; - assert(GetElementPtrInst::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) - Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx); - else - abort(); + Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx); return false; } - case Instruction::Store: { - std::vector<Value*> Idx; - if (!isa<PointerType>(Raw.Ty)) return true; - const CompositeType *TopTy = dyn_cast<CompositeType>(Raw.Ty); - switch (Raw.NumOperands) { - case 0: - case 1: std::cerr << "Invalid store encountered!\n"; return true; - case 2: break; - case 3: - if (!TopTy) return true; - Idx.push_back(V = getValue(TopTy->getIndexType(), Raw.Arg3)); - if (!V) return true; - break; - default: - std::vector<unsigned> &args = *Raw.VarArgs; - const CompositeType *ElTy = TopTy; - unsigned i, E; - for (i = 0, E = args.size(); ElTy && i != E; ++i) { - Idx.push_back(V = getValue(ElTy->getIndexType(), args[i])); - if (!V) return true; - - const Type *ETy = GetElementPtrInst::getIndexedType(Raw.Ty, Idx, true); - ElTy = dyn_cast_or_null<CompositeType>(ETy); - } - if (i != E) - return true; // didn't use up all of the indices! + case Instruction::Load: + if (Raw.NumOperands != 1) return true; + if (!isa<PointerType>(Raw.Ty)) return true; + Res = new LoadInst(getValue(Raw.Ty, Raw.Arg1)); + return false; - delete Raw.VarArgs; - break; - } + case Instruction::Store: { + if (!isa<PointerType>(Raw.Ty) || Raw.NumOperands != 2) return true; Value *Ptr = getValue(Raw.Ty, Raw.Arg2); - if (!Idx.empty()) { - std::cerr << "WARNING: Bytecode contains load instruction with indices. " - << "Replacing with getelementptr/load pair\n"; - - const Type *ElType = GetElementPtrInst::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; diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 3076f2032c..8a56f228b4 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -222,7 +222,7 @@ bool BytecodeParser::ParseBasicBlock(const unsigned char *&Buf, while (Buf < EndBuf) { Instruction *Inst; - if (ParseInstruction(Buf, EndBuf, Inst, /*HACK*/BB)) { + if (ParseInstruction(Buf, EndBuf, Inst)) { delete BB; return true; } diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index 9044c0f6c5..a64794a701 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -137,7 +137,7 @@ private: bool ParseBasicBlock (const unsigned char *&Buf, const unsigned char *End, BasicBlock *&); bool ParseInstruction (const unsigned char *&Buf, const unsigned char *End, - Instruction *&, BasicBlock *BB /*HACK*/); + Instruction *&); bool ParseRawInst (const unsigned char *&Buf, const unsigned char *End, RawInst &); |