diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-03 17:17:02 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-03 17:17:02 +0000 |
commit | 9f132765a2d8277f8cc4a4053542b19940862aad (patch) | |
tree | c4f19727b85af36ced440a5ed4fa83958f49ab01 /lib/Bytecode/Reader/Reader.cpp | |
parent | 42ddd84addeabef697be2d2f7e33c8f8acb446d9 (diff) |
Support ICmp/FCmp constant expression reading and writing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index d294e9e025..9286279216 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -701,6 +701,8 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds, } case Instruction::ICmp: case Instruction::FCmp: + if (Oprnds.size() != 3) + error("Cmp instructions requires 3 operands"); // These instructions encode the comparison predicate as the 3rd operand. Result = CmpInst::create(Instruction::OtherOps(Opcode), static_cast<unsigned short>(Oprnds[2]), @@ -1351,6 +1353,16 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { ConstantExpr::getShuffleVector(ArgVec[0], ArgVec[1], ArgVec[2]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; + } else if (Opcode == Instruction::ICmp) { + if (ArgVec.size() != 2) + error("Invalid ICmp constant expr arguments"); + unsigned short pred = read_vbr_uint(); + return ConstantExpr::getICmp(pred, ArgVec[0], ArgVec[1]); + } else if (Opcode == Instruction::FCmp) { + if (ArgVec.size() != 2) + error("Invalid FCmp constant expr arguments"); + unsigned short pred = read_vbr_uint(); + return ConstantExpr::getFCmp(pred, ArgVec[0], ArgVec[1]); } else { // All other 2-operand expressions Constant* Result = ConstantExpr::get(Opcode, ArgVec[0], ArgVec[1]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); |