[PATCH] D59426: [PR41010][OpenCL] Allow OpenCL C style vector initialization in C++

2019-07-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia abandoned this revision.
Anastasia added a comment.

Created a follow up review in https://reviews.llvm.org/D65286


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

https://reviews.llvm.org/D59426



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


[PATCH] D59426: [PR41010][OpenCL] Allow OpenCL C style vector initialization in C++

2019-07-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

ping!


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

https://reviews.llvm.org/D59426



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


[PATCH] D59426: [PR41010][OpenCL] Allow OpenCL C style vector initialization in C++

2019-07-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

@rsmith, do you have any comments here? It would be quite useful to have this 
patch in Clang9.


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

https://reviews.llvm.org/D59426



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


[PATCH] D59426: [PR41010][OpenCL] Allow OpenCL C style vector initialization in C++

2019-03-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a reviewer: rsmith.
rjmccall added inline comments.



Comment at: lib/Sema/SemaInit.cpp:1295
+? InitializedEntity::InitializeTemporary(ElemType)
+: Entity;
+

There should at least be a comment here explaining this, but mostly it's been 
so long since I've really understood this code that I'd like Richard to look at 
it.


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

https://reviews.llvm.org/D59426



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


[PATCH] D59426: [PR41010][OpenCL] Allow OpenCL C style vector initialization in C++

2019-03-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, bader.
Herald added subscribers: jdoerfert, ebevhan, yaxunl.

Not sure it's the right approach but the idea is that we would like to accept 
vector contraction syntax from OpenCL C.

This commit fixes Sema checks when creating a vector using compound vector 
syntax. We should pass the type of initializing expression consistently, to 
avoid mismatch with the initializer.

This change also improves testing for the vector creation.


https://reviews.llvm.org/D59426

Files:
  lib/Sema/SemaInit.cpp
  test/CodeGenOpenCL/vector_literals_valid.cl

Index: test/CodeGenOpenCL/vector_literals_valid.cl
===
--- test/CodeGenOpenCL/vector_literals_valid.cl
+++ test/CodeGenOpenCL/vector_literals_valid.cl
@@ -1,22 +1,61 @@
-// RUN: %clang_cc1 -emit-llvm %s -o %t
+// RUN: %clang_cc1 -emit-llvm %s -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -cl-std=c++ -O0 | FileCheck %s
 
-typedef __attribute__(( ext_vector_type(2) ))  int int2;
-typedef __attribute__(( ext_vector_type(3) ))  int int3;
+typedef __attribute__((ext_vector_type(2))) int int2;
+typedef __attribute__((ext_vector_type(3))) int int3;
 typedef __attribute__(( ext_vector_type(4) ))  int int4;
 typedef __attribute__(( ext_vector_type(8) ))  int int8;
-typedef __attribute__(( ext_vector_type(4) ))  float float4;
+typedef __attribute__((ext_vector_type(4))) float float4;
 
 void vector_literals_valid() {
-  int4 a_1_1_1_1 = (int4)(1,2,3,4);
-  int4 a_2_1_1 = (int4)((int2)(1,2),3,4);
-  int4 a_1_2_1 = (int4)(1,(int2)(2,3),4);
-  int4 a_1_1_2 = (int4)(1,2,(int2)(3,4));
-  int4 a_2_2 = (int4)((int2)(1,2),(int2)(3,4));
-  int4 a_3_1 = (int4)((int3)(1,2,3),4);
-  int4 a_1_3 = (int4)(1,(int3)(2,3,4));
+  //CHECK: store <4 x i32> , <4 x i32>*
+
+  int4 a_1_1_1_1 = (int4)(1, 2, 3, 4);
+
+  //CHECK: store <2 x i32> , <2 x i32>*
+  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> 
+  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> 
+  //CHECK: insertelement <4 x i32> %{{.+}}, i32 3, i32 2
+  //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
+  int4 a_2_1_1 = (int4)((int2)(1, 2), 3, 4);
+
+  //CHECK: store <2 x i32> , <2 x i32>*
+  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> 
+  //CHECK: shufflevector <4 x i32> , <4 x i32> %{{.+}}, <4 x i32> 
+  //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
+  int4 a_1_2_1 = (int4)(1, (int2)(2, 3), 4);
+
+  //CHECK: store <2 x i32> , <2 x i32>*
+  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> 
+  //CHECK: shufflevector <4 x i32> , <4 x i32> %{{.+}}, <4 x i32> 
+  int4 a_1_1_2 = (int4)(1, 2, (int2)(3, 4));
+
+  //CHECK: store <2 x i32> , <2 x i32>*
+  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> 
+  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> 
+  //CHECK: store <2 x i32> , <2 x i32>*
+  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> 
+  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> %{{.+}}, <4 x i32> 
+  int4 a_2_2 = (int4)((int2)(1, 2), (int2)(3, 4));
+
+  //CHECK: store <4 x i32> , <4 x i32>*
+  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <3 x i32> 
+  //CHECK: shufflevector <3 x i32> %{{.+}}, <3 x i32> undef, <4 x i32> 
+  //CHECK: shufflevector <4 x i32> , <4 x i32> %{{.+}}, <4 x i32> 
+  int4 a_1_3 = (int4)(1, (int3)(2, 3, 4));
+
+  //CHECK: store <4 x i32> , <4 x i32>* %a
   int4 a = (int4)(1);
-  int8 b = (int8)(1,2,a.xy,a);
-  float4 V2 = (float4) (1);
-}
 
+  //CHECK: load <4 x i32>, <4 x i32>* %a, align 16
+  //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> undef, <2 x i32> 
+  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <8 x i32> 
+  //CHECK: shufflevector <8 x i32> , <8 x i32> %{{.+}}, <8 x i32> 
+  //CHECK: load <4 x i32>, <4 x i32>* %a, align 16
+  //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> undef, <8 x i32> 
+  //CHECK: shufflevector <8 x i32> %{{.+}}, <8 x i32> %{{.+}}, <8 x i32> 
+  int8 b = (int8)(1, 2, a.xy, a);
 
+  //CHECK: store <4 x float> , <4 x float>* %V2
+  float4 V2 = (float4)(1);
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1289,7 +1289,12 @@
 // FIXME: Better EqualLoc?
 InitializationKind Kind =
 InitializationKind::CreateCopy(expr->getBeginLoc(), SourceLocation());
-InitializationSequence Seq(SemaRef, Entity, Kind, expr,
+auto TmpEntity =
+(ElemType->isExtVectorType() && !Entity.getType()->isExtVectorType())
+? InitializedEntity::InitializeTemporary(ElemType)
+: Entity;
+
+InitializationSequence Seq(SemaRef, TmpEntity, Kind, expr,
/*TopLevelOfInitList*/ true);
 
 // C++14 [dcl.init.aggr]p13:
@@ -1300,8 +1305,7 @@