[PATCH] D133634: [clang] Allow vector of BitInt

Xiang Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 9 22:55:25 PDT 2022


python3kgae created this revision.
python3kgae added reviewers: beanz, pow2clk, Anastasia, aaron.ballman, bogner.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove check which disable BitInt as element type for ext_vector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133634

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/builtin-classify-type.c


Index: clang/test/Sema/builtin-classify-type.c
===================================================================
--- clang/test/Sema/builtin-classify-type.c
+++ clang/test/Sema/builtin-classify-type.c
@@ -29,6 +29,8 @@
   __attribute__((vector_size(16))) int vec;
   typedef __attribute__((ext_vector_type(4))) int evec_t;
   evec_t evec;
+  typedef _BitInt(16) int16_t3 __attribute__((ext_vector_type(3)));
+  int16_t3 t3;
   _Atomic int atomic_i;
   _Atomic double atomic_d;
   _Complex int complex_i;
Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2707,7 +2707,7 @@
   // We explictly allow bool elements in ext_vector_type for C/C++.
   bool IsNoBoolVecLang = getLangOpts().OpenCL || getLangOpts().OpenCLCPlusPlus;
   if ((!T->isDependentType() && !T->isIntegerType() &&
-       !T->isRealFloatingType()) || T->isBitIntType() ||
+       !T->isRealFloatingType()) ||
       (IsNoBoolVecLang && T->isBooleanType())) {
     Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T;
     return QualType();
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -4080,9 +4080,10 @@
 
 /// getExtVectorType - Return the unique reference to an extended vector type of
 /// the specified element type and size. VectorType must be a built-in type.
-QualType
-ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) const {
-  assert(vecType->isBuiltinType() || vecType->isDependentType());
+QualType ASTContext::getExtVectorType(QualType vecType,
+                                      unsigned NumElts) const {
+  assert(vecType->isBuiltinType() || vecType->isDependentType() ||
+         vecType->isBitIntType());
 
   // Check if we've already instantiated a vector of this type.
   llvm::FoldingSetNodeID ID;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133634.459259.patch
Type: text/x-patch
Size: 1965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220910/9ea57a9a/attachment.bin>


More information about the cfe-commits mailing list