[PATCH] D105988: [OpenCL] NULL introduced prior to v2.0

2021-07-15 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 358911.
Topotuna added a comment.

Full diff now added. Redundant condition `#if` removed


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

https://reviews.llvm.org/D105988

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
-
-#define NULL ((void*)0)
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify 
%s
+// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 
 void foo(){
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,9 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #define NULL ((void*)0)
-#endif
 
 /**
  * Value of maximum non-infinite single-precision floating-point


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
-
-#define NULL ((void*)0)
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 
 void foo(){
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,9 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #define NULL ((void*)0)
-#endif
 
 /**
  * Value of maximum non-infinite single-precision floating-point
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105988: [OpenCL] NULL introduced prior to v2.0

2021-07-15 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked 2 inline comments as done.
Topotuna added inline comments.



Comment at: clang/test/SemaOpenCL/null_literal.cl:7
 
 #define NULL ((void*)0)
 

Anastasia wrote:
> Anastasia wrote:
> > I think we should remove this `NULL` definition but instead add 
> > `-finclude-default-header -fdeclare-opencl-builtins` to test the definition 
> > you are adding in the header.
> Ok, is this a full diff? 
> https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
> 
> 
> Because the file appears to be incompletely displayed or something...
Apologies. That was not a full diff. Should be fixed now.


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

https://reviews.llvm.org/D105988

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


[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 359256.
Topotuna added a comment.

Patch made compatible with changes to D105988 


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

https://reviews.llvm.org/D105987

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -3,27 +3,46 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 
 void foo(){
 
 global int* ptr1 = NULL;
 
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__global void *'}}
+#endif
 global int* ptr2 = (global void*)0;
 
 constant int* ptr3 = NULL;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing 
'__constant int *__private' with an expression of type '__global void *' 
changes address space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__constant int 
*__private' with an rvalue of type '__global void *'}}
+#else
+// expected-error@+2{{initializing '__constant int *__private' with an 
expression of type '__global void *' changes address space of pointer}}
+#endif
+constant int* ptr4 = (global void*)0;
 
 #ifdef CL20
 // Accept explicitly pointer to generic address space in OpenCL v2.0.
 global int* ptr5 = (generic void*)0;
 #endif
 
-global int* ptr6 = (local void*)0; // expected-error{{initializing '__global 
int *__private' with an expression of type '__local void *' changes address 
space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__local void *'}}
+#else
+// expected-error@+2{{initializing '__global int *__private' with an 
expression of type '__local void *' changes address space of pointer}}
+#endif
+global int* ptr6 = (local void*)0;
 
 bool cmp = ptr1 == NULL;
 
-cmp = ptr1 == (local void*)0; // expected-error{{comparison between  
('__global int *' and '__local void *') which are pointers to non-overlapping 
address spaces}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{comparison of distinct pointer types ('__global int *' 
and '__local void *')}}
+#else
+// expected-error@+2{{comparison between  ('__global int *' and '__local void 
*') which are pointers to non-overlapping address spaces}}
+#endif
+cmp = ptr1 == (local void*)0;
 
 cmp = ptr3 == NULL;
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,11 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
+#if defined(__OPENCL_CPP_VERSION__)
+#define NULL nullptr
+#elif defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
+#endif
 
 /**
  * Value of maximum non-infinite single-precision floating-point


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -3,27 +3,46 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header -verify %s
 
 void foo(){
 
 global int* ptr1 = NULL;
 
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int *__private' with an rvalue of type '__global void *'}}
+#endif
 global int* ptr2 = (global void*)0;
 
 constant int* ptr3 = NULL;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__constant int *__private' with an rvalue of type '__global void *'}}
+#else
+// expected-error@+2{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
+#endif
+constant int* ptr4 = (global void*)0;
 
 #ifdef CL20
 // Accept explicitly pointer to generic address space i

[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/test/SemaOpenCL/null_literal.cl:13
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__global void *'}}
+#endif

Anastasia wrote:
> hmm, you should not get those errors though https://godbolt.org/z/qvr7x11TM
The `expected-error` here refers to line 15 which displays an error: 
https://godbolt.org/z/zYzGedzv4


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

https://reviews.llvm.org/D105987

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


[PATCH] D106254: [OpenCL][NFC] Refactors conditional versioning

2021-07-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Removes run line declaration -DCL20 and substitutes it with
condition on macro CL_VERSION_2_0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106254

Files:
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 
 void foo(){
 
@@ -14,7 +14,7 @@
 
 constant int* ptr4 = (global void*)0; // expected-error{{initializing 
'__constant int *__private' with an expression of type '__global void *' 
changes address space of pointer}}
 
-#ifdef CL20
+#if __OPENCL_C_VERSION__ == CL_VERSION_2_0
 // Accept explicitly pointer to generic address space in OpenCL v2.0.
 global int* ptr5 = (generic void*)0;
 #endif


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 
 void foo(){
 
@@ -14,7 +14,7 @@
 
 constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
 
-#ifdef CL20
+#if __OPENCL_C_VERSION__ == CL_VERSION_2_0
 // Accept explicitly pointer to generic address space in OpenCL v2.0.
 global int* ptr5 = (generic void*)0;
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 359702.
Topotuna added a comment.

Separate NFC performed in D106254 


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

https://reviews.llvm.org/D105987

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -3,27 +3,46 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 
 void foo(){
 
 global int* ptr1 = NULL;
 
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__global void *'}}
+#endif
 global int* ptr2 = (global void*)0;
 
 constant int* ptr3 = NULL;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing 
'__constant int *__private' with an expression of type '__global void *' 
changes address space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__constant int 
*__private' with an rvalue of type '__global void *'}}
+#else
+// expected-error@+2{{initializing '__constant int *__private' with an 
expression of type '__global void *' changes address space of pointer}}
+#endif
+constant int* ptr4 = (global void*)0;
 
 #if __OPENCL_C_VERSION__ == CL_VERSION_2_0
 // Accept explicitly pointer to generic address space in OpenCL v2.0.
 global int* ptr5 = (generic void*)0;
 #endif
 
-global int* ptr6 = (local void*)0; // expected-error{{initializing '__global 
int *__private' with an expression of type '__local void *' changes address 
space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__local void *'}}
+#else
+// expected-error@+2{{initializing '__global int *__private' with an 
expression of type '__local void *' changes address space of pointer}}
+#endif
+global int* ptr6 = (local void*)0;
 
 bool cmp = ptr1 == NULL;
 
-cmp = ptr1 == (local void*)0; // expected-error{{comparison between  
('__global int *' and '__local void *') which are pointers to non-overlapping 
address spaces}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{comparison of distinct pointer types ('__global int *' 
and '__local void *')}}
+#else
+// expected-error@+2{{comparison between  ('__global int *' and '__local void 
*') which are pointers to non-overlapping address spaces}}
+#endif
+cmp = ptr1 == (local void*)0;
 
 cmp = ptr3 == NULL;
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,11 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
+#if defined(__OPENCL_CPP_VERSION__)
+#define NULL nullptr
+#elif defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
+#endif
 
 /**
  * Value of maximum non-infinite single-precision floating-point


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -3,27 +3,46 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header -verify %s
 
 void foo(){
 
 global int* ptr1 = NULL;
 
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int *__private' with an rvalue of type '__global void *'}}
+#endif
 global int* ptr2 = (global void*)0;
 
 constant int* ptr3 = NULL;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__constant int *__private' with an rvalue of type '__global void *'}}
+#else
+// expected-error@+2{{initializing '__constant int *__private' with an expression of type '__global void *' changes address space of pointer}}
+#endif
+constant int* ptr4 = (global void*)0;
 
 #if __OPENCL_C_VERSION__ == CL_VERSION_2_0
 // Accept explicitl

[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/test/SemaOpenCL/null_literal.cl:26
 
 #ifdef CL20
 // Accept explicitly pointer to generic address space in OpenCL v2.0.

Anastasia wrote:
> while we are at it, do you mind changing this check into 
> 
> `__OPENCL_CPP_VERSION__ == 200`
> 
> and then we can remove `-DCL20` from the run line
Done in a separate patch D106254 because it is unrelated to this change.


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

https://reviews.llvm.org/D105987

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


[PATCH] D106266: [C++4OpenCL] Add run line standard aliases clc++1.0 and CLC++1.0

2021-07-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: jeroen.dobbelaere, ldrumm, dexonsmith, dang, yaxunl.
Topotuna requested review of this revision.
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

The commit renames language standard from openclcpp to openclcpp10.
It also enables run line arguments -cl-std=clc++1.0 and
-cl-std=CLC++1.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106266

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/unknown-std.cl
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -478,7 +478,7 @@
   LangStd = LangStandard::lang_opencl10;
   break;
 case clang::Language::OpenCLCXX:
-  LangStd = LangStandard::lang_openclcpp;
+  LangStd = LangStandard::lang_openclcpp10;
   break;
 case clang::Language::CUDA:
   LangStd = LangStandard::lang_cuda;
Index: clang/test/Driver/unknown-std.cl
===
--- clang/test/Driver/unknown-std.cl
+++ clang/test/Driver/unknown-std.cl
@@ -11,7 +11,7 @@
 // CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
 // CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
-// CHECK-NEXT: note: use 'clc++' for 'C++ for OpenCL' standard
+// CHECK-NEXT: note: use 'clc++1.0' for 'C++ for OpenCL 1.0' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -49,6 +49,8 @@
 // CLSTDALL-NEXT: CL3.0
 // CLSTDALL-NEXT: clc++
 // CLSTDALL-NEXT: CLC++
+// CLSTDALL-NEXT: clc++1.0
+// CLSTDALL-NEXT: CLC++1.0
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3088,7 +3088,7 @@
   LangStd = LangStandard::lang_opencl10;
   break;
 case Language::OpenCLCXX:
-  LangStd = LangStandard::lang_openclcpp;
+  LangStd = LangStandard::lang_openclcpp10;
   break;
 case Language::CUDA:
   LangStd = LangStandard::lang_cuda;
@@ -3161,7 +3161,7 @@
 Opts.OpenCLVersion = 200;
   else if (LangStd == LangStandard::lang_opencl30)
 Opts.OpenCLVersion = 300;
-  else if (LangStd == LangStandard::lang_openclcpp)
+  else if (LangStd == LangStandard::lang_openclcpp10)
 Opts.OpenCLCPlusPlusVersion = 100;
 
   // OpenCL has some additional defaults.
@@ -3311,7 +3311,7 @@
   case LangStandard::lang_opencl12:
   case LangStandard::lang_opencl20:
   case LangStandard::lang_opencl30:
-  case LangStandard::lang_openclcpp:
+  case LangStandard::lang_openclcpp10:
 StdOpt = OPT_cl_std_EQ;
 break;
   default:
@@ -3605,7 +3605,8 @@
 .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
 .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
 .Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
-.Cases("clc++", "CLC++", LangStandard::lang_openclcpp)
+.Cases("clc++", "CLC++", LangStandard::lang_openclcpp10)
+.Cases("clc++1.0", "CLC++1.0", LangStandard::lang_openclcpp10)
 .Default(LangStandard::lang_unspecified);
 
 if (OpenCLLangStd == LangStandard::lang_unspecified) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -843,7 +843,7 @@
   HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">,
   MarshallingInfoFlag>;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, Flags<[CC1Option]>,
-  HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
+  HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_corr

[PATCH] D106266: [C++4OpenCL] Add run line standard aliases clc++1.0 and CLC++1.0

2021-07-20 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 360059.
Topotuna added a comment.

`clc++` made no longer deprecated


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

https://reviews.llvm.org/D106266

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/unknown-std.cl
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -478,7 +478,7 @@
   LangStd = LangStandard::lang_opencl10;
   break;
 case clang::Language::OpenCLCXX:
-  LangStd = LangStandard::lang_openclcpp;
+  LangStd = LangStandard::lang_openclcpp10;
   break;
 case clang::Language::CUDA:
   LangStd = LangStandard::lang_cuda;
Index: clang/test/Driver/unknown-std.cl
===
--- clang/test/Driver/unknown-std.cl
+++ clang/test/Driver/unknown-std.cl
@@ -11,7 +11,7 @@
 // CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
 // CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
-// CHECK-NEXT: note: use 'clc++' for 'C++ for OpenCL' standard
+// CHECK-NEXT: note: use 'clc++1.0' or 'clc++' for 'C++ for OpenCL 1.0' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -49,6 +49,8 @@
 // CLSTDALL-NEXT: CL3.0
 // CLSTDALL-NEXT: clc++
 // CLSTDALL-NEXT: CLC++
+// CLSTDALL-NEXT: clc++1.0
+// CLSTDALL-NEXT: CLC++1.0
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3088,7 +3088,7 @@
   LangStd = LangStandard::lang_opencl10;
   break;
 case Language::OpenCLCXX:
-  LangStd = LangStandard::lang_openclcpp;
+  LangStd = LangStandard::lang_openclcpp10;
   break;
 case Language::CUDA:
   LangStd = LangStandard::lang_cuda;
@@ -3161,7 +3161,7 @@
 Opts.OpenCLVersion = 200;
   else if (LangStd == LangStandard::lang_opencl30)
 Opts.OpenCLVersion = 300;
-  else if (LangStd == LangStandard::lang_openclcpp)
+  else if (LangStd == LangStandard::lang_openclcpp10)
 Opts.OpenCLCPlusPlusVersion = 100;
 
   // OpenCL has some additional defaults.
@@ -3311,7 +3311,7 @@
   case LangStandard::lang_opencl12:
   case LangStandard::lang_opencl20:
   case LangStandard::lang_opencl30:
-  case LangStandard::lang_openclcpp:
+  case LangStandard::lang_openclcpp10:
 StdOpt = OPT_cl_std_EQ;
 break;
   default:
@@ -3605,7 +3605,8 @@
 .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
 .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
 .Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
-.Cases("clc++", "CLC++", LangStandard::lang_openclcpp)
+.Cases("clc++", "CLC++", LangStandard::lang_openclcpp10)
+.Cases("clc++1.0", "CLC++1.0", LangStandard::lang_openclcpp10)
 .Default(LangStandard::lang_unspecified);
 
 if (OpenCLLangStd == LangStandard::lang_unspecified) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -843,7 +843,7 @@
   HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">,
   MarshallingInfoFlag>;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, Flags<[CC1Option]>,
-  HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
+  HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group, Flags<[CC1Option]>,
Index: clang/include/clang/Basic/LangStandards.def
===
--- clang/include/clang/Basic/LangStandards.def
++

[PATCH] D106266: [C++4OpenCL] Add run line standard aliases clc++1.0 and CLC++1.0

2021-07-20 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added inline comments.



Comment at: clang/include/clang/Basic/LangStandards.def:187
  Digraphs | HexFloat | OpenCL)
+LANGSTANDARD_ALIAS_DEPR(openclcpp10, "clc++")
 

Anastasia wrote:
> I am not sure we should move it into the deprecated category yet... for now 
> let's just use `LANGSTANDARD_ALIAS`.
You are right. I tried to closely follow how `cl1.0` version is regarded on 
line 169, but it is a slightly different case because `cl` has more than one 
version already.



Comment at: clang/test/Driver/unknown-std.cl:14
 // CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
-// CHECK-NEXT: note: use 'clc++' for 'C++ for OpenCL' standard
+// CHECK-NEXT: note: use 'clc++1.0' for 'C++ for OpenCL 1.0' standard
 

Anastasia wrote:
> does it not print `clc++` anymore?
The error messages here are derived from language definitions in file 
`Basic/LangStandards.def`, so both files need to be modified accordingly.


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

https://reviews.llvm.org/D106266

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


[PATCH] D106266: [C++4OpenCL] Add run line standard aliases clc++1.0 and CLC++1.0

2021-07-22 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

That is good to know. Thank you for sorting it out


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

https://reviews.llvm.org/D106266

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


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-26 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change provides a way to conveniently declare types that have
address space qualifiers removed.

Since OpenCL adds address spaces implicitly even when they are not
specified in source, it is useful to allow deriving address space
unqualified types.

Fixes llvm.org/PR45326


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, 
int>::value,
+"__generic address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, 
char>::value,
+"__global address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, 
ulong>::value,
+"__private address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, 
short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, 
int3>::value,
+"__constant address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by 
__remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,28 @@
 global OnlySL *d,
   );
 
+Address space removal
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed, as described in `C++ for
+OpenCL v1.0 s2.3.12
+`_.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+__private __remove_address_space var3;
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space 

[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-26 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

Change to `LanguageExtensions.rst` assumes there is a section about the utility 
on official C++ for OpenCL documentation. However, it is not yet documented


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106785

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


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-27 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 361937.
Topotuna added a comment.

Reference to C++ for OpenCL 1.0 specification removed. More elaborate code 
example added.


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

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, 
int>::value,
+"__generic address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, 
char>::value,
+"__global address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, 
ulong>::value,
+"__private address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, 
short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, 
int3>::value,
+"__constant address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by 
__remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,30 @@
 global OnlySL *d,
   );
 
+Address space removal
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. The tool only throws away
+address space qualifiers, therefore, other type qualifiers such as
+``const`` or ``volatile`` remain unchanged.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+T var1; // error - local function variable with global address space
+__private T var2; // error - conflicting address space qualifiers
+__private __remove_address_space var3; // compiled - var3 is __private 
int
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, short>::

[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-27 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 361954.
Topotuna added a comment.

Additional tests added for `is_same`


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

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp

Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_is_same() {
+  static_assert(is_same::value);
+  static_assert(!is_same::value);
+  static_assert(!is_same<__private int, int>::value);
+}
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, int3>::value,
+"__constant address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by __remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,30 @@
 global OnlySL *d,
   );
 
+Address space removal
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. The tool only throws away
+address space qualifiers, therefore, other type qualifiers such as
+``const`` or ``volatile`` remain unchanged.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+T var1; // error - local function variable with global address space
+__private T var2; // error - conflicting address space qualifiers
+__private __remove_address_space var3; // var3 is __private int
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-27 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 361975.
Topotuna added a comment.

Documentation rewording


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

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp

Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_is_same() {
+  static_assert(is_same::value);
+  static_assert(!is_same::value);
+  static_assert(!is_same<__private int, int>::value);
+}
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, int3>::value,
+"__constant address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by __remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,30 @@
 global OnlySL *d,
   );
 
+Builtin address space removal utility
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. This utility only affects
+address space qualifiers, therefore, other type qualifiers such as
+``const`` or ``volatile`` remain unchanged.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+T var1; // error - local function variable with global address space
+__private T var2; // error - conflicting address space qualifiers
+__private __remove_address_space var3; // var3 is __private int
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-27 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1964
 
+Address space removal
+-

Anastasia wrote:
> Anastasia wrote:
> > Maybe we could title it something like:
> > 
> > `Address space removal utility`
> > or
> > `Address space removal trait`
> > ?
> Although we could also be more specific and name it
> `Remove address space builtin function`?
`Builtin address space removal utility`?

I would prefer not to leave wording "Remove address space" in description 
because it is already what utility name says and so it adds no extra 
information.



Comment at: clang/docs/LanguageExtensions.rst:1968
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. The tool only throws away
+address space qualifiers, therefore, other type qualifiers such as

Anastasia wrote:
> 
I would rather use word "affects" instead of "removes" here. There is already 
excessive amount of "remove" in this paragraph


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

https://reviews.llvm.org/D106785

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


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-27 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 362027.
Topotuna added a comment.

Test case added that checks if __remove_address_space modifies types without 
address space


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

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp

Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_is_same() {
+  static_assert(is_same::value);
+  static_assert(!is_same::value);
+  static_assert(!is_same<__private int, int>::value);
+}
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space::type, int>::value,
+"type without an address space unexpectedly modified by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, int3>::value,
+"__constant address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by __remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,30 @@
 global OnlySL *d,
   );
 
+Builtin address space removal utility
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. This utility only affects
+address space qualifiers, therefore, other type qualifiers such as
+``const`` or ``volatile`` remain unchanged.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+T var1; // error - local function variable with global address space
+__private T var2; // error - conflicting address space qualifiers
+__private __remove_address_space var3; // var3 is __private int
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125208: [OpenCL] Fix __remove_address_space documentation code example

2022-05-09 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Herald added a project: All.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously code example didn't compile because of missing keyword
'typename'. Keyword is now inserted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125208

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2156,7 +2156,7 @@
   void foo(T *par){
 T var1; // error - local function variable with global address space
 __private T var2; // error - conflicting address space qualifiers
-__private __remove_address_space::type var3; // var3 is __private int
+__private typename __remove_address_space::type var3; // var3 is 
__private int
   }
 
   void bar(){


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2156,7 +2156,7 @@
   void foo(T *par){
 T var1; // error - local function variable with global address space
 __private T var2; // error - conflicting address space qualifiers
-__private __remove_address_space::type var3; // var3 is __private int
+__private typename __remove_address_space::type var3; // var3 is __private int
   }
 
   void bar(){
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109874: [OpenCL] Defines helper function for OpenCL default address space

2021-09-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Herald added subscribers: ldrumm, Anastasia, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109874

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3879,8 +3879,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, 
LangAS::opencl_generic);
+  if (S.getLangOpts().OpenCL && !ArgType.hasAddressSpace())
+ArgType = S.Context.getAddrSpaceQualType(
+ArgType, S.Context.getDefaultOpenCLAddrSpace());
   ArgType = S.Context.getLValueReferenceType(ArgType);
 }
   } else {
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1430,7 +1430,7 @@
 
 LangAS Sema::getDefaultCXXMethodAddrSpace() const {
   if (getLangOpts().OpenCL)
-return LangAS::opencl_generic;
+return getASTContext().getDefaultOpenCLAddrSpace();
   return LangAS::Default;
 }
 
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -1362,6 +1362,12 @@
   /// Get address space for OpenCL type.
   LangAS getOpenCLTypeAddrSpace(const Type *T) const;
 
+  /// Returns default address space based on OpenCL version and enabled 
features
+  inline LangAS getDefaultOpenCLAddrSpace() {
+return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
+  : LangAS::opencl_private;
+  }
+
   void setcudaConfigureCallDecl(FunctionDecl *FD) {
 cudaConfigureCallDecl = FD;
   }


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3879,8 +3879,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, LangAS::opencl_generic);
+  if (S.getLangOpts().OpenCL && !ArgType.hasAddressSpace())
+ArgType = S.Context.getAddrSpaceQualType(
+ArgType, S.Context.getDefaultOpenCLAddrSpace());
   ArgType = S.Context.getLValueReferenceType(ArgType);
 }
   } else {
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1430,7 +1430,7 @@
 
 LangAS Sema::getDefaultCXXMethodAddrSpace() const {
   if (getLangOpts().OpenCL)
-return LangAS::opencl_generic;
+return getASTContext().getDefaultOpenCLAddrSpace();
   return LangAS::Default;
 }
 
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -1362,6 +1362,12 @@
   /// Get address space for OpenCL type.
   LangAS getOpenCLTypeAddrSpace(const Ty

[PATCH] D109874: [OpenCL] Defines helper function for OpenCL default address space

2021-09-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna planned changes to this revision.
Topotuna added a comment.

Current change is an initial draft. More code refactoring will be performed and 
change summary provided in near future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109874

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


[PATCH] D109305: [OpenCL] Supports optional program scope global variables in C++ for OpenCL 2021

2021-09-16 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG054e331d9dbd: [OpenCL] Supports optional program scope 
global variables in C++ for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109305

Files:
  clang/include/clang/Basic/OpenCLOptions.h
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
 constant int G2 = 0;
 
@@ -43,19 +47,23 @@
 #endif
 
 static generic float g_generic_static_var = 0;
-#if (__OPENCL_C_VERSION__ < 300)
+#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
 // expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
 // expected-error@-3 {{program scope variable must reside in constant address space}}
-#elif (__OPENCL_C_VERSION__ == 300)
- #if !defined(__opencl_c_generic_address_space)
-// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
- #endif
- #if !defined(__opencl_c_program_scope_global_variables)
-// expected-error@-9 {{program scope variable must reside in constant address space}}
- #endif
- #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
-// expected-error@-12 {{program scope variable must reside in global or constant address space}}
- #endif
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
+#if !defined(__opencl_c_generic_address_space)
+#if (__OPENCL_C_VERSION__ == 300)
+// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
+#elif (__OPENCL_CPP_VERSION__ == 202100)
+// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
+#endif
+#endif
+#if !defined(__opencl_c_program_scope_global_variables)
+// expected-error@-13 {{program scope variable must reside in constant address space}}
+#endif
+#if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
+// expected-error@-16 {{program scope variable must reside in global or constant address space}}
+#endif
 #endif
 
 extern float g_implicit_extern_var;
@@ -85,32 +93,36 @@
 #endif
 
 extern generic float g_generic_extern_var;
-#if (__OPENCL_C_VERSION__ < 300)
+#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
 // expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
 // expected-error@-3 {{extern variable must reside in constant address space}}
-#elif (__OPENCL_C_VERSION__ == 300)
- #if !defined(__opencl_c_generic_address_space)
-// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
- #endif
- #if !defined(__opencl_c_program_scope_global_variables)
-// expected-error@-9 {{extern variable must reside in constant address space}}
- #endif
- #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
-// expected-error@-12 {{extern variable must reside in global or constant address space}}
- #endif
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
+#if !defined(__opencl_c_generic_address_space)
+#if (__OPENCL_C_VERSION__ == 300)
+// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
+#elif (__OPENCL_CPP_VERSION__ == 202100)
+// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
+#endif
+#endif
+#if !defined(__opencl_c_program_scope_global_variables)
+// expec

[PATCH] D109874: [OpenCL] Defines helper function for OpenCL default address space

2021-09-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 372937.
Topotuna edited the summary of this revision.
Topotuna added reviewers: olestrohm, Anastasia.
Topotuna added a comment.

Code refactored inside `clang/lib/AST/Expr.cpp`. Commit message added.


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

https://reviews.llvm.org/D109874

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, 
LangAS::opencl_generic);
+  if (S.getLangOpts().OpenCL && !ArgType.hasAddressSpace())
+ArgType = S.Context.getAddrSpaceQualType(
+ArgType, S.Context.getDefaultOpenCLAddrSpace());
   ArgType = S.Context.getLValueReferenceType(ArgType);
 }
   } else {
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1430,7 +1430,7 @@
 
 LangAS Sema::getDefaultCXXMethodAddrSpace() const {
   if (getLangOpts().OpenCL)
-return LangAS::opencl_generic;
+return getASTContext().getDefaultOpenCLAddrSpace();
   return LangAS::Default;
 }
 
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3779,11 +3779,7 @@
 // has non-default address space it is not treated as nullptr.
 // (__generic void*)0 in OpenCL 2.0 should not be treated as nullptr
 // since it cannot be assigned to a pointer to constant address space.
-if ((Ctx.getLangOpts().OpenCLVersion >= 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_generic) ||
-(Ctx.getLangOpts().OpenCL &&
- Ctx.getLangOpts().OpenCLVersion < 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_private))
+if (Pointee.getAddressSpace() == Ctx.getDefaultOpenCLAddrSpace())
   Qs.removeAddressSpace();
 
 if (Pointee->isVoidType() && Qs.empty() && // to void*
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -1362,6 +1362,12 @@
   /// Get address space for OpenCL type.
   LangAS getOpenCLTypeAddrSpace(const Type *T) const;
 
+  /// Returns default address space based on OpenCL version and enabled 
features
+  inline LangAS getDefaultOpenCLAddrSpace() {
+return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
+  : LangAS::opencl_private;
+  }
+
   void setcudaConfigureCallDecl(FunctionDecl *FD) {
 cudaConfigureCallDecl = FD;
   }


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, La

[PATCH] D109306: [OpenCL] Supports optional pipe types in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37cdc7ebd9a3: [OpenCL] Supports optional pipe types in C++ 
for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109306

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,13 +1,15 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
 extern pipe write_only int get_pipe(); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_program_scope_global_variables))
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_program_scope_global_variables))
 // expected-error-re@-2{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
 #else
 // FIXME: '__private' here makes no sense since program scope variables feature is not supported, should diagnose as '__global' probably
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,14 +1,18 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
 
 void foo(read_only pipe int p);
 #if __OPENCL_C_VERSION__ > 120
 // expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
 // expected-error@-3 {{access qualifier can only be used for pipe and image type}}
-#else
-// expected-warning@-5 {{type specifier missing, defaults to 'int'}}
+#elif defined(__OPENCL_CPP_VERSION__)
+// expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}}
 // expected-error@-6 {{access qualifier can only be used for pipe and image type}}
-// expected-error@-7 {{expected ')'}} expected-note@-7 {{to match this '('}}
+#else
+// expected-warning@-8 {{type specifier missing, defaults to 'int'}}
+// expected-error@-9 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-10 {{expected ')'}} expected-note@-10 {{to match this '('}}
 #endif
 
 // 'pipe' should be accepted as an identifier.
@@ -16,8 +20,16 @@
 #if __OPENCL_C_VERSION__ > 120
 // expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
 // expected-warning@-3 {{typedef requires a name}}
+#elif defined(__OPENCL_CPP_VERSION__)
+// expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}}
+// expected-warning@-6 {{typedef requires a name}}
 #endif
 
 void bar() {
- reserve_id_t r; // expected-error {{use of undeclared identifier 'reserve_id_t'}}
+ reserve_id_t r;
+#if defined(__OPENCL_C_VERSION__)
+// expected-error@-2 {{use of

[PATCH] D109307: [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 2021

2021-09-17 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb7e9d203c679: [OpenCL] Supports optional same image reads 
and writes in C++ for OpenCL 2021 (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109307?vs=370855&id=373203#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109307

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/access-qualifier.cl

Index: clang/test/SemaOpenCL/access-qualifier.cl
===
--- clang/test/SemaOpenCL/access-qualifier.cl
+++ clang/test/SemaOpenCL/access-qualifier.cl
@@ -2,24 +2,38 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s -cl-ext=-__opencl_c_read_write_images
 
 typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
 
 typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}}
 typedef read_only image1d_t img1d_ro;
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 typedef read_write image1d_t img1d_rw;
 #endif
 
 typedef int Int;
 typedef read_only int IntRO; // expected-error {{access qualifier can only be used for pipe and image type}}
 
+void myWrite(write_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+// expected-note@-3 {{passing argument to parameter here}}
+#else
+// expected-note@-5 {{candidate function not viable: no known conversion from '__private img1d_ro' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+// expected-note@-6 {{candidate function not viable: no known conversion from '__private img1d_ro_default' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+#endif
 
-void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passing argument to parameter here}}
-void myRead(read_only image1d_t); // expected-note {{passing argument to parameter here}}
+void myRead(read_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+#else
+// expected-note@-4 {{candidate function not viable: no known conversion from '__private img1d_wo' (aka '__private __write_only image1d_t') to '__private __read_only image1d_t' for 1st argument}}
+#endif
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 void myReadWrite(read_write image1d_t);
 #else
 void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}}
@@ -27,25 +41,40 @@
 
 
 kernel void k1(img1d_wo img) {
-  myRead(img); // expected-error {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+  myRead(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myRead'}}
+#endif
 }
 
 kernel void k2(img1d_ro img) {
-  myWrite(img); // expected-error {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+  myWrite(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myWrite'}}
+#endif
 }
 
 kernel void k3(img1d_wo img) {
   myWrite(img);
 }
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_

[PATCH] D109328: [OpenCL] Supports optional writing to 3d images in C++ for OpenCL 2021

2021-09-20 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca3bebd8440f: [OpenCL] Supports optional writing to 3d 
images in C++ for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109328

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/test/Misc/opencl-c-3.0.incorrect_options.cl
===
--- clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -8,6 +8,8 @@
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
 
 // CHECK-FP64: error: options cl_khr_fp64 and __opencl_c_fp64 are set to 
different values
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1732,10 +1732,6 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
-// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
-// unified into one when __opencl_c_3d_image_writes option is enabled in
-// C++ for OpenCL 2021
-bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
 bool IsOpenCLC30Compatible =
 S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
@@ -1756,7 +1752,7 @@
   S.getLangOpts())) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result
-  << (IsOpenCLC30
+  << (IsOpenCLC30Compatible
   ? "cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
   : "cl_khr_3d_image_writes");
   declarator.setInvalidType();


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown 

[PATCH] D109424: [OpenCL] Supports atomics in C++ for OpenCL 2021

2021-09-20 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG228dd20c3f1e: [OpenCL] Supports atomics in C++ for OpenCL 
2021 (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109424?vs=371277&id=373599#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109424

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13256,7 +13256,7 @@
 #endif //cl_khr_fp64
 #endif
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 void __ovld atomic_init(volatile __global atomic_int *object, int value);
 void __ovld atomic_init(volatile __local atomic_int *object, int value);
 void __ovld atomic_init(volatile __global atomic_uint *object, uint value);
@@ -13273,7 +13273,7 @@
 void __ovld atomic_init(volatile __local atomic_double *object, double value);
 #endif //cl_khr_fp64
 #endif
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 
 // atomic_work_item_fence()
 void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order, memory_scope scope);
@@ -13317,7 +13317,7 @@
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add(volatile __global atomic_int *object, int operand);
 int __ovld atomic_fetch_add(volatile __local atomic_int *object, int operand);
 uint __ovld atomic_fetch_add(volatile __global atomic_uint *object, uint operand);
@@ -13398,7 +13398,7 @@
 uintptr_t __ovld atomic_fetch_add(volatile __global atomic_uintptr_t *object, ptrdiff_t operand);
 uintptr_t __ovld atomic_fetch_sub(volatile __local atomic_uintptr_t *object, ptrdiff_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 #endif
 
 #if defined(__opencl_c_atomic_scope_device)
@@ -13436,7 +13436,7 @@
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *object, int operand, memory_order order);
 int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *object, int operand, memory_order order);
 uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *object, uint operand, memory_order order);
@@ -13517,7 +13517,7 @@
 uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 #endif
 
 #if defined(__opencl_c_generic_address_space)
@@ -13554,7 +13554,7 @@
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
 #endif
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *object, int operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *object, uint operand, memory_order order, memory_scope scope);
@@ -13635,7 +13635,7 @@
 uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrd

[PATCH] D109492: [OpenCL] Test case for C++ for OpenCL 2021 in OpenCL C header test

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG57b8b5c114b6: [OpenCL] Test case for C++ for OpenCL 2021 in 
OpenCL C header test (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109492

Files:
  clang/test/Headers/opencl-c-header.cl


Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 
| FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 
| FileCheck %s
-// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++ 
| FileCheck %s --check-prefix=CHECK20
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify 
-cl-std=clc++1.0 | FileCheck %s --check-prefix=CHECK20
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL3.0 
| FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify 
-cl-std=clc++2021 | FileCheck %s
 
 // Test including the default header as a module.
 // The module should be compiled only once and loaded from cache afterwards.
@@ -57,7 +58,7 @@
 // CHECK20: _Z16convert_char_rtec
 char f(char x) {
 // Check functionality from OpenCL 2.0 onwards
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
   ndrange_t t;
   x = ctz(x);
 #endif //__OPENCL_C_VERSION__
@@ -82,7 +83,7 @@
 #endif
 
 // Verify that ATOMIC_VAR_INIT is defined.
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
 global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
 // CHECK-MOD: Reading modules


Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 | FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 | FileCheck %s
-// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++ | FileCheck %s --check-prefix=CHECK20
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++1.0 | FileCheck %s --check-prefix=CHECK20
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL3.0 | FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++2021 | FileCheck %s
 
 // Test including the default header as a module.
 // The module should be compiled only once and loaded from cache afterwards.
@@ -57,7 +58,7 @@
 // CHECK20: _Z16convert_char_rtec
 char f(char x) {
 // Check functionality from OpenCL 2.0 onwards
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
   ndrange_t t;
   x = ctz(x);
 #endif //__OPENCL_C_VERSION__
@@ -82,7 +83,7 @@
 #endif
 
 // Verify that ATOMIC_VAR_INIT is defined.
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
 global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
 // CHECK-MOD: Reading modules
___
cfe-commits mailing list
cfe-commits@lists.llvm.o

[PATCH] D109874: [OpenCL] Defines helper function for OpenCL default address space

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 373834.
Topotuna edited the summary of this revision.
Topotuna added a comment.

Helper function renamed for clarity. Additional check added to `if` statement 
to ensure it is only carried out in OpenCL.


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

https://reviews.llvm.org/D109874

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultPointeeOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, 
LangAS::opencl_generic);
+  if (S.getLangOpts().OpenCL && !ArgType.hasAddressSpace())
+ArgType = S.Context.getAddrSpaceQualType(
+ArgType, S.Context.getDefaultPointeeOpenCLAddrSpace());
   ArgType = S.Context.getLValueReferenceType(ArgType);
 }
   } else {
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1430,7 +1430,7 @@
 
 LangAS Sema::getDefaultCXXMethodAddrSpace() const {
   if (getLangOpts().OpenCL)
-return LangAS::opencl_generic;
+return getASTContext().getDefaultPointeeOpenCLAddrSpace();
   return LangAS::Default;
 }
 
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3779,11 +3779,8 @@
 // has non-default address space it is not treated as nullptr.
 // (__generic void*)0 in OpenCL 2.0 should not be treated as nullptr
 // since it cannot be assigned to a pointer to constant address space.
-if ((Ctx.getLangOpts().OpenCLVersion >= 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_generic) ||
-(Ctx.getLangOpts().OpenCL &&
- Ctx.getLangOpts().OpenCLVersion < 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_private))
+if (Ctx.getLangOpts().OpenCL &&
+Pointee.getAddressSpace() == 
Ctx.getDefaultPointeeOpenCLAddrSpace())
   Qs.removeAddressSpace();
 
 if (Pointee->isVoidType() && Qs.empty() && // to void*
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -1362,6 +1362,12 @@
   /// Get address space for OpenCL type.
   LangAS getOpenCLTypeAddrSpace(const Type *T) const;
 
+  /// Returns default address space based on OpenCL version and enabled 
features
+  inline LangAS getDefaultPointeeOpenCLAddrSpace() {
+return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
+  : LangAS::opencl_private;
+  }
+
   void setcudaConfigureCallDecl(FunctionDecl *FD) {
 cudaConfigureCallDecl = FD;
   }


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultPointeeOpenCLAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !

[PATCH] D109874: [OpenCL] Defines helper function for OpenCL default address space

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked 2 inline comments as done.
Topotuna added a comment.

Both comments addressed. Personally, I would shuffle words around to rename 
helper function as `getDefaultOpenCLPointeeAddrSpace` or 
`getOpenCLDefaultPointeeAddrSpace`. Although I am not sure if there are some 
assumed naming conventions in Clang. Originally, I was following the name of 
`getDefaultCXXMethodAddrSpace`.


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

https://reviews.llvm.org/D109874

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


[PATCH] D110155: [OpenCL] Allow optional __generic in __remove_address_space utility

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang builtin utility `__remove_address_space` now works if generic
address space is not supported in C++ for OpenCL 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110155

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes 
-fdeclare-opencl-builtins -finclude-default-header
 
 template
 struct is_same {
@@ -19,8 +21,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by 
__remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, 
int>::value,
 "__generic address space not removed by 
__remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, 
char>::value,
 "__global address space not removed by 
__remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, 
ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -fdeclare-opencl-builtins -finclude-default-header
 
 template
 struct is_same {
@@ -19,8 +21,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by __remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
 "__generic address space not removed by __remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
 "__global address space not removed by __remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109874: [OpenCL] Defines helper function for OpenCL default address space

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32b994bca666: [OpenCL] Defines helper function for OpenCL 
default address space (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109874?vs=373834&id=373915#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109874

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLPointeeAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
-ArgType = S.Context.getAddrSpaceQualType(ArgType, 
LangAS::opencl_generic);
+  if (S.getLangOpts().OpenCL && !ArgType.hasAddressSpace())
+ArgType = S.Context.getAddrSpaceQualType(
+ArgType, S.Context.getDefaultOpenCLPointeeAddrSpace());
   ArgType = S.Context.getLValueReferenceType(ArgType);
 }
   } else {
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1430,7 +1430,7 @@
 
 LangAS Sema::getDefaultCXXMethodAddrSpace() const {
   if (getLangOpts().OpenCL)
-return LangAS::opencl_generic;
+return getASTContext().getDefaultOpenCLPointeeAddrSpace();
   return LangAS::Default;
 }
 
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3779,11 +3779,8 @@
 // has non-default address space it is not treated as nullptr.
 // (__generic void*)0 in OpenCL 2.0 should not be treated as nullptr
 // since it cannot be assigned to a pointer to constant address space.
-if ((Ctx.getLangOpts().OpenCLVersion >= 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_generic) ||
-(Ctx.getLangOpts().OpenCL &&
- Ctx.getLangOpts().OpenCLVersion < 200 &&
- Pointee.getAddressSpace() == LangAS::opencl_private))
+if (Ctx.getLangOpts().OpenCL &&
+Pointee.getAddressSpace() == 
Ctx.getDefaultOpenCLPointeeAddrSpace())
   Qs.removeAddressSpace();
 
 if (Pointee->isVoidType() && Qs.empty() && // to void*
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -1362,6 +1362,12 @@
   /// Get address space for OpenCL type.
   LangAS getOpenCLTypeAddrSpace(const Type *T) const;
 
+  /// Returns default address space based on OpenCL version and enabled 
features
+  inline LangAS getDefaultOpenCLPointeeAddrSpace() {
+return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic
+  : LangAS::opencl_private;
+  }
+
   void setcudaConfigureCallDecl(FunctionDecl *FD) {
 cudaConfigureCallDecl = FD;
   }


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2092,9 +2092,7 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType, S.getLangOpts().OpenCLGenericAddressSpace
- ? LangAS::opencl_generic
- : LangAS::opencl_private);
+PointeeType, S.getASTContext().getDefaultOpenCLPointeeAddrSpace());
   return PointeeType;
 }
 
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3894,8 +3894,9 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (is

[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

Changes rG054e331d9dbd 
 and 
rG37cdc7ebd9a3 
 contain 
test cases that display C++ for OpenCL version 2021 in diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108379

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


[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:1729
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images

Topotuna wrote:
> Anastasia wrote:
> > Topotuna wrote:
> > > Anastasia wrote:
> > > > I think we should just replace `IsOpenCLC30` as it is when only used in 
> > > > the diagnostic that we should report the same as for OpenCL 3.0.
> > > > 
> > > > 
> > > > Also I would suggest changing name to `IsOpenCLC30Compatible` to make 
> > > > it clearer. 
> > > That diagnostic is responsible for `__opencl_c_3d_image_writes` feature 
> > > while current commit addresses `__opencl_c_images`. I wanted to keep 
> > > commits separate and was planning to finish transitioning from 
> > > `IsOpenCLC30` to `IsOpenCLC30Compatible` in a future commit.
> > > 
> > > I agree that `IsOpenCLC30Compatible` would be clearer. Thank you.
> > Ok, let's just only rename it for now and add a FIXME comment explaining 
> > that the variables should be unified later on.
> > 
> > I suspect your subsequent commits would include the unification?
> Yes, I will perform unification when adding support for 
> `__opencl_c_3d_image_writes` optional core feature.
Change rGca3bebd8440f performs mentioned variable unification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109002

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


[PATCH] D110184: [OpenCL] Constructor address space test adjusted for C++ for OpenCL 2021

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Reuses C++ for OpenCL constructor address space test so that it
supports optional generic address spaces in version 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110184

Files:
  clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp


Index: clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple spir-unknown-unknown | 
FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -DGENERIC -emit-llvm -o - -O0 -triple 
spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -DGENERIC -emit-llvm -o - -O0 -triple 
spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -emit-llvm -o - -O0 
-triple spir-unknown-unknown | FileCheck %s
 
 // CHECK: %struct.X = type { i32 }
 
@@ -11,8 +13,10 @@
   int x;
 
   // Local variables are handled in local_addrspace_init.clcpp
-  X() /*__generic*/ : x(0) {}
+  X() /*__generic or __private*/ : x(0) {}
+#if defined(GENERIC)
   X() __private : x(0) {}
+#endif
   X() __global : x(0) {}
   constexpr X() __constant : x(0) {}
   constexpr X(int x) __constant : x(x) {}


Index: clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -DGENERIC -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -DGENERIC -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
 
 // CHECK: %struct.X = type { i32 }
 
@@ -11,8 +13,10 @@
   int x;
 
   // Local variables are handled in local_addrspace_init.clcpp
-  X() /*__generic*/ : x(0) {}
+  X() /*__generic or __private*/ : x(0) {}
+#if defined(GENERIC)
   X() __private : x(0) {}
+#endif
   X() __global : x(0) {}
   constexpr X() __constant : x(0) {}
   constexpr X(int x) __constant : x(x) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110185: [OpenCL] Reuse C++ for OpenCL 1.0 address space tests for version 2021

2021-09-21 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds `RUN` lines in C++ for OpenCL address space tests to cover
version 2021. With all optional core features enabled by default,
C++ for OpenCL 2021 is expected to behave exactly the same way as
C++ for OpenCL 1.0. Therefore, no adjustments were needed in test
code itself.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110185

Files:
  clang/test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp

Index: clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
@@ -1,4 +1,5 @@
-//RUN: %clang_cc1 %s -triple spir -emit-llvm -O0 -o - | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir -emit-llvm -O0 -o - | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir -emit-llvm -O0 -o - | FileCheck %s
 
 //CHECK-LABEL: define{{.*}} spir_func void @_Z3barPU3AS1i
 void bar(global int *gl) {
Index: clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s --check-prefix=CHECK-DEFINITIONS
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s --check-prefix=CHECK-DEFINITIONS
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s --check-prefix=CHECK-DEFINITIONS
 
 // This test ensures the proper address spaces and address space cast are used
 // for constructors, member functions and destructors.
Index: clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
@@ -1,4 +1,5 @@
-//RUN: %clang_cc1 %s -triple spir -emit-llvm -o - -O0 | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir -emit-llvm -o - -O0 | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir -emit-llvm -o - -O0 | FileCheck %s
 
 typedef short short2 __attribute__((ext_vector_type(2)));
 
Index: clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
@@ -1,4 +1,5 @@
-//RUN: %clang_cc1 %s -triple spir -emit-llvm -O0 -o - | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir -emit-llvm -O0 -o - | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir -emit-llvm -O0 -o - | FileCheck %s
 
 enum E {
   a,
Index: clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -pedantic -verify -O0 -o - -DDECL | FileCheck %s --check-prefixes="COMMON,EXPL"
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -pedantic -verify -O0 -o - -DDECL -DUSE_DEFLT | FileCheck %s --check-prefixes="COMMON,IMPL"
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -pedantic -verify -O0 -o - | FileCheck %s --check-prefixes="COMMON,IMPL"
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -emit-llvm -pedantic -verify -O0 -o - -DDECL | FileCheck %s --check-prefixes="COMMON,EXPL"
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -emit-llvm -pedantic -verify -O0 -o - -DDECL -DUSE_DEFLT | FileCheck %s --check-prefixes="COMMO

[PATCH] D107163: [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode

2021-07-30 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Definition of __cpp_threadsafe_static_init macro is controlled by
language option Opts.ThreadsafeStatics. This patch sets language
option to false by default in OpenCL mode, resulting in macro
__cpp_threadsafe_static_init being undefined. Default value can be
overriden using command line option -fthreadsafe-statics.

Change is supposed to address portability because not all OpenCL
vendors support thread safe implementation of static initialization.

Fixes llvm.org/PR48012


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107163

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/threadsafe-statics.clcpp


Index: clang/test/Driver/threadsafe-statics.clcpp
===
--- /dev/null
+++ clang/test/Driver/threadsafe-statics.clcpp
@@ -0,0 +1,11 @@
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+
+// CHECK-NO-THREADSAFE-STATICS: "-cc1"
+// CHECK-NO-THREADSAFE-STATICS: "-fno-threadsafe-statics"
+// CHECK-NO-THREADSAFE-STATICS-NOT: "-fthreadsafe-statics"
+
+// RUN: %clang -### -fthreadsafe-statics -DTHREADSAFE_STATICS -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-THREADSAFE-STATICS %s
+
+// CHECK-THREADSAFE-STATICS: "-cc1"
+// CHECK-THREADSAFE-STATICS-NOT: "-fno-threadsafe-statics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6147,7 +6147,8 @@
   // than 19.
   if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
   // -fno-delayed-template-parsing is default, except when targeting MSVC.


Index: clang/test/Driver/threadsafe-statics.clcpp
===
--- /dev/null
+++ clang/test/Driver/threadsafe-statics.clcpp
@@ -0,0 +1,11 @@
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 | FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+
+// CHECK-NO-THREADSAFE-STATICS: "-cc1"
+// CHECK-NO-THREADSAFE-STATICS: "-fno-threadsafe-statics"
+// CHECK-NO-THREADSAFE-STATICS-NOT: "-fthreadsafe-statics"
+
+// RUN: %clang -### -fthreadsafe-statics -DTHREADSAFE_STATICS -c %s 2>&1 | FileCheck --check-prefix=CHECK-THREADSAFE-STATICS %s
+
+// CHECK-THREADSAFE-STATICS: "-cc1"
+// CHECK-THREADSAFE-STATICS-NOT: "-fno-threadsafe-statics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6147,7 +6147,8 @@
   // than 19.
   if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
   // -fno-delayed-template-parsing is default, except when targeting MSVC.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107163: [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode

2021-07-30 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/test/Driver/threadsafe-statics.clcpp:2
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+

Anastasia wrote:
> Worth adding one more RUN line with `-fthreadsafe-statics` passed.
Such RUN line is present on line 8. Should I move it up so that all RUN lines 
are close to one another?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107163

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


[PATCH] D107163: [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode

2021-08-02 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Topotuna marked an inline comment as done.
Closed by commit rGb13fc7311eab: [OpenCL] __cpp_threadsafe_static_init is by 
default undefined in OpenCL mode. (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107163

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/threadsafe-statics.clcpp


Index: clang/test/Driver/threadsafe-statics.clcpp
===
--- /dev/null
+++ clang/test/Driver/threadsafe-statics.clcpp
@@ -0,0 +1,11 @@
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+
+// CHECK-NO-THREADSAFE-STATICS: "-cc1"
+// CHECK-NO-THREADSAFE-STATICS: "-fno-threadsafe-statics"
+// CHECK-NO-THREADSAFE-STATICS-NOT: "-fthreadsafe-statics"
+
+// RUN: %clang -### -fthreadsafe-statics -DTHREADSAFE_STATICS -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-THREADSAFE-STATICS %s
+
+// CHECK-THREADSAFE-STATICS: "-cc1"
+// CHECK-THREADSAFE-STATICS-NOT: "-fno-threadsafe-statics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6192,7 +6192,8 @@
   // than 19.
   if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
   // -fno-delayed-template-parsing is default, except when targeting MSVC.


Index: clang/test/Driver/threadsafe-statics.clcpp
===
--- /dev/null
+++ clang/test/Driver/threadsafe-statics.clcpp
@@ -0,0 +1,11 @@
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 | FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+
+// CHECK-NO-THREADSAFE-STATICS: "-cc1"
+// CHECK-NO-THREADSAFE-STATICS: "-fno-threadsafe-statics"
+// CHECK-NO-THREADSAFE-STATICS-NOT: "-fthreadsafe-statics"
+
+// RUN: %clang -### -fthreadsafe-statics -DTHREADSAFE_STATICS -c %s 2>&1 | FileCheck --check-prefix=CHECK-THREADSAFE-STATICS %s
+
+// CHECK-THREADSAFE-STATICS: "-cc1"
+// CHECK-THREADSAFE-STATICS-NOT: "-fno-threadsafe-statics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6192,7 +6192,8 @@
   // than 19.
   if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
   // -fno-delayed-template-parsing is default, except when targeting MSVC.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-08-05 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 364420.
Topotuna added a comment.

Documentation section title reworded


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

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp

Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_is_same() {
+  static_assert(is_same::value);
+  static_assert(!is_same::value);
+  static_assert(!is_same<__private int, int>::value);
+}
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space::type, int>::value,
+"type without an address space unexpectedly modified by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, int3>::value,
+"__constant address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by __remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,30 @@
 global OnlySL *d,
   );
 
+Remove address space builtin function
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. This utility only affects
+address space qualifiers, therefore, other type qualifiers such as
+``const`` or ``volatile`` remain unchanged.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+T var1; // error - local function variable with global address space
+__private T var2; // error - conflicting address space qualifiers
+__private __remove_address_space var3; // var3 is __private int
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-08-06 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5a2f05dcc80: [C++4OpenCL] Introduces __remove_address_space 
utility (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp

Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_is_same() {
+  static_assert(is_same::value);
+  static_assert(!is_same::value);
+  static_assert(!is_same<__private int, int>::value);
+}
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space::type, int>::value,
+"type without an address space unexpectedly modified by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, int3>::value,
+"__constant address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by __remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -572,6 +572,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,30 @@
 global OnlySL *d,
   );
 
+Remove address space builtin function
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed. This utility only affects
+address space qualifiers, therefore, other type qualifiers such as
+``const`` or ``volatile`` remain unchanged.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+T var1; // error - local function variable with global address space
+__private T var2; // error - conflicting address space qualifiers
+__private __remove_address_space var3; // var3 is __private int
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107648: [OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.

2021-08-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Herald added a reviewer: aaron.ballman.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Some Clang diagnostics could only report OpenCL C version. Because
C++ for OpenCL can be used as an alternative to OpenCL C, the text
for diagnostics should reflect that.

Output text modified for these diagnostics:
`warn_option_invalid_ocl_version`
`err_attribute_requires_opencl_version`
`warn_opencl_attr_deprecated_ignored`
`ext_opencl_ext_vector_type_rgba_selector`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107648

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/Frontend/opencl.cl
  clang/test/SemaOpenCL/ext_vectors.cl
  clang/test/SemaOpenCL/nosvm.cl

Index: clang/test/SemaOpenCL/nosvm.cl
===
--- clang/test/SemaOpenCL/nosvm.cl
+++ clang/test/SemaOpenCL/nosvm.cl
@@ -1,13 +1,14 @@
 // RUN: %clang_cc1 -verify %s
 // RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s
+// RUN: %clang_cc1 -verify -cl-std=clc++1.0 %s
 // RUN: %clang_cc1 -verify -x c -D NOCL %s
 
 #ifndef NOCL
 kernel void f(__attribute__((nosvm)) global int* a);
 #ifndef CL20
-// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}}
+// expected-error@-2 {{'nosvm' attribute requires OpenCL C version 2.0}}
 #else
-// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}}
+// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL C version 2.0}}
 #endif
 
 __attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}
Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
Index: clang/test/Frontend/opencl.cl
===
--- clang/test/Frontend/opencl.cl
+++ clang/test/Frontend/opencl.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++ -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++1.0 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
@@ -10,6 +10,7 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+// RUN: %clang_cc1 -cl-std=clc++1.0 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCLCPP-VERSION10 %s
 
 #ifdef SYNTAX
 class test{
@@ -30,6 +31,7 @@
   // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
 
-// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL C version 1.1 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL C version 1.2 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL C version 2.0 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCLCPP-VERSION10: warning: C++ for OpenCL version 1.0 does not support the option '-cl-strict-aliasing'
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMemb

[PATCH] D107648: [OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.

2021-08-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 364796.
Topotuna added a comment.

Diagnostic argument index updated (from `%1` to `%2`)


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

https://reviews.llvm.org/D107648

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/Frontend/opencl.cl
  clang/test/SemaOpenCL/ext_vectors.cl
  clang/test/SemaOpenCL/nosvm.cl

Index: clang/test/SemaOpenCL/nosvm.cl
===
--- clang/test/SemaOpenCL/nosvm.cl
+++ clang/test/SemaOpenCL/nosvm.cl
@@ -1,13 +1,14 @@
 // RUN: %clang_cc1 -verify %s
 // RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s
+// RUN: %clang_cc1 -verify -cl-std=clc++1.0 %s
 // RUN: %clang_cc1 -verify -x c -D NOCL %s
 
 #ifndef NOCL
 kernel void f(__attribute__((nosvm)) global int* a);
 #ifndef CL20
-// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}}
+// expected-error@-2 {{'nosvm' attribute requires OpenCL C version 2.0}}
 #else
-// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}}
+// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL C version 2.0}}
 #endif
 
 __attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}
Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
Index: clang/test/Frontend/opencl.cl
===
--- clang/test/Frontend/opencl.cl
+++ clang/test/Frontend/opencl.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++ -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++1.0 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
@@ -10,6 +10,7 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+// RUN: %clang_cc1 -cl-std=clc++1.0 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCLCPP-VERSION10 %s
 
 #ifdef SYNTAX
 class test{
@@ -30,6 +31,7 @@
   // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
 
-// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL C version 1.1 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL C version 1.2 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL C version 2.0 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCLCPP-VERSION10: warning: C++ for OpenCL version 1.0 does not support the option '-cl-strict-aliasing'
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -343,7 +343,7 @@
   if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
-<< StringRef(DiagBegin, 1) << SourceRange(CompLoc);
+<< StringRef(DiagBegin, 1) << SourceRange(CompLoc) << 0 << "3.0";
   }
 }
   } else {
Index: clang/lib/Sema/SemaDeclAttr.cpp
===

[PATCH] D107648: [OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.

2021-08-09 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 365157.
Topotuna added a comment.
Herald added a subscriber: dexonsmith.

Diagnostics reworded. Helper function `getOpenCLVersionString()` added. Tests 
updated


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

https://reviews.llvm.org/D107648

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Frontend/opencl.cl
  clang/test/SemaOpenCL/ext_vectors.cl
  clang/test/SemaOpenCL/nosvm.cl

Index: clang/test/SemaOpenCL/nosvm.cl
===
--- clang/test/SemaOpenCL/nosvm.cl
+++ clang/test/SemaOpenCL/nosvm.cl
@@ -1,13 +1,16 @@
 // RUN: %clang_cc1 -verify %s
 // RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s
+// RUN: %clang_cc1 -verify -cl-std=clc++1.0 -D CLCPP10 %s
 // RUN: %clang_cc1 -verify -x c -D NOCL %s
 
 #ifndef NOCL
 kernel void f(__attribute__((nosvm)) global int* a);
-#ifndef CL20
-// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}}
+#if defined(CL20)
+// expected-warning@-2 {{'nosvm' attribute is deprecated and ignored in OpenCL C version 2.0}}
+#elif defined(CLCPP10)
+// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in C++ for OpenCL version 1.0}}
 #else
-// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}}
+// expected-error@-6 {{attribute 'nosvm' is supported in the OpenCL version 2.0}}
 #endif
 
 __attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}
Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,12 +10,12 @@
 
   V = V.abgr;
 #if (__OPENCL_C_VERSION__ < 300)
-  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 3.0 feature}}
+  // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
 #if (__OPENCL_C_VERSION__ < 300)
-  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 3.0 feature}}
+  // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
 #endif
 }
