diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-05 05:54:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-05 05:54:46 +0000 |
commit | fdd87907185162d3ffec237c426530d63c23bcca (patch) | |
tree | 764fe48a8294ae462f454fb0fd7f82e4f03bacca /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 3a2e503e33efdbf723f95fc592fe62335248b078 (diff) | |
download | bcm5719-llvm-fdd87907185162d3ffec237c426530d63c23bcca.tar.gz bcm5719-llvm-fdd87907185162d3ffec237c426530d63c23bcca.zip |
strength reduce a ton of type equality tests to check the typeid (Through
the new predicates I added) instead of going through a context and doing a
pointer comparison. Besides being cheaper, this allows a smart compiler
to turn the if sequence into a switch.
llvm-svn: 83297
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index fe0366fb629..50fc78c1c78 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -342,7 +342,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) { resize(Idx + 1); if (Value *V = MDValuePtrs[Idx]) { - assert(V->getType() == Type::getMetadataTy(Context) && "Type mismatch in value table!"); + assert(V->getType()->isMetadataTy() && "Type mismatch in value table!"); return V; } @@ -808,7 +808,7 @@ bool BitcodeReader::ParseMetadata() { SmallVector<Value*, 8> Elts; for (unsigned i = 0; i != Size; i += 2) { const Type *Ty = getTypeByID(Record[i], false); - if (Ty == Type::getMetadataTy(Context)) + if (Ty->isMetadataTy()) Elts.push_back(MDValueList.getValueFwdRef(Record[i+1])); else if (Ty != Type::getVoidTy(Context)) Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty)); @@ -967,19 +967,19 @@ bool BitcodeReader::ParseConstants() { case bitc::CST_CODE_FLOAT: { // FLOAT: [fpval] if (Record.empty()) return Error("Invalid FLOAT record"); - if (CurTy == Type::getFloatTy(Context)) + if (CurTy->isFloatTy()) V = ConstantFP::get(Context, APFloat(APInt(32, (uint32_t)Record[0]))); - else if (CurTy == Type::getDoubleTy(Context)) + else if (CurTy->isDoubleTy()) V = ConstantFP::get(Context, APFloat(APInt(64, Record[0]))); - else if (CurTy == Type::getX86_FP80Ty(Context)) { + else if (CurTy->isX86_FP80Ty()) { // Bits are not stored the same way as a normal i80 APInt, compensate. uint64_t Rearrange[2]; Rearrange[0] = (Record[1] & 0xffffLL) | (Record[0] << 16); Rearrange[1] = Record[0] >> 48; V = ConstantFP::get(Context, APFloat(APInt(80, 2, Rearrange))); - } else if (CurTy == Type::getFP128Ty(Context)) + } else if (CurTy->isFP128Ty()) V = ConstantFP::get(Context, APFloat(APInt(128, 2, &Record[0]), true)); - else if (CurTy == Type::getPPC_FP128Ty(Context)) + else if (CurTy->isPPC_FP128Ty()) V = ConstantFP::get(Context, APFloat(APInt(128, 2, &Record[0]))); else V = UndefValue::get(CurTy); |