summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/InstructionReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-15 06:13:09 +0000
committerChris Lattner <sabre@nondot.org>2004-01-15 06:13:09 +0000
commitfaaf32db19ec78dd0c01f071c93cf86ae857c524 (patch)
tree17998eab651141e2084c7c6901b82ef1702e75bd /llvm/lib/Bytecode/Reader/InstructionReader.cpp
parent1af644d9d6e2d7f3073d021aa2578966cc139e86 (diff)
downloadbcm5719-llvm-faaf32db19ec78dd0c01f071c93cf86ae857c524.tar.gz
bcm5719-llvm-faaf32db19ec78dd0c01f071c93cf86ae857c524.zip
Change all of the bytecode reader primitives to throw exceptions instead of
returning error codes. Because they don't return an error code, they can return the value read, which simplifies the code and makes the reader more efficient (yaay!). Also eliminate the special case code for little endian machines. llvm-svn: 10871
Diffstat (limited to 'llvm/lib/Bytecode/Reader/InstructionReader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/InstructionReader.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/llvm/lib/Bytecode/Reader/InstructionReader.cpp b/llvm/lib/Bytecode/Reader/InstructionReader.cpp
index 4beb2b0c11d..21a1490397a 100644
--- a/llvm/lib/Bytecode/Reader/InstructionReader.cpp
+++ b/llvm/lib/Bytecode/Reader/InstructionReader.cpp
@@ -36,9 +36,7 @@ namespace {
RawInst::RawInst(const unsigned char *&Buf, const unsigned char *EndBuf,
std::vector<unsigned> &Args) {
- unsigned Op, Typ;
- if (read(Buf, EndBuf, Op))
- throw std::string("Error reading from buffer.");
+ unsigned Op = read(Buf, EndBuf);
// bits Instruction format: Common to all formats
// --------------------------
@@ -85,25 +83,19 @@ RawInst::RawInst(const unsigned char *&Buf, const unsigned char *EndBuf,
break;
case 0:
Buf -= 4; // Hrm, try this again...
- if (read_vbr(Buf, EndBuf, Opcode))
- throw std::string("Error reading from buffer.");
+ Opcode = read_vbr_uint(Buf, EndBuf);
Opcode >>= 2;
- if (read_vbr(Buf, EndBuf, Type))
- throw std::string("Error reading from buffer.");
+ Type = read_vbr_uint(Buf, EndBuf);
- unsigned NumOperands;
- if (read_vbr(Buf, EndBuf, NumOperands))
- throw std::string("Error reading from buffer.");
+ unsigned NumOperands = read_vbr_uint(Buf, EndBuf);
Args.resize(NumOperands);
if (NumOperands == 0)
throw std::string("Zero-argument instruction found; this is invalid.");
for (unsigned i = 0; i != NumOperands; ++i)
- if (read_vbr(Buf, EndBuf, Args[i]))
- throw std::string("Error reading from buffer");
- if (align32(Buf, EndBuf))
- throw std::string("Unaligned bytecode buffer.");
+ Args[i] = read_vbr_uint(Buf, EndBuf);
+ align32(Buf, EndBuf);
break;
}
}
OpenPOWER on IntegriCloud