From: Chris Lattner Date: Fri, 13 Jan 2006 19:49:02 +0000 (+0000) Subject: Add some functionality to the IntrinsicInst class and some comments X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=874357fa759c8d3b61fad1bcc73aab3e473ecd1a;p=oota-llvm.git Add some functionality to the IntrinsicInst class and some comments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25289 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h index 2b26ad52154..90b3761a09b 100644 --- a/include/llvm/IntrinsicInst.h +++ b/include/llvm/IntrinsicInst.h @@ -30,6 +30,9 @@ #include "llvm/Intrinsics.h" namespace llvm { + /// IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic + /// functions. This allows the standard isa/dyncast/cast functionality to + /// work with calls to intrinsic functions. class IntrinsicInst : public CallInst { IntrinsicInst(); // DO NOT IMPLEMENT IntrinsicInst(const IntrinsicInst&); // DO NOT IMPLEMENT @@ -40,6 +43,23 @@ namespace llvm { /// casts from the specified value, returning the original uncasted value. /// Note that the returned value is guaranteed to have pointer type. static Value *StripPointerCasts(Value *Ptr); + + /// getIntrinsicID - Return the intrinsic ID of this intrinsic. + /// + Intrinsic::ID getIntrinsicID() const { + return (Intrinsic::ID)getCalledFunction()->getIntrinsicID(); + } + + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const IntrinsicInst *) { return true; } + static inline bool classof(const CallInst *I) { + if (const Function *CF = I->getCalledFunction()) + return CF->getIntrinsicID() != 0; + return false; + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } }; /// DbgInfoIntrinsic - This is the common base class for debug info intrinsics