From: Craig Topper Date: Fri, 25 Dec 2015 04:06:20 +0000 (+0000) Subject: [IR] Mark the Type subclass helper methods 'inline' and move their definitions to... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=adcf2671f5f60c17cbbbe92349baf499cf0895c5;p=oota-llvm.git [IR] Mark the Type subclass helper methods 'inline' and move their definitions to DerivedTypes.h so they can be inlined by the compiler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256406 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/DerivedTypes.h b/include/llvm/IR/DerivedTypes.h index 0767b46e483..071e69b1e80 100644 --- a/include/llvm/IR/DerivedTypes.h +++ b/include/llvm/IR/DerivedTypes.h @@ -91,6 +91,10 @@ public: } }; +unsigned Type::getIntegerBitWidth() const { + return cast(this)->getBitWidth(); +} + /// FunctionType - Class to represent function types /// class FunctionType : public Type { @@ -143,6 +147,18 @@ public: static_assert(AlignOf::Alignment >= AlignOf::Alignment, "Alignment sufficient for objects appended to FunctionType"); +bool Type::isFunctionVarArg() const { + return cast(this)->isVarArg(); +} + +Type *Type::getFunctionParamType(unsigned i) const { + return cast(this)->getParamType(i); +} + +unsigned Type::getFunctionNumParams() const { + return cast(this)->getNumParams(); +} + /// CompositeType - Common super class of ArrayType, StructType, PointerType /// and VectorType. class CompositeType : public Type { @@ -294,6 +310,18 @@ public: } }; +StringRef Type::getStructName() const { + return cast(this)->getName(); +} + +unsigned Type::getStructNumElements() const { + return cast(this)->getNumElements(); +} + +Type *Type::getStructElementType(unsigned N) const { + return cast(this)->getElementType(N); +} + /// SequentialType - This is the superclass of the array, pointer and vector /// type classes. All of these represent "arrays" in memory. The array type /// represents a specifically sized array, pointer types are unsized/unknown @@ -325,6 +353,10 @@ public: } }; +Type *Type::getSequentialElementType() const { + return cast(this)->getElementType(); +} + /// ArrayType - Class to represent array types. /// class ArrayType : public SequentialType { @@ -352,6 +384,10 @@ public: } }; +uint64_t Type::getArrayNumElements() const { + return cast(this)->getNumElements(); +} + /// VectorType - Class to represent vector types. /// class VectorType : public SequentialType { @@ -439,6 +475,10 @@ public: } }; +unsigned Type::getVectorNumElements() const { + return cast(this)->getNumElements(); +} + /// PointerType - Class to represent pointers. /// class PointerType : public SequentialType { @@ -473,6 +513,10 @@ public: } }; +unsigned Type::getPointerAddressSpace() const { + return cast(getScalarType())->getAddressSpace(); +} + } // End llvm namespace #endif diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index 97227cebdb1..b2920dd3de6 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -337,28 +337,28 @@ public: // only intended to cover the core methods that are frequently used, helper // methods should not be added here. - unsigned getIntegerBitWidth() const; + inline unsigned getIntegerBitWidth() const; - Type *getFunctionParamType(unsigned i) const; - unsigned getFunctionNumParams() const; - bool isFunctionVarArg() const; + inline Type *getFunctionParamType(unsigned i) const; + inline unsigned getFunctionNumParams() const; + inline bool isFunctionVarArg() const; - StringRef getStructName() const; - unsigned getStructNumElements() const; - Type *getStructElementType(unsigned N) const; + inline StringRef getStructName() const; + inline unsigned getStructNumElements() const; + inline Type *getStructElementType(unsigned N) const; - Type *getSequentialElementType() const; + inline Type *getSequentialElementType() const; - uint64_t getArrayNumElements() const; + inline uint64_t getArrayNumElements() const; Type *getArrayElementType() const { return getSequentialElementType(); } - unsigned getVectorNumElements() const; + inline unsigned getVectorNumElements() const; Type *getVectorElementType() const { return getSequentialElementType(); } Type *getPointerElementType() const { return getSequentialElementType(); } /// \brief Get the address space of this pointer or pointer vector type. - unsigned getPointerAddressSpace() const; + inline unsigned getPointerAddressSpace() const; //===--------------------------------------------------------------------===// // Static members exported by the Type class itself. Useful for getting diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp index 649962690dd..4c1baf52a58 100644 --- a/lib/IR/Type.cpp +++ b/lib/IR/Type.cpp @@ -162,55 +162,6 @@ bool Type::isSizedDerivedType(SmallPtrSetImpl *Visited) const { return cast(this)->isSized(Visited); } -//===----------------------------------------------------------------------===// -// Subclass Helper Methods -//===----------------------------------------------------------------------===// - -unsigned Type::getIntegerBitWidth() const { - return cast(this)->getBitWidth(); -} - -bool Type::isFunctionVarArg() const { - return cast(this)->isVarArg(); -} - -Type *Type::getFunctionParamType(unsigned i) const { - return cast(this)->getParamType(i); -} - -unsigned Type::getFunctionNumParams() const { - return cast(this)->getNumParams(); -} - -StringRef Type::getStructName() const { - return cast(this)->getName(); -} - -unsigned Type::getStructNumElements() const { - return cast(this)->getNumElements(); -} - -Type *Type::getStructElementType(unsigned N) const { - return cast(this)->getElementType(N); -} - -Type *Type::getSequentialElementType() const { - return cast(this)->getElementType(); -} - -uint64_t Type::getArrayNumElements() const { - return cast(this)->getNumElements(); -} - -unsigned Type::getVectorNumElements() const { - return cast(this)->getNumElements(); -} - -unsigned Type::getPointerAddressSpace() const { - return cast(getScalarType())->getAddressSpace(); -} - - //===----------------------------------------------------------------------===// // Primitive 'Type' data //===----------------------------------------------------------------------===//