[cfe-commits] r106619 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Type.h include/clang/Basic/DiagnosticParseKinds.td include/clang/Parse/DeclSpec.h lib/AST/ASTContext.cpp lib/AST/ASTImporter.cpp lib/AST/TypePrinter.cpp lib/CodeGen/Mangle.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp lib/Parse/DeclSpec.cpp lib/Sema/SemaChecking.cpp lib/Sema/SemaType.cpp lib/Sema/TreeTransform.h test/Makefile test/Parser/altivec.c test/Parser/cxx-altivec.cpp

Chris Lattner sabre at nondot.org
Tue Jun 22 23:00:24 PDT 2010


Author: lattner
Date: Wed Jun 23 01:00:24 2010
New Revision: 106619

URL: http://llvm.org/viewvc/llvm-project?rev=106619&view=rev
Log:
improve altivec vector bool/pixel support, patch by Anton Yartsev
with several tweaks by me.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/include/clang/Parse/DeclSpec.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/ASTImporter.cpp
    cfe/trunk/lib/AST/TypePrinter.cpp
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/lib/Frontend/PCHReader.cpp
    cfe/trunk/lib/Frontend/PCHWriter.cpp
    cfe/trunk/lib/Parse/DeclSpec.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/Makefile
    cfe/trunk/test/Parser/altivec.c
    cfe/trunk/test/Parser/cxx-altivec.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jun 23 01:00:24 2010
@@ -563,7 +563,7 @@
   /// 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,
-                         bool AltiVec, bool IsPixel);
+                         VectorType::AltiVecSpecific AltiVecSpec);
 
   /// getExtVectorType - Return the unique reference to an extended vector type
   /// of the specified element type and size.  VectorType must be a built-in

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Jun 23 01:00:24 2010
@@ -1650,6 +1650,13 @@
 /// Since the constructor takes the number of vector elements, the
 /// 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 ...'
+  };
 protected:
   /// ElementType - The element type of the vector.
   QualType ElementType;
@@ -1657,21 +1664,16 @@
   /// NumElements - The number of elements in the vector.
   unsigned NumElements;
 
-  /// AltiVec - True if this is for an Altivec vector.
-  bool AltiVec;
-
-  /// Pixel - True if this is for an Altivec vector pixel.
-  bool Pixel;
+  AltiVecSpecific AltiVecSpec;
 
   VectorType(QualType vecType, unsigned nElements, QualType canonType,
-      bool isAltiVec, bool isPixel) :
+      AltiVecSpecific altiVecSpec) :
     Type(Vector, canonType, vecType->isDependentType()),
-    ElementType(vecType), NumElements(nElements),
-    AltiVec(isAltiVec), Pixel(isPixel) {}
+    ElementType(vecType), NumElements(nElements), AltiVecSpec(altiVecSpec) {}
   VectorType(TypeClass tc, QualType vecType, unsigned nElements,
-             QualType canonType, bool isAltiVec, bool isPixel)
+             QualType canonType, AltiVecSpecific altiVecSpec)
     : Type(tc, canonType, vecType->isDependentType()), ElementType(vecType),
-      NumElements(nElements), AltiVec(isAltiVec), Pixel(isPixel) {}
+      NumElements(nElements), AltiVecSpec(altiVecSpec) {}
   friend class ASTContext;  // ASTContext creates these.
   
   virtual Linkage getLinkageImpl() const;
@@ -1684,22 +1686,18 @@
   bool isSugared() const { return false; }
   QualType desugar() const { return QualType(this, 0); }
 
-  bool isAltiVec() const { return AltiVec; }
-  
-  bool isPixel() const { return Pixel; }
-  
+  AltiVecSpecific getAltiVecSpecific() const { return AltiVecSpec; }
+
   void Profile(llvm::FoldingSetNodeID &ID) {
-    Profile(ID, getElementType(), getNumElements(), getTypeClass(),
-      AltiVec, Pixel);
+    Profile(ID, getElementType(), getNumElements(), getTypeClass(), AltiVecSpec);
   }
   static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType,
                       unsigned NumElements, TypeClass TypeClass,
