]> granicus.if.org Git - clang/commitdiff
Add a variant of GCC-style vector types for ARM NEON.
authorBob Wilson <bob.wilson@apple.com>
Wed, 10 Nov 2010 21:56:12 +0000 (21:56 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 10 Nov 2010 21:56:12 +0000 (21:56 +0000)
NEON vector types need to be mangled in a special way to comply with ARM's ABI,
similar to some of the AltiVec-specific vector types.  This patch is mostly
just renaming a bunch of "AltiVecSpecific" things, since they will no longer
be specific to AltiVec.  Besides that, it just adds the new "NeonVector" enum.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118724 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
include/clang/AST/ASTContext.h
include/clang/AST/Type.h
lib/AST/ASTContext.cpp
lib/AST/ASTImporter.cpp
lib/AST/TypePrinter.cpp
lib/CodeGen/Mangle.cpp
lib/Sema/SemaChecking.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaType.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp

index becafb66e5202a23164bc0b85471afa8d9acea0b..9e2221b21798a2a00ac600bf95b0f2905614a175 100644 (file)
@@ -596,7 +596,7 @@ public:
   /// getVectorType - Return the unique reference to a vector type of
   /// the specified element type and size. VectorType must be a built-in type.
   QualType getVectorType(QualType VectorType, unsigned NumElts,
-                         VectorType::AltiVecSpecific AltiVecSpec);
+                         VectorType::VectorKind VecKind);
 
   /// getExtVectorType - Return the unique reference to an extended vector type
   /// of the specified element type and size.  VectorType must be a built-in
index 9540389aaf020aeebceaea53943d435d493d7561..73c1911c2705f77c399a55f40bcfe437824b5d4b 100644 (file)
@@ -929,9 +929,9 @@ protected:
 
     unsigned : NumTypeBits;
 
-    /// AltiVecSpec - AltiVec-specific vector information, used
-    /// to differentiate things like 'pixel'.
-    unsigned AltiVecSpec : 2;
+    /// VecKind - The kind of vector, either a generic vector type or some
+    /// target-specific vector type such as for AltiVec or Neon.
+    unsigned VecKind : 2;
 
     /// NumElements - The number of elements in the vector.
     unsigned NumElements : 30 - NumTypeBits;
@@ -1913,29 +1913,30 @@ public:
 /// client is responsible for converting the size into the number of elements.
 class VectorType : public Type, public llvm::FoldingSetNode {
 public:
-  enum AltiVecSpecific {
-    NotAltiVec,  // is not AltiVec vector
-    AltiVec,     // is AltiVec vector
-    Pixel,       // is AltiVec 'vector Pixel'
-    Bool         // is AltiVec 'vector bool ...'
+  enum VectorKind {
+    GenericVector,  // not a target-specific vector type
+    AltiVecVector,  // is AltiVec vector
+    AltiVecPixel,   // is AltiVec 'vector Pixel'
+    AltiVecBool,    // is AltiVec 'vector bool ...'
+    NeonVector      // is ARM Neon vector
   };
 protected:
   /// ElementType - The element type of the vector.
   QualType ElementType;
 
   VectorType(QualType vecType, unsigned nElements, QualType canonType,
-      AltiVecSpecific altiVecSpec) :
+             VectorKind vecKind) :
     Type(Vector, canonType, vecType->isDependentType(),
          vecType->isVariablyModifiedType()), ElementType(vecType) {
-    VectorTypeBits.AltiVecSpec = altiVecSpec;
+    VectorTypeBits.VecKind = vecKind;
     VectorTypeBits.NumElements = nElements;
   }
   
   VectorType(TypeClass tc, QualType vecType, unsigned nElements,
-             QualType canonType, AltiVecSpecific altiVecSpec)
+             QualType canonType, VectorKind vecKind)
     : Type(tc, canonType, vecType->isDependentType(),
            vecType->isVariablyModifiedType()), ElementType(vecType) {
-    VectorTypeBits.AltiVecSpec = altiVecSpec;
+    VectorTypeBits.VecKind = vecKind;
     VectorTypeBits.NumElements = nElements;
   }
   friend class ASTContext;  // ASTContext creates these.
@@ -1950,21 +1951,21 @@ public:
   bool isSugared() const { return false; }
   QualType desugar() const { return QualType(this, 0); }
 
