diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/Expressions.cpp | 2 | ||||
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 32 | ||||
-rw-r--r-- | lib/Bytecode/Writer/InstructionWriter.cpp | 2 | ||||
-rw-r--r-- | lib/Bytecode/Writer/Writer.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/InstrSched/SchedGraph.cpp | 2 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Execution.cpp | 2 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/UserInput.cpp | 2 | ||||
-rw-r--r-- | lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 2 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ConstantProp.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InductionVars.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 14 |
14 files changed, 41 insertions, 35 deletions
diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index 2235cdaa37..a6f889f698 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -233,7 +233,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { return Expr; } - Instruction *I = Expr->castInstructionAsserting(); + Instruction *I = cast<Instruction>(Expr); const Type *Ty = I->getType(); switch (I->getOpcode()) { // Handle each instruction type seperately diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index a02b7d8295..7a32813fc1 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -408,7 +408,13 @@ static void setValueName(Value *V, char *NameStr) { return; } - // Otherwise, we are a simple redefinition of a value, baaad + // Otherwise, we are a simple redefinition of a value, check to see if it + // is defined the same as the old one... + if (const Type *Ty = dyn_cast<const Type>(Existing)) { + if (Ty == cast<const Type>(V)) return; // Yes, it's equal. + } else { + + } ThrowException("Redefinition of value name '" + Name + "' in the '" + V->getType()->getDescription() + "' type plane!"); } @@ -996,7 +1002,7 @@ MethodHeaderH : TypesV STRINGCONSTANT '(' ArgList ')' { Method *M = 0; if (SymbolTable *ST = CurModule.CurrentModule->getSymbolTable()) { if (Value *V = ST->lookup(MT, $2)) { // Method already in symtab? - M = V->castMethodAsserting(); + M = cast<Method>(V); // Yes it is. If this is the case, either we need to be a forward decl, // or it needs to be. @@ -1136,16 +1142,16 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result... $$ = new ReturnInst(); } | BR LABEL ValueRef { // Unconditional Branch... - $$ = new BranchInst(getVal(Type::LabelTy, $3)->castBasicBlockAsserting()); + $$ = new BranchInst(cast<BasicBlock>(getVal(Type::LabelTy, $3))); } // Conditional Branch... | BR BOOL ValueRef ',' LABEL ValueRef ',' LABEL ValueRef { - $$ = new BranchInst(getVal(Type::LabelTy, $6)->castBasicBlockAsserting(), - getVal(Type::LabelTy, $9)->castBasicBlockAsserting(), + $$ = new BranchInst(cast<BasicBlock>(getVal(Type::LabelTy, $6)), + cast<BasicBlock>(getVal(Type::LabelTy, $9)), getVal(Type::BoolTy, $3)); } | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' { SwitchInst *S = new SwitchInst(getVal($2, $3), - getVal(Type::LabelTy, $6)->castBasicBlockAsserting()); + cast<BasicBlock>(getVal(Type::LabelTy, $6))); $$ = S; list<pair<ConstPoolVal*, BasicBlock*> >::iterator I = $8->begin(), @@ -1160,7 +1166,7 @@ JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef { if (V == 0) ThrowException("May only switch on a constant pool value!"); - $$->push_back(make_pair(V, getVal($5, $6)->castBasicBlockAsserting())); + $$->push_back(make_pair(V, cast<BasicBlock>(getVal($5, $6)))); } | IntType ConstValueRef ',' LABEL ValueRef { $$ = new list<pair<ConstPoolVal*, BasicBlock*> >(); @@ -1169,7 +1175,7 @@ JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef { if (V == 0) ThrowException("May only switch on a constant pool value!"); - $$->push_back(make_pair(V, getVal($4, $5)->castBasicBlockAsserting())); + $$->push_back(make_pair(V, cast<BasicBlock>(getVal($4, $5)))); } Inst : OptAssign InstVal { @@ -1182,13 +1188,13 @@ Inst : OptAssign InstVal { PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes $$ = new list<pair<Value*, BasicBlock*> >(); $$->push_back(make_pair(getVal(*$1, $3), - getVal(Type::LabelTy, $5)->castBasicBlockAsserting())); + cast<BasicBlock>(getVal(Type::LabelTy, $5)))); delete $1; } | PHIList ',' '[' ValueRef ',' ValueRef ']' { $$ = $1; $1->push_back(make_pair(getVal($1->front().first->getType(), $4), - getVal(Type::LabelTy, $6)->castBasicBlockAsserting())); + cast<BasicBlock>(getVal(Type::LabelTy, $6)))); } @@ -1238,7 +1244,7 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef { | CALL TypesV ValueRef '(' ValueRefListE ')' { const MethodType *Ty; - if (!(Ty = (*$2)->dyncastMethodType())) { + if (!(Ty = dyn_cast<MethodType>($2->get()))) { // Pull out the types of all of the arguments... vector<const Type*> ParamTypes; for (list<Value*>::iterator I = $5->begin(), E = $5->end(); I != E; ++I) @@ -1251,7 +1257,7 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef { // Create the call node... if (!$5) { // Has no arguments? - $$ = new CallInst(V->castMethodAsserting(), vector<Value*>()); + $$ = new CallInst(cast<Method>(V), vector<Value*>()); } else { // Has arguments? // Loop through MethodType's arguments and ensure they are specified // correctly! @@ -1268,7 +1274,7 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef { if (I != E || (ArgI != ArgE && !Ty->isVarArg())) ThrowException("Invalid number of parameters detected!"); - $$ = new CallInst(V->castMethodAsserting(), + $$ = new CallInst(cast<Method>(V), vector<Value*>($5->begin(), $5->end())); } delete $5; diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp index bb0990d1c2..256f7c8288 100644 --- a/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/lib/Bytecode/Writer/InstructionWriter.cpp @@ -215,7 +215,7 @@ void BytecodeWriter::processInstruction(const Instruction *I) { if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1]; NumOperands++; } else if (I->getOpcode() == Instruction::Call && // Handle VarArg calls - I->getOperand(0)->getType()->castMethodType()->isVarArg()) { + cast<MethodType>(I->getOperand(0)->getType())->isVarArg()) { outputInstrVarArgsCall(I, Table, Type, Out); return; } diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index da480180a8..04a0ca4624 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -108,7 +108,7 @@ void BytecodeWriter::outputConstants(bool isMethod) { // << Out.size() << "\n"; outputConstant(CPV); } else { - const Type *Ty = V->castTypeAsserting(); + const Type *Ty = cast<const Type>(V); outputType(Ty); } } diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index 2656cd21cc..40601300f7 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -535,7 +535,7 @@ SchedGraph::addSSAEdge(SchedGraphNode* node, if (!val->isInstruction()) return; const Instruction* thisVMInstr = node->getInstr(); - const Instruction* defVMInstr = val->castInstructionAsserting(); + const Instruction* defVMInstr = cast<const Instruction>(val); // Phi instructions are the only ones that produce a value but don't get // any non-dummy machine instructions. Return here as an optimization. diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index ff4e037ce2..3ecc3ec0ea 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -810,7 +810,7 @@ void Interpreter::printValue(const string &Name) { Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name)); if (!PickedVal) return; - if (const Method *M = PickedVal->castMethod()) { + if (const Method *M = dyn_cast<const Method>(PickedVal)) { cout << M; // Print the method } else { // Otherwise there should be an annotation for the slot# printValue(PickedVal->getType(), diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp index 508bd4a324..eb5725fedd 100644 --- a/lib/ExecutionEngine/Interpreter/UserInput.cpp +++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp @@ -144,7 +144,7 @@ bool Interpreter::callMethod(const string &Name) { if (PickedMeth == 0) return true; - Method *M = PickedMeth->castMethodAsserting(); + Method *M = cast<Method>(PickedMeth); vector<GenericValue> Args; // TODO, get args from user... diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index 2656cd21cc..40601300f7 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -535,7 +535,7 @@ SchedGraph::addSSAEdge(SchedGraphNode* node, if (!val->isInstruction()) return; const Instruction* thisVMInstr = node->getInstr(); - const Instruction* defVMInstr = val->castInstructionAsserting(); + const Instruction* defVMInstr = cast<const Instruction>(val); // Phi instructions are the only ones that produce a value but don't get // any non-dummy machine instructions. Return here as an optimization. diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index c37dae16ac..9001c746e7 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -158,8 +158,8 @@ void SparcAsmPrinter::emitMachineInst(const MachineInstr *MI) { const Value *Val = Op.getVRegValue(); if (!Val) { Out << "\t<*NULL Value*>"; - } else if (Val->isBasicBlock()) { - Out << getID(Val->castBasicBlockAsserting()); + } else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(Val)) { + Out << getID(BB); } else { Out << "<unknown value=" << Val << ">"; } diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 480a2696b5..ea36745c68 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -152,7 +152,7 @@ bool ADCE::doADCE() { // they are known to be alive as well... // for (unsigned op = 0, End = I->getNumOperands(); op != End; ++op) { - if (Instruction *Operand = I->getOperand(op)->castInstruction()) + if (Instruction *Operand = dyn_cast<Instruction>(I->getOperand(op))) markInstructionLive(Operand); } } diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index fdf58cb56d..8b87916242 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -85,8 +85,8 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) { if (T->getOpcode() == Instruction::Br) { BranchInst *BI = (BranchInst*)T; if (BI->isUnconditional()) return false; // Can't optimize uncond branch - BasicBlock *Dest1 = BI->getOperand(0)->castBasicBlockAsserting(); - BasicBlock *Dest2 = BI->getOperand(1)->castBasicBlockAsserting(); + BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0)); + BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1)); if (BI->getCondition()->isConstant()) { // Are we branching on constant? // YES. Change to unconditional branch... diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 69521d6c8b..6815ccb9a4 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -76,7 +76,7 @@ static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V, if (isLoopInvariant(Int, V)) return isLIC; // loop variant computations must be instructions! - Instruction *I = V->castInstructionAsserting(); + Instruction *I = cast<Instruction>(V); switch (I->getOpcode()) { // Handle each instruction seperately case Instruction::Add: case Instruction::Sub: { diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 268b654d14..78b6c3df7b 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -127,7 +127,7 @@ private: // inline bool markOverdefined(Value *V) { if (ValueState[V].markOverdefined()) { - if (Instruction *I = V->castInstruction()) { + if (Instruction *I = dyn_cast<Instruction>(V)) { //cerr << "markOverdefined: " << V; InstWorkList.push_back(I); // Only instructions go on the work list } @@ -497,7 +497,7 @@ void SCCP::UpdateInstruction(Instruction *I) { // void SCCP::OperandChangedState(User *U) { // Only instructions use other variable values! - Instruction *I = U->castInstructionAsserting(); + Instruction *I = cast<Instruction>(U); if (!BBExecutable.count(I->getParent())) return; // Inst not executable yet! UpdateInstruction(I); diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 24d7cc8e7f..e40006c233 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -35,24 +35,24 @@ ostream &WriteAsOperand(ostream &Out, const Value *V, bool PrintType, if (PrintName && V->hasName()) { Out << " %" << V->getName(); } else { - if (const ConstPoolVal *CPV = V->castConstant()) { + if (const ConstPoolVal *CPV = dyn_cast<const ConstPoolVal>(V)) { Out << " " << CPV->getStrValue(); } else { int Slot; if (Table) { Slot = Table->getValSlot(V); } else { - if (const Type *Ty = V->castType()) { + if (const Type *Ty = dyn_cast<const Type>(V)) { return Out << " " << Ty; - } else if (const MethodArgument *MA = V->castMethodArgument()) { + } else if (const MethodArgument *MA =dyn_cast<const MethodArgument>(V)){ Table = new SlotCalculator(MA->getParent(), true); - } else if (const Instruction *I = V->castInstruction()) { + } else if (const Instruction *I = dyn_cast<const Instruction>(V)) { Table = new SlotCalculator(I->getParent()->getParent(), true); - } else if (const BasicBlock *BB = V->castBasicBlock()) { + } else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(V)) { Table = new SlotCalculator(BB->getParent(), true); - } else if (const Method *Meth = V->castMethod()) { + } else if (const Method *Meth = dyn_cast<const Method>(V)) { Table = new SlotCalculator(Meth, true); - } else if (const Module *Mod = V->castModule()) { + } else if (const Module *Mod = dyn_cast<const Module>(V)) { Table = new SlotCalculator(Mod, true); } else { return Out << "BAD VALUE TYPE!"; |