Various cleanups and simplifications. This speeds up reading a bytecode file

Bill gave me from 8.69s to 6.90s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-10-08 21:18:57 +00:00
parent 7f58de2b99
commit 36392bc524
3 changed files with 57 additions and 61 deletions

View File

@@ -161,12 +161,12 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
delete PN;
return true;
case 2: PN->addIncoming(getValue(Raw->Ty, Raw->Arg1),
cast<BasicBlock>(getValue(Type::LabelTy,
cast<BasicBlock>(getValue(Type::LabelTyID,
Raw->Arg2)));
break;
default:
PN->addIncoming(getValue(Raw->Ty, Raw->Arg1),
cast<BasicBlock>(getValue(Type::LabelTy, Raw->Arg2)));
cast<BasicBlock>(getValue(Type::LabelTyID, Raw->Arg2)));
if (Raw->VarArgs->size() & 1) {
std::cerr << "PHI Node with ODD number of arguments!\n";
delete PN;
@@ -175,7 +175,7 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
std::vector<unsigned> &args = *Raw->VarArgs;
for (unsigned i = 0; i < args.size(); i+=2)
PN->addIncoming(getValue(Raw->Ty, args[i]),
cast<BasicBlock>(getValue(Type::LabelTy, args[i+1])));
cast<BasicBlock>(getValue(Type::LabelTyID, args[i+1])));
}
delete Raw->VarArgs;
break;
@@ -188,7 +188,7 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
case Instruction::Shr:
Res = new ShiftInst((Instruction::OtherOps)Raw->Opcode,
getValue(Raw->Ty, Raw->Arg1),
getValue(Type::UByteTy, Raw->Arg2));
getValue(Type::UByteTyID, Raw->Arg2));
return false;
case Instruction::Ret:
if (Raw->NumOperands == 0) {
@@ -200,12 +200,12 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
case Instruction::Br:
if (Raw->NumOperands == 1) {
Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTy,Raw->Arg1)));
Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTyID,Raw->Arg1)));
return false;
} else if (Raw->NumOperands == 3) {
Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTy, Raw->Arg1)),
cast<BasicBlock>(getValue(Type::LabelTy, Raw->Arg2)),
getValue(Type::BoolTy , Raw->Arg3));
Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTyID, Raw->Arg1)),
cast<BasicBlock>(getValue(Type::LabelTyID, Raw->Arg2)),
getValue(Type::BoolTyID , Raw->Arg3));
return false;
}
break;
@@ -213,7 +213,7 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
case Instruction::Switch: {
SwitchInst *I =
new SwitchInst(getValue(Raw->Ty, Raw->Arg1),
cast<BasicBlock>(getValue(Type::LabelTy, Raw->Arg2)));
cast<BasicBlock>(getValue(Type::LabelTyID, Raw->Arg2)));
Res = I;
if (Raw->NumOperands < 3) return false; // No destinations? Weird.
@@ -226,7 +226,7 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
std::vector<unsigned> &args = *Raw->VarArgs;
for (unsigned i = 0; i < args.size(); i += 2)
I->addCase(cast<Constant>(getValue(Raw->Ty, args[i])),
cast<BasicBlock>(getValue(Type::LabelTy, args[i+1])));
cast<BasicBlock>(getValue(Type::LabelTyID, args[i+1])));
delete Raw->VarArgs;
return false;
@@ -311,11 +311,11 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
if (!FTy->isVarArg()) {
if (Raw->NumOperands < 3) return true;
Normal = cast<BasicBlock>(getValue(Type::LabelTy, Raw->Arg2));
Normal = cast<BasicBlock>(getValue(Type::LabelTyID, Raw->Arg2));
if (Raw->NumOperands == 3)
Except = cast<BasicBlock>(getValue(Type::LabelTy, Raw->Arg3));
Except = cast<BasicBlock>(getValue(Type::LabelTyID, Raw->Arg3));
else {
Except = cast<BasicBlock>(getValue(Type::LabelTy, args[0]));
Except = cast<BasicBlock>(getValue(Type::LabelTyID, args[0]));
FunctionType::ParamTypes::const_iterator It = PL.begin();
for (unsigned i = 1; i < args.size(); i++) {
@@ -329,13 +329,13 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
if (args.size() < 4) return true;
if (getType(args[0]) != Type::LabelTy ||
getType(args[2]) != Type::LabelTy) return true;
Normal = cast<BasicBlock>(getValue(Type::LabelTy, args[1]));
Except = cast<BasicBlock>(getValue(Type::LabelTy, args[3]));
Normal = cast<BasicBlock>(getValue(Type::LabelTyID, args[1]));
Except = cast<BasicBlock>(getValue(Type::LabelTyID, args[3]));
if ((args.size() & 1) != 0)
return true; // Must be pairs of type/value
for (unsigned i = 4; i < args.size(); i+=2) {
Params.push_back(getValue(getType(args[i]), args[i+1]));
Params.push_back(getValue(args[i], args[i+1]));
if (Params.back() == 0) return true;
}
}
@@ -347,7 +347,7 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
}
case Instruction::Malloc:
if (Raw->NumOperands > 2) return true;
V = Raw->NumOperands ? getValue(Type::UIntTy, Raw->Arg1) : 0;
V = Raw->NumOperands ? getValue(Type::UIntTyID, Raw->Arg1) : 0;
if (const PointerType *PTy = dyn_cast<PointerType>(Raw->Ty))
Res = new MallocInst(PTy->getElementType(), V);
else
@@ -356,7 +356,7 @@ bool BytecodeParser::ParseInstruction(const unsigned char *&Buf,
case Instruction::Alloca:
if (Raw->NumOperands > 2) return true;
V = Raw->NumOperands ? getValue(Type::UIntTy, Raw->Arg1) : 0;
V = Raw->NumOperands ? getValue(Type::UIntTyID, Raw->Arg1) : 0;
if (const PointerType *PTy = dyn_cast<PointerType>(Raw->Ty))
Res = new AllocaInst(PTy->getElementType(), V);
else