diff options
author | Dan Gohman <gohman@apple.com> | 2008-09-16 01:01:33 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-09-16 01:01:33 +0000 |
commit | c5d2892e62203e4701bb7807af8f8ef121fab6fb (patch) | |
tree | b76149977721b2c48568b1048ed9fef3263127b7 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | f9081a2cd57a9999fcc48d35ac3456d67d1b2830 (diff) | |
download | bcm5719-llvm-c5d2892e62203e4701bb7807af8f8ef121fab6fb.tar.gz bcm5719-llvm-c5d2892e62203e4701bb7807af8f8ef121fab6fb.zip |
Re-enables the new vector select in the bitcode reader, by modifying the
bitcode reader/writer as follows:
- add and use new bitcode FUNC_CODE_INST_VSELECT to handle the llvm
select opcode using either i1 or [N x i1] as the selector.
- retain old BITCODE FUNC_CODE_INST_SELECT in the bitcode reader to
handle select on i1 for backwards compatibility with existing bitcode
files.
- re-enable the vector-select.ll test program.
Also, rename the recently added bitcode opcode FUNC_CODE_INST_VCMP to
FUNC_CODE_INST_CMP2 and make the bitcode writer use it to handle
fcmp/icmp on scalars or vectors. In the bitcode writer, use
FUNC_CODE_INST_CMP for vfcmp/vicmp only. In the bitcode reader, have
FUNC_CODE_INST_CMP handle icmp/fcmp returning bool, for backwards
compatibility with existing bitcode files.
Patch by Preston Gurd!
llvm-svn: 56233
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index d7f5b092353..975075c60e5 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1495,15 +1495,32 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { } case bitc::FUNC_CODE_INST_SELECT: { // SELECT: [opval, ty, opval, opval] + // obsolete form of select + // handles select i1 ... in old bitcode unsigned OpNum = 0; Value *TrueVal, *FalseVal, *Cond; if (getValueTypePair(Record, OpNum, NextValueNo, TrueVal) || getValue(Record, OpNum, TrueVal->getType(), FalseVal) || getValue(Record, OpNum, Type::Int1Ty, Cond)) return Error("Invalid SELECT record"); + + I = SelectInst::Create(Cond, TrueVal, FalseVal); + break; + } + + case bitc::FUNC_CODE_INST_VSELECT: {// VSELECT: [ty,opval,opval,predty,pred] + // new form of select + // handles select i1 or select [N x i1] + unsigned OpNum = 0; + Value *TrueVal, *FalseVal, *Cond; + if (getValueTypePair(Record, OpNum, NextValueNo, TrueVal) || + getValue(Record, OpNum, TrueVal->getType(), FalseVal) || + getValueTypePair(Record, OpNum, NextValueNo, Cond)) + return Error("Invalid SELECT record"); // select condition can be either i1 or [N x i1] - if (const VectorType* vector_type = dyn_cast<const VectorType>(Cond->getType())) { + if (const VectorType* vector_type = + dyn_cast<const VectorType>(Cond->getType())) { // expect <n x i1> if (vector_type->getElementType() != Type::Int1Ty) return Error("Invalid SELECT condition type"); @@ -1557,6 +1574,8 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { } case bitc::FUNC_CODE_INST_CMP: { // CMP: [opty, opval, opval, pred] + // VFCmp/VICmp + // or old form of ICmp/FCmp returning bool unsigned OpNum = 0; Value *LHS, *RHS; if (getValueTypePair(Record, OpNum, NextValueNo, LHS) || @@ -1574,16 +1593,15 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { I = new VICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); break; } - case bitc::FUNC_CODE_INST_VCMP: { // VCMP: [opty, opval, opval, pred] - // Fcmp/ICmp returning vector of bool + case bitc::FUNC_CODE_INST_CMP2: { // CMP2: [opty, opval, opval, pred] + // Fcmp/ICmp returning bool or vector of bool unsigned OpNum = 0; Value *LHS, *RHS; if (getValueTypePair(Record, OpNum, NextValueNo, LHS) || getValue(Record, OpNum, LHS->getType(), RHS) || OpNum+1 != Record.size()) - return Error("Invalid VCMP record"); + return Error("Invalid CMP2 record"); - // will always be vector if (LHS->getType()->isFPOrFPVector()) I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); else |