[llvm] 339177d - [SVE] Break dependency of Type.h on DerivedTypes.h

Christopher Tetreault via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 12:43:49 PDT 2020


Author: Christopher Tetreault
Date: 2020-06-12T12:43:33-07:00
New Revision: 339177d1da0c6f0cf181ba987836148acb526926

URL: https://github.com/llvm/llvm-project/commit/339177d1da0c6f0cf181ba987836148acb526926
DIFF: https://github.com/llvm/llvm-project/commit/339177d1da0c6f0cf181ba987836148acb526926.diff

LOG: [SVE] Break dependency of Type.h on DerivedTypes.h

Summary:
Inline functions in Type.h depended upon inline functions isVectorTy and
getScalarType defined in DerivedTypes.h. Reimplement these functions in
Type.h in terms of Type

Reviewers: rengolin, efriedma, echristo, c-rhodes, david-arm

Reviewed By: echristo

Subscribers: tschuett, rkruppe, psnobl, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81684

Added: 
    

Modified: 
    llvm/include/llvm/IR/DerivedTypes.h
    llvm/include/llvm/IR/Type.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 6a9c747d4713..25eb783cf6cd 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -537,8 +537,6 @@ class VectorType : public Type {
   }
 };
 
-bool Type::isVectorTy() const { return isa<VectorType>(this); }
-
 /// Class to represent fixed width SIMD vectors
 class FixedVectorType : public VectorType {
 protected:
@@ -705,12 +703,6 @@ unsigned Type::getPointerAddressSpace() const {
   return cast<PointerType>(getScalarType())->getAddressSpace();
 }
 
-Type *Type::getScalarType() const {
-  if (isVectorTy())
-    return cast<VectorType>(this)->getElementType();
-  return const_cast<Type *>(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
index 7043775f2439..1f546884b924 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -228,7 +228,9 @@ class Type {
   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 @@ class Type {
 
   /// 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<Type *>(this);
+  }
 
   //===--------------------------------------------------------------------===//
   // Type Iteration support.


        


More information about the llvm-commits mailing list