aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Assembly/Writer.h12
-rw-r--r--include/llvm/BasicBlock.h8
-rw-r--r--include/llvm/CodeGen/InstrForest.h4
-rw-r--r--include/llvm/ConstPoolVals.h20
-rw-r--r--include/llvm/DerivedTypes.h48
-rw-r--r--include/llvm/Function.h4
-rw-r--r--include/llvm/GlobalVariable.h4
-rw-r--r--include/llvm/InstrTypes.h27
-rw-r--r--include/llvm/Instruction.h9
-rw-r--r--include/llvm/Module.h4
-rw-r--r--include/llvm/Type.h35
-rw-r--r--include/llvm/Value.h2
-rw-r--r--include/llvm/iMemory.h63
-rw-r--r--include/llvm/iOther.h42
-rw-r--r--include/llvm/iTerminators.h27
15 files changed, 214 insertions, 95 deletions
diff --git a/include/llvm/Assembly/Writer.h b/include/llvm/Assembly/Writer.h
index 39b0cb6..020989e 100644
--- a/include/llvm/Assembly/Writer.h
+++ b/include/llvm/Assembly/Writer.h
@@ -92,13 +92,13 @@ inline ostream &operator<<(ostream &o, const Type *T) {
inline ostream &operator<<(ostream &o, const Value *I) {
switch (I->getValueType()) {
case Value::TypeVal: return o << cast<const Type>(I);
- case Value::ConstantVal: WriteToAssembly((const ConstPoolVal*)I,o);break;
+ case Value::ConstantVal: WriteToAssembly(cast<ConstPoolVal>(I) , o); break;
case Value::MethodArgumentVal: return o << I->getType() << " "<< I->getName();
- case Value::InstructionVal:WriteToAssembly((const Instruction *)I, o);break;
- case Value::BasicBlockVal: WriteToAssembly((const BasicBlock *)I, o);break;
- case Value::MethodVal: WriteToAssembly((const Method *)I, o);break;
- case Value::GlobalVal: WriteToAssembly((const GlobalVariable*)I,o);break;
- case Value::ModuleVal: WriteToAssembly((const Module *)I,o); break;
+ case Value::InstructionVal:WriteToAssembly(cast<Instruction>(I) , o); break;
+ case Value::BasicBlockVal: WriteToAssembly(cast<BasicBlock>(I) , o); break;
+ case Value::MethodVal: WriteToAssembly(cast<Method>(I) , o); break;
+ case Value::GlobalVal: WriteToAssembly(cast<GlobalVariable>(I), o); break;
+ case Value::ModuleVal: WriteToAssembly(cast<Module>(I) , o); break;
default: return o << "<unknown value type: " << I->getValueType() << ">";
}
return o;
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index 1d1623b..cf29cbd 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -110,8 +110,8 @@ public:
InstListType &getInstList() { return InstList; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const BasicBlock *BB) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const BasicBlock *BB) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == Value::BasicBlockVal;
}
@@ -168,9 +168,7 @@ public:
inline void advancePastConstPool() {
// TODO: This is bad
// Loop to ignore constant pool references
- while (It != BB->use_end() &&
- (((*It)->getValueType() != Value::InstructionVal) ||
- !(((Instruction*)(*It))->isTerminator())))
+ while (It != BB->use_end() && !isa<TerminatorInst>(*It))
++It;
}
diff --git a/include/llvm/CodeGen/InstrForest.h b/include/llvm/CodeGen/InstrForest.h
index 6fe622d..113e35e 100644
--- a/include/llvm/CodeGen/InstrForest.h
+++ b/include/llvm/CodeGen/InstrForest.h
@@ -171,7 +171,7 @@ public:
Instruction *getInstruction() const {
assert(treeNodeType == NTInstructionNode);
- return (Instruction*)val;
+ return cast<Instruction>(val);
}
protected:
virtual void dumpNode(int indent) const;
@@ -234,7 +234,7 @@ protected:
//
//------------------------------------------------------------------------
-class InstrForest : private hash_map<const Instruction*, InstructionNode*> {
+class InstrForest : private hash_map<const Instruction *, InstructionNode*> {
private:
hash_set<InstructionNode*> treeRoots;
diff --git a/include/llvm/ConstPoolVals.h b/include/llvm/ConstPoolVals.h
index 342070c..4edfa80 100644
--- a/include/llvm/ConstPoolVals.h
+++ b/include/llvm/ConstPoolVals.h
@@ -34,8 +34,8 @@ public:
static ConstPoolVal *getNullConstant(const Type *Ty);
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const ConstPoolVal *) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const ConstPoolVal *) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == Value::ConstantVal;
}
};
@@ -68,12 +68,12 @@ public:
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) {
+ static inline bool classof(const ConstPoolBool *) { return true; }
+ static bool classof(const ConstPoolVal *CPV) {
return (CPV == True) | (CPV == False);
}
- static inline bool isa(const Value *V) {
- return ::isa<ConstPoolVal>(V) && isa(cast<ConstPoolVal>(V));
+ static inline bool classof(const Value *V) {
+ return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
}
};
@@ -108,10 +108,10 @@ public:
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));
+ static inline bool classof(const ConstPoolInt *) { return true; }
+ static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
+ static inline bool classof(const Value *V) {
+ return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
}
};
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h
index 5a51e64..750b284 100644
--- a/include/llvm/DerivedTypes.h
+++ b/include/llvm/DerivedTypes.h
@@ -80,12 +80,12 @@ public:
void refineAbstractTypeTo(const Type *NewType);
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const DerivedType *T) { return true; }
- static inline bool isa(const Type *T) {
+ static inline bool classof(const DerivedType *T) { return true; }
+ static inline bool classof(const Type *T) {
return T->isDerivedType();
}
- static inline bool isa(const Value *V) {
- return ::isa<Type>(V) && isa(cast<const Type>(V));
+ static inline bool classof(const Value *V) {
+ return isa<Type>(V) && classof(cast<const Type>(V));
}
};
@@ -133,12 +133,12 @@ public:
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const MethodType *T) { return true; }
- static inline bool isa(const Type *T) {
+ static inline bool classof(const MethodType *T) { return true; }
+ static inline bool classof(const Type *T) {
return T->getPrimitiveID() == MethodTyID;
}
- static inline bool isa(const Value *V) {
- return ::isa<Type>(V) && isa(cast<const Type>(V));
+ static inline bool classof(const Value *V) {
+ return isa<Type>(V) && classof(cast<const Type>(V));
}
};
@@ -181,12 +181,12 @@ public:
static ArrayType *get(const Type *ElementType, int NumElements = -1);
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const ArrayType *T) { return true; }
- static inline bool isa(const Type *T) {
+ static inline bool classof(const ArrayType *T) { return true; }
+ static inline bool classof(const Type *T) {
return T->getPrimitiveID() == ArrayTyID;
}
- static inline bool isa(const Value *V) {
- return ::isa<Type>(V) && isa(cast<const Type>(V));
+ static inline bool classof(const Value *V) {
+ return isa<Type>(V) && classof(cast<const Type>(V));
}
};
@@ -226,12 +226,12 @@ public:
static StructType *get(const vector<const Type*> &Params);
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const StructType *T) { return true; }
- static inline bool isa(const Type *T) {
+ static inline bool classof(const StructType *T) { return true; }
+ static inline bool classof(const Type *T) {
return T->getPrimitiveID() == StructTyID;
}
- static inline bool isa(const Value *V) {
- return ::isa<Type>(V) && isa(cast<const Type>(V));
+ static inline bool classof(const Value *V) {
+ return isa<Type>(V) && classof(cast<const Type>(V));
}
};
@@ -269,12 +269,12 @@ public:
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const PointerType *T) { return true; }
- static inline bool isa(const Type *T) {
+ static inline bool classof(const PointerType *T) { return true; }
+ static inline bool classof(const Type *T) {
return T->getPrimitiveID() == PointerTyID;
}
- static inline bool isa(const Value *V) {
- return ::isa<Type>(V) && isa(cast<const Type>(V));
+ static inline bool classof(const Value *V) {
+ return isa<Type>(V) && classof(cast<const Type>(V));
}
};
@@ -299,12 +299,12 @@ public:
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const OpaqueType *T) { return true; }
- static inline bool isa(const Type *T) {
+ static inline bool classof(const OpaqueType *T) { return true; }
+ static inline bool classof(const Type *T) {
return T->getPrimitiveID() == OpaqueTyID;
}
- static inline bool isa(const Value *V) {
- return ::isa<Type>(V) && isa(cast<const Type>(V));
+ static inline bool classof(const Value *V) {
+ return isa<Type>(V) && classof(cast<const Type>(V));
}
};
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index f6c8aa2..227ab53 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -93,8 +93,8 @@ public:
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const Method *T) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const Method *T) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == Value::MethodVal;
}
diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h
index f301844..3ee7f6d 100644
--- a/include/llvm/GlobalVariable.h
+++ b/include/llvm/GlobalVariable.h
@@ -61,8 +61,8 @@ public:
inline bool isConstant() const { return Constant; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const GlobalVariable *) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const GlobalVariable *) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == Value::GlobalVal;
}
};
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 75c4943..db85a39 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -40,6 +40,15 @@ public:
inline BasicBlock *getSuccessor(unsigned idx) {
return (BasicBlock*)((const TerminatorInst *)this)->getSuccessor(idx);
}
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const TerminatorInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() >= FirstTermOp && I->getOpcode() < NumTermOps;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -70,6 +79,15 @@ public:
}
virtual const char *getOpcodeName() const = 0;
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const UnaryOperator *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() >= FirstUnaryOp && I->getOpcode() < NumUnaryOps;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -111,6 +129,15 @@ public:
void swapOperands() {
swap(Operands[0], Operands[1]);
}
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BinaryOperator *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() >= FirstBinaryOp && I->getOpcode() < NumBinaryOps;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
#endif
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index 93b68a2..71bb8e2 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -66,7 +66,7 @@ public:
unsigned getInstType() const { return iType; }
inline bool isTerminator() const { // Instance of TerminatorInst?
- return iType >= FirstTermOp && iType < NumTermOps;
+ return iType >= FirstTermOp && iType < NumTermOps;
}
inline bool isDefinition() const { return !isTerminator(); }
inline bool isUnaryOp() const {
@@ -76,9 +76,6 @@ public:
return iType >= FirstBinaryOp && iType < NumBinaryOps;
}
- // isPHINode() - This is used frequently enough to allow it to exist
- inline bool isPHINode() const { return iType == PHINode; }
-
// dropAllReferences() - This function is in charge of "letting go" of all
// objects that this Instruction refers to. This first lets go of all
// references to hidden values generated code for this instruction,
@@ -88,8 +85,8 @@ public:
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const Instruction *I) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const Instruction *I) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == Value::InstructionVal;
}
diff --git a/include/llvm/Module.h b/include/llvm/Module.h
index a9f920e..823d4d8 100644
--- a/include/llvm/Module.h
+++ b/include/llvm/Module.h
@@ -94,8 +94,8 @@ public:
inline Method *back() { return MethodList.back(); }
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const Module *T) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const Module *T) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == Value::ModuleVal;
}
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index 687b12a..cc68266 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -189,42 +189,19 @@ public:
inline bool isDerivedType() const { return ID >= FirstDerivedTyID; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const Type *T) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const Type *T) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == Value::TypeVal;
}
- // Methods for determining the subtype of this Type. The cast*() methods are
- // equilivent to using dynamic_cast<>... if the cast is successful, this is
- // returned, otherwise you get a null pointer, allowing expressions like this:
- //
- // if (MethodType *MTy = Ty->dyncastMethodType()) { ... }
- //
- // This section also defines a family of isArrayType(), isLabelType(),
- // etc functions...
- //
- // The family of functions Ty->cast<type>() is used in the same way as the
- // Ty->dyncast<type>() instructions, but they assert the expected type instead
- // of checking it at runtime.
+ // Methods for determining the subtype of this Type. This section defines a
+ // family of isArrayType(), isLabelType(), etc functions...
//
#define HANDLE_PRIM_TYPE(NAME, SIZE) \
inline bool is##NAME##Type() const { return ID == NAME##TyID; }
#define HANDLE_DERV_TYPE(NAME, CLASS) \
- inline bool is##NAME##Type() const { return ID == NAME##TyID; } \
- inline const CLASS *dyncast##NAME##Type() const { /*const version */ \
- return is##NAME##Type() ? (const CLASS*)this : 0; \
- } \
- inline CLASS *dyncast##NAME##Type() { /* nonconst version */ \
- return is##NAME##Type() ? (CLASS*)this : 0; \
- } \
- inline const CLASS *cast##NAME##Type() const { /*const version */ \
- assert(is##NAME##Type() && "Expected TypeTy: " #NAME); \
- return (const CLASS*)this; \
- } \
- inline CLASS *cast##NAME##Type() { /* nonconst version */ \
- assert(is##NAME##Type() && "Expected TypeTy: " #NAME); \
- return (CLASS*)this; \
- }
+ inline bool is##NAME##Type() const { return ID == NAME##TyID; }
+
#include "llvm/Type.def"
private:
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index 1acf2e2..5716d29 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -185,7 +185,7 @@ template <class X> class real_type <class UseTy<X> > { typedef X *Type; };
// if (isa<Type>(myVal)) { ... }
//
template <class X, class Y>
-inline bool isa(Y Val) { return X::isa(Val); }
+inline bool isa(Y Val) { return X::classof(Val); }
// cast<X> - Return the argument parameter cast to the specified type. This
diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h
index 5667da6..147ff18 100644
--- a/include/llvm/iMemory.h
+++ b/include/llvm/iMemory.h
@@ -27,16 +27,16 @@ public:
if (ArraySize) {
// Make sure they didn't try to specify a size for !(unsized array) type
- assert((getType()->getValueType()->isArrayType() &&
- ((const ArrayType*)getType()->getValueType())->isUnsized()) &&
- "Trying to allocate something other than unsized array, with size!");
+ assert(getType()->getValueType()->isArrayType() &&
+ cast<ArrayType>(getType()->getValueType())->isUnsized() &&
+ "Trying to allocate something other than unsized array, with size!");
Operands.reserve(1);
Operands.push_back(Use(ArraySize, this));
} else {
// Make sure that the pointer is not to an unsized array!
assert(!getType()->getValueType()->isArrayType() ||
- ((const ArrayType*)getType()->getValueType())->isSized() &&
+ cast<const ArrayType>(getType()->getValueType())->isSized() &&
"Trying to allocate unsized array without size!");
}
}
@@ -64,6 +64,15 @@ public:
}
virtual const char *getOpcodeName() const { return "malloc"; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const MallocInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Malloc);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -81,6 +90,15 @@ public:
}
virtual const char *getOpcodeName() const { return "alloca"; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const AllocaInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Alloca);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -102,6 +120,15 @@ public:
virtual const char *getOpcodeName() const { return "free"; }
virtual bool hasSideEffects() const { return true; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const FreeInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Free);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -160,6 +187,15 @@ public:
virtual const char* getOpcodeName() const { return "load"; }
virtual Value* getPtrOperand() { return this->getOperand(0); }
virtual int getFirstOffsetIdx() const { return (this->getNumOperands() > 1)? 1 : -1;}
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const LoadInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Load);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -182,6 +218,15 @@ public:
virtual bool hasSideEffects() const { return true; }
virtual Value* getPtrOperand() { return this->getOperand(1); }
virtual int getFirstOffsetIdx() const { return (this->getNumOperands() > 2)? 2 : -1;}
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const StoreInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Store);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -206,6 +251,16 @@ public:
inline bool isArraySelector() const { return !isStructSelector(); }
bool isStructSelector() const;
+
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const GetElementPtrInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::GetElementPtr);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
#endif // LLVM_IMEMORY_H
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h
index 1e4733d..d0e0e2e 100644
--- a/include/llvm/iOther.h
+++ b/include/llvm/iOther.h
@@ -55,6 +55,16 @@ public:
// removeIncomingValue - Remove an incoming value. This is useful if a
// predecessor basic block is deleted. The value removed is returned.
Value *removeIncomingValue(const BasicBlock *BB);
+
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const PHINode *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() == Instruction::PHINode;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -79,6 +89,15 @@ public:
virtual Instruction *clone() const { return new CastInst(*this); }
virtual const char *getOpcodeName() const { return "cast"; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const CastInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() == Cast;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -105,8 +124,8 @@ public:
inline Method *getParent() { return Parent; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool isa(const MethodArgument *) { return true; }
- static inline bool isa(const Value *V) {
+ static inline bool classof(const MethodArgument *) { return true; }
+ static inline bool classof(const Value *V) {
return V->getValueType() == MethodArgumentVal;
}
};
@@ -133,6 +152,15 @@ public:
Method *getCalledMethod() {
return cast<Method>(Operands[0]);
}
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const CallInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() == Instruction::Call;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -161,6 +189,16 @@ public:
virtual const char *getOpcodeName() const {
return getOpcode() == Shl ? "shl" : "shr";
}
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const ShiftInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Shr) |
+ (I->getOpcode() == Instruction::Shl);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
#endif
diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h
index 6978da5..e1b53f0 100644
--- a/include/llvm/iTerminators.h
+++ b/include/llvm/iTerminators.h
@@ -56,6 +56,15 @@ public:
//
virtual const BasicBlock *getSuccessor(unsigned idx) const { return 0; }
virtual unsigned getNumSuccessors() const { return 0; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const ReturnInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Ret);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -105,6 +114,15 @@ public:
}
virtual unsigned getNumSuccessors() const { return 1+!isUnconditional(); }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BranchInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Br);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
@@ -161,6 +179,15 @@ public:
return cast<ConstPoolVal>(Operands[idx*2]);
}
virtual unsigned getNumSuccessors() const { return Operands.size()/2; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const SwitchInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::Switch);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
#endif