From 6e3abaa77f916341ed000b1a3883aec563967a88 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 26 Jan 2012 00:01:10 +0000 Subject: Ok, break down and add some cast<>'ing helper methods to the Type class to reduce the number of cast<>'s we have. This allows someone to use things like Ty->getVectorNumElements() instead of cast(Ty)->getNumElements() when you know that a type is a vector. It would be a great general cleanup to move the codebase to use these, I will do so in the code I'm touching. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148999 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Type.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include/llvm/Type.h') diff --git a/include/llvm/Type.h b/include/llvm/Type.h index e7c165b1bf..d3b2f1383f 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -314,6 +314,32 @@ public: /// unsigned getNumContainedTypes() const { return NumContainedTys; } + //===--------------------------------------------------------------------===// + // Helper methods corresponding to subclass methods. This forces a cast to + // the specified subclass and calls its accessor. "getVectorNumElements" (for + // example) is shorthand for cast(Ty)->getNumElements(). This is + // only intended to cover the core methods that are frequently used, helper + // methods should not be added here. + + unsigned getIntegerBitWidth() const; + + Type *getFunctionParamType(unsigned i) const; + unsigned getFunctionNumParams() const; + bool isFunctionVarArg() const; + + // TODO: StructType + + Type *getSequentialElementType() const; + + uint64_t getArrayNumElements() const; + Type *getArrayElementType() const { return getSequentialElementType(); } + + unsigned getVectorNumElements() const; + Type *getVectorElementType() const { return getSequentialElementType(); } + + unsigned getPointerAddressSpace() const; + Type *getPointerElementType() const { return getSequentialElementType(); } + //===--------------------------------------------------------------------===// // Static members exported by the Type class itself. Useful for getting // instances of Type. -- cgit v1.2.3