-  AltiVecSpecific getAltiVecSpecific() const {
-    return AltiVecSpecific(VectorTypeBits.AltiVecSpec);
+  VectorKind getVectorKind() const {
+    return VectorKind(VectorTypeBits.VecKind);
   }
 
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getElementType(), getNumElements(),
-            getTypeClass(), getAltiVecSpecific());
+            getTypeClass(), getVectorKind());
   }
   static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType,
                       unsigned NumElements, TypeClass TypeClass,
-                      AltiVecSpecific AltiVecSpec) {
+                      VectorKind VecKind) {
     ID.AddPointer(ElementType.getAsOpaquePtr());
     ID.AddInteger(NumElements);
     ID.AddInteger(TypeClass);
-    ID.AddInteger(AltiVecSpec);
+    ID.AddInteger(VecKind);
   }
 
   static bool classof(const Type *T) {
@@ -1980,7 +1981,7 @@ public:
 /// points, colors, and textures (modeled after OpenGL Shading Language).
 class ExtVectorType : public VectorType {
   ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) :
-    VectorType(ExtVector, vecType, nElements, canonType, NotAltiVec) {}
+    VectorType(ExtVector, vecType, nElements, canonType, GenericVector) {}
   friend class ASTContext;  // ASTContext creates these.
 public:
   static int getPointAccessorIdx(char c) {
index c9c7e5c2af8632472f5f5800b2c8e63718c1b23a..9146eb57aa99b8be4a392e2f726f820ecbb36500 100644 (file)
@@ -1602,7 +1602,7 @@ QualType ASTContext::getIncompleteArrayType(QualType EltTy,
 /// getVectorType - Return the unique reference to a vector type of
 /// the specified element type and size. VectorType must be a built-in type.
 QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
-                                   VectorType::AltiVecSpecific AltiVecSpec) {
+                                   VectorType::VectorKind VecKind) {
   BuiltinType *BaseType;
 
   BaseType = dyn_cast<BuiltinType>(getCanonicalType(vecType).getTypePtr());
@@ -1610,7 +1610,7 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
 
   // Check if we've already instantiated a vector of this type.
   llvm::FoldingSetNodeID ID;
-  VectorType::Profile(ID, vecType, NumElts, Type::Vector, AltiVecSpec);
+  VectorType::Profile(ID, vecType, NumElts, Type::Vector, VecKind);
 
   void *InsertPos = 0;
   if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
@@ -1621,14 +1621,14 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
   QualType Canonical;
   if (!vecType.isCanonical()) {
     Canonical = getVectorType(getCanonicalType(vecType), NumElts,
-      VectorType::NotAltiVec);
+      VectorType::GenericVector);
 
     // Get the new insert position for the node we care about.
     VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
   }
   VectorType *New = new (*this, TypeAlignment)
-    VectorType(vecType, NumElts, Canonical, AltiVecSpec);
+    VectorType(vecType, NumElts, Canonical, VecKind);
   VectorTypes.InsertNode(New, InsertPos);
   Types.push_back(New);
   return QualType(New, 0);
@@ -1645,7 +1645,7 @@ QualType ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) {
   // Check if we've already instantiated a vector of this type.
   llvm::FoldingSetNodeID ID;
   VectorType::Profile(ID, vecType, NumElts, Type::ExtVector,
-                      VectorType::NotAltiVec);
+                      VectorType::GenericVector);
   void *InsertPos = 0;
   if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
     return QualType(VTP, 0);
@@ -4287,10 +4287,10 @@ bool ASTContext::areCompatibleVectorTypes(QualType FirstVec,
   // AltiVec vectors types are identical to equivalent GCC vector types
   const VectorType *First = FirstVec->getAs<VectorType>();
   const VectorType *Second = SecondVec->getAs<VectorType>();
-  if ((((First->getAltiVecSpecific() == VectorType::AltiVec) &&
-        (Second->getAltiVecSpecific() == VectorType::NotAltiVec)) ||
-       ((First->getAltiVecSpecific() == VectorType::NotAltiVec) &&
-        (Second->getAltiVecSpecific() == VectorType::AltiVec))) &&
+  if ((((First->getVectorKind() == VectorType::AltiVecVector) &&
+        (Second->getVectorKind() == VectorType::GenericVector)) ||
+       ((First->getVectorKind() == VectorType::GenericVector) &&
+        (Second->getVectorKind() == VectorType::AltiVecVector))) &&
       hasSameType(First->getElementType(), Second->getElementType()) &&
       (First->getNumElements() == Second->getNumElements()))
     return true;
@@ -5243,7 +5243,7 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) {
   // Turn <4 x signed int> -> <4 x unsigned int>
   if (const VectorType *VTy = T->getAs<VectorType>())
     return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
-             VTy->getNumElements(), VTy->getAltiVecSpecific());
+                         VTy->getNumElements(), VTy->getVectorKind());
 
   // For enums, we return the unsigned version of the base type.
   if (const EnumType *ETy = T->getAs<EnumType>())
@@ -5422,7 +5422,7 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
     
     // TODO: No way to make AltiVec vectors in builtins yet.
     Type = Context.getVectorType(ElementType, NumElements,
-                                 VectorType::NotAltiVec);
+                                 VectorType::GenericVector);
     break;
   }
   case 'X': {
index 7747e617e3a50bbfe72f4f1a442efe7215843d0e..159a269534898a716847b30435140a3ed0cbdc9e 100644 (file)
@@ -441,7 +441,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
       return false;
     if (Vec1->getNumElements() != Vec2->getNumElements())
       return false;
-    if (Vec1->getAltiVecSpecific() != Vec2->getAltiVecSpecific())
+    if (Vec1->getVectorKind() != Vec2->getVectorKind())
       return false;
     break;
   }
