diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h --- a/llvm/include/llvm/IR/DerivedTypes.h +++ b/llvm/include/llvm/IR/DerivedTypes.h @@ -537,8 +537,6 @@ } }; -bool Type::isVectorTy() const { return isa(this); } - /// Class to represent fixed width SIMD vectors class FixedVectorType : public VectorType { protected: @@ -705,12 +703,6 @@ return cast(getScalarType())->getAddressSpace(); } -Type *Type::getScalarType() const { - if (isVectorTy()) - return cast(this)->getElementType(); - return const_cast(this); -} - } // end namespace llvm #endif // LLVM_IR_DERIVEDTYPES_H diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h --- a/llvm/include/llvm/IR/Type.h +++ b/llvm/include/llvm/IR/Type.h @@ -228,7 +228,9 @@ bool isPtrOrPtrVectorTy() const { return getScalarType()->isPointerTy(); } /// True if this is an instance of VectorType. - inline bool isVectorTy() const; + inline bool isVectorTy() const { + return getTypeID() == ScalableVectorTyID || getTypeID() == FixedVectorTyID; + } /// Return true if this type could be converted with a lossless BitCast to /// type 'Ty'. For example, i8* to i32*. BitCasts are valid for types of the @@ -304,7 +306,11 @@ /// If this is a vector type, return the element type, otherwise return /// 'this'. - inline Type *getScalarType() const; + inline Type *getScalarType() const { + if (isVectorTy()) + return getContainedType(0); + return const_cast(this); + } //===--------------------------------------------------------------------===// // Type Iteration support.