-                      bool isAltiVec, bool isPixel) {
+                      unsigned AltiVecSpec) {
     ID.AddPointer(ElementType.getAsOpaquePtr());
     ID.AddInteger(NumElements);
     ID.AddInteger(TypeClass);
-    ID.AddBoolean(isAltiVec);
-    ID.AddBoolean(isPixel);
+    ID.AddInteger(AltiVecSpec);
   }
 
   static bool classof(const Type *T) {
@@ -1715,7 +1713,7 @@
 /// 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, false, false) {}
+    VectorType(ExtVector, vecType, nElements, canonType, NotAltiVec) {}
   friend class ASTContext;  // ASTContext creates these.
 public:
   static int getPointAccessorIdx(char c) {

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Jun 23 01:00:24 2010
@@ -171,11 +171,15 @@
 def err_invalid_decl_spec_combination : Error<
   "cannot combine with previous '%0' declaration specifier">;
 def err_invalid_vector_decl_spec_combination : Error<
-  "cannot combine with previous '%0' declaration specifier. '__vector' must be first">;
+  "cannot combine with previous '%0' declaration specifier. "
+  "'__vector' must be first">;
 def err_invalid_pixel_decl_spec_combination : Error<
-  "'__pixel' must be preceded by '__vector'.  '%0' declaration specifier not allowed here">;
-def err_invalid_vector_double_decl_spec_combination : Error<
-  "cannot use 'double' with '__vector'">;
+  "'__pixel' must be preceded by '__vector'.  "
+  "'%0' declaration specifier not allowed here">;
+def err_invalid_vector_decl_spec : Error<
+  "cannot use '%0' with '__vector'">;
+def err_invalid_vector_bool_decl_spec : Error<
+  "cannot use '%0' with '__vector bool'">;
 def warn_vector_long_decl_spec_combination : Warning<
   "Use of 'long' with '__vector' is deprecated">, InGroup<Deprecated>;
 def err_friend_invalid_in_context : Error<

Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jun 23 01:00:24 2010
@@ -170,6 +170,7 @@
   /*TST*/unsigned TypeSpecType : 5;
   bool TypeAltiVecVector : 1;
   bool TypeAltiVecPixel : 1;
+  bool TypeAltiVecBool : 1;
   bool TypeSpecOwned : 1;
 
   // type-qualifiers
@@ -237,6 +238,7 @@
       TypeSpecType(TST_unspecified),
       TypeAltiVecVector(false),
       TypeAltiVecPixel(false),
+      TypeAltiVecBool(false),
       TypeSpecOwned(false),
       TypeQualifiers(TSS_unspecified),
       FS_inline_specified(false),
@@ -278,6 +280,7 @@
   TST getTypeSpecType() const { return (TST)TypeSpecType; }
   bool isTypeAltiVecVector() const { return TypeAltiVecVector; }
   bool isTypeAltiVecPixel() const { return TypeAltiVecPixel; }
+  bool isTypeAltiVecBool() const { return TypeAltiVecBool; }
   bool isTypeSpecOwned() const { return TypeSpecOwned; }
   void *getTypeRep() const { return TypeRep; }
   CXXScopeSpec &getTypeSpecScope() { return TypeScope; }

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jun 23 01:00:24 2010
@@ -1514,7 +1514,7 @@
 /// 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,
-                                   bool IsAltiVec, bool IsPixel) {
+    VectorType::AltiVecSpecific AltiVecSpec) {
   BuiltinType *baseType;
 
   baseType = dyn_cast<BuiltinType>(getCanonicalType(vecType).getTypePtr());
@@ -1522,8 +1522,8 @@
 
   // Check if we've already instantiated a vector of this type.
   llvm::FoldingSetNodeID ID;
-  VectorType::Profile(ID, vecType, NumElts, Type::Vector,
-    IsAltiVec, IsPixel);
+  VectorType::Profile(ID, vecType, NumElts, Type::Vector, AltiVecSpec);
+
   void *InsertPos = 0;
   if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
     return QualType(VTP, 0);
@@ -1531,16 +1531,19 @@
   // If the element type isn't canonical, this won't be a canonical type either,
   // so fill in the canonical type field.
   QualType Canonical;
-  if (!vecType.isCanonical() || IsAltiVec || IsPixel) {
-    Canonical = getVectorType(getCanonicalType(vecType),
-      NumElts, false, false);
+  if (!vecType.isCanonical() || (AltiVecSpec == VectorType::AltiVec)) {
+    // pass VectorType::NotAltiVec for AltiVecSpec to make AltiVec canonical
+    // vector type (except 'vector bool ...' and 'vector Pixel') the same as
+    // the equivalent GCC vector types
+    Canonical = getVectorType(getCanonicalType(vecType), NumElts,
+      VectorType::NotAltiVec);
 
     // 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, IsAltiVec, IsPixel);
+    VectorType(vecType, NumElts, Canonical, AltiVecSpec);
   VectorTypes.InsertNode(New, InsertPos);
   Types.push_back(New);
   return QualType(New, 0);
@@ -1556,7 +1559,8 @@
 
   // Check if we've already instantiated a vector of this type.
   llvm::FoldingSetNodeID ID;
-  VectorType::Profile(ID, vecType, NumElts, Type::ExtVector, false, false);
+  VectorType::Profile(ID, vecType, NumElts, Type::ExtVector,
+                      VectorType::NotAltiVec);
   void *InsertPos = 0;
   if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
     return QualType(VTP, 0);
@@ -4933,7 +4937,7 @@
   // Turn <4 x signed int> -> <4 x unsigned int>
   if (const VectorType *VTy = T->getAs<VectorType>())
     return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
-             VTy->getNumElements(), VTy->isAltiVec(), VTy->isPixel());
+             VTy->getNumElements(), VTy->getAltiVecSpecific());
 
   // For enums, we return the unsigned version of the base type.
   if (const EnumType *ETy = T->getAs<EnumType>())
@@ -5091,7 +5095,8 @@
 
     QualType ElementType = DecodeTypeFromStr(Str, Context, Error, false);
     // FIXME: Don't know what to do about AltiVec.
-    Type = Context.getVectorType(ElementType, NumElements, false, false);
+    Type = Context.getVectorType(ElementType, NumElements,
+                                 VectorType::NotAltiVec);
     break;
   }
   case 'X': {

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Jun 23 01:00:24 2010
@@ -440,9 +440,7 @@
       return false;
     if (Vec1->getNumElements() != Vec2->getNumElements())
       return false;
-    if (Vec1->isAltiVec() != Vec2->isAltiVec())
-      return false;
-    if (Vec1->isPixel() != Vec2->isPixel())
+    if (Vec1->getAltiVecSpecific() != Vec2->getAltiVecSpecific())
       return false;
     break;
   }
@@ -1191,8 +1189,7 @@
   
   return Importer.getToContext().getVectorType(ToElementType, 
                                                T->getNumElements(),
-                                               T->isAltiVec(),
-                                               T->isPixel());
+                                               T->getAltiVecSpecific());
 }
 
 QualType ASTNodeImporter::VisitExtVectorType(ExtVectorType *T) {

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Jun 23 01:00:24 2010
@@ -227,12 +227,13 @@
 }
 
 void TypePrinter::PrintVector(const VectorType *T, std::string &S) { 
-  if (T->isAltiVec()) {
-    if (T->isPixel())
+  if (T->getAltiVecSpecific() != VectorType::NotAltiVec) {
+    if (T->getAltiVecSpecific() == VectorType::Pixel)
       S = "__vector __pixel " + S;
     else {
       Print(T->getElementType(), S);
-      S = "__vector " + S;
+      S = ((T->getAltiVecSpecific() == VectorType::Bool)
+           ? "__vector __bool " : "__vector ") + S;
     }
   } else {
     // FIXME: We prefer to print the size directly here, but have no way

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Wed Jun 23 01:00:24 2010
@@ -1322,12 +1322,20 @@
 }
 
 // GNU extension: vector types
-// <type>        ::= <vector-type>
-// <vector-type> ::= Dv <positive dimension number> _ <element type>
-//               ::= Dv [<dimension expression>] _ <element type>
+// <type>                  ::= <vector-type>
+// <vector-type>           ::= Dv <positive dimension number> _
+//                                    <extended element type>
+//                         ::= Dv [<dimension expression>] _ <element type>
+// <extended element type> ::= <element type>
+//                         ::= p # AltiVec vector pixel
 void CXXNameMangler::mangleType(const VectorType *T) {
   Out << "Dv" << T->getNumElements() << '_';
-  mangleType(T->getElementType());
+  if (T->getAltiVecSpecific() == VectorType::Pixel)
+    Out << 'p';
+  else if (T->getAltiVecSpecific() == VectorType::Bool)
+    Out << 'b';
+  else
+    mangleType(T->getElementType());
 }
 void CXXNameMangler::mangleType(const ExtVectorType *T) {
   mangleType(static_cast<const VectorType*>(T));

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Jun 23 01:00:24 2010
@@ -2060,20 +2060,20 @@
   }
 
   case pch::TYPE_VECTOR: {
-    if (Record.size() != 4) {
+    if (Record.size() != 3) {
       Error("incorrect encoding of vector type in PCH file");
       return QualType();
     }
 
     QualType ElementType = GetType(Record[0]);
     unsigned NumElements = Record[1];
-    bool AltiVec = Record[2];
-    bool Pixel = Record[3];
-    return Context->getVectorType(ElementType, NumElements, AltiVec, Pixel);
+    unsigned AltiVecSpec = Record[2];
+    return Context->getVectorType(ElementType, NumElements,
+                                  (VectorType::AltiVecSpecific)AltiVecSpec);
   }
 
   case pch::TYPE_EXT_VECTOR: {
-    if (Record.size() != 4) {
+    if (Record.size() != 3) {
       Error("incorrect encoding of extended vector type in PCH file");
       return QualType();
     }

Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed Jun 23 01:00:24 2010
@@ -128,8 +128,7 @@
 void PCHTypeWriter::VisitVectorType(const VectorType *T) {
   Writer.AddTypeRef(T->getElementType(), Record);
   Record.push_back(T->getNumElements());
-  Record.push_back(T->isAltiVec());
-  Record.push_back(T->isPixel());
+  Record.push_back(T->getAltiVecSpecific());
   Code = pch::TYPE_VECTOR;
 }
 

Modified: cfe/trunk/lib/Parse/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/DeclSpec.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Parse/DeclSpec.cpp Wed Jun 23 01:00:24 2010
@@ -253,7 +253,8 @@
     return BadSpecifier(W, (TSW)TypeSpecWidth, PrevSpec, DiagID);
   TypeSpecWidth = W;
   TSWLoc = Loc;
-  if (TypeAltiVecVector && ((TypeSpecWidth == TSW_long) || (TypeSpecWidth == TSW_longlong))) {
+  if (TypeAltiVecVector && !TypeAltiVecBool &&
+      ((TypeSpecWidth == TSW_long) || (TypeSpecWidth == TSW_longlong))) {
     PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
     DiagID = diag::warn_vector_long_decl_spec_combination;
     return true;
@@ -290,13 +291,18 @@
     DiagID = diag::err_invalid_decl_spec_combination;
     return true;
   }
+  if (TypeAltiVecVector && (T == TST_bool) && !TypeAltiVecBool) {
+    TypeAltiVecBool = true;
+    TSTLoc = Loc;
+    return false;
+  }
   TypeSpecType = T;
   TypeRep = Rep;
   TSTLoc = Loc;
   TypeSpecOwned = Owned;
-  if (TypeAltiVecVector && (TypeSpecType == TST_double)) {
+  if (TypeAltiVecVector && !TypeAltiVecBool && (TypeSpecType == TST_double)) {
     PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
-    DiagID = diag::err_invalid_vector_double_decl_spec_combination;
+    DiagID = diag::err_invalid_vector_decl_spec;
     return true;
   }
   return false;
@@ -316,14 +322,12 @@
 
 bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
                           const char *&PrevSpec, unsigned &DiagID) {
-  if (!TypeAltiVecVector || (TypeSpecType != TST_unspecified)) {
+  if (!TypeAltiVecVector || TypeAltiVecPixel ||
+      (TypeSpecType != TST_unspecified)) {
     PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType);
     DiagID = diag::err_invalid_pixel_decl_spec_combination;
     return true;
   }
-  TypeSpecType = TST_int;
-  TypeSpecSign = TSS_unsigned;
-  TypeSpecWidth = TSW_short;
   TypeAltiVecPixel = isAltiVecPixel;
   TSTLoc = Loc;
   return false;
@@ -438,6 +442,42 @@
   // Check the type specifier components first.
   SourceManager &SrcMgr = PP.getSourceManager();
 
+  // Validate and finalize AltiVec vector declspec.
+  if (TypeAltiVecVector) {
+    if (TypeAltiVecBool) {
+      // Sign specifiers are not allowed with vector bool. (PIM 2.1)
+      if (TypeSpecSign != TSS_unspecified) {
+        Diag(D, TSSLoc, SrcMgr, diag::err_invalid_vector_bool_decl_spec)
+          << getSpecifierName((TSS)TypeSpecSign);
+      }
+
+      // Only char/int are valid with vector bool. (PIM 2.1)
+      if ((TypeSpecType != TST_unspecified) && (TypeSpecType != TST_char) &&
+          (TypeSpecType != TST_int) || TypeAltiVecPixel) {
+        Diag(D, TSTLoc, SrcMgr, diag::err_invalid_vector_bool_decl_spec)
+          << (TypeAltiVecPixel ? "__pixel" :
+                                 getSpecifierName((TST)TypeSpecType));
+      }
+
+      // Only 'short' is valid with vector bool. (PIM 2.1)
+      if ((TypeSpecWidth != TSW_unspecified) && (TypeSpecWidth != TSW_short))
+        Diag(D, TSWLoc, SrcMgr, diag::err_invalid_vector_bool_decl_spec)
+          << getSpecifierName((TSW)TypeSpecWidth);
+
+      // Elements of vector bool are interpreted as unsigned. (PIM 2.1)
+      if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) ||
+          (TypeSpecWidth != TSW_unspecified))
+        TypeSpecSign = TSS_unsigned;
+    }
+
+    if (TypeAltiVecPixel) {
+      //TODO: perform validation
+      TypeSpecType = TST_int;
+      TypeSpecSign = TSS_unsigned;
+      TypeSpecWidth = TSW_short;
+    }
+  }
+
   // signed/unsigned are only valid with int/char/wchar_t.
   if (TypeSpecSign != TSS_unspecified) {
     if (TypeSpecType == TST_unspecified)
@@ -513,7 +553,6 @@
     ClearStorageClassSpecs();
   }
 
-
   // Okay, now we can infer the real type.
 
   // TODO: return "auto function" and other bad things based on the real type.

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Jun 23 01:00:24 2010
@@ -782,7 +782,8 @@
       return ExprError();
     } else if (numElements != numResElements) {
       QualType eltType = LHSType->getAs<VectorType>()->getElementType();
-      resType = Context.getVectorType(eltType, numResElements, false, false);
+      resType = Context.getVectorType(eltType, numResElements,
+                                      VectorType::NotAltiVec);
     }
   }
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jun 23 01:00:24 2010
@@ -383,8 +383,12 @@
   } 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");
-    Result = Context.getVectorType(Result, 128/typeSize, true,
-      DS.isTypeAltiVecPixel());
+    VectorType::AltiVecSpecific AltiVecSpec = VectorType::AltiVec;
+    if (DS.isTypeAltiVecPixel())
+      AltiVecSpec = VectorType::Pixel;
+    else if (DS.isTypeAltiVecBool())
+      AltiVecSpec = VectorType::Bool;
+    Result = Context.getVectorType(Result, 128/typeSize, AltiVecSpec);
   }
 
   assert(DS.getTypeSpecComplex() != DeclSpec::TSC_imaginary &&
@@ -1162,7 +1166,8 @@
         }
 
         if (FTI.NumArgs && FTI.ArgInfo[0].Param == 0) {
-          // C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition.
+          // C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function
+          // definition.
           Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);
           D.setInvalidType(true);
           break;
@@ -1880,7 +1885,8 @@
 /// The raw attribute should contain precisely 1 argument, the vector size for
 /// the variable, measured in bytes. If curType and rawAttr are well formed,
 /// this routine will return a new vector type.
-static void HandleVectorSizeAttr(QualType& CurType, const AttributeList &Attr, Sema &S) {
+static void HandleVectorSizeAttr(QualType& CurType, const AttributeList &Attr,
+                                 Sema &S) {
   // Check the attribute arugments.
   if (Attr.getNumArgs() != 1) {
     S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
@@ -1923,7 +1929,8 @@
 
   // 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, false, false);
+  CurType = S.Context.getVectorType(CurType, vectorSize/typeSize,
+                                    VectorType::NotAltiVec);
 }
 
 void ProcessTypeAttributeList(Sema &S, QualType &Result,

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Jun 23 01:00:24 2010
@@ -442,7 +442,7 @@
   /// 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,
-    bool IsAltiVec, bool IsPixel);
+    VectorType::AltiVecSpecific AltiVecSpec);
 
   /// \brief Build a new extended vector type given the element type and
   /// number of elements.
@@ -2811,7 +2811,7 @@
   if (getDerived().AlwaysRebuild() ||
       ElementType != T->getElementType()) {
     Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
-      T->isAltiVec(), T->isPixel());
+      T->getAltiVecSpecific());
     if (Result.isNull())
       return QualType();
   }