@@ -1190,7 +1190,7 @@ QualType ASTNodeImporter::VisitVectorType(VectorType *T) {
   
   return Importer.getToContext().getVectorType(ToElementType, 
                                                T->getNumElements(),
-                                               T->getAltiVecSpecific());
+                                               T->getVectorKind());
 }
 
 QualType ASTNodeImporter::VisitExtVectorType(ExtVectorType *T) {
index 333a10ede70731e0b717849b84757c85bdf81cee..2e7e06fef78e2d5115b5d8ceeb5bd698e08c1b00 100644 (file)
@@ -251,12 +251,12 @@ void TypePrinter::PrintDependentSizedExtVector(
 }
 
 void TypePrinter::PrintVector(const VectorType *T, std::string &S) { 
-  if (T->getAltiVecSpecific() != VectorType::NotAltiVec) {
-    if (T->getAltiVecSpecific() == VectorType::Pixel)
+  if (T->getVectorKind() != VectorType::GenericVector) {
+    if (T->getVectorKind() == VectorType::AltiVecPixel)
       S = "__vector __pixel " + S;
     else {
       Print(T->getElementType(), S);
-      S = ((T->getAltiVecSpecific() == VectorType::Bool)
+      S = ((T->getVectorKind() == VectorType::AltiVecBool)
            ? "__vector __bool " : "__vector ") + S;
     }
   } else {
index d1e3a98789e703e7f4051a26d2b3749011f06ed6..9deb02159583f383d8cad0fe04f9dee7c7f0b442 100644 (file)
@@ -1411,9 +1411,9 @@ void CXXNameMangler::mangleType(const ComplexType *T) {
 //                         ::= p # AltiVec vector pixel
 void CXXNameMangler::mangleType(const VectorType *T) {
   Out << "Dv" << T->getNumElements() << '_';
-  if (T->getAltiVecSpecific() == VectorType::Pixel)
+  if (T->getVectorKind() == VectorType::AltiVecPixel)
     Out << 'p';
-  else if (T->getAltiVecSpecific() == VectorType::Bool)
+  else if (T->getVectorKind() == VectorType::AltiVecBool)
     Out << 'b';
   else
     mangleType(T->getElementType());
index e69ebe2250d881eb5ffd4b180623805fdc7aca67..921df8e2fba51485e5d077461997ab495a373aad 100644 (file)
@@ -811,7 +811,7 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
     } else if (numElements != numResElements) {
       QualType eltType = LHSType->getAs<VectorType>()->getElementType();
       resType = Context.getVectorType(eltType, numResElements,
-                                      VectorType::NotAltiVec);
+                                      VectorType::GenericVector);
     }
   }
 
index e601a7d328c45cf8c46fe72323ed02649f332e8b..7a2db6337604bcbaaf318937f0a0a351b9fbf88b 100644 (file)
@@ -914,7 +914,7 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity,
         VecType = SemaRef.Context.getExtVectorType(elementType, numIElts);
       else
         VecType = SemaRef.Context.getVectorType(elementType, numIElts,
-                                                IVT->getAltiVecSpecific());
+                                                IVT->getVectorKind());
       CheckSubElementType(ElementEntity, IList, VecType, Index,
                           StructuredList, StructuredIndex);
       numEltsInit += numIElts;
index e7219302c1d1fa18800322a6717a5ef48609fd2c..cb99a9f8928d7e2a897ee0479393cf90b5fb80d1 100644 (file)
@@ -388,12 +388,12 @@ static QualType ConvertDeclSpecToType(Sema &TheSema,
   } else if (DS.isTypeAltiVecVector()) {
     unsigned typeSize = static_cast<unsigned>(Context.getTypeSize(Result));
     assert(typeSize > 0 && "type size for vector must be greater than 0 bits");
-    VectorType::AltiVecSpecific AltiVecSpec = VectorType::AltiVec;
+    VectorType::VectorKind VecKind = VectorType::AltiVecVector;
     if (DS.isTypeAltiVecPixel())
-      AltiVecSpec = VectorType::Pixel;
+      VecKind = VectorType::AltiVecPixel;
     else if (DS.isTypeAltiVecBool())
-      AltiVecSpec = VectorType::Bool;
-    Result = Context.getVectorType(Result, 128/typeSize, AltiVecSpec);
+      VecKind = VectorType::AltiVecBool;
+    Result = Context.getVectorType(Result, 128/typeSize, VecKind);
   }
 
   // FIXME: Imaginary.
@@ -2044,7 +2044,7 @@ static void HandleVectorSizeAttr(QualType& CurType, const AttributeList &Attr,
   // Success! Instantiate the vector type, the number of elements is > 0, and
   // not required to be a power of 2, unlike GCC.
   CurType = S.Context.getVectorType(CurType, vectorSize/typeSize,
-                                    VectorType::NotAltiVec);
+                                    VectorType::GenericVector);
 }
 
 void ProcessTypeAttributeList(Sema &S, QualType &Result,
index 47822c5a9b2895c51714e72eecc9c44cf8e745f9..655980c85a48bb6abb51867206266c19409aee8a 100644 (file)
@@ -440,7 +440,7 @@ public:
   /// By default, performs semantic analysis when building the vector type.
   /// Subclasses may override this routine to provide different behavior.
   QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
-    VectorType::AltiVecSpecific AltiVecSpec);
+                             VectorType::VectorKind VecKind);
 
   /// \brief Build a new extended vector type given the element type and
   /// number of elements.
@@ -2841,7 +2841,7 @@ QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
   if (getDerived().AlwaysRebuild() ||
       ElementType != T->getElementType()) {
     Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
-      T->getAltiVecSpecific());
+                                            T->getVectorKind());
     if (Result.isNull())
       return QualType();
   }
