[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D77313#1957970 , @sammccall wrote:

> In D77313#1957690 , @efriedma wrote:
>
> > I think I would rather just pay the extra 8 bytes per VectorType, and 
> > expand this to support all vector types supported by LLVM.  It's not like 
> > we allocate enough VectorTypes for it to matter, anyway.
>
>
> Sounds reasonable to me, I'll try that.


This alternative is in D77335 , which is much 
simpler.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77313/new/

https://reviews.llvm.org/D77313



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D77313#1957690 , @efriedma wrote:

> I think I would rather just pay the extra 8 bytes per VectorType, and expand 
> this to support all vector types supported by LLVM.  It's not like we 
> allocate enough VectorTypes for it to matter, anyway.


llvm::VectorType seems to accept arbitrary `unsigned` size, so IIUC you'd 
suggest putting just putting `unsigned NumElements` in `VectorType`, which 
would cost 4 bytes and another 4 in padding. 
Sounds reasonable to me, I'll try that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77313/new/

https://reviews.llvm.org/D77313



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I think I would rather just pay the extra 8 bytes per VectorType, and expand 
this to support all vector types supported by LLVM.  It's not like we allocate 
enough VectorTypes for it to matter, anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77313/new/

https://reviews.llvm.org/D77313



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, rjmccall, erichkeane.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This used to be 1-2043 elements, and recently regressed to a limit of 1023.
The new behavior is an almost-superset of GCC, which accepts powers of two up
to 2**62.

This change frees one further bit in VectorType in case Type grows again.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77313

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/types.c
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -343,7 +343,7 @@
 template 
 struct PR15730 {
   typedef T __attribute__((vector_size(N * sizeof(T type;
-  typedef T __attribute__((vector_size(8192))) type2; // #2
+  typedef T __attribute__((vector_size(1))) type2; // #2
   typedef T __attribute__((vector_size(3))) type3; // #3
 };
 
@@ -352,25 +352,27 @@
   const TemplateVectorType::type Works2 = {};
   // expected-error@#1 {{invalid vector element type 'bool'}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool;
+  const TemplateVectorType::type NoBool = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoComplex;
+  const TemplateVectorType::type NoComplex = {};
   // expected-error@#1 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type BadSize;
-  // expected-error@#1 {{vector size too large}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type TooLarge;
+  const TemplateVectorType::type BadSize = {};
+  const TemplateVectorType::type SmallNonPower = {};
+  const TemplateVectorType::type LargePower = {};
+  // expected-error@#1 {{vector size exceeds 256 and is not a power of two}}
+  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
+  const TemplateVectorType::type LargeNonPower = {};
   // expected-error@#1 {{zero vector size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type Zero;
+  const TemplateVectorType::type Zero = {};
 
-  // expected-error@#2 {{vector size too large}}
+  // expected-error@#2 {{not a power of two}}
   // expected-error@#3 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, int>' requested here}}
   const PR15730<8, int>::type PR15730_1 = {};
-  // expected-error@#2 {{vector size too large}}
+  // expected-error@#2 {{not a power of two}}
   // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, char>' requested here}}
   const PR15730<8, char>::type2 PR15730_2 = {};
 }
Index: clang/test/Sema/types.c
===
--- clang/test/Sema/types.c
+++ clang/test/Sema/types.c
@@ -70,8 +70,18 @@
 }
 
 // vector size too large
-int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
-typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
+char __attribute__ ((vector_size(255))) v1;
+char __attribute__ ((vector_size(256))) v2;
+char __attribute__ ((vector_size(257))) v3; // expected-error {{vector size exceeds 256 and is not a power of two}}
+char __attribute__ ((vector_size(512))) v4;
+char __attribute__ ((vector_size(0x1000))) v5;
+char __attribute__ ((vector_size(0x1))) v6; // expected-error {{vector size too large}}
+typedef int __attribute__ ((ext_vector_type(255))) e1;
+typedef int __attribute__ ((ext_vector_type(256))) e2;
+typedef int __attribute__ ((ext_vector_type(257))) e3; // expected-error {{vector size exceeds 256 and is not a power of two}}
+typedef int __attribute__ ((ext_vector_type(512))) e4;
+typedef int __attribute__ ((ext_vector_type(0x1000))) e5;
+typedef int __attribute__ ((ext_vector_type(0x1))) e6; // expected-error {{vector size too large}}
 
 // no support for vector enum type
 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
Index: clang/lib/Sema/SemaType.cpp
===
---