diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-08 03:37:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-08 03:37:16 +0000 |
commit | 3ce5e887aef457701da95f1c6ccbd58ec3d32fe4 (patch) | |
tree | 592c2926477b5415711d09dfc46c64982e3bb4f0 /include/llvm/IntrinsicInst.h | |
parent | ff9dcee534bf8108dd7b6a77f45db8f17e4125c6 (diff) | |
download | llvm-3ce5e887aef457701da95f1c6ccbd58ec3d32fe4.tar.gz llvm-3ce5e887aef457701da95f1c6ccbd58ec3d32fe4.tar.bz2 llvm-3ce5e887aef457701da95f1c6ccbd58ec3d32fe4.tar.xz |
Introduce a new MemTransferInst pseudo class, which is a common
parent between MemCpyInst and MemMoveInst, simplify some code to
use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IntrinsicInst.h')
-rw-r--r-- | include/llvm/IntrinsicInst.h | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h index 1877eec38f..924fec26d2 100644 --- a/include/llvm/IntrinsicInst.h +++ b/include/llvm/IntrinsicInst.h @@ -220,81 +220,79 @@ namespace llvm { } }; - - /// MemCpyInst - This class wraps the llvm.memcpy intrinsic. + /// MemSetInst - This class wraps the llvm.memset intrinsic. /// - struct MemCpyInst : public MemIntrinsic { + struct MemSetInst : public MemIntrinsic { /// get* - Return the arguments to the instruction. /// - Value *getRawSource() const { return const_cast<Value*>(getOperand(2)); } - - /// getSource - This is just like getRawSource, but it strips off any cast - /// instructions that feed it, giving the original input. The returned - /// value is guaranteed to be a pointer. - Value *getSource() const { return getRawSource()->stripPointerCasts(); } - - - void setSource(Value *Ptr) { - assert(getRawSource()->getType() == Ptr->getType() && + Value *getValue() const { return const_cast<Value*>(getOperand(2)); } + + void setValue(Value *Val) { + assert(getValue()->getType() == Val->getType() && "setSource called with pointer of wrong type!"); - setOperand(2, Ptr); + setOperand(2, Val); } - + // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const MemCpyInst *) { return true; } + static inline bool classof(const MemSetInst *) { return true; } static inline bool classof(const IntrinsicInst *I) { - return I->getIntrinsicID() == Intrinsic::memcpy; + return I->getIntrinsicID() == Intrinsic::memset; } static inline bool classof(const Value *V) { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } }; - - /// MemMoveInst - This class wraps the llvm.memmove intrinsic. + + /// MemTransferInst - This class wraps the llvm.memcpy/memmove intrinsics. /// - struct MemMoveInst : public MemIntrinsic { + struct MemTransferInst : public MemIntrinsic { /// get* - Return the arguments to the instruction. /// Value *getRawSource() const { return const_cast<Value*>(getOperand(2)); } - + /// getSource - This is just like getRawSource, but it strips off any cast /// instructions that feed it, giving the original input. The returned /// value is guaranteed to be a pointer. Value *getSource() const { return getRawSource()->stripPointerCasts(); } - + void setSource(Value *Ptr) { assert(getRawSource()->getType() == Ptr->getType() && "setSource called with pointer of wrong type!"); setOperand(2, Ptr); } - + // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const MemMoveInst *) { return true; } + static inline bool classof(const MemTransferInst *) { return true; } static inline bool classof(const IntrinsicInst *I) { - return I->getIntrinsicID() == Intrinsic::memmove; + return I->getIntrinsicID() == Intrinsic::memcpy || + I->getIntrinsicID() == Intrinsic::memmove; } static inline bool classof(const Value *V) { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } }; - - /// MemSetInst - This class wraps the llvm.memset intrinsic. + + + /// MemCpyInst - This class wraps the llvm.memcpy intrinsic. /// - struct MemSetInst : public MemIntrinsic { - /// get* - Return the arguments to the instruction. - /// - Value *getValue() const { return const_cast<Value*>(getOperand(2)); } - - void setValue(Value *Val) { - assert(getValue()->getType() == Val->getType() && - "setSource called with pointer of wrong type!"); - setOperand(2, Val); + struct MemCpyInst : public MemTransferInst { + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const MemCpyInst *) { return true; } + static inline bool classof(const IntrinsicInst *I) { + return I->getIntrinsicID() == Intrinsic::memcpy; + } + static inline bool classof(const Value *V) { + return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } + }; + /// MemMoveInst - This class wraps the llvm.memmove intrinsic. + /// + struct MemMoveInst : public MemTransferInst { // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const MemSetInst *) { return true; } + static inline bool classof(const MemMoveInst *) { return true; } static inline bool classof(const IntrinsicInst *I) { - return I->getIntrinsicID() == Intrinsic::memset; + return I->getIntrinsicID() == Intrinsic::memmove; } static inline bool classof(const Value *V) { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); |