@@ -6345,11 +6345,10 @@
 
 template<typename Derived>
 QualType TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
-                                       unsigned NumElements,
-                                       bool IsAltiVec, bool IsPixel) {
+                                     unsigned NumElements,
+                                     VectorType::AltiVecSpecific AltiVecSpec) {
   // FIXME: semantic checking!
-  return SemaRef.Context.getVectorType(ElementType, NumElements,
-                                       IsAltiVec, IsPixel);
+  return SemaRef.Context.getVectorType(ElementType, NumElements, AltiVecSpec);
 }
 
 template<typename Derived>

Modified: cfe/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Makefile?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/test/Makefile (original)
+++ cfe/trunk/test/Makefile Wed Jun 23 01:00:24 2010
@@ -18,7 +18,7 @@
 ifdef VERBOSE
 TESTARGS = -v
 else
-TESTARGS = -s -v 
+TESTARGS = -s -v -j16
 endif
 endif
 

Modified: cfe/trunk/test/Parser/altivec.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/altivec.c?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/test/Parser/altivec.c (original)
+++ cfe/trunk/test/Parser/altivec.c Wed Jun 23 01:00:24 2010
@@ -13,7 +13,9 @@
 __vector signed int vv_sint;
 __vector unsigned int vv_ui;
 __vector float vv_f;