@@ -6458,10 +6458,10 @@ TreeTransform<Derived>::RebuildDependentSizedArrayType(QualType ElementType,
 
 template<typename Derived>
 QualType TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
-                                     unsigned NumElements,
-                                     VectorType::AltiVecSpecific AltiVecSpec) {
+                                               unsigned NumElements,
+                                               VectorType::VectorKind VecKind) {
   // FIXME: semantic checking!
-  return SemaRef.Context.getVectorType(ElementType, NumElements, AltiVecSpec);
+  return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
 }
 
 template<typename Derived>
index c0d347d039512e776c71b8276ddd08c3c7810c56..2a6692a3e7792a270ab40d5ba0818f2bc0694835 100644 (file)
@@ -2783,9 +2783,9 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) {
 
     QualType ElementType = GetType(Record[0]);
     unsigned NumElements = Record[1];
-    unsigned AltiVecSpec = Record[2];
+    unsigned VecKind = Record[2];
     return Context->getVectorType(ElementType, NumElements,
-                                  (VectorType::AltiVecSpecific)AltiVecSpec);
+                                  (VectorType::VectorKind)VecKind);
   }
 
   case TYPE_EXT_VECTOR: {
index 8fc60ced771aacdbe86f5733f2525b8b722ef9a0..27862ae59cb9060c11e79ecc3bf69ed69b49c952 100644 (file)
@@ -143,7 +143,7 @@ void ASTTypeWriter::VisitVariableArrayType(const VariableArrayType *T) {
 void ASTTypeWriter::VisitVectorType(const VectorType *T) {
   Writer.AddTypeRef(T->getElementType(), Record);
   Record.push_back(T->getNumElements());
-  Record.push_back(T->getAltiVecSpecific());
+  Record.push_back(T->getVectorKind());
   Code = TYPE_VECTOR;
 }