diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-05 00:13:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-05 00:13:28 +0000 |
commit | 5133a5cf2ee42b5a4d4c7af2d90b41af769cc307 (patch) | |
tree | aaa16e9338c469696fb6cf026b5ebe88db2de6d5 /include/llvm/Constants.h | |
parent | 00413e3d63c99ceed5d162ef650ad74c0db4e5d8 (diff) | |
download | external_llvm-5133a5cf2ee42b5a4d4c7af2d90b41af769cc307.zip external_llvm-5133a5cf2ee42b5a4d4c7af2d90b41af769cc307.tar.gz external_llvm-5133a5cf2ee42b5a4d4c7af2d90b41af769cc307.tar.bz2 |
Add some new methods to forward to
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8852 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r-- | include/llvm/Constants.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index c885c61..bf88ef7 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -17,6 +17,9 @@ class PointerType; template<class ConstantClass, class TypeClass, class ValType> struct ConstantCreator; +template<class ConstantClass, class TypeClass> +struct ConvertConstantType; + //===--------------------------------------------------------------------------- /// ConstantIntegral - Shared superclass of boolean and integer constants. @@ -482,6 +485,7 @@ class ConstantExpr : public Constant { unsigned iType; // Operation type (an Instruction opcode) friend struct ConstantCreator<ConstantExpr,Type, std::pair<unsigned, std::vector<Constant*> > >; + friend struct ConvertConstantType<ConstantExpr, Type>; protected: // Cast creation ctor @@ -491,6 +495,15 @@ protected: // GEP instruction creation ctor ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList, const Type *DestTy); + + // These private methods are used by the type resolution code to create + // ConstantExprs in intermediate forms. + static Constant *getTy(const Type *Ty, unsigned Opcode, + Constant *C1, Constant *C2); + static Constant *getShiftTy(const Type *Ty, + unsigned Opcode, Constant *C1, Constant *C2); + static Constant *getGetElementPtrTy(const Type *Ty, Constant *C, + const std::vector<Constant*> &IdxList); public: // Static methods to construct a ConstantExpr of different kinds. Note that @@ -499,15 +512,23 @@ public: // expression into something simpler if possible. /// Cast constant expr + /// static Constant *getCast(Constant *C, const Type *Ty); /// Binary constant expr - Use with binary operators... - static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); + /// + static Constant *get(unsigned Opcode, Constant *C1, Constant *C2) { + return getTy(C1->getType(), Opcode, C1, C2); + } /// getShift - Return a shift left or shift right constant expr - static Constant *getShift(unsigned Opcode, Constant *C1, Constant *C2); + /// + static Constant *getShift(unsigned Opcode, Constant *C1, Constant *C2) { + return getShiftTy(C1->getType(), Opcode, C1, C2); + } /// Getelementptr form... + /// static Constant *getGetElementPtr(Constant *C, const std::vector<Constant*> &IdxList); |