Index: clang/test/Frontend/opencl.cl
===
--- clang/test/Frontend/opencl.cl
+++ clang/test/Frontend/opencl.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++ -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++1.0 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
@@ -10,6 +10,7 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+// RUN: %clang_cc1 -cl-std=clc++1.0 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCLCPP-VERSION10 %s
 
 #ifdef SYNTAX
 class test{
@@ -30,6 +31,7 @@
   // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
 
-// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL C version 1.1 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL C version 1.2 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION20: war

[PATCH] D107648: [OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.

2021-08-09 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 365179.
Topotuna added a comment.

Diagnostic `err_opencl_unknown_type_specifier` addressed. Deprecation 
conditions changed in `nosvm` attribute test.


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

https://reviews.llvm.org/D107648

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Frontend/opencl.cl
  clang/test/SemaOpenCL/ext_vectors.cl
  clang/test/SemaOpenCL/nosvm.cl

Index: clang/test/SemaOpenCL/nosvm.cl
===
--- clang/test/SemaOpenCL/nosvm.cl
+++ clang/test/SemaOpenCL/nosvm.cl
@@ -1,13 +1,16 @@
 // RUN: %clang_cc1 -verify %s
 // RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s
+// RUN: %clang_cc1 -verify -cl-std=clc++1.0 -D CLCPP10 %s
 // RUN: %clang_cc1 -verify -x c -D NOCL %s
 
 #ifndef NOCL
 kernel void f(__attribute__((nosvm)) global int* a);
-#ifndef CL20
-// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}}
+#if defined(CL20)
+// expected-warning@-2 {{'nosvm' attribute is deprecated and ignored in OpenCL C version 2.0}}
+#elif defined(CLCPP10)
+// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in C++ for OpenCL version 1.0}}
 #else
-// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}}
+// expected-error@-6 {{attribute 'nosvm' is supported in the OpenCL version 2.0 onwards}}
 #endif
 
 __attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}
Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,12 +10,12 @@
 
   V = V.abgr;
 #if (__OPENCL_C_VERSION__ < 300)
-  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 3.0 feature}}
+  // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
 #if (__OPENCL_C_VERSION__ < 300)
