diff options
29 files changed, 150 insertions, 134 deletions
diff --git a/include/llvm/Analysis/ConstantsScanner.h b/include/llvm/Analysis/ConstantsScanner.h index cbf976573e..4c86834d21 100644 --- a/include/llvm/Analysis/ConstantsScanner.h +++ b/include/llvm/Analysis/ConstantsScanner.h @@ -24,7 +24,7 @@ class constant_iterator inline bool isAtConstant() const { assert(!InstI.atEnd() && OpIdx < InstI->getNumOperands() && "isAtConstant called with invalid arguments!"); - return InstI->getOperand(OpIdx)->isConstant(); + return isa<ConstPoolVal>(InstI->getOperand(OpIdx)); } public: diff --git a/include/llvm/Analysis/InstForest.h b/include/llvm/Analysis/InstForest.h index eac08f91e5..967ed45ec9 100644 --- a/include/llvm/Analysis/InstForest.h +++ b/include/llvm/Analysis/InstForest.h @@ -116,7 +116,7 @@ public: } o << getValue(); - if (!getValue()->isInstruction()) o << "\n"; + if (!isa<Instruction>(getValue())) o << "\n"; for (unsigned i = 0; i < getNumChildren(); ++i) getChild(i)->print(o, Indent+1); @@ -229,7 +229,7 @@ InstTreeNode<Payload>::InstTreeNode(InstForest<Payload> &IF, Value *V, InstTreeNode *Parent) : super(Parent) { getTreeData().first.first = V; // Save tree node - if (!V->isInstruction()) { + if (!isa<Instruction>(V)) { assert((isa<ConstPoolVal>(V) || isa<BasicBlock>(V) || isa<MethodArgument>(V) || isa<GlobalVariable>(V)) && "Unrecognized value type for InstForest Partition!"); diff --git a/include/llvm/ConstPoolVals.h b/include/llvm/ConstPoolVals.h index 1bd2dce811..342070c9ca 100644 --- a/include/llvm/ConstPoolVals.h +++ b/include/llvm/ConstPoolVals.h @@ -66,6 +66,15 @@ public: virtual string getStrValue() const; inline bool getValue() const { return Val; } + + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool isa(const ConstPoolBool *) { return true; } + static bool isa(const ConstPoolVal *CPV) { + return (CPV == True) | (CPV == False); + } + static inline bool isa(const Value *V) { + return ::isa<ConstPoolVal>(V) && isa(cast<ConstPoolVal>(V)); + } }; @@ -97,6 +106,13 @@ public: // specified value. as above, we work only with very small values here. // static ConstPoolInt *get(const Type *Ty, unsigned char V); + + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool isa(const ConstPoolInt *) { return true; } + static bool isa(const ConstPoolVal *CPV); // defined in CPV.cpp + static inline bool isa(const Value *V) { + return ::isa<ConstPoolVal>(V) && isa(cast<ConstPoolVal>(V)); + } }; @@ -117,7 +133,6 @@ public: inline int64_t getValue() const { return Val.Signed; } }; - //===--------------------------------------------------------------------------- // ConstPoolUInt - Unsigned Integer Values [ubyte, ushort, uint, ulong] // diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 3ef46cac86..1acf2e299d 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -79,34 +79,12 @@ public: // equivalent to using dynamic_cast<>... if the cast is successful, this is // returned, otherwise you get a null pointer. // - // This section also defines a family of isType, isConstant, - // isMethodArgument, etc functions... - // // The family of functions Val->cast<type>Asserting() is used in the same // way as the Val->cast<type>() instructions, but they assert the expected // type instead of checking it at runtime. // inline ValueTy getValueType() const { return VTy; } - // Use a macro to define the functions, otherwise these definitions are just - // really long and ugly. -#define CAST_FN(NAME, CLASS) \ - inline bool is##NAME() const { return VTy == NAME##Val; } \ - inline const CLASS *cast##NAME() const { /*const version */ \ - return is##NAME() ? (const CLASS*)this : 0; \ - } \ - inline CLASS *cast##NAME() { /* nonconst version */ \ - return is##NAME() ? (CLASS*)this : 0; \ - } \ - - CAST_FN(Constant , ConstPoolVal ) - CAST_FN(MethodArgument, MethodArgument) - CAST_FN(Instruction , Instruction ) - CAST_FN(BasicBlock , BasicBlock ) - CAST_FN(Method , Method ) - CAST_FN(Global , GlobalVariable) -#undef CAST_FN - // replaceAllUsesWith - Go through the uses list for this definition and make // each use point to "D" instead of "this". After this completes, 'this's // use list should be empty. @@ -207,7 +185,7 @@ template <class X> class real_type <class UseTy<X> > { typedef X *Type; }; // if (isa<Type>(myVal)) { ... } // template <class X, class Y> -bool isa(Y Val) { return X::isa(Val); } +inline bool isa(Y Val) { return X::isa(Val); } // cast<X> - Return the argument parameter cast to the specified type. This @@ -218,7 +196,7 @@ bool isa(Y Val) { return X::isa(Val); } // cast<const Instruction>(myVal)->getParent() // template <class X, class Y> -X *cast(Y Val) { +inline X *cast(Y Val) { assert(isa<X>(Val) && "Invalid cast argument type!"); return (X*)(real_type<Y>::Type)Val; } @@ -233,7 +211,7 @@ X *cast(Y Val) { // template <class X, class Y> -X *dyn_cast(Y Val) { +inline X *dyn_cast(Y Val) { return isa<X>(Val) ? cast<X>(Val) : 0; } @@ -241,28 +219,52 @@ X *dyn_cast(Y Val) { // isa - Provide some specializations of isa so that we have to include the // subtype header files to test to see if the value is a subclass... // -template <> bool isa<Type, Value*>(Value *Val) { +template <> inline bool isa<Type, const Value*>(const Value *Val) { return Val->getValueType() == Value::TypeVal; } -template <> bool isa<ConstPoolVal, Value*>(Value *Val) { +template <> inline bool isa<Type, Value*>(Value *Val) { + return Val->getValueType() == Value::TypeVal; +} +template <> inline bool isa<ConstPoolVal, const Value*>(const Value *Val) { return Val->getValueType() == Value::ConstantVal; } -template <> bool isa<MethodArgument, Value*>(Value *Val) { +template <> inline bool isa<ConstPoolVal, Value*>(Value *Val) { + return Val->getValueType() == Value::ConstantVal; +} +template <> inline bool isa<MethodArgument, const Value*>(const Value *Val) { + return Val->getValueType() == Value::MethodArgumentVal; +} +template <> inline bool isa<MethodArgument, Value*>(Value *Val) { return Val->getValueType() == Value::MethodArgumentVal; } -template <> bool isa<Instruction, Value*>(Value *Val) { +template <> inline bool isa<Instruction, const Value*>(const Value *Val) { + return Val->getValueType() == Value::InstructionVal; +} +template <> inline bool isa<Instruction, Value*>(Value *Val) { return Val->getValueType() == Value::InstructionVal; } -template <> bool isa<BasicBlock, Value*>(Value *Val) { +template <> inline bool isa<BasicBlock, const Value*>(const Value *Val) { + return Val->getValueType() == Value::BasicBlockVal; +} +template <> inline bool isa<BasicBlock, Value*>(Value *Val) { return Val->getValueType() == Value::BasicBlockVal; } -template <> bool isa<Method, Value*>(Value *Val) { +template <> inline bool isa<Method, const Value*>(const Value *Val) { + return Val->getValueType() == Value::MethodVal; +} +template <> inline bool isa<Method, Value*>(Value *Val) { return Val->getValueType() == Value::MethodVal; } -template <> bool isa<GlobalVariable, Value*>(Value *Val) { +template <> inline bool isa<GlobalVariable, const Value*>(const Value *Val) { return Val->getValueType() == Value::GlobalVal; } -template <> bool isa<Module, Value*>(Value *Val) { +template <> inline bool isa<GlobalVariable, Value*>(Value *Val) { + return Val->getValueType() == Value::GlobalVal; +} +template <> inline bool isa<Module, const Value*>(const Value *Val) { + return Val->getValueType() == Value::ModuleVal; +} +template <> inline bool isa<Module, Value*>(Value *Val) { return Val->getValueType() == Value::ModuleVal; } diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index 8c9d75f2bd..cb83d41236 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -16,14 +16,17 @@ using namespace opt; // Get all the constant handling stuff using namespace analysis; ExprType::ExprType(Value *Val) { - if (Val && Val->isConstant() && Val->getType()->isIntegral()) { - Offset = (ConstPoolInt*)Val->castConstant(); - Var = 0; - ExprTy = Constant; - } else { - Var = Val; Offset = 0; - ExprTy = Var ? Linear : Constant; - } + if (Val) + if (ConstPoolInt *CPI = dyn_cast<ConstPoolInt>(Val)) { + Offset = CPI; + Var = 0; + ExprTy = Constant; + Scale = 0; + return; + } + + Var = Val; Offset = 0; + ExprTy = Var ? Linear : Constant; Scale = 0; } diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 88986c288a..bedb65f4a8 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -167,10 +167,7 @@ struct BBPlaceHolderHelper : public BasicBlock { }; struct MethPlaceHolderHelper : public Method { - MethPlaceHolderHelper(const Type *Ty) - : Method((const MethodType*)Ty) { - assert(Ty->isMethodType() && "Method placeholders must be method types!"); - } + MethPlaceHolderHelper(const Type *Ty) : Method(cast<const MethodType>(Ty)) {} }; typedef PlaceholderValue<TypePlaceHolderHelper> TypePlaceHolder; diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index 67cfff7b97..aaecedddfa 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -241,8 +241,8 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf, unsigned Slot; if (read_vbr(Buf, EndBuf, Slot)) return failure(true); Value *V = getValue(AT->getElementType(), Slot, false); - if (!V || !V->isConstant()) return failure(true); - Elements.push_back((ConstPoolVal*)V); + if (!V || !isa<ConstPoolVal>(V)) return failure(true); + Elements.push_back(cast<ConstPoolVal>(V)); } V = ConstPoolArray::get(AT, Elements); break; @@ -257,9 +257,9 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf, unsigned Slot; if (read_vbr(Buf, EndBuf, Slot)) return failure(true); Value *V = getValue(ET[i], Slot, false); - if (!V || !V->isConstant()) + if (!V || !isa<ConstPoolVal>(V)) return failure(true); - Elements.push_back((ConstPoolVal*)V); + Elements.push_back(cast<ConstPoolVal>(V)); } V = ConstPoolStruct::get(ST, Elements); diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index 8c3e08ff94..300c40999e 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -266,25 +266,25 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, case 0: cerr << "Invalid load encountered!\n"; return failure(true); case 1: break; case 2: V = getValue(Type::UByteTy, Raw.Arg2); - if (!V->isConstant()) return failure(true); - Idx.push_back(V->castConstant()); + if (!isa<ConstPoolVal>(V)) return failure(true); + Idx.push_back(cast<ConstPoolVal>(V)); break; case 3: V = getValue(Type::UByteTy, Raw.Arg2); - if (!V->isConstant()) return failure(true); - Idx.push_back(V->castConstant()); + if (!isa<ConstPoolVal>(V)) return failure(true); + Idx.push_back(cast<ConstPoolVal>(V)); V = getValue(Type::UByteTy, Raw.Arg3); - if (!V->isConstant()) return failure(true); - Idx.push_back(V->castConstant()); + if (!isa<ConstPoolVal>(V)) return failure(true); + Idx.push_back(cast<ConstPoolVal>(V)); break; default: V = getValue(Type::UByteTy, Raw.Arg2); - if (!V->isConstant()) return failure(true); - Idx.push_back(V->castConstant()); + if (!isa<ConstPoolVal>(V)) return failure(true); + Idx.push_back(cast<ConstPoolVal>(V)); vector<unsigned> &args = *Raw.VarArgs; for (unsigned i = 0, E = args.size(); i != E; ++i) { V = getValue(Type::UByteTy, args[i]); - if (!V->isConstant()) return failure(true); - Idx.push_back(V->castConstant()); + if (!isa<ConstPoolVal>(V)) return failure(true); + Idx.push_back(cast<ConstPoolVal>(V)); } delete Raw.VarArgs; break; @@ -304,15 +304,15 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, case 1: cerr << "Invalid store encountered!\n"; return failure(true); case 2: break; case 3: V = getValue(Type::UByteTy, Raw.Arg3); - if (!V->isConstant()) return failure(true); - Idx.push_back(V->castConstant()); + if (!isa<ConstPoolVal>(V)) return failure(true); + Idx.push_back(cast<ConstPoolVal>(V)); break; default: vector<unsigned> &args = *Raw.VarArgs; for (unsigned i = 0, E = args.size(); i != E; ++i) { V = getValue(Type::UByteTy, args[i]); - if (!V->isConstant()) return failure(true); - Idx.push_back(V->castConstant()); + if (!isa<ConstPoolVal>(V)) return failure(true); + Idx.push_back(cast<ConstPoolVal>(V)); } delete Raw.VarArgs; break; diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index b7904bb60f..0e4883034e 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -206,7 +206,7 @@ bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf, return failure(true); } BCR_TRACE(4, "Map: '" << Name << "' to #" << slot << ":" << D; - if (!D->isInstruction()) cerr << endl); + if (!isa<Instruction>(D)) cerr << endl); D->setName(Name, ST); } @@ -291,7 +291,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf, Value *MethPHolder = getValue(MTy, MethSlot, false); assert(MethPHolder && "Something is broken no placeholder found!"); - assert(MethPHolder->isMethod() && "Not a method?"); + assert(isa<Method>(MethPHolder) && "Not a method?"); unsigned type; // Type slot assert(!getTypeSlot(MTy, type) && "How can meth type not exist?"); @@ -359,7 +359,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End, if (read_vbr(Buf, End, MethSignature)) return failure(true); while (MethSignature != Type::VoidTyID) { // List is terminated by Void const Type *Ty = getType(MethSignature); - if (!Ty || !Ty->isMethodType()) { + if (!Ty || !isa<MethodType>(Ty)) { cerr << "Method not meth type! Ty = " << Ty << endl; return failure(true); } diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index ed4f1a4bba..cf5a43ef3b 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -129,8 +129,7 @@ struct BBPlaceHolderHelper : public BasicBlock { struct MethPlaceHolderHelper : public Method { MethPlaceHolderHelper(const Type *Ty) - : Method((const MethodType*)Ty) { - assert(Ty->isMethodType() && "Method placeholders must be method types!"); + : Method(cast<const MethodType>(Ty)) { } }; diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index d0f37fb723..38980e5e63 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -106,7 +106,7 @@ void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) { for (SymbolTable::const_iterator I = ST->begin(), E = ST->end(); I != E; ++I) for (SymbolTable::type_const_iterator TI = I->second.begin(), TE = I->second.end(); TI != TE; ++TI) - if (TI->second->isConstant()) + if (isa<ConstPoolVal>(TI->second)) insertValue(TI->second); } @@ -223,7 +223,7 @@ int SlotCalculator::getValSlot(const Value *D) const { int SlotCalculator::insertValue(const Value *D) { - if (D->isConstant() || D->isGlobal()) { + if (isa<ConstPoolVal>(D) || isa<GlobalVariable>(D)) { const User *U = (const User *)D; // This makes sure that if a constant has uses (for example an array // of const ints), that they are inserted also. Same for global variable diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 94cbcec328..5df2fdabde 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -79,7 +79,7 @@ void BytecodeWriter::outputConstants(bool isMethod) { ValNo = Type::FirstDerivedTyID; // Start emitting at the derived types... // Scan through and ignore method arguments... - for (; ValNo < Plane.size() && Plane[ValNo]->isMethodArgument(); ValNo++) + for (; ValNo < Plane.size() && isa<MethodArgument>(Plane[ValNo]); ValNo++) /*empty*/; unsigned NC = ValNo; // Number of constants @@ -103,7 +103,7 @@ void BytecodeWriter::outputConstants(bool isMethod) { for (unsigned i = ValNo; i < ValNo+NC; ++i) { const Value *V = Plane[i]; - if (const ConstPoolVal *CPV = V->castConstant()) { + if (const ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) { //cerr << "Serializing value: <" << V->getType() << ">: " // << ((const ConstPoolVal*)V)->getStrValue() << ":" // << Out.size() << "\n"; @@ -127,7 +127,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) { // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2+ = slot# unsigned oSlot = ((unsigned)Slot << 2) | (GV->hasInitializer() << 1) | - GV->isConstant(); + isa<ConstPoolVal>(GV); output_vbr(oSlot, Out); // If we have an initialized, output it now. diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index 40601300f7..852c4f2686 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -532,7 +532,7 @@ SchedGraph::addSSAEdge(SchedGraphNode* node, const Value* val, const TargetMachine& target) { - if (!val->isInstruction()) return; + if (!isa<Instruction>(val)) return; const Instruction* thisVMInstr = node->getInstr(); const Instruction* defVMInstr = cast<const Instruction>(val); @@ -642,7 +642,6 @@ void SchedGraph::addNonSSAEdgesForValue(const Instruction* instr, const TargetMachine& target) { - assert(instr->isInstruction()); if (instr->isPHINode()) return; diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp index 9f4df08d38..f5a524707b 100644 --- a/lib/CodeGen/InstrSelection/InstrForest.cpp +++ b/lib/CodeGen/InstrSelection/InstrForest.cpp @@ -275,12 +275,12 @@ InstrForest::buildTreeForInstruction(Instruction *instr) // Check latter condition here just to simplify the next IF. bool includeAddressOperand = - (operand->isBasicBlock() || operand->isMethod()) + (isa<BasicBlock>(operand) || isa<Method>(operand)) && !instr->isTerminator(); - if (includeAddressOperand || operand->isInstruction() || - operand->isConstant() || operand->isMethodArgument() || - operand->isGlobal()) + if (includeAddressOperand || isa<Instruction>(operand) || + isa<ConstPoolVal>(operand) || isa<MethodArgument>(operand) || + isa<GlobalVariable>(operand)) { // This operand is a data value @@ -300,15 +300,15 @@ InstrForest::buildTreeForInstruction(Instruction *instr) // is used directly, i.e., made a child of the instruction node. // InstrTreeNode* opTreeNode; - if (operand->isInstruction() && operand->use_size() == 1 && - ((Instruction*)operand)->getParent() == instr->getParent() && + if (isa<Instruction>(operand) && operand->use_size() == 1 && + cast<Instruction>(operand)->getParent() == instr->getParent() && ! instr->isPHINode() && instr->getOpcode() != Instruction::Call) { // Recursively create a treeNode for it. opTreeNode = buildTreeForInstruction((Instruction*)operand); } - else if (ConstPoolVal *CPV = operand->castConstant()) + else if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(operand)) { // Create a leaf node for a constant opTreeNode = new ConstantNode(CPV); diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 1e3300763d..64076286f4 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -141,7 +141,7 @@ operator<<(ostream &os, const MachineOperand &mop) case MachineOperand::MO_PCRelativeDisp: { const Value* opVal = mop.getVRegValue(); - bool isLabel = opVal->isMethod() || opVal->isBasicBlock(); + bool isLabel = isa<Method>(opVal) || isa<BasicBlock>(opVal); return os << "%disp(" << (isLabel? "label " : "addr-of-val ") << opVal << ")"; @@ -221,7 +221,7 @@ Set3OperandsFromInstrJUNK(MachineInstr* minstr, minstr->SetMachineOperand(op1Position, /*regNum*/ target.zeroRegNum); else { - if (op1Value->isConstant()) + if (isa<ConstPoolVal>(op1Value)) { // value is constant and must be loaded from constant pool returnFlags = returnFlags | (1 << op1Position); @@ -247,7 +247,7 @@ Set3OperandsFromInstrJUNK(MachineInstr* minstr, minstr->SetMachineOperand(op2Position, machineRegNum); else if (op2type == MachineOperand::MO_VirtualRegister) { - if (op2Value->isConstant()) + if (isa<ConstPoolVal>(op2Value)) { // value is constant and must be loaded from constant pool returnFlags = returnFlags | (1 << op2Position); @@ -318,7 +318,7 @@ ChooseRegOrImmed(Value* val, // Check for the common case first: argument is not constant // - ConstPoolVal *CPV = val->castConstant(); + ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(val); if (!CPV) return opType; if (CPV->getType() == Type::BoolTy) diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 3ecc3ec0ea..d88d91ff1f 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -25,7 +25,7 @@ static unsigned getOperandSlot(Value *V) { case Type::TY##TyID: Result.TY##Val = ((CLASS*)CPV)->getValue(); break static GenericValue getOperandValue(Value *V, ExecutionContext &SF) { - if (ConstPoolVal *CPV = V->castConstant()) { + if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) { GenericValue Result; switch (CPV->getType()->getPrimitiveID()) { GET_CONST_VAL(Bool , ConstPoolBool); @@ -48,7 +48,7 @@ static GenericValue getOperandValue(Value *V, ExecutionContext &SF) { } static void printOperandInfo(Value *V, ExecutionContext &SF) { - if (!V->isConstant()) { + if (!isa<ConstPoolVal>(V)) { unsigned TyP = V->getType()->getUniqueID(); // TypePlane for value unsigned Slot = getOperandSlot(V); cout << "Value=" << (void*)V << " TypeID=" << TyP << " Slot=" << Slot diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp index eb5725fedd..e9fc9db343 100644 --- a/lib/ExecutionEngine/Interpreter/UserInput.cpp +++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp @@ -134,7 +134,7 @@ bool Interpreter::callMethod(const string &Name) { vector<Value*> Options = LookupMatchingNames(Name); for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches... - if (!Options[i]->isMethod()) { + if (!isa<Method>(Options[i])) { Options.erase(Options.begin()+i); --i; } diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index 40601300f7..852c4f2686 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -532,7 +532,7 @@ SchedGraph::addSSAEdge(SchedGraphNode* node, const Value* val, const TargetMachine& target) { - if (!val->isInstruction()) return; + if (!isa<Instruction>(val)) return; const Instruction* thisVMInstr = node->getInstr(); const Instruction* defVMInstr = cast<const Instruction>(val); @@ -642,7 +642,6 @@ void SchedGraph::addNonSSAEdgesForValue(const Instruction* instr, const TargetMachine& target) { - assert(instr->isInstruction()); if (instr->isPHINode()) return; diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index 9f4df08d38..f5a524707b 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -275,12 +275,12 @@ InstrForest::buildTreeForInstruction(Instruction *instr) // Check latter condition here just to simplify the next IF. bool includeAddressOperand = - (operand->isBasicBlock() || operand->isMethod()) + (isa<BasicBlock>(operand) || isa<Method>(operand)) && !instr->isTerminator(); - if (includeAddressOperand || operand->isInstruction() || - operand->isConstant() || operand->isMethodArgument() || - operand->isGlobal()) + if (includeAddressOperand || isa<Instruction>(operand) || + isa<ConstPoolVal>(operand) || isa<MethodArgument>(operand) || + isa<GlobalVariable>(operand)) { // This operand is a data value @@ -300,15 +300,15 @@ InstrForest::buildTreeForInstruction(Instruction *instr) // is used directly, i.e., made a child of the instruction node. // InstrTreeNode* opTreeNode; - if (operand->isInstruction() && operand->use_size() == 1 && - ((Instruction*)operand)->getParent() == instr->getParent() && + if (isa<Instruction>(operand) && operand->use_size() == 1 && + cast<Instruction>(operand)->getParent() == instr->getParent() && ! instr->isPHINode() && instr->getOpcode() != Instruction::Call) { // Recursively create a treeNode for it. opTreeNode = buildTreeForInstruction((Instruction*)operand); } - else if (ConstPoolVal *CPV = operand->castConstant()) + else if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(operand)) { // Create a leaf node for a constant opTreeNode = new ConstantNode(CPV); diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index 572e1b175b..b1b5e01aff 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -60,7 +60,7 @@ static int64_t GetConstantValueAsSignedInt(const Value *V, bool &isValidConstant) { - if (!V->isConstant()) + if (!isa<ConstPoolVal>(V)) { isValidConstant = false; return 0; @@ -374,8 +374,8 @@ ChooseAddInstructionByType(const Type* |