aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-05 05:54:46 +0000
committerChris Lattner <sabre@nondot.org>2009-10-05 05:54:46 +0000
commit82cdc06a6626e9a9fae300fafaeae9702ffb3808 (patch)
tree4ed7b0bdfe761ae52997a152437d00ddaae10360 /lib/Bitcode
parent4509b017dfea39a23da470417d3abbeab298b79f (diff)
downloadexternal_llvm-82cdc06a6626e9a9fae300fafaeae9702ffb3808.zip
external_llvm-82cdc06a6626e9a9fae300fafaeae9702ffb3808.tar.gz
external_llvm-82cdc06a6626e9a9fae300fafaeae9702ffb3808.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp14
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp8
2 files changed, 10 insertions, 12 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index fe0366f..50fc78c 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/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);
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 5857c59..ae269df 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -729,18 +729,16 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
Code = bitc::CST_CODE_FLOAT;
const Type *Ty = CFP->getType();
- if (Ty == Type::getFloatTy(Ty->getContext()) ||
- Ty == Type::getDoubleTy(Ty->getContext())) {
+ if (Ty->isFloatTy() || Ty->isDoubleTy()) {
Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
- } else if (Ty == Type::getX86_FP80Ty(Ty->getContext())) {
+ } else if (Ty->isX86_FP80Ty()) {
// api needed to prevent premature destruction
// bits are not in the same order as a normal i80 APInt, compensate.
APInt api = CFP->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();
Record.push_back((p[1] << 48) | (p[0] >> 16));
Record.push_back(p[0] & 0xffffLL);
- } else if (Ty == Type::getFP128Ty(Ty->getContext()) ||
- Ty == Type::getPPC_FP128Ty(Ty->getContext())) {
+ } else if (Ty->isFP128Ty() || Ty->isPPC_FP128Ty()) {
APInt api = CFP->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();
Record.push_back(p[0]);