-  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 3.0 feature}}
+  // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
 #endif
 }
Index: clang/test/Frontend/opencl.cl
===
--- clang/test/Frontend/opencl.cl
+++ clang/test/Frontend/opencl.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++ -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++1.0 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
@@ -10,6 +10,7 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+// RUN: %clang_cc1 -cl-std=clc++1.0 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCLCPP-VERSION10 %s
 
 #ifdef SYNTAX
 class test{
@@ -30,6 +31,7 @@
   // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
 
-// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL C version 1.1 does not support the option '-cl-strict-aliasing'
+// CHECK-INVALID-OPENCL-VERSION12: warni

[PATCH] D107648: [OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.

2021-08-13 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcfdfb75c1ff3: [OpenCL] Clang diagnostics allow reporting C++ 
for OpenCL version. (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D107648?vs=365179&id=366259#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107648

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Frontend/opencl.cl
  clang/test/SemaOpenCL/ext_vectors.cl
  clang/test/SemaOpenCL/nosvm.cl

Index: clang/test/SemaOpenCL/nosvm.cl
===
--- clang/test/SemaOpenCL/nosvm.cl
+++ clang/test/SemaOpenCL/nosvm.cl
@@ -1,13 +1,16 @@
 // RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 %s
+// RUN: %clang_cc1 -verify -cl-std=clc++1.0 %s
 // RUN: %clang_cc1 -verify -x c -D NOCL %s
 
 #ifndef NOCL
 kernel void f(__attribute__((nosvm)) global int* a);
-#ifndef CL20
-// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}}
+#if (__OPENCL_C_VERSION__ == 200)
+// expected-warning@-2 {{'nosvm' attribute is deprecated and ignored in OpenCL C version 2.0}}
+#elif (__OPENCL_CPP_VERSION__ == 100)
+// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in C++ for OpenCL version 1.0}}
 #else
-// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}}
+// expected-error@-6 {{attribute 'nosvm' is supported in the OpenCL version 2.0 onwards}}
 #endif
 
 __attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}
Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,12 +10,12 @@
 
   V = V.abgr;
 #if (__OPENCL_C_VERSION__ < 300)
-  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 3.0 feature}}
+  // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
 #if (__OPENCL_C_VERSION__ < 300)