-__vector bool vv_b;
+__vector bool char vv_bc;
+__vector bool short vv_bs;
+__vector bool int vv_bi;
 __vector __pixel vv_p;
 __vector pixel vv__p;
 __vector int vf__r();
@@ -33,7 +35,9 @@
 vector signed int v_sint;
 vector unsigned int v_ui;
 vector float v_f;
-vector bool v_b;
+vector bool char v_bc;
+vector bool short v_bs;
+vector bool int v_bi;
 vector __pixel v_p;
 vector pixel v__p;
 vector int f__r();
@@ -57,14 +61,20 @@
 vector unsigned long int v_uli;     // expected-warning {{Use of 'long' with '__vector' is deprecated}}
 __vector long double  vv_ld;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
 vector long double  v_ld;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector bool v_b;                    // expected-warning {{type specifier missing, defaults to 'int'}}
 
 // These should have errors.
-__vector double vv_d;               // expected-error {{cannot use 'double' with '__vector'}}
-__vector double vv_d;               // expected-error {{cannot use 'double' with '__vector'}}
-vector double v_d;                  // expected-error {{cannot use 'double' with '__vector'}}
-vector double v_d;                  // expected-error {{cannot use 'double' with '__vector'}}
-__vector long double  vv_ld;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double  v_ld;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector double vv_d1;               // expected-error {{cannot use 'double' with '__vector'}}
+vector double v_d2;                  // expected-error {{cannot use 'double' with '__vector'}}
+__vector long double  vv_ld3;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector long double  v_ld4;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector bool float v_bf;              // expected-error {{cannot use 'float' with '__vector bool'}}
+vector bool double v_bd;             // expected-error {{cannot use 'double' with '__vector bool'}}
+vector bool pixel v_bp;              // expected-error {{cannot use '__pixel' with '__vector bool'}}
+vector bool signed char v_bsc;       // expected-error {{cannot use 'signed' with '__vector bool'}}
+vector bool unsigned int v_bsc2;     // expected-error {{cannot use 'unsigned' with '__vector bool'}}
+vector bool long v_bl;               // expected-error {{cannot use 'long' with '__vector bool'}}
+vector bool long long v_bll;         // expected-error {{cannot use 'long long' with '__vector bool'}}
 
 void f() {
   __vector unsigned int v = {0,0,0,0};

Modified: cfe/trunk/test/Parser/cxx-altivec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-altivec.cpp?rev=106619&r1=106618&r2=106619&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-altivec.cpp (original)
+++ cfe/trunk/test/Parser/cxx-altivec.cpp Wed Jun 23 01:00:24 2010
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s
-// This is the same as the C version:
 
 __vector char vv_c;
 __vector signed char vv_sc;
@@ -14,7 +13,9 @@
 __vector signed int vv_sint;
 __vector unsigned int vv_ui;
 __vector float vv_f;
-__vector bool vv_b;
+__vector bool char vv_bc;
+__vector bool short vv_bs;
+__vector bool int vv_bi;
 __vector __pixel vv_p;
 __vector pixel vv__p;
 __vector int vf__r();
@@ -34,7 +35,9 @@
 vector signed int v_sint;
 vector unsigned int v_ui;
 vector float v_f;
-vector bool v_b;
+vector bool char v_bc;
+vector bool short v_bs;
+vector bool int v_bi;
 vector __pixel v_p;
 vector pixel v__p;
 vector int f__r();
@@ -64,6 +67,14 @@
 vector double v_d2;                  // expected-error {{cannot use 'double' with '__vector'}}
 __vector long double  vv_ld3;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
 vector long double  v_ld4;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector bool v_b;                     // expected-error {{error: C++ requires a type specifier for all declarations}}
+vector bool float v_bf;              // expected-error {{cannot use 'float' with '__vector bool'}}
+vector bool double v_bd;             // expected-error {{cannot use 'double' with '__vector bool'}}
+vector bool pixel v_bp;              // expected-error {{cannot use '__pixel' with '__vector bool'}}
+vector bool signed char v_bsc;       // expected-error {{cannot use 'signed' with '__vector bool'}}
+vector bool unsigned int v_bsc2;      // expected-error {{cannot use 'unsigned' with '__vector bool'}}
+vector bool long v_bl;               // expected-error {{cannot use 'long' with '__vector bool'}}
+vector bool long long v_bll;         // expected-error {{cannot use 'long long' with '__vector bool'}}
 
 void f() {
   __vector unsigned int v = {0,0,0,0};





More information about the cfe-commits mailing list