-  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 3.0 feature}}
+  // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
 #endif
 }
Index: clang/test/Frontend/opencl.cl
===
--- clang/test/Frontend/opencl.cl
+++ clang/test/Frontend/opencl.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++ -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++1.0 -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
 // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
@@ -10,6 +10,7 @@
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
+// RUN: %clang_cc1 -cl-std=clc++1.0 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCLCPP-VERSION10 %s
 
 #ifdef SYNTAX
 class test{
@@ -30,6 +31,7 @@
   // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}}
 #endif
 
-// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing'
-// CHECK-INVALID-O

[PATCH] D108038: [C++4OpenCL] C++ for OpenCL version 2021 introduced to command line

2021-08-13 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, dexonsmith, dang, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Introduces language standard `lang_openclcpp2021` and allows
`clc++2021` as a version flag for `-cl-std` in command line.
Defines macros related to C++ for OpenCL version 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108038

Files:
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/unknown-std.cl
  clang/test/Frontend/stdlang.c

Index: clang/test/Frontend/stdlang.c
===
--- clang/test/Frontend/stdlang.c
+++ clang/test/Frontend/stdlang.c
@@ -7,12 +7,16 @@
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl3.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=clc++ -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=clc++1.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=clc++2021 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL3.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CLC++ -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CLC++1.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CLC++2021 -DOPENCL %s
 // RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 // CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
Index: clang/test/Driver/unknown-std.cl
===
--- clang/test/Driver/unknown-std.cl
+++ clang/test/Driver/unknown-std.cl
@@ -12,6 +12,7 @@
 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
 // CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
 // CHECK-NEXT: note: use 'clc++1.0' or 'clc++' for 'C++ for OpenCL 1.0' standard
+// CHECK-NEXT: note: use 'clc++2021' for 'C++ for OpenCL 2021' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -51,6 +51,8 @@
 // CLSTDALL-NEXT: CLC++
 // CLSTDALL-NEXT: clc++1.0
 // CLSTDALL-NEXT: CLC++1.0
+// CLSTDALL-NEXT: clc++2021
+// CLSTDALL-NEXT: CLC++2021
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -433,11 +433,18 @@
   // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
   if (LangOpts.OpenCL) {
 if (LangOpts.CPlusPlus) {
-  if (LangOpts.OpenCLCPlusPlusVersion == 100)
+  switch (LangOpts.OpenCLCPlusPlusVersion) {
+  case 100:
 Builder.defineMacro("__OPENCL_CPP_VERSION__", "100");
-  else
+break;
+  case 202100:
+Builder.defineMacro("__OPENCL_CPP_VERSION__", "202100");
+break;
+  default:
 llvm_unreachable("Unsupported C++ version for OpenCL");
+  }
   Builder.defineMacro("__CL_CPP_VERSION_1_0__", "100");
+  Builder.defineMacro("__CL_CPP_VERSION_2021__", "202100");
 } else {
   // OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
   // language standard with which the program is compiled. __OPENCL_VERSION__
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3165,6 +3165,8 @@
 Opts.OpenCLVersion = 300;
   else if (LangStd == LangStandard::lang_openclcpp10)
 Opts.OpenCLCPlusPlusVersion = 100;
+  else if (LangStd == LangStandard::lang_openclcpp2021)
+Opts.OpenCLCPlusPlusVersion = 202100;
 
   // OpenCL has some additional defaults.
   if (Opts.OpenCL) {
@@ -3314,6 +3316,7 @@
   case LangStandard::lang_opencl20:
   case LangStandard::lang_opencl30:
   case LangStandard::lang_openclcpp10:
+  case LangStandard::lang_openclcpp2021:
 StdOpt = OPT_cl_std_EQ;
 break;
   default:
@@ -3612,6 +3615,7 @@
 .Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
 .Cases("clc++", "CLC++", LangStandard::l

[PATCH] D108113: [C++4OpenCL] Enable -cl-std flag clc++21 as a shorthand for clc++2021

2021-08-16 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, dexonsmith, dang, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allows `clc++21` and `CLC++21` to be used as possible options for
`-cl-std` in command line to represent C++ for OpenCL version 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108113

Files:
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Frontend/stdlang.c


Index: clang/test/Frontend/stdlang.c
===
--- clang/test/Frontend/stdlang.c
+++ clang/test/Frontend/stdlang.c
@@ -9,6 +9,7 @@
 // RUN: %clang_cc1 -x cl -cl-std=clc++ -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=clc++1.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=clc++2021 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=clc++21 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
@@ -17,6 +18,7 @@
 // RUN: %clang_cc1 -x cl -cl-std=CLC++ -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CLC++1.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CLC++2021 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CLC++21 -DOPENCL %s
 // RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 // CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -53,6 +53,8 @@
 // CLSTDALL-NEXT: CLC++1.0
 // CLSTDALL-NEXT: clc++2021
 // CLSTDALL-NEXT: CLC++2021
+// CLSTDALL-NEXT: clc++21
+// CLSTDALL-NEXT: CLC++21
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s 
-check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s 
-check-prefix=FNOSANICOVERALL
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3616,6 +3616,7 @@
 .Cases("clc++", "CLC++", LangStandard::lang_openclcpp10)
 .Cases("clc++1.0", "CLC++1.0", LangStandard::lang_openclcpp10)
 .Cases("clc++2021", "CLC++2021", LangStandard::lang_openclcpp2021)
+.Cases("clc++21", "CLC++21", LangStandard::lang_openclcpp2021)
 .Default(LangStandard::lang_unspecified);
 
 if (OpenCLLangStd == LangStandard::lang_unspecified) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -866,7 +866,7 @@
   MarshallingInfoFlag>;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL language standard to compile for.">,
-  
Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0,clc++2021,CLC++2021">;
+  
Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0,clc++2021,CLC++2021,clc++21,CLC++21">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, 
Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], 
"cl-fp32-correctly-rounded-divide-sqrt">, Group, 
Flags<[CC1Option]>,
Index: clang/include/clang/Basic/LangStandards.def
===
--- clang/include/clang/Basic/LangStandards.def
+++ clang/include/clang/Basic/LangStandards.def
@@ -200,6 +200,8 @@
 LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++")
 LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
 LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
+LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "clc++21")
+LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++21")
 
 // CUDA
 LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",


Index: clang/test/Frontend/stdlang.c
===
--- clang/test/Frontend/stdlang.c
+++ clang/test/Frontend/stdlang.c
@@ -9,6 +9,7 @@
 // RUN: %clang_cc1 -x cl -cl-std=clc++ -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=clc++1.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=clc++2021 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=clc++21 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
@@ -17,6 +18,7 @@
 // RUN: %clang_cc1 -x c

[PATCH] D108038: [C++4OpenCL] C++ for OpenCL version 2021 introduced to command line

2021-08-18 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0d0628b2d213: [OpenCL] C++ for OpenCL version 2021 
introduced to command line. (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108038

Files:
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/unknown-std.cl
  clang/test/Frontend/stdlang.c

Index: clang/test/Frontend/stdlang.c
===
--- clang/test/Frontend/stdlang.c
+++ clang/test/Frontend/stdlang.c
@@ -7,12 +7,16 @@
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl3.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=clc++ -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=clc++1.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=clc++2021 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL3.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CLC++ -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CLC++1.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CLC++2021 -DOPENCL %s
 // RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 // CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
Index: clang/test/Driver/unknown-std.cl
===
--- clang/test/Driver/unknown-std.cl
+++ clang/test/Driver/unknown-std.cl
@@ -12,6 +12,7 @@
 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
 // CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
 // CHECK-NEXT: note: use 'clc++1.0' or 'clc++' for 'C++ for OpenCL 1.0' standard
+// CHECK-NEXT: note: use 'clc++2021' for 'C++ for OpenCL 2021' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -51,6 +51,8 @@
 // CLSTDALL-NEXT: CLC++
 // CLSTDALL-NEXT: clc++1.0
 // CLSTDALL-NEXT: CLC++1.0
+// CLSTDALL-NEXT: clc++2021
+// CLSTDALL-NEXT: CLC++2021
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -433,11 +433,18 @@
   // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
   if (LangOpts.OpenCL) {
 if (LangOpts.CPlusPlus) {
-  if (LangOpts.OpenCLCPlusPlusVersion == 100)
+  switch (LangOpts.OpenCLCPlusPlusVersion) {
+  case 100:
 Builder.defineMacro("__OPENCL_CPP_VERSION__", "100");
-  else
+break;
+  case 202100:
+Builder.defineMacro("__OPENCL_CPP_VERSION__", "202100");
+break;
+  default:
 llvm_unreachable("Unsupported C++ version for OpenCL");
+  }
   Builder.defineMacro("__CL_CPP_VERSION_1_0__", "100");
+  Builder.defineMacro("__CL_CPP_VERSION_2021__", "202100");
 } else {
   // OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
   // language standard with which the program is compiled. __OPENCL_VERSION__
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3165,6 +3165,8 @@
 Opts.OpenCLVersion = 300;
   else if (LangStd == LangStandard::lang_openclcpp10)
 Opts.OpenCLCPlusPlusVersion = 100;
+  else if (LangStd == LangStandard::lang_openclcpp2021)
+Opts.OpenCLCPlusPlusVersion = 202100;
 
   // OpenCL has some additional defaults.
   if (Opts.OpenCL) {
@@ -3314,6 +3316,7 @@
   case LangStandard::lang_opencl20:
   case LangStandard::lang_opencl30:
   case LangStandard::lang_openclcpp10:
+  case LangStandard::lang_openclcpp2021:
 StdOpt = OPT_cl_std_EQ;
 break;
   default:
@@ -3612,6 +3615,7 @@
 .Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
 .Cases("clc++", "CLC++", LangStandard::lang_openclcpp10)
 .Cases("clc++1.0", "CLC++1.0", LangStandard::lang_openclcpp10)
+.Cases

[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, dexonsmith, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

C++ for OpenCL version 2021 and later are expected to consist of a
major version number only. Therefore, a different constructor for
`VersionTuple` needs to be called when reporting language version.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108379

Files:
  clang/lib/Basic/LangOptions.cpp


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

In D108379#2954826 , @Anastasia wrote:

> LGTM! Thanks!
>
> I imagine you will be adding some tests that will check the correctness of 
> diagnostic wording in the subsequent commits?

Yes, I will add tests for diagnostics reporting once C++ for OpenCL 2021 
achieves similar functionality as OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108379

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


[PATCH] D105987: [C++4OpenCL] NULL redefined as nullptr

2021-07-14 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Herald added subscribers: ldrumm, Anastasia, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Redefines NULL as nullptr instead of ((void*)0) in C++ for OpenCL.

Such internal representation of NULL provides compatibility with
C++11 and later language standards.

Fixes llvm.org/PR48098


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105987

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,31 +1,48 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.0 -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
-
-#define NULL ((void*)0)
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify 
%s
+// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 
 void foo(){
 
 global int* ptr1 = NULL;
 
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+2{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__global void *'}}
+#endif
 global int* ptr2 = (global void*)0;
 
 constant int* ptr3 = NULL;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing 
'__constant int *__private' with an expression of type '__global void *' 
changes address space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__constant int 
*__private' with an rvalue of type '__global void *'}}
+#else
+// expected-error@+2{{initializing '__constant int *__private' with an 
expression of type '__global void *' changes address space of pointer}}
+#endif
+constant int* ptr4 = (global void*)0;
 
 #ifdef CL20
 // Accept explicitly pointer to generic address space in OpenCL v2.0.
 global int* ptr5 = (generic void*)0;
 #endif
 
-global int* ptr6 = (local void*)0; // expected-error{{initializing '__global 
int *__private' with an expression of type '__local void *' changes address 
space of pointer}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{cannot initialize a variable of type '__global int 
*__private' with an rvalue of type '__local void *'}}
+#else
+// expected-error@+2{{initializing '__global int *__private' with an 
expression of type '__local void *' changes address space of pointer}}
+#endif
+global int* ptr6 = (local void*)0;
 
 bool cmp = ptr1 == NULL;
 
-cmp = ptr1 == (local void*)0; // expected-error{{comparison between  
('__global int *' and '__local void *') which are pointers to non-overlapping 
address spaces}}
+#if defined(__OPENCL_CPP_VERSION__)
+// expected-error@+4{{comparison of distinct pointer types ('__global int *' 
and '__local void *')}}
+#else
+// expected-error@+2{{comparison between  ('__global int *' and '__local void 
*') which are pointers to non-overlapping address spaces}}
+#endif
+cmp = ptr1 == (local void*)0;
 
 cmp = ptr3 == NULL;
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,9 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
+#if defined(__OPENCL_CPP_VERSION__)
+#define NULL nullptr
+#elif defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
 #endif
 


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,31 +1,48 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.0 -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
-
-#define NULL ((void*)0)
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdec

[PATCH] D105988: [OpenCL] NULL introduced prior to v2.0

2021-07-14 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Herald added subscribers: ldrumm, Anastasia, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

NULL macro maps to ((void*)0) for OpenCL versions earlier than 2.0

NULL was undefined in OpenCL prior to version 2.0. However, the
language specification states that `macro names defined by the C99
specification but not currently supported by OpenCL are reserved
for future use`. Therefore, application developers cannot redefine
NULL.

The change is supposed to resolve inconsistency between language
versions. Currently there is no apparent reason why NULL should
be kept undefined.

Fixes llvm.org/PR48102


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105988

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.0 -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
 
 #define NULL ((void*)0)
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
 #endif
 


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.0 -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -verify %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
 
 #define NULL ((void*)0)
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105988: [OpenCL] NULL introduced prior to v2.0

2021-07-14 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 358625.
Topotuna added a comment.

Added compile time flags

  -finclude-default-header -fdeclare-opencl-builtins

instead of

  #define NULL ((void*)0)


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

https://reviews.llvm.org/D105988

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify 
%s
-// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
+
+#define NULL ((void*)0)
 
 void foo(){
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #define NULL ((void*)0)
 #endif
 


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
+
+#define NULL ((void*)0)
 
 void foo(){
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 #define NULL ((void*)0)
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105988: [OpenCL] NULL introduced prior to v2.0

2021-07-14 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 358628.
Topotuna added a comment.

Wrong diff file added previously


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

https://reviews.llvm.org/D105988

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/SemaOpenCL/null_literal.cl


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
-
-#define NULL ((void*)0)
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify 
%s
+// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins 
-finclude-default-header -verify %s
 
 void foo(){
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
 #endif
 


Index: clang/test/SemaOpenCL/null_literal.cl
===
--- clang/test/SemaOpenCL/null_literal.cl
+++ clang/test/SemaOpenCL/null_literal.cl
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
-
-#define NULL ((void*)0)
+// RUN: %clang_cc1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.0 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.1 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -fdeclare-opencl-builtins -finclude-default-header -verify %s
 
 void foo(){
 
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -164,7 +164,7 @@
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__OPENCL_CPP_VERSION__) || defined(__OPENCL_C_VERSION__)
 #define NULL ((void*)0)
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110184: [OpenCL] Constructor address space test adjusted for C++ for OpenCL 2021

2021-11-08 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

In D110184#3115361 , @Anastasia wrote:

> Ping, @Topotuna do you still plan to commit this?

Ah, yes. I will commit it in the next couple of days as well as D110155 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110184

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


[PATCH] D110155: [OpenCL] Allow optional __generic in __remove_address_space utility

2021-11-09 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG81081daef029: [OpenCL] Allow optional __generic in 
__remove_address_space utility (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110155

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes 
-fdeclare-opencl-builtins -finclude-default-header
 
 template
 struct is_same {
@@ -19,8 +21,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by 
__remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, 
int>::value,
 "__generic address space not removed by 
__remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, 
char>::value,
 "__global address space not removed by 
__remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, 
ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -fdeclare-opencl-builtins -finclude-default-header
 
 template
 struct is_same {
@@ -19,8 +21,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by __remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
 "__generic address space not removed by __remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
 "__global address space not removed by __remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110155: [OpenCL] Allow optional __generic in __remove_address_space utility

2021-11-09 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

In D110155#3117786 , @carlosgalvezp 
wrote:

> Hi! I believe this commit broke a number of CI jobs, would you be able to 
> look into it?
>
> https://lab.llvm.org/buildbot/#/builders/52/builds/12263

Hi, I am aware it broke some of the builds. However, I cannot recreate the 
issue locally. Planning to revert the change shortly to investigate it further


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110155

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


[PATCH] D110155: [OpenCL] Allow optional __generic in __remove_address_space utility

2021-11-12 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 386773.
Topotuna added a comment.
Herald added a subscriber: Naghasan.

Run line `-triple` is now set explicitly. Test moved from `CodeGenOpenCLCXX` 
directory to `SemaOpenCLCXX`


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

https://reviews.llvm.org/D110155

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
  clang/test/SemaOpenCLCXX/remove-address-space.clcpp


Index: clang/test/SemaOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/SemaOpenCLCXX/remove-address-space.clcpp
+++ clang/test/SemaOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++1.0 
-fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes 
-fdeclare-opencl-builtins -finclude-default-header
+
+// expected-no-diagnostics
 
 template
 struct is_same {
@@ -19,8 +23,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by 
__remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, 
int>::value,
 "__generic address space not removed by 
__remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, 
char>::value,
 "__global address space not removed by 
__remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, 
ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };


Index: clang/test/SemaOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/SemaOpenCLCXX/remove-address-space.clcpp
+++ clang/test/SemaOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++1.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++2021 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -fdeclare-opencl-builtins -finclude-default-header
+
+// expected-no-diagnostics
 
 template
 struct is_same {
@@ -19,8 +23,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by __remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
 "__generic address space not removed by __remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
 "__global address space not removed by __remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110184: [OpenCL] Constructor address space test adjusted for C++ for OpenCL 2021

2021-11-12 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG388e8110db6f: [OpenCL] Constructor address space test 
adjusted for C++ for OpenCL 2021 (authored by Topotuna).
Herald added a subscriber: Naghasan.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110184

Files:
  clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp


Index: clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple spir-unknown-unknown | 
FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -DGENERIC -emit-llvm -o - -O0 -triple 
spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -DGENERIC -emit-llvm -o - -O0 -triple 
spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -emit-llvm -o - -O0 
-triple spir-unknown-unknown | FileCheck %s
 
 // CHECK: %struct.X = type { i32 }
 
@@ -11,8 +13,10 @@
   int x;
 
   // Local variables are handled in local_addrspace_init.clcpp
-  X() /*__generic*/ : x(0) {}
+  X() /*__generic or __private*/ : x(0) {}
+#if defined(GENERIC)
   X() __private : x(0) {}
+#endif
   X() __global : x(0) {}
   constexpr X() __constant : x(0) {}
   constexpr X(int x) __constant : x(x) {}


Index: clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -DGENERIC -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -DGENERIC -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
 
 // CHECK: %struct.X = type { i32 }
 
@@ -11,8 +13,10 @@
   int x;
 
   // Local variables are handled in local_addrspace_init.clcpp
-  X() /*__generic*/ : x(0) {}
+  X() /*__generic or __private*/ : x(0) {}
+#if defined(GENERIC)
   X() __private : x(0) {}
+#endif
   X() __global : x(0) {}
   constexpr X() __constant : x(0) {}
   constexpr X(int x) __constant : x(x) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110155: [OpenCL] Allow optional __generic in __remove_address_space utility

2021-11-30 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 390617.
Topotuna added a comment.

Run line argument reordering


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

https://reviews.llvm.org/D110155

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
  clang/test/SemaOpenCLCXX/remove-address-space.clcpp


Index: clang/test/SemaOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/SemaOpenCLCXX/remove-address-space.clcpp
+++ clang/test/SemaOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown 
-fdeclare-opencl-builtins -finclude-default-header -verify
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown 
-fdeclare-opencl-builtins -finclude-default-header -verify
+// RUN: %clang_cc1 %s -cl-std=clc++2021 
-cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -triple 
spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -verify
+
+// expected-no-diagnostics
 
 template
 struct is_same {
@@ -19,8 +23,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by 
__remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, 
int>::value,
 "__generic address space not removed by 
__remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, 
char>::value,
 "__global address space not removed by 
__remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, 
ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };


Index: clang/test/SemaOpenCLCXX/remove-address-space.clcpp
===
--- clang/test/SemaOpenCLCXX/remove-address-space.clcpp
+++ clang/test/SemaOpenCLCXX/remove-address-space.clcpp
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -verify
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -verify
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -verify
+
+// expected-no-diagnostics
 
 template
 struct is_same {
@@ -19,8 +23,10 @@
 void test_remove_address_space() {
   static_assert(is_same<__remove_address_space::type, int>::value,
 "type without an address space unexpectedly modified by __remove_address_space");
+#if defined(__opencl_c_generic_address_space)
   static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
 "__generic address space not removed by __remove_address_space");
+#endif
   static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
 "__global address space not removed by __remove_address_space");
   static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -600,9 +600,11 @@
 // C++ for OpenCL - __remove_address_space
 #if defined(__OPENCL_CPP_VERSION__)
 template  struct __remove_address_space { using type = _Tp; };
+#if defined(__opencl_c_generic_address_space)
 template  struct __remove_address_space<__generic _Tp> {
   using type = _Tp;
 };
+#endif
 template  struct __remove_address_space<__global _Tp> {
   using type = _Tp;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110185: [OpenCL] Reuse C++ for OpenCL 1.0 address space tests for version 2021

2021-11-30 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 390622.
Topotuna added a comment.
Herald added a subscriber: Naghasan.

Test coverage expanded


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

https://reviews.llvm.org/D110185

Files:
  clang/test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
  clang/test/SemaOpenCLCXX/address-space-castoperators.clcpp
  clang/test/SemaOpenCLCXX/address-space-cond.clcpp
  clang/test/SemaOpenCLCXX/address-space-deduction.clcpp
  clang/test/SemaOpenCLCXX/address-space-lambda.clcpp
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.clcpp
  clang/test/SemaOpenCLCXX/address-space-of-this.clcpp
  clang/test/SemaOpenCLCXX/address-space-references.clcpp
  clang/test/SemaOpenCLCXX/address-space-templates.clcpp
  clang/test/SemaOpenCLCXX/address_space_overloading.clcpp
  clang/test/SemaOpenCLCXX/addrspace-auto.clcpp
  clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
  clang/test/SemaOpenCLCXX/addrspace_cast.clcpp
  clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.clcpp

Index: clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.clcpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -pedantic -verify -ast-dump | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -pedantic -verify -ast-dump | FileCheck %s
 
 // expected-no-diagnostics
 
Index: clang/test/SemaOpenCLCXX/addrspace_cast.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace_cast.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace_cast.clcpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -pedantic -verify -fsyntax-only
 
 void foo(global int *gl, const global int *gl_const, global int &gl_ref) {
   //FIXME: Diagnostics can be improved to be more specific in some cases.
Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -pedantic -ast-dump -verify | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -pedantic -ast-dump -verify | FileCheck %s
 
 __constant int g1; // expected-error {{variable in constant address space must be initialized}}
 __constant int g2 = 0;
Index: clang/test/SemaOpenCLCXX/addrspace-auto.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-auto.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-auto.clcpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -pedantic -ast-dump -verify | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -pedantic -ast-dump -verify | FileCheck %s
 
 __constant int i = 1;
 //CHECK: |-VarDecl {{.*}} ai '__global int':'__global int'
Index: clang/test/SemaOpenCLCXX/address_space_overloading.clcpp
===
--- clang/test/SemaOpenCLCXX/address_space_overloading.clcpp
+++ clang/test/SemaOpenCLCXX/address_space_overloading.clcpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // expected-no-diagnostics
 
 struct RetGlob {
Index: clang/test/SemaOpenCLCXX/address-space-templates.clcpp
===
--- clang/test/SemaOpenCLCXX/address-space-templates.clcpp
+++ clang/test/SemaOpenCLCXX/address-space-templates.clcpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -cl-std=clc++1.0 -triple spir-unknown-unknown -pedantic -verify -ast-dump | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -triple spir-unknown-unknown -pedantic -verify -ast-dump | FileCheck %s
 
 template 
 struct S {
Index: clang/test/SemaOpenCLCXX/address-space-references.clcpp
==

[PATCH] D116271: [Docs] Document C++ for OpenCL 2021 support in clang

2022-01-03 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna accepted this revision.
Topotuna added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D116271

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


[PATCH] D110155: [OpenCL] Allow optional __generic in __remove_address_space utility

2021-12-27 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna closed this revision.
Topotuna added a comment.

Closed by commit: rGb5fef6dbfd6b4c84d61155fd2221064bcc1ecdcf 



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

https://reviews.llvm.org/D110155

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


[PATCH] D116271: [Docs] Document C++ for OpenCL 2021 support in clang

2021-12-27 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

Overall, I think that adjustments are accurate. Suggested a couple of small 
edits




Comment at: clang/docs/OpenCLSupport.rst:28-29
 
-For general issues and bugs with OpenCL in clang refer to `Bugzilla
-`__.
+For general issues and bugs with OpenCL in clang refer to `the following 
Github issue
+list
+`__.





Comment at: clang/docs/OpenCLSupport.rst:323
 
-Clang implements language version 1.0 published in `the official
+Clang implements language version 1.0 and 2021 published in `the official
 release of C++ for OpenCL Documentation




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

https://reviews.llvm.org/D116271

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


[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-20 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ae9262857a1: [OpenCL] Fix version reporting of C++ for 
OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108379

Files:
  clang/lib/Basic/LangOptions.cpp


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108461: [OpenCL] Supports optional generic address space in C++ for OpenCL 2021

2021-08-20 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_generic_address_space`
in C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108461

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/Headers/opencl-c-header.cl
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -2,14 +2,16 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=clc++1.0 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -cl-std=clc++2021 %s -verify -triple spir-unknown-unknown
 // RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=clc++1.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=clc++2021 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
 // Extensions in all versions
 #ifndef cl_clang_storage_class_specifiers
Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
-// RUN: %clang_cc1 %s -cl-std=clc++ -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
 
 __constant int ci = 1;
 
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -1,12 +1,15 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL2.0
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++1.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL3.0 -cl-ext=+__opencl

[PATCH] D108461: [OpenCL] Supports optional generic address space in C++ for OpenCL 2021

2021-08-23 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna planned changes to this revision.
Topotuna added a comment.

`__opencl_c_generic_address_space` should not have been chosen as the first 
feature to be addressed out of all OpenCL 3.0 optional core features. This is 
because `__opencl_c_device_enqueue` has a dependency on this feature. I will 
review the order in which OpenCL 3.0 optional features should be introduced to 
C++ for OpenCL 2021 and return to this revision when all dependencies are 
resolved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108461

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


[PATCH] D108693: [OpenCL] Defines helper function for kernel language compatible OpenCL version

2021-08-25 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, dexonsmith, yaxunl.
Herald added a reviewer: aaron.ballman.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change defines a helper function getOpenCLCompatibleVersion()
inside LangOptions class. The function contains mapping between
C++ for OpenCL versions and their corresponding compatible OpenCL
versions. This mapping function should be updated each time a new
C++ for OpenCL language version is introduced. The helper function
is expected to simplify conditions on OpenCL C and C++ for OpenCL
versions inside compiler code.

Code refactoring performed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108693

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1369,8 +1369,7 @@
 // value being declared, poison it as invalid so we don't get chains of
 // errors.
 declarator.setInvalidType(true);
-  } else if ((S.getLangOpts().OpenCLVersion >= 200 ||
-  S.getLangOpts().OpenCLCPlusPlus) &&
+  } else if (S.getLangOpts().getOpenCLCompatibleVersion() >= 200 &&
  DS.isTypeSpecPipe()) {
 S.Diag(DeclLoc, diag::err_missing_actual_pipe_type)
   << DS.getSourceRange();
@@ -5093,7 +5092,7 @@
 "__cl_clang_variadic_functions", S.getLangOpts()) &&
 !(D.getIdentifier() &&
   ((D.getIdentifier()->getName() == "printf" &&
-(LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion >= 120)) ||
+LangOpts.getOpenCLCompatibleVersion() >= 120) ||
D.getIdentifier()->getName().startswith("__" {
   S.Diag(D.getIdentifierLoc(), diag::err_opencl_variadic_function);
   D.setInvalidType(true);
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12270,7 +12270,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
+  if (getLangOpts().getOpenCLCompatibleVersion() >= 200) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }
@@ -12529,8 +12529,9 @@
/*AllowBoolConversions*/false);
   if (vType.isNull())
 return InvalidOperands(Loc, LHS, RHS);
-  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
-  !getLangOpts().OpenCLCPlusPlus && vType->hasFloatingRepresentation())
+  if (getLangOpts().OpenCL &&
+  getLangOpts().getOpenCLCompatibleVersion() < 120 &&
+  vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
   // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
   //usage of the logical operators && and || with vectors in C. This
@@ -14981,8 +14982,7 @@
   }
 } else if (resultType->isExtVectorType()) {
   if (Context.getLangOpts().OpenCL &&
-  Context.getLangOpts().OpenCLVersion < 120 &&
-  !Context.getLangOpts().OpenCLCPlusPlus) {
+  Context.getLangOpts().getOpenCLCompatibleVersion() < 120) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on vector float types.
 QualType T = resultType->castAs()->getElementType();
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7488,7 +7488,7 @@
 }
 
 static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
-  if (S.LangOpts.OpenCLVersion < 200 && !S.LangOpts.OpenCLCPlusPlusVersion)
+  if (S.LangOpts.getOpenCLCompatibleVersion() < 200)
 S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version)
 << AL << "2.0" << 1;
   else
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8824,8 +8824,7 @@
 // OpenCL v3.0 s6.11.a:
 // A kernel function argument cannot be declared as a pointer to a pointer
 // type. [...] This restriction only applies to OpenCL C 1.2 or below.
-if (S.getLangOpts().OpenCLVersion <= 120 &&
-

[PATCH] D108704: [OpenCL] Define OpenCL 3.0 optional core features in C++ for OpenCL 2021

2021-08-25 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Modifies OpenCL 3.0 optional core feature macro definitions so that
they are set analogously in C++ for OpenCL 2021.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108704

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/Headers/opencl-c-header.cl
  clang/test/SemaOpenCL/features.cl


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -6,6 +6,14 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL3.0 -cl-ext=+all \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=+all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
+// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
+// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=+all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
 
 // For OpenCL C 2.0 feature macros are defined only in header, so test that 
earlier OpenCL
 // versions don't define feature macros accidentally and CL2.0 don't define 
them without header
@@ -15,7 +23,7 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL2.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
-// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CLC++ \
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 
 // Note that __opencl_c_int64 is always defined assuming
Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -175,13 +175,13 @@
 #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 // OpenCL C features.
-#if (__OPENCL_C_VERSION__ == 300)
+#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #if __opencl_c_atomic_scope_all_devices != 1
 #error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices"
 #endif
 
-#elif (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
 
 #ifndef  __opencl_c_pipes
 #error "Feature macro __opencl_c_pipes should be defined"
@@ -262,6 +262,6 @@
 #error "Incorrect feature macro __opencl_c_subgroups define"
 #endif
 
-#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #endif // defined(__SPIR__)
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -30,7 +30,7 @@
 #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 // Define feature macros for OpenCL C 2.0
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
 #define __opencl_c_pipes 1
 #define __opencl_c_generic_address_space 1
 #define __opencl_c_work_group_collective_functions 1
@@ -45,12 +45,12 @@
 #endif
 
 // Define header-only feature macros for OpenCL C 3.0.
-#if (__OPENCL_C_VERSION__ == 300)
+#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 // For the SPIR target all features are supported.
 #if defined(__SPIR__)
 #define __opencl_c_atomic_scope_all_devices 1
 #endif // defined(__SPIR__)
-#endif // (__OPENCL_C_VERSION__ == 300)
+#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 // built-in scalar data types:
 


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -6,6 +6,14 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o -

[PATCH] D108693: [OpenCL] Defines helper function for kernel language compatible OpenCL version

2021-08-31 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9bc1b3bee55: [OpenCL] Defines helper function for kernel 
language compatible OpenCL version (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108693

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1369,8 +1369,7 @@
 // value being declared, poison it as invalid so we don't get chains of
 // errors.
 declarator.setInvalidType(true);
-  } else if ((S.getLangOpts().OpenCLVersion >= 200 ||
-  S.getLangOpts().OpenCLCPlusPlus) &&
+  } else if (S.getLangOpts().getOpenCLCompatibleVersion() >= 200 &&
  DS.isTypeSpecPipe()) {
 S.Diag(DeclLoc, diag::err_missing_actual_pipe_type)
   << DS.getSourceRange();
@@ -5093,7 +5092,7 @@
 "__cl_clang_variadic_functions", S.getLangOpts()) &&
 !(D.getIdentifier() &&
   ((D.getIdentifier()->getName() == "printf" &&
-(LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion >= 120)) ||
+LangOpts.getOpenCLCompatibleVersion() >= 120) ||
D.getIdentifier()->getName().startswith("__" {
   S.Diag(D.getIdentifierLoc(), diag::err_opencl_variadic_function);
   D.setInvalidType(true);
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12263,7 +12263,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
+  if (getLangOpts().getOpenCLCompatibleVersion() >= 200) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }
@@ -12522,8 +12522,9 @@
/*AllowBoolConversions*/false);
   if (vType.isNull())
 return InvalidOperands(Loc, LHS, RHS);
-  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
-  !getLangOpts().OpenCLCPlusPlus && vType->hasFloatingRepresentation())
+  if (getLangOpts().OpenCL &&
+  getLangOpts().getOpenCLCompatibleVersion() < 120 &&
+  vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
   // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
   //usage of the logical operators && and || with vectors in C. This
@@ -14974,8 +14975,7 @@
   }
 } else if (resultType->isExtVectorType()) {
   if (Context.getLangOpts().OpenCL &&
-  Context.getLangOpts().OpenCLVersion < 120 &&
-  !Context.getLangOpts().OpenCLCPlusPlus) {
+  Context.getLangOpts().getOpenCLCompatibleVersion() < 120) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on vector float types.
 QualType T = resultType->castAs()->getElementType();
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7519,7 +7519,7 @@
 }
 
 static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
-  if (S.LangOpts.OpenCLVersion < 200 && !S.LangOpts.OpenCLCPlusPlusVersion)
+  if (S.LangOpts.getOpenCLCompatibleVersion() < 200)
 S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version)
 << AL << "2.0" << 1;
   else
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8834,8 +8834,7 @@
 // OpenCL v3.0 s6.11.a:
 // A kernel function argument cannot be declared as a pointer to a pointer
 // type. [...] This restriction only applies to OpenCL C 1.2 or below.
-if (S.getLangOpts().OpenCLVersion <= 120 &&
-!S.getLangOpts().OpenCLCPlusPlus) {
+if (S.getLangOpts().getOpenCLCompatibleVersion() <= 120) {
   S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
   D.setInvalidType();
   return;
@@ -10017,7 +10016,7 @@
 
 // OpenCL 2.0 pipe restrictions forbids pipe packet types to be non-value
 // types.
-if (getLangOpts().OpenCLVersion >= 200 || getLangOpts

[PATCH] D108989: [OpenCL] Supports optional 64-bit floating point types in C++ for OpenCL 2021

2021-08-31 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_fp64` in C++ for OpenCL
2021 enabling a respective optional core feature from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108989

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenOpenCL/printf.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/fp64-fp16-options.cl

Index: clang/test/SemaOpenCL/fp64-fp16-options.cl
===
--- clang/test/SemaOpenCL/fp64-fp16-options.cl
+++ clang/test/SemaOpenCL/fp64-fp16-options.cl
@@ -6,6 +6,7 @@
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 
 // Test with some extensions enabled or disabled by cmd-line args
 //
@@ -20,6 +21,9 @@
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 //
 // Concatenating
 // RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64
@@ -29,6 +33,9 @@
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 
 // Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
 // disables all extensions by default, but supported core extensions for a
@@ -36,7 +43,7 @@
 // enabled by default with -cl-std=CL2.0).
 //
 // RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 #ifdef _OPENCL_H_
 // expected-no-diagnostics
@@ -46,7 +53,7 @@
 // expected-no-diagnostics
 #endif
 
-#ifdef __OPENCL_CPP_VERSION__
+#if __OPENCL_CPP_VERSION__ == 100
 // expected-no-diagnostics
 #endif
 
@@ -92,7 +99,7 @@
 void f2(void) {
   double d;
 #ifdef NOFP64
-#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) || __OPENCL_CPP_VERSION__ >= 202100)
 // expected-error@-3{{use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support}}
 #else
 // expected-error@-5{{use of type 'double' requires cl_khr_fp64 support}}
@@ -102,7 +109,7 @@
   typedef double double4 __attribute__((ext_vector_type(4)));
   double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
 #ifdef NOFP64
-#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) || __OPENCL_CPP_VERSIO

[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-08-31 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_images` in C++ for
OpenCL 2021 enabling a respective optional core feature from
OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109002

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1726,6 +1726,7 @@
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1735,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when 
and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Comp &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result << "__opencl_c_images";


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1726,6 +1726,7 @@
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1735,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Comp &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecType

[PATCH] D108704: [OpenCL] Define OpenCL 3.0 optional core features in C++ for OpenCL 2021

2021-09-01 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb321c2ea274: [OpenCL] Define OpenCL 3.0 optional core 
features in C++ for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108704

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/test/Headers/opencl-c-header.cl
  clang/test/SemaOpenCL/features.cl


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -6,6 +6,14 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL3.0 -cl-ext=+all \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=+all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
+// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
+// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++2021 -cl-ext=+all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
 
 // For OpenCL C 2.0 feature macros are defined only in header, so test that 
earlier OpenCL
 // versions don't define feature macros accidentally and CL2.0 don't define 
them without header
@@ -15,7 +23,7 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CL2.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
-// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=CLC++ \
+// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl 
-cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 
 // Note that __opencl_c_int64 is always defined assuming
Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -175,13 +175,13 @@
 #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 // OpenCL C features.
-#if (__OPENCL_C_VERSION__ == 300)
+#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #if __opencl_c_atomic_scope_all_devices != 1
 #error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices"
 #endif
 
-#elif (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
 
 #ifndef  __opencl_c_pipes
 #error "Feature macro __opencl_c_pipes should be defined"
@@ -262,6 +262,6 @@
 #error "Incorrect feature macro __opencl_c_subgroups define"
 #endif
 
-#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 #endif // defined(__SPIR__)
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -30,7 +30,7 @@
 #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 // Define feature macros for OpenCL C 2.0
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
 #define __opencl_c_pipes 1
 #define __opencl_c_generic_address_space 1
 #define __opencl_c_work_group_collective_functions 1
@@ -45,12 +45,12 @@
 #endif
 
 // Define header-only feature macros for OpenCL C 3.0.
-#if (__OPENCL_C_VERSION__ == 300)
+#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 // For the SPIR target all features are supported.
 #if defined(__SPIR__)
 #define __opencl_c_atomic_scope_all_devices 1
 #endif // defined(__SPIR__)
-#endif // (__OPENCL_C_VERSION__ == 300)
+#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 
 // built-in scalar data types:
 


Index: clang/test/SemaOpenCL/features.cl
===
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -6,6 +6,14 @@
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
 // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \
 // RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES

[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-01 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:1729
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images

Anastasia wrote:
> I think we should just replace `IsOpenCLC30` as it is when only used in the 
> diagnostic that we should report the same as for OpenCL 3.0.
> 
> 
> Also I would suggest changing name to `IsOpenCLC30Compatible` to make it 
> clearer. 
That diagnostic is responsible for `__opencl_c_3d_image_writes` feature while 
current commit addresses `__opencl_c_images`. I wanted to keep commits separate 
and was planning to finish transitioning from `IsOpenCLC30` to 
`IsOpenCLC30Compatible` in a future commit.

I agree that `IsOpenCLC30Compatible` would be clearer. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109002

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


[PATCH] D108461: [OpenCL] Supports optional generic address space sematics in C++ for OpenCL 2021

2021-09-01 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 369913.
Topotuna retitled this revision from "[OpenCL] Supports optional generic 
address space in C++ for OpenCL 2021" to "[OpenCL] Supports optional generic 
address space sematics in C++ for OpenCL 2021".
Topotuna edited the summary of this revision.
Topotuna added a comment.

The previously suggested change was split into intermediate steps:
reviews.llvm.org/rGf9bc1b3bee55 
 - 
introduced a mapping function for C++ for OpenCL version compatibility with 
OpenCL and modified condition for setting `OpenCLGenericAddressSpace` language 
option.
reviews.llvm.org/rGfb321c2ea274 
 - enabled 
all OpenCL 3.0 optional core feature macros without implementing their support 
in C++ for OpenCL 2021.

This change only enables semantics for optional generic address space although 
actual functionality is not yet implemented in C++ for OpenCL 2021.


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

https://reviews.llvm.org/D108461

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl


Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space 
-verify -pedantic -fsyntax-only
-// RUN: %clang_cc1 %s -cl-std=clc++ -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++2021 
-cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
 
 __constant int ci = 1;
 
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -1,12 +1,15 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=CL2.0
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=clc++
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=clc++1.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space
 
 /* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to
 *  different address spaces, mainly described in Sections 6.5.5 and 6.5.6.
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -406,12 +406,13 @@
 // for OpenCL C 2.0 but with no access to target capabilities. Target
 // should be immutable once created and thus these language options need
 // to be defined only once.
-if (Opts.OpenCLVersion == 300) {
+if (Opts.getOpenCLCompatibleVersion() == 300) {
   const auto &OpenCLFeaturesMap = getSupportedOpenCLOpts();
   Opts.OpenCLGenericAddressSpace = hasFeatureEnabled(
   OpenCLFeaturesMap, "__opencl_c_generic_address_space");
-  Opts.OpenCLPipes =
-  has

[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-02 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 370237.
Topotuna added a comment.

Boolean variable renamed to `IsOpenCLC30Compatible`. `FIXME` comment added.


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

https://reviews.llvm.org/D109002

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1725,7 +1725,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enables in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1739,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when 
and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Compatible &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result << "__opencl_c_images";


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1725,7 +1725,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enables in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1739,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+   

[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-02 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:1729
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images

Anastasia wrote:
> Topotuna wrote:
> > Anastasia wrote:
> > > I think we should just replace `IsOpenCLC30` as it is when only used in 
> > > the diagnostic that we should report the same as for OpenCL 3.0.
> > > 
> > > 
> > > Also I would suggest changing name to `IsOpenCLC30Compatible` to make it 
> > > clearer. 
> > That diagnostic is responsible for `__opencl_c_3d_image_writes` feature 
> > while current commit addresses `__opencl_c_images`. I wanted to keep 
> > commits separate and was planning to finish transitioning from 
> > `IsOpenCLC30` to `IsOpenCLC30Compatible` in a future commit.
> > 
> > I agree that `IsOpenCLC30Compatible` would be clearer. Thank you.
> Ok, let's just only rename it for now and add a FIXME comment explaining that 
> the variables should be unified later on.
> 
> I suspect your subsequent commits would include the unification?
Yes, I will perform unification when adding support for 
`__opencl_c_3d_image_writes` optional core feature.


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

https://reviews.llvm.org/D109002

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


[PATCH] D109150: [OpenCL] Disallows static kernel functions in C++ for OpenCL

2021-09-02 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is disallowed in OpenCL C to declare static kernel functions and
C++ for OpenCL is expected to inherit such behaviour. Error is now
correctly reported in C++ for OpenCL when declaring a static kernel
function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109150

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/storageclass-cl20.cl


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be 
declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9969,8 +9969,8 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if ((getLangOpts().getOpenCLCompatibleVersion() >= 120) &&
+(SC == SC_Static)) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9969,8 +9969,8 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if ((getLangOpts().getOpenCLCompatibleVersion() >= 120) &&
+(SC == SC_Static)) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108989: [OpenCL] Supports optional 64-bit floating point types in C++ for OpenCL 2021

2021-09-03 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd74f4b10834: [OpenCL] Supports optional 64-bit floating 
point types in C++ for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108989

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenOpenCL/printf.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/fp64-fp16-options.cl

Index: clang/test/SemaOpenCL/fp64-fp16-options.cl
===
--- clang/test/SemaOpenCL/fp64-fp16-options.cl
+++ clang/test/SemaOpenCL/fp64-fp16-options.cl
@@ -6,6 +6,7 @@
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 
 // Test with some extensions enabled or disabled by cmd-line args
 //
@@ -20,6 +21,9 @@
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 //
 // Concatenating
 // RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64
@@ -29,6 +33,9 @@
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -cl-ext=+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,+__opencl_c_fp64,+cl_khr_fp64 -DFP64
+// RUN: %clang_cc1 -cl-std=clc++2021 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 
 // Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
 // disables all extensions by default, but supported core extensions for a
@@ -36,7 +43,7 @@
 // enabled by default with -cl-std=CL2.0).
 //
 // RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 #ifdef _OPENCL_H_
 // expected-no-diagnostics
@@ -46,7 +53,7 @@
 // expected-no-diagnostics
 #endif
 
-#ifdef __OPENCL_CPP_VERSION__
+#if __OPENCL_CPP_VERSION__ == 100
 // expected-no-diagnostics
 #endif
 
@@ -92,7 +99,7 @@
 void f2(void) {
   double d;
 #ifdef NOFP64
-#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) || __OPENCL_CPP_VERSION__ >= 202100)
 // expected-error@-3{{use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support}}
 #else
 // expected-error@-5{{use of type 'double' requires cl_khr_fp64 support}}
@@ -102,7 +109,7 @@
   typedef double double4 __attribute__((ext_vector_type(4)));
   double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
 #ifdef NOFP64
-#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 300) || __OPENCL_CPP_VERSION__ >= 202100)
 // expected-error@-4 {{use of type 'double' requires cl_khr_fp64 and __opencl_c_fp64 support}}
 #else
 // expected-error@-6 {{use of type 'double' requires cl

[PATCH] D109305: [OpenCL] Supports optional program scope global variables in C++ for OpenCL 2021

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for macro `__opencl_c_program_scope_global_variables`
in C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109305

Files:
  clang/include/clang/Basic/OpenCLOptions.h
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
 constant int G2 = 0;
 
@@ -43,19 +47,23 @@
 #endif
 
 static generic float g_generic_static_var = 0;
-#if (__OPENCL_C_VERSION__ < 300)
+#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
 // expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
 // expected-error@-3 {{program scope variable must reside in constant address space}}
-#elif (__OPENCL_C_VERSION__ == 300)
- #if !defined(__opencl_c_generic_address_space)
-// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
- #endif
- #if !defined(__opencl_c_program_scope_global_variables)
-// expected-error@-9 {{program scope variable must reside in constant address space}}
- #endif
- #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
-// expected-error@-12 {{program scope variable must reside in global or constant address space}}
- #endif
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
+#if !defined(__opencl_c_generic_address_space)
+#if (__OPENCL_C_VERSION__ == 300)
+// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
+#elif (__OPENCL_CPP_VERSION__ == 202100)
+// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
+#endif
+#endif
+#if !defined(__opencl_c_program_scope_global_variables)
+// expected-error@-13 {{program scope variable must reside in constant address space}}
+#endif
+#if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
+// expected-error@-16 {{program scope variable must reside in global or constant address space}}
+#endif
 #endif
 
 extern float g_implicit_extern_var;
@@ -85,32 +93,36 @@
 #endif
 
 extern generic float g_generic_extern_var;
-#if (__OPENCL_C_VERSION__ < 300)
+#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
 // expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
 // expected-error@-3 {{extern variable must reside in constant address space}}
-#elif (__OPENCL_C_VERSION__ == 300)
- #if !defined(__opencl_c_generic_address_space)
-// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
- #endif
- #if !defined(__opencl_c_program_scope_global_variables)
-// expected-error@-9 {{extern variable must reside in constant address space}}
- #endif
- #if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
-// expected-error@-12 {{extern variable must reside in global or constant address space}}
- #endif
+#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
+#if !defined(__opencl_c_generic_address_space)
+#if (__OPENCL_C_VERSION__ == 300)
+// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
+#elif (__OPENCL_CPP_VERSION__ == 202100)
+// expected-error@-9 {{C++ for OpenCL version 2021

[PATCH] D109306: [OpenCL] Supports optional pipe types in C++ for OpenCL 2021

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_pipes` in C++ for
OpenCL 2021 enabling a respective optional core feature from
OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109306

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,13 +1,15 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
 extern pipe write_only int get_pipe(); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_program_scope_global_variables))
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_program_scope_global_variables))
 // expected-error-re@-2{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
 #else
 // FIXME: '__private' here makes no sense since program scope variables feature is not supported, should diagnose as '__global' probably
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,14 +1,18 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
 
 void foo(read_only pipe int p);
 #if __OPENCL_C_VERSION__ > 120
 // expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
 // expected-error@-3 {{access qualifier can only be used for pipe and image type}}
-#else
-// expected-warning@-5 {{type specifier missing, defaults to 'int'}}
+#elif defined(__OPENCL_CPP_VERSION__)
+// expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}}
 // expected-error@-6 {{access qualifier can only be used for pipe and image type}}
-// expected-error@-7 {{expected ')'}} expected-note@-7 {{to match this '('}}
+#else
+// expected-warning@-8 {{type specifier missing, defaults to 'int'}}
+// expected-error@-9 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-10 {{expected ')'}} expected-note@-10 {{to match this '('}}
 #endif
 
 // 'pipe' should be accepted as an identifier.
@@ -16,8 +20,16 @@
 #if __OPENCL_C_VERSION__ > 120
 // expected-error@-2 {{OpenCL C version 3.0 does not support the 'pipe' type qualifier}}
 // expected-warning@-3 {{typedef requires a name}}
+#elif defined(__OPENCL_CPP_VERSION__)
+// expected-error@-5 {{C++ for OpenCL version 2021 does not support the 'pipe' type qualifier}}
+// expected-warning@-6 {{typedef requires a name}}
 #endif
 
 void bar() {
- reserve_id_t r; // expected-e

[PATCH] D109307: [OpenCL] Supports optional same image reads and writes in C++ for OpenCL 2021

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Herald added a reviewer: aaron.ballman.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro `__opencl_c_read_write_images` in
C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109307

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/access-qualifier.cl

Index: clang/test/SemaOpenCL/access-qualifier.cl
===
--- clang/test/SemaOpenCL/access-qualifier.cl
+++ clang/test/SemaOpenCL/access-qualifier.cl
@@ -2,24 +2,38 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL3.0 %s -cl-ext=-__opencl_c_read_write_images
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=clc++2021 %s -cl-ext=-__opencl_c_read_write_images
 
 typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
 
 typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}}
 typedef read_only image1d_t img1d_ro;
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 typedef read_write image1d_t img1d_rw;
 #endif
 
 typedef int Int;
 typedef read_only int IntRO; // expected-error {{access qualifier can only be used for pipe and image type}}
 
+void myWrite(write_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+// expected-note@-3 {{passing argument to parameter here}}
+#else
+// expected-note@-5 {{candidate function not viable: no known conversion from '__private img1d_ro' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+// expected-note@-6 {{candidate function not viable: no known conversion from '__private img1d_ro_default' (aka '__private __read_only image1d_t') to '__private __write_only image1d_t' for 1st argument}}
+#endif
 
-void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passing argument to parameter here}}
-void myRead(read_only image1d_t); // expected-note {{passing argument to parameter here}}
+void myRead(read_only image1d_t);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-note@-2 {{passing argument to parameter here}}
+#else
+// expected-note@-4 {{candidate function not viable: no known conversion from '__private img1d_wo' (aka '__private __write_only image1d_t') to '__private __read_only image1d_t' for 1st argument}}
+#endif
 
-#if (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_read_write_images))
+#if (__OPENCL_C_VERSION__ == 200) || ((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) && defined(__opencl_c_read_write_images))
 void myReadWrite(read_write image1d_t);
 #else
 void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}}
@@ -27,25 +41,40 @@
 
 
 kernel void k1(img1d_wo img) {
-  myRead(img); // expected-error {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+  myRead(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myRead'}}
+#endif
 }
 
 kernel void k2(img1d_ro img) {
-  myWrite(img); // expected-error {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+  myWrite(img);
+#if !defined(__OPENCL_CPP_VERSION__)
+// expected-error@-2 {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
+#else
+// expected-error@-4 {{no matching function for call to 'myWrite'}}
+#endif
 }
 
 kernel void k3(img1d_wo img) {
   myWrite(img);
 }
 
-

[PATCH] D108461: [OpenCL] Supports optional generic address space sematics in C++ for OpenCL 2021

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/lib/Basic/TargetInfo.cpp:413
   OpenCLFeaturesMap, "__opencl_c_generic_address_space");
-  Opts.OpenCLPipes =
-  hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
+  if (Opts.OpenCLVersion == 300)
+Opts.OpenCLPipes =

Anastasia wrote:
> Ok, I am guessing this will be changed back to one check later on?
Yes, the change that removes this check is already put for review: D109306


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

https://reviews.llvm.org/D108461

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


[PATCH] D108461: [OpenCL] Supports optional generic address space sematics in C++ for OpenCL 2021

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Topotuna marked an inline comment as done.
Closed by commit rGcc9260a0fb7c: [OpenCL] Supports optional generic address 
space semantics in C++ for OpenCL… (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108461

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl


Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space 
-verify -pedantic -fsyntax-only
-// RUN: %clang_cc1 %s -cl-std=clc++ -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++1.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=clc++2021 
-cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
 
 __constant int ci = 1;
 
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -1,12 +1,15 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=CL2.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=CL2.0
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=clc++
-// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=clc++
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=clc++1.0
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DCONSTANT -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGLOBAL -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only 
-DGENERIC -cl-std=clc++2021 -cl-ext=+__opencl_c_generic_address_space
 
 /* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to
 *  different address spaces, mainly described in Sections 6.5.5 and 6.5.6.
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -406,12 +406,13 @@
 // for OpenCL C 2.0 but with no access to target capabilities. Target
 // should be immutable once created and thus these language options need
 // to be defined only once.
-if (Opts.OpenCLVersion == 300) {
+if (Opts.getOpenCLCompatibleVersion() == 300) {
   const auto &OpenCLFeaturesMap = getSupportedOpenCLOpts();
   Opts.OpenCLGenericAddressSpace = hasFeatureEnabled(
   OpenCLFeaturesMap, "__opencl_c_generic_address_space");
-  Opts.OpenCLPipes =
-  hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
+  if (Opts.OpenCLVersion == 300)
+Opts.OpenCLPipes =
+hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
 }
   }
 


Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
-// RUN: %clang_

[PATCH] D109150: [OpenCL] Disallows static kernel functions in C++ for OpenCL

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:9972
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if ((getLangOpts().getOpenCLCompatibleVersion() >= 120) &&
+(SC == SC_Static)) {

Anastasia wrote:
> I wonder though if we should just drop a version check here completely.
> 
> I don't think we can allow this in the earlier OpenCL versions. The reason 
> why it doesn't apply to earlier versions is that `static`/`extern` wasn't 
> allowed at all so presumably frontend would reject such a case earlier.
> 
> I think the extra check is not doing anything useful here, but only adds 
> extra code to read and maintain.
That is correct. If `static` or `extern` is used in OpenCL C 1.0, diagnostic 
`err_opencl_unknown_type_specifier` is displayed before control flow reaches 
this part of code. And so removing the check here doesn't seem to change the 
compiler behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109150

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


[PATCH] D109150: [OpenCL] Disallows static kernel functions in C++ for OpenCL

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 370895.
Topotuna added a comment.

Condition on OpenCL C / C++ for OpenCL version removed because it was redundant.


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

https://reviews.llvm.org/D109150

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/storageclass-cl20.cl


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be 
declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9969,8 +9969,7 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if (SC == SC_Static) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9969,8 +9969,7 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if (SC == SC_Static) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109328: [OpenCL] Supports optional writing to 3d images in C++ for OpenCL 2021

2021-09-06 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds support for a feature macro __opencl_c_3d_image_writes in
C++ for OpenCL 2021 enabling a respective optional core feature
from OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109328

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/test/Misc/opencl-c-3.0.incorrect_options.cl
===
--- clang/test/Misc/opencl-c-3.0.incorrect_options.cl
+++ clang/test/Misc/opencl-c-3.0.incorrect_options.cl
@@ -8,6 +8,8 @@
 // RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_pipes,-__opencl_c_generic_address_space %s 2>&1 | FileCheck 
-check-prefix=CHECK-PIPES %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
 // RUN: not %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,+__opencl_c_images,-cl_khr_3d_image_writes 
%s 2>&1 | FileCheck -check-prefix=CHECK-3D-WRITE-IMAGES-DIFF %s
+// RUN: not %clang_cc1 -cl-std=clc++2021 -triple spir-unknown-unknown 
-cl-ext=+__opencl_c_3d_image_writes,-__opencl_c_images %s 2>&1 | FileCheck 
-check-prefix=CHECK-3D-WRITE-IMAGES-DEPS %s
 
 // CHECK-FP64: error: options cl_khr_fp64 and __opencl_c_fp64 are set to 
different values
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1732,10 +1732,6 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
-// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
-// unified into one when __opencl_c_3d_image_writes option is enabled in
-// C++ for OpenCL 2021
-bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
 bool IsOpenCLC30Compatible =
 S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
@@ -1756,7 +1752,7 @@
   S.getLangOpts())) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result
-  << (IsOpenCLC30
+  << (IsOpenCLC30Compatible
   ? "cl_khr_3d_image_writes and __opencl_c_3d_image_writes"
   : "cl_khr_3d_image_writes");
   declarator.setInvalidType();


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,

[PATCH] D109150: [OpenCL] Disallows static kernel functions in C++ for OpenCL

2021-09-07 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc33e296be1da: [OpenCL] Disallows static kernel functions in 
C++ for OpenCL (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109150

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/storageclass-cl20.cl


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be 
declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9970,8 +9970,7 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if (SC == SC_Static) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9970,8 +9970,7 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if (SC == SC_Static) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109327: [OpenCL][Docs] Release 13 notes

2021-09-07 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

Overall, I think the release notes accurately describe tasks I have been 
working on. A couple of suggestions and minor grammatical changes provided.




Comment at: clang/docs/ReleaseNotes.rst:159
+
+- All builtin types, macros and functions declarations are now added by default
+  without any command-line flags. A flag is provided ``-cl-no-stdinc`` to

`function declarations` - first word in singular form



Comment at: clang/docs/ReleaseNotes.rst:168
+  C++ for OpenCL.
+
+Misc common changes:

Would it be worth mentioning that command line flag `-cl-std=clc++1.0` is now 
allowed and preferred over `-cl-std=clc++`?



Comment at: clang/docs/ReleaseNotes.rst:174
+
+- Fix OpenCL C language version and SPIR address space reporting in DWARF.
+

`Fixed OpenCL C language version ...` - past form of "fix" for consistency with 
other bullet points



Comment at: clang/docs/ReleaseNotes.rst:194
+
+- ``cl_khr_integer_dot_product`` for dedicated support of DOT product.
+

Is there a reason why `DOT` is written in all capitals? If yes, then maybe it 
should be written like so in `Arm dot product extension` on line 177 as well?



Comment at: clang/docs/ReleaseNotes.rst:218
+
+- Added ``NULL`` macro to internal headers.
+

I think this should be rephrased. NULL macro was already present in internal 
headers but now its value is redefined to `nullptr`. I would suggest listing it 
as:
```
- Redefined ``NULL`` macro in internal headers to be compatible with C++.
```


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

https://reviews.llvm.org/D109327

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


[PATCH] D109366: [OpenCL] Tests C++ for OpenCL 2021 version macros

2021-09-07 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Version macro definitions are tested for C++ for OpenCL 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109366

Files:
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -135,8 +135,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL30
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
-// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +176,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -135,8 +135,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL30
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
-// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +176,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109370: [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021

2021-09-07 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`.rgba` vector extension setting in C++ for OpenCL 2021 is now
performed analogously to OpenCL C 3.0. Test case added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109370

Files:
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaOpenCL/ext_vectors.cl


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109424: [OpenCL] Supports atomics in C++ for OpenCL 2021

2021-09-08 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Atomics in C++ for OpenCL 2021 are now handled the same way as in
OpenCL C 3.0. This is a header-only change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109424

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13256,7 +13256,7 @@
 #endif //cl_khr_fp64
 #endif
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 void __ovld atomic_init(volatile __global atomic_int *object, int value);
 void __ovld atomic_init(volatile __local atomic_int *object, int value);
 void __ovld atomic_init(volatile __global atomic_uint *object, uint value);
@@ -13273,7 +13273,7 @@
 void __ovld atomic_init(volatile __local atomic_double *object, double value);
 #endif //cl_khr_fp64
 #endif
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 
 // atomic_work_item_fence()
 void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order, memory_scope scope);
@@ -13317,7 +13317,7 @@
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add(volatile __global atomic_int *object, int operand);
 int __ovld atomic_fetch_add(volatile __local atomic_int *object, int operand);
 uint __ovld atomic_fetch_add(volatile __global atomic_uint *object, uint operand);
@@ -13398,7 +13398,7 @@
 uintptr_t __ovld atomic_fetch_add(volatile __global atomic_uintptr_t *object, ptrdiff_t operand);
 uintptr_t __ovld atomic_fetch_sub(volatile __local atomic_uintptr_t *object, ptrdiff_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 #endif
 
 #if defined(__opencl_c_atomic_scope_device)
@@ -13436,7 +13436,7 @@
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *object, int operand, memory_order order);
 int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *object, int operand, memory_order order);
 uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *object, uint operand, memory_order order);
@@ -13517,7 +13517,7 @@
 uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 #endif
 
 #if defined(__opencl_c_generic_address_space)
@@ -13554,7 +13554,7 @@
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
 #endif
 #endif //defined(__opencl_c_generic_address_space)
-#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100)
 int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *object, int operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *object, uint operand, memory_order order, memory_scope scope);
@@ -13635,7 +13635,7 @@
 uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope sc

[PATCH] D109492: [OpenCL] Test case for C++ for OpenCL 2021 in OpenCL C header test

2021-09-09 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

RUN line representing C++ for OpenCL 2021 added to the test. This
should have been done as part of earlier commit fb321c2ea274 
 but
was missed during rebasing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109492

Files:
  clang/test/Headers/opencl-c-header.cl


Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 
| FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 
| FileCheck %s
-// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++ 
| FileCheck %s --check-prefix=CHECK20
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify 
-cl-std=clc++1.0 | FileCheck %s --check-prefix=CHECK20
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL3.0 
| FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify 
-cl-std=clc++2021 | FileCheck %s
 
 // Test including the default header as a module.
 // The module should be compiled only once and loaded from cache afterwards.
@@ -57,7 +58,7 @@
 // CHECK20: _Z16convert_char_rtec
 char f(char x) {
 // Check functionality from OpenCL 2.0 onwards
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
   ndrange_t t;
   x = ctz(x);
 #endif //__OPENCL_C_VERSION__
@@ -82,7 +83,7 @@
 #endif
 
 // Verify that ATOMIC_VAR_INIT is defined.
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
 global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
 // CHECK-MOD: Reading modules


Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 | FileCheck %s
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 | FileCheck %s
-// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++ | FileCheck %s --check-prefix=CHECK20
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++1.0 | FileCheck %s --check-prefix=CHECK20
 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL3.0 | FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++2021 | FileCheck %s
 
 // Test including the default header as a module.
 // The module should be compiled only once and loaded from cache afterwards.
@@ -57,7 +58,7 @@
 // CHECK20: _Z16convert_char_rtec
 char f(char x) {
 // Check functionality from OpenCL 2.0 onwards
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
   ndrange_t t;
   x = ctz(x);
 #endif //__OPENCL_C_VERSION__
@@ -82,7 +83,7 @@
 #endif
 
 // Verify that ATOMIC_VAR_INIT is defined.
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
+#if (__OPENCL_CPP_VERSION__ == 100) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
 global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_V

[PATCH] D109366: [OpenCL] Tests C++ for OpenCL version macros

2021-09-09 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 371544.
Topotuna retitled this revision from "[OpenCL] Tests C++ for OpenCL 2021 
version macros" to "[OpenCL] Tests C++ for OpenCL version macros".
Topotuna edited the summary of this revision.
Topotuna added a comment.

Test case added for command line flag `-cl-std=clc++`


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

https://reviews.llvm.org/D109366

Files:
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -136,7 +136,11 @@
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -173,10 +177,21 @@
 // CHECK-CL30: #define __OPENCL_C_VERSION__ 300
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP: #define __OPENCL_CPP_VERSION__ 100
+// CHECK-CLCPP-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP-NOT: #define __ENDIAN_LITTLE__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -136,7 +136,11 @@
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -173,10 +177,21 @@
 // CHECK-CL30: #define __OPENCL_C_VERSION__ 300
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP: #define __OPENCL_CPP_VERSION__ 100
+// CHECK-CLCPP-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP-NOT: #define __ENDIAN_LITTLE__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109327: [OpenCL][Docs] Release 13 notes

2021-09-10 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna accepted this revision.
Topotuna added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks


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

https://reviews.llvm.org/D109327

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


[PATCH] D109366: [OpenCL] Tests C++ for OpenCL version macros

2021-09-10 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 371831.
Topotuna added a comment.

Reuses `--check-prefix=CHECK-CLCPP10` for default C++ for OpenCL command line 
version


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

https://reviews.llvm.org/D109366

Files:
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -137,6 +137,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +178,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -137,6 +137,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +178,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109366: [OpenCL] Tests C++ for OpenCL version macros

2021-09-14 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad88632b6503: [OpenCL] Tests C++ for OpenCL version macros 
(authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109366

Files:
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -137,6 +137,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +178,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -137,6 +137,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +178,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109370: [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021

2021-09-14 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09dc454b00b8: [OpenCL] Enables .rgba vector extension in C++ 
for OpenCL 2021 (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109370

Files:
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaOpenCL/ext_vectors.cl


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-15 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Topotuna marked an inline comment as done.
Closed by commit rG3b9470a6c46d: [OpenCL] Supports optional image types in C++ 
for OpenCL 2021 (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109002?vs=370237&id=372662#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109002

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1732,7 +1732,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enabled in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1741,7 +1746,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when 
and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Compatible &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result << "__opencl_c_images";


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1732,7 +1732,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enabled in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write ty

  1   2   >