r339678 - [OpenCL] Add test for constant sampler argument

2018-08-14 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Aug 14 06:56:52 2018
New Revision: 339678

URL: http://llvm.org/viewvc/llvm-project?rev=339678&view=rev
Log:
[OpenCL] Add test for constant sampler argument

Modified:
cfe/trunk/test/SemaOpenCL/sampler_t.cl

Modified: cfe/trunk/test/SemaOpenCL/sampler_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/sampler_t.cl?rev=339678&r1=339677&r2=339678&view=diff
==
--- cfe/trunk/test/SemaOpenCL/sampler_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/sampler_t.cl Tue Aug 14 06:56:52 2018
@@ -33,6 +33,8 @@ constant sampler_t glb_smp9 = 0x1000
 
 void foo(sampler_t); // expected-note{{passing argument to parameter here}}
 
+void constant_sampler(constant sampler_t s); // expected-error{{parameter may 
not be qualified with an address space}}
+
 constant struct sampler_s {
   sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to 
declare a structure or union field}}
 } sampler_str = {0};


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


r331874 - [OpenCL] Restrict various keywords in OpenCL C++ mode

2018-05-09 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed May  9 06:16:17 2018
New Revision: 331874

URL: http://llvm.org/viewvc/llvm-project?rev=331874&view=rev
Log:
[OpenCL] Restrict various keywords in OpenCL C++ mode

Restrict the following keywords in the OpenCL C++ language mode,
according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification.

 - dynamic_cast
 - typeid
 - register (already restricted in OpenCL C, update the diagnostic)
 - thread_local
 - exceptions (try/catch/throw)
 - access qualifiers read_only, write_only, read_write

Support the `__global`, `__local`, `__constant`, `__private`, and
`__generic` keywords in OpenCL C++.  Leave the unprefixed address
space qualifiers such as global available, i.e., do not mark them as
reserved keywords in OpenCL C++.  libclcxx provides explicit address
space pointer classes such as `global_ptr` and `global` that are
implemented using the `__`-prefixed qualifiers.

Differential Revision: https://reviews.llvm.org/D46022

Added:
cfe/trunk/test/Parser/opencl-cxx-keywords.cl
cfe/trunk/test/SemaOpenCLCXX/
cfe/trunk/test/SemaOpenCLCXX/restricted.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/Parser/opencl-cl20.cl
cfe/trunk/test/Parser/opencl-storage-class.cl
cfe/trunk/test/SemaOpenCL/storageclass.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=331874&r1=331873&r2=331874&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed May  9 06:16:17 
2018
@@ -232,6 +232,10 @@ def note_mt_message : Note<"[rewriter] %
 def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to 
GC managed memory; it will become unmanaged in ARC">;
 def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to 
be used with an object with ownership other than __unsafe_unretained">;
 
+// OpenCL C++.
+def err_openclcxx_not_supported : Error<
+  "'%0' is not supported in OpenCL C++">;
+
 // OpenMP
 def err_omp_more_one_clause : Error<
   "directive '#pragma omp %0' cannot contain more than one '%1' 
clause%select{| with '%3' name modifier| with 'source' dependence}2">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=331874&r1=331873&r2=331874&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed May  9 06:16:17 
2018
@@ -1078,6 +1078,8 @@ def err_opencl_logical_exclusive_or : Er
 // OpenCL C++.
 def err_openclcxx_virtual_function : Error<
   "virtual functions are not supported in OpenCL C++">;
+def err_openclcxx_reserved : Error<
+  "'%0' is a reserved keyword in OpenCL C++">;
 
 // OpenMP support.
 def warn_pragma_omp_ignored : Warning<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331874&r1=331873&r2=331874&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May  9 06:16:17 
2018
@@ -8609,7 +8609,8 @@ def note_opencl_typedef_access_qualifier
 
 // OpenCL Section 6.8.g
 def err_opencl_unknown_type_specifier : Error<
-  "OpenCL version %0 does not support the '%1' %select{type qualifier|storage 
class specifier}2">;
+  "OpenCL %select{C|C++}0 version %1 does not support the '%2' "
+  "%select{type qualifier|storage class specifier}3">;
 
 // OpenCL v2.0 s6.12.5 Blocks restrictions
 def err_opencl_block_storage_type : Error<

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=331874&r1=331873&r2=331874&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed May  9 06:16:17 2018
@@ -249,8 +249,10 @@ PUNCTUATOR(caretcaret,"^^")
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
 //   KEYNOMS18 - This is a keyword th

r304978 - [libclang] Expose typedef and address space functions

2017-06-08 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Jun  8 09:22:04 2017
New Revision: 304978

URL: http://llvm.org/viewvc/llvm-project?rev=304978&view=rev
Log:
[libclang] Expose typedef and address space functions

Expose the following functions:
 - clang_getTypedefName
 - clang_getAddressSpace

Patch by Simon Perretta.

Differential Revision: https://reviews.llvm.org/D33598

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_type.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CXType.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=304978&r1=304977&r2=304978&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Jun  8 09:22:04 2017
@@ -2162,6 +2162,12 @@ class Type(Structure):
 
 return conf.lib.clang_isFunctionTypeVariadic(self)
 
+def get_address_space(self):
+return conf.lib.clang_getAddressSpace(self)
+
+def get_typedef_name(self):
+return conf.lib.clang_getTypedefName(self)
+
 def is_pod(self):
 """Determine whether this Type represents plain old data (POD)."""
 return conf.lib.clang_isPODType(self)
@@ -3665,6 +3671,11 @@ functionList = [
Type,
Type.from_result),
 
+  ("clang_getTypedefName",
+   [Type],
+   _CXString,
+   _CXString.from_result),
+
   ("clang_getTypeKindSpelling",
[c_uint],
_CXString,

Modified: cfe/trunk/bindings/python/tests/cindex/test_type.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_type.py?rev=304978&r1=304977&r2=304978&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_type.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_type.py Thu Jun  8 09:22:04 2017
@@ -37,37 +37,44 @@ def test_a_struct():
 assert not fields[0].type.is_const_qualified()
 assert fields[0].type.kind == TypeKind.INT
 assert fields[0].type.get_canonical().kind == TypeKind.INT
+assert fields[0].type.get_typedef_name() == ''
 
 assert fields[1].spelling == 'b'
 assert not fields[1].type.is_const_qualified()
 assert fields[1].type.kind == TypeKind.TYPEDEF
 assert fields[1].type.get_canonical().kind == TypeKind.INT
 assert fields[1].type.get_declaration().spelling == 'I'
+assert fields[1].type.get_typedef_name() == 'I'
 
 assert fields[2].spelling == 'c'
 assert not fields[2].type.is_const_qualified()
 assert fields[2].type.kind == TypeKind.LONG
 assert fields[2].type.get_canonical().kind == TypeKind.LONG
+assert fields[2].type.get_typedef_name() == ''
 
 assert fields[3].spelling == 'd'
 assert not fields[3].type.is_const_qualified()
 assert fields[3].type.kind == TypeKind.ULONG
 assert fields[3].type.get_canonical().kind == TypeKind.ULONG
+assert fields[3].type.get_typedef_name() == ''
 
 assert fields[4].spelling == 'e'
 assert not fields[4].type.is_const_qualified()
 assert fields[4].type.kind == TypeKind.LONG
 assert fields[4].type.get_canonical().kind == TypeKind.LONG
+assert fields[4].type.get_typedef_name() == ''
 
 assert fields[5].spelling == 'f'
 assert fields[5].type.is_const_qualified()
 assert fields[5].type.kind == TypeKind.INT
 assert fields[5].type.get_canonical().kind == TypeKind.INT
+assert fields[5].type.get_typedef_name() == ''
 
 assert fields[6].spelling == 'g'
 assert not fields[6].type.is_const_qualified()
 assert fields[6].type.kind == TypeKind.POINTER
 assert fields[6].type.get_pointee().kind == TypeKind.INT
+assert fields[6].type.get_typedef_name() == ''
 
 assert fields[7].spelling == 'h'
 assert not fields[7].type.is_const_qualified()
@@ -75,6 +82,7 @@ def test_a_struct():
 assert fields[7].type.get_pointee().kind == TypeKind.POINTER
 assert fields[7].type.get_pointee().get_pointee().kind == TypeKind.POINTER
 assert fields[7].type.get_pointee().get_pointee().get_pointee().kind == 
TypeKind.INT
+assert fields[7].type.get_typedef_name() == ''
 
 def test_references():
 """Ensure that a Type maintains a reference to a TranslationUnit."""
@@ -404,3 +412,12 @@ def test_decay():
 assert a.kind == TypeKind.INCOMPLETEARRAY
 assert a.element_type.kind == TypeKind.INT
 assert a.get_canonical().kind == TypeKind.INCOMPLETEARRAY
+
+def test_addrspace():
+"""Ensure the address space can be queried"""
+tu = get_tu('__attribute__((address_space(2))) int testInteger = 3;', 'c')
+
+testInteger = get_cursor(tu, 'testInteger')
+
+assert testInteger is not None, "Could not find testInteger."
+assert testInteger.type.get_address_space() == 2

Modified: cfe/trunk/include/clang

r322278 - [OpenCL] Reorder the CLK_sRGBx/sRGBA defines, NFC

2018-01-11 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Jan 11 06:05:38 2018
New Revision: 322278

URL: http://llvm.org/viewvc/llvm-project?rev=322278&view=rev
Log:
[OpenCL] Reorder the CLK_sRGBx/sRGBA defines, NFC

Swap them so that all channel order defines are ordered according to
their values.

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=322278&r1=322277&r2=322278&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Thu Jan 11 06:05:38 2018
@@ -15421,8 +15421,8 @@ int __ovld __cnfn get_image_channel_data
 #define CLK_DEPTH_STENCIL 0x10BE
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #define CLK_sRGB  0x10BF
-#define CLK_sRGBA 0x10C1
 #define CLK_sRGBx 0x10C0
+#define CLK_sRGBA 0x10C1
 #define CLK_sBGRA 0x10C2
 #define CLK_ABGR  0x10C3
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0


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


r334700 - [OpenCL] Support new/delete in Sema

2018-06-14 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Jun 14 02:51:54 2018
New Revision: 334700

URL: http://llvm.org/viewvc/llvm-project?rev=334700&view=rev
Log:
[OpenCL] Support new/delete in Sema

Reject uses of the default new/delete operators with a diagnostic
instead of a crash in OpenCL C++ mode and accept user-defined forms.

Differential Revision: https://reviews.llvm.org/D46651

Added:
cfe/trunk/test/SemaOpenCLCXX/newdelete.cl
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=334700&r1=334699&r2=334700&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jun 14 02:51:54 2018
@@ -13007,6 +13007,13 @@ CheckOperatorNewDeleteDeclarationScope(S
   return false;
 }
 
+static QualType
+RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
+  QualType QTy = PtrTy->getPointeeType();
+  QTy = SemaRef.Context.removeAddrSpaceQualType(QTy);
+  return SemaRef.Context.getPointerType(QTy);
+}
+
 static inline bool
 CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
 CanQualType ExpectedResultType,
@@ -13022,6 +13029,13 @@ CheckOperatorNewDeleteTypes(Sema &SemaRe
 diag::err_operator_new_delete_dependent_result_type)
 << FnDecl->getDeclName() << ExpectedResultType;
 
+  // OpenCL C++: the operator is valid on any address space.
+  if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
+if (auto *PtrTy = ResultType->getAs()) {
+  ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
+}
+  }
+
   // Check that the result type is what we expect.
   if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType)
 return SemaRef.Diag(FnDecl->getLocation(),
@@ -13047,6 +13061,13 @@ CheckOperatorNewDeleteTypes(Sema &SemaRe
   << FnDecl->getDeclName() << ExpectedFirstParamType;
 
   // Check that the first parameter type is what we expect.
+  if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
+// OpenCL C++: the operator is valid on any address space.
+if (auto *PtrTy =
+FnDecl->getParamDecl(0)->getType()->getAs()) {
+  FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
+}
+  }
   if (SemaRef.Context.getCanonicalType(FirstParamType).getUnqualifiedType() !=
   ExpectedFirstParamType)
 return SemaRef.Diag(FnDecl->getLocation(), InvalidParamTypeDiag)

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=334700&r1=334699&r2=334700&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Jun 14 02:51:54 2018
@@ -2146,7 +2146,8 @@ bool Sema::CheckAllocatedType(QualType A
   else if (AllocType->isVariablyModifiedType())
 return Diag(Loc, diag::err_variably_modified_new_type)
  << AllocType;
-  else if (AllocType.getAddressSpace() != LangAS::Default)
+  else if (AllocType.getAddressSpace() != LangAS::Default &&
+   !getLangOpts().OpenCLCPlusPlus)
 return Diag(Loc, diag::err_address_space_qualified_new)
   << AllocType.getUnqualifiedType()
   << AllocType.getQualifiers().getAddressSpaceAttributePrintValue();
@@ -2362,6 +2363,11 @@ bool Sema::FindAllocationFunctions(Sourc
   LookupQualifiedName(R, Context.getTranslationUnitDecl());
 }
 
+if (getLangOpts().OpenCLCPlusPlus && R.empty()) {
+  Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  return true;
+}
+
 assert(!R.empty() && "implicitly declared allocation functions not found");
 assert(!R.isAmbiguous() && "global allocation functions are ambiguous");
 
@@ -2597,6 +2603,11 @@ void Sema::DeclareGlobalNewDelete() {
   if (GlobalNewDeleteDeclared)
 return;
 
+  // OpenCL C++ 1.0 s2.9: the implicitly declared new and delete operators
+  // are not supported.
+  if (getLangOpts().OpenCLCPlusPlus)
+return;
+
   // C++ [basic.std.dynamic]p2:
   //   [...] The following allocation and deallocation functions (18.4) are
   //   implicitly declared in global scope in each translation unit of a
@@ -3230,7 +3241,8 @@ Sema::ActOnCXXDelete(SourceLocation Star
 QualType Pointee = Type->getAs()->getPointeeType();
 QualType PointeeElem = Context.getBaseElementType(Pointee);
 
-if (Pointee.getAddressSpace() != LangAS::Default)
+if (Pointee.getAddressSpace() != LangAS::Default &&
+!getLangOpts().OpenCLCPlusPlus)
   return Diag(Ex.get()->getLocStart(),
   diag::err_address_space_qualified_delete)
<< Pointee.getUnqualifiedType()
@@ -3305,6 +3317,11 @@ Sema::ActOnCXXDelete(SourceLocation Star
 }
 
 

r345825 - Allow clk_event_t comparisons

2018-11-01 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Nov  1 05:43:00 2018
New Revision: 345825

URL: http://llvm.org/viewvc/llvm-project?rev=345825&view=rev
Log:
Allow clk_event_t comparisons

Also rename `invalid-clk-events-cl2.0.cl` to `clk_event_t.cl` and
repurpose it to include both positive and negative clk_event_t tests.

Differential Revision: https://reviews.llvm.org/D53871

Added:
cfe/trunk/test/SemaOpenCL/clk_event_t.cl
Removed:
cfe/trunk/test/SemaOpenCL/invalid-clk-events-cl2.0.cl
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=345825&r1=345824&r2=345825&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Nov  1 05:43:00 2018
@@ -10497,6 +10497,10 @@ QualType Sema::CheckCompareOperands(Expr
   }
 
   if (getLangOpts().OpenCLVersion >= 200) {
+if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
+  return computeResultTy();
+}
+
 if (LHSType->isQueueT() && RHSType->isQueueT()) {
   return computeResultTy();
 }

Added: cfe/trunk/test/SemaOpenCL/clk_event_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clk_event_t.cl?rev=345825&view=auto
==
--- cfe/trunk/test/SemaOpenCL/clk_event_t.cl (added)
+++ cfe/trunk/test/SemaOpenCL/clk_event_t.cl Thu Nov  1 05:43:00 2018
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+// Taken from opencl-c.h
+#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+
+global clk_event_t ce; // expected-error {{the '__global clk_event_t' type 
cannot be used to declare a program scope variable}}
+
+int clk_event_tests() {
+  event_t e;
+  clk_event_t ce1;
+  clk_event_t ce2;
+
+  if (e == ce1) { // expected-error {{invalid operands to binary expression 
('event_t' and 'clk_event_t')}}
+return 9;
+  }
+
+  if (ce1 != ce2) {
+return 1;
+  }
+  else if (ce1 == CLK_NULL_EVENT || ce2 != CLK_NULL_EVENT) {
+return 0;
+  }
+
+  return 2;
+}

Removed: cfe/trunk/test/SemaOpenCL/invalid-clk-events-cl2.0.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-clk-events-cl2.0.cl?rev=345824&view=auto
==
--- cfe/trunk/test/SemaOpenCL/invalid-clk-events-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-clk-events-cl2.0.cl (removed)
@@ -1,3 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
-
-global clk_event_t ce; // expected-error {{the '__global clk_event_t' type 
cannot be used to declare a program scope variable}}


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


r358566 - [libclang] Expose ext_vector_type

2019-04-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed Apr 17 02:08:50 2019
New Revision: 358566

URL: http://llvm.org/viewvc/llvm-project?rev=358566&view=rev
Log:
[libclang] Expose ext_vector_type

Differential Revision: https://reviews.llvm.org/D60775

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/opencl-types.cl
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=358566&r1=358565&r2=358566&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Wed Apr 17 02:08:50 2019
@@ -2121,6 +2121,8 @@ TypeKind.OCLEVENT = TypeKind(158)
 TypeKind.OCLQUEUE = TypeKind(159)
 TypeKind.OCLRESERVEID = TypeKind(160)
 
+TypeKind.EXTVECTOR = TypeKind(176)
+
 class RefQualifierKind(BaseEnumeration):
 """Describes a specific ref-qualifier of a type."""
 

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=358566&r1=358565&r2=358566&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Apr 17 02:08:50 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 54
+#define CINDEX_VERSION_MINOR 55
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3315,7 +3315,9 @@ enum CXTypeKind {
   CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
   CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
 
-  CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175
+  CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
+
+  CXType_ExtVector = 176
 };
 
 /**

Modified: cfe/trunk/test/Index/opencl-types.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/opencl-types.cl?rev=358566&r1=358565&r2=358566&view=diff
==
--- cfe/trunk/test/Index/opencl-types.cl (original)
+++ cfe/trunk/test/Index/opencl-types.cl Wed Apr 17 02:08:50 2019
@@ -17,11 +17,11 @@ void kernel testFloatTypes() {
 }
 
 // CHECK: VarDecl=scalarHalf:11:8 (Definition){{( \(invalid\))?}} [type=half] 
[typekind=Half] [isPOD=1]
-// CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] 
[canonicaltype=half __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] 
[canonicaltype=half __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=ExtVector] [isPOD=1]
 // CHECK: VarDecl=scalarFloat:13:9 (Definition) [type=float] [typekind=Float] 
[isPOD=1]
-// CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] 
[typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] 
[typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=ExtVector] [isPOD=1]
 // CHECK: VarDecl=scalarDouble:15:10 (Definition){{( \(invalid\))?}} 
[type=double] [typekind=Double] [isPOD=1]
-// CHECK: VarDecl=vectorDouble:16:11 (Definition){{( \(invalid\))?}} 
[type=double4] [typekind=Typedef] [canonicaltype=double 
__attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=vectorDouble:16:11 (Definition){{( \(invalid\))?}} 
[type=double4] [typekind=Typedef] [canonicaltype=double 
__attribute__((ext_vector_type(4)))] [canonicaltypekind=ExtVector] [isPOD=1]
 
 #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
 

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=358566&r1=358565&r2=358566&view=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Wed Apr 17 02:08:50 2019
@@ -109,6 +109,7 @@ static CXTypeKind GetTypeKind(QualType T
 TKCASE(VariableArray);
 TKCASE(DependentSizedArray);
 TKCASE(Vector);
+TKCASE(ExtVector);
 TKCASE(MemberPointer);
 TKCASE(Auto);
 TKCASE(Elaborated);
@@ -600,6 +601,7 @@ CXString clang_getTypeKindSpelling(enum
 TKIND(VariableArray);
 TKIND(DependentSizedArray);
 TKIND(Vector);
+TKIND(ExtVector);
 TKIND(MemberPointer);
 TKIND(Auto);
 TKIND(Elaborated);
@@ -804,6 +806,9 @@ CXType clang_getElementType(CXType CT) {
 case Type::Vector:
   ET = cast (TP)->getElementType();
   break;
+case Type::ExtVector:
+  ET = cast(TP)->getElementType();
+  break;
 cas

r342638 - [OpenCL] Diagnose redundant address space conversion

2018-09-20 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Sep 20 03:07:27 2018
New Revision: 342638

URL: http://llvm.org/viewvc/llvm-project?rev=342638&view=rev
Log:
[OpenCL] Diagnose redundant address space conversion

Add a warning if a parameter with a named address space is passed
to a to_addr builtin.

For example:

  int i;
  to_private(&i); // generate warning as conversion from private to private is 
redundant.

Patch by Alistair Davies.

Differential Revision: https://reviews.llvm.org/D51411

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=342638&r1=342637&r2=342638&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 20 03:07:27 
2018
@@ -8613,6 +8613,10 @@ def err_opencl_variadic_function : Error
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extension : Error<
   "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">;
+def warn_opencl_generic_address_space_arg : Warning<
+  "passing non-generic address space pointer to %0"
+  " may cause dynamic conversion affecting performance">,
+  InGroup, DefaultIgnore;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=342638&r1=342637&r2=342638&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 20 03:07:27 2018
@@ -849,6 +849,13 @@ static bool SemaOpenCLBuiltinToAddr(Sema
 return true;
   }
 
+  if (RT->getPointeeType().getAddressSpace() != LangAS::opencl_generic) {
+S.Diag(Call->getArg(0)->getBeginLoc(),
+   diag::warn_opencl_generic_address_space_arg)
+<< Call->getDirectCallee()->getNameInfo().getAsString()
+<< Call->getArg(0)->getSourceRange();
+  }
+
   RT = RT->getPointeeType();
   auto Qual = RT.getQualifiers();
   switch (BuiltinID) {

Modified: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl?rev=342638&r1=342637&r2=342638&view=diff
==
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl (original)
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl Thu Sep 20 03:07:27 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -verify -fsyntax-only %s
-// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL2.0 %s
 
 void test(void) {
   global int *glob;
@@ -43,6 +43,7 @@ void test(void) {
   // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to '__local int *' from 'int'}}
 #else
   // expected-error@-4{{assigning '__global int *' to '__local int *' changes 
address space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
 #endif
 
   global char *glob_c = to_global(loc);
@@ -50,6 +51,7 @@ void test(void) {
   // expected-warning@-2{{incompatible integer to pointer conversion 
initializing '__global char *' with an expression of type 'int'}}
 #else
   // expected-warning@-4{{incompatible pointer types initializing '__global 
char *' with an expression of type '__global int *'}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
 #endif
 
 }


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


r342876 - Fix Wundef NDEBUG warning; NFC

2018-09-24 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Sep 24 05:12:03 2018
New Revision: 342876

URL: http://llvm.org/viewvc/llvm-project?rev=342876&view=rev
Log:
Fix Wundef NDEBUG warning; NFC

Check for definedness of the NDEBUG macro rather than its value,
to be consistent with other uses.

Modified:
cfe/trunk/lib/Sema/ParsedAttr.cpp

Modified: cfe/trunk/lib/Sema/ParsedAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParsedAttr.cpp?rev=342876&r1=342875&r2=342876&view=diff
==
--- cfe/trunk/lib/Sema/ParsedAttr.cpp (original)
+++ cfe/trunk/lib/Sema/ParsedAttr.cpp Mon Sep 24 05:12:03 2018
@@ -82,7 +82,7 @@ void AttributeFactory::deallocate(Parsed
   if (freeListIndex >= FreeLists.size())
 FreeLists.resize(freeListIndex + 1);
 
-#if !NDEBUG
+#ifndef NDEBUG
   // In debug mode, zero out the attribute to help find memory overwriting.
   memset(Attr, 0, size);
 #endif


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


r342968 - [OpenCL] Allow zero assignment and comparisons between queue_t type variables

2018-09-25 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Sep 25 05:59:34 2018
New Revision: 342968

URL: http://llvm.org/viewvc/llvm-project?rev=342968&view=rev
Log:
[OpenCL] Allow zero assignment and comparisons between queue_t type variables

This change allows for zero assignment and comparison of queue_t
type variables, and extends null_queue.cl to test this.

Patch by Alistair Davies.

Differential Revision: https://reviews.llvm.org/D51727

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaOpenCL/null_queue.cl

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=342968&r1=342967&r2=342968&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Sep 25 05:59:34 2018
@@ -8086,6 +8086,13 @@ Sema::CheckSingleAssignmentConstraints(Q
 return Compatible;
   }
 
+  // OpenCL queue_t type assignment.
+  if (LHSType->isQueueT() && RHS.get()->isNullPointerConstant(
+ Context, Expr::NPC_ValueDependentIsNull)) {
+RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
+return Compatible;
+  }
+
   // This check seems unnatural, however it is necessary to ensure the proper
   // conversion of functions/arrays. If the conversion were done for all
   // DeclExpr's (created by ActOnIdExpression), it would mess up the unary
@@ -10423,6 +10430,10 @@ QualType Sema::CheckCompareOperands(Expr
   }
 
   if (getLangOpts().OpenCLVersion >= 200) {
+if (LHSType->isQueueT() && RHSType->isQueueT()) {
+  return computeResultTy();
+}
+
 if (LHSIsNull && RHSType->isQueueT()) {
   LHS = ImpCastExprToType(LHS.get(), RHSType, CK_NullToPointer);
   return computeResultTy();

Modified: cfe/trunk/test/SemaOpenCL/null_queue.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/null_queue.cl?rev=342968&r1=342967&r2=342968&view=diff
==
--- cfe/trunk/test/SemaOpenCL/null_queue.cl (original)
+++ cfe/trunk/test/SemaOpenCL/null_queue.cl Tue Sep 25 05:59:34 2018
@@ -1,12 +1,30 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 extern queue_t get_default_queue();
 
-bool compare() {
-  return 1 == get_default_queue() && // expected-error{{invalid operands to 
binary expression ('int' and 'queue_t')}}
- get_default_queue() == 1; // expected-error{{invalid operands to 
binary expression ('queue_t' and 'int')}}
-}
+void queue_arg(queue_t); // expected-note {{passing argument to parameter 
here}}
 
 void init() {
   queue_t q1 = 1; // expected-error{{initializing 'queue_t' with an expression 
of incompatible type 'int'}}
   queue_t q = 0;
 }
+
+void assign() {
+  queue_t q2, q3;
+  q2 = 5; // expected-error{{assigning to 'queue_t' from incompatible type 
'int'}}
+  q3 = 0;
+  q2 = q3 = 0;
+}
+
+bool compare() {
+  queue_t q4, q5;
+  return 1 == get_default_queue() && // expected-error{{invalid operands to 
binary expression ('int' and 'queue_t')}}
+ get_default_queue() == 1 && // expected-error{{invalid operands to 
binary expression ('queue_t' and 'int')}}
+q4 == q5 &&
+q4 != 0 &&
+q4 != 0.0f; // expected-error{{invalid operands to binary 
expression ('queue_t' and 'float')}}
+}
+
+void call() {
+  queue_arg(5); // expected-error {{passing 'int' to parameter of incompatible 
type 'queue_t'}}
+  queue_arg(0);
+}


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


r343207 - [OpenCL] Improve extension-version.cl and to_addr_builtin.cl tests

2018-09-27 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Sep 27 06:20:29 2018
New Revision: 343207

URL: http://llvm.org/viewvc/llvm-project?rev=343207&view=rev
Log:
[OpenCL] Improve extension-version.cl and to_addr_builtin.cl tests

Add cl_khr_depth_images to extension-version.cl.

Extend to_addr_builtin.cl to additionally test the built-in methods
to_private and to_local, and test assignment with to_global to
incorrect types.

Patch by Alistair Davies.

Differential Revision: https://reviews.llvm.org/D52020

Modified:
cfe/trunk/test/SemaOpenCL/extension-version.cl
cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl

Modified: cfe/trunk/test/SemaOpenCL/extension-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=343207&r1=343206&r2=343207&view=diff
==
--- cfe/trunk/test/SemaOpenCL/extension-version.cl (original)
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl Thu Sep 27 06:20:29 2018
@@ -283,6 +283,18 @@
 #pragma OPENCL EXTENSION cl_amd_media_ops2: enable
 
 #if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_khr_depth_images
+#error "Missing cl_khr_depth_images define"
+#endif
+#else
+#ifdef cl_khr_depth_images
+#error "Incorrect cl_khr_depth_images define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_depth_images' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_depth_images: enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
 #ifndef cl_intel_subgroups
 #error "Missing cl_intel_subgroups define"
 #endif

Modified: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl?rev=343207&r1=343206&r2=343207&view=diff
==
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl (original)
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl Thu Sep 27 06:20:29 2018
@@ -5,6 +5,8 @@ void test(void) {
   global int *glob;
   local int *loc;
   constant int *con;
+  private int *priv;
+  global float *glob_wrong_ty;
   typedef constant int const_int_ty;
   const_int_ty *con_typedef;
 
@@ -46,6 +48,72 @@ void test(void) {
   // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
 #endif
 
+  loc = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{implicit declaration of function 'to_private' is 
invalid in OpenCL}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning 
to '__local int *' from 'int'}}
+#else
+  // expected-error@-5{{assigning 'int *' to '__local int *' changes address 
space of pointer}}
+  // expected-warning@-6{{passing non-generic address space pointer to 
to_private may cause dynamic conversion affecting performance}}
+#endif
+
+  loc = to_local(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{implicit declaration of function 'to_local' is invalid 
in OpenCL}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning 
to '__local int *' from 'int'}}
+  // expected-note@-4{{did you mean 'to_global'}}
+  // expected-note@13{{'to_global' declared here}}
+#else
+  // expected-warning@-7{{passing non-generic address space pointer to 
to_local may cause dynamic conversion affecting performance}}
+#endif
+
+  priv = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to 'int *' from 'int'}}
+#else
+  // expected-error@-4{{assigning '__global int *' to 'int *' changes address 
space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
+#endif
+
+  priv = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to 'int *' from 'int'}}
+#else
+  // expected-warning@-4{{passing non-generic address space pointer to 
to_private may cause dynamic conversion affecting performance}}
+#endif
+
+
+  priv = to_local(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to 'int *' from 'int'}}
+#else
+  // expected-error@-4{{assigning '__local int *' to 'int *' changes address 
space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_local may cause dynamic conversion affecting performance}}
+#endif
+
+  glob = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to '__global int *' from 'int'}}
+#else
+  // expected-warning@-4{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
+#endif
+
+  glob = to_private(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0

r343582 - Revert r326937 "[OpenCL] Remove block invoke function from emitted block literal struct"

2018-10-02 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Oct  2 06:02:24 2018
New Revision: 343582

URL: http://llvm.org/viewvc/llvm-project?rev=343582&view=rev
Log:
Revert r326937 "[OpenCL] Remove block invoke function from emitted block 
literal struct"

This reverts r326937 as it broke block argument handling in OpenCL.
See the discussion on https://reviews.llvm.org/D43783 .

The next commit will add a test case that revealed the issue.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
cfe/trunk/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
cfe/trunk/test/CodeGenOpenCL/blocks.cl
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
cfe/trunk/test/SemaOpenCL/block-array-capturing.cl

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=343582&r1=343581&r2=343582&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Oct  2 06:02:24 2018
@@ -446,12 +446,25 @@ static void initializeForBlockHeader(Cod
 
   assert(elementTypes.empty());
   if (CGM.getLangOpts().OpenCL) {
-// The header is basically 'struct { int; int;
+// The header is basically 'struct { int; int; generic void *;
 // custom_fields; }'. Assert that struct is packed.
+auto GenericAS =
+CGM.getContext().getTargetAddressSpace(LangAS::opencl_generic);
+auto GenPtrAlign =
+CharUnits::fromQuantity(CGM.getTarget().getPointerAlign(GenericAS) / 
8);
+auto GenPtrSize =
+CharUnits::fromQuantity(CGM.getTarget().getPointerWidth(GenericAS) / 
8);
+assert(CGM.getIntSize() <= GenPtrSize);
+assert(CGM.getIntAlign() <= GenPtrAlign);
+assert((2 * CGM.getIntSize()).isMultipleOf(GenPtrAlign));
 elementTypes.push_back(CGM.IntTy); /* total size */
 elementTypes.push_back(CGM.IntTy); /* align */
-unsigned Offset = 2 * CGM.getIntSize().getQuantity();
-unsigned BlockAlign = CGM.getIntAlign().getQuantity();
+elementTypes.push_back(
+CGM.getOpenCLRuntime()
+.getGenericVoidPointerType()); /* invoke function */
+unsigned Offset =
+2 * CGM.getIntSize().getQuantity() + GenPtrSize.getQuantity();
+unsigned BlockAlign = GenPtrAlign.getQuantity();
 if (auto *Helper =
 CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) {
   for (auto I : Helper->getCustomFieldTypes()) /* custom fields */ {
@@ -906,12 +919,20 @@ llvm::Value *CodeGenFunction::EmitBlockL
 
 llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
   bool IsOpenCL = CGM.getContext().getLangOpts().OpenCL;
+  auto GenVoidPtrTy =
+  IsOpenCL ? CGM.getOpenCLRuntime().getGenericVoidPointerType() : 
VoidPtrTy;
+  LangAS GenVoidPtrAddr = IsOpenCL ? LangAS::opencl_generic : LangAS::Default;
+  auto GenVoidPtrSize = CharUnits::fromQuantity(
+  CGM.getTarget().getPointerWidth(
+  CGM.getContext().getTargetAddressSpace(GenVoidPtrAddr)) /
+  8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
   CodeGenFunction BlockCGF{CGM, true};
   BlockCGF.SanOpts = SanOpts;
   auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
+  auto *blockFn = llvm::ConstantExpr::getPointerCast(InvokeFn, GenVoidPtrTy);
 
   // If there is nothing to capture, we can emit this as a global block.
   if (blockInfo.CanBeGlobal)
@@ -987,12 +1008,11 @@ llvm::Value *CodeGenFunction::EmitBlockL
   llvm::ConstantInt::get(IntTy, blockInfo.BlockAlign.getQuantity()),
   getIntSize(), "block.align");
 }
-if (!IsOpenCL) {
-  addHeaderField(llvm::ConstantExpr::getBitCast(InvokeFn, VoidPtrTy),
- getPointerSize(), "block.invoke");
+addHeaderField(blockFn, GenVoidPtrSize, "block.invoke");
+if (!IsOpenCL)
   addHeaderField(descriptor, getPointerSize(), "block.descriptor");
-} else if (auto *Helper =
-   CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) {
+else if (auto *Helper =
+ CGM.getTargetCodeGenInfo().getTargetOpenCLBlockHelper()) {
   for (auto I : Helper->getCustomFieldValues(*this, blockInfo)) {
 addHeaderField(
 I.first,
@@ -1196,23 +1216,38 @@ llvm::Type *CodeGenModule::getBlockDescr
 }
 
 llvm::Type *CodeGenModule::getGenericBlockLiteralType() {
-  assert(!getLangOpts().OpenCL && "OpenCL does not need this");
-
   if (GenericBlockLiteralType)
 return GenericBlockLiteralType;
 
   llvm::Type *BlockDescPtrTy = getBlockDescriptorType();
 
-  // struct __block_literal_generic {
-  //   void *__isa;
-  //   int __flags;
-  //   int __reserved;
-  //   void (*__invoke)(void *);
-  //   struct __block_descriptor *__de

r343583 - [OpenCL] Add block argument CodeGen test

2018-10-02 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Oct  2 06:02:27 2018
New Revision: 343583

URL: http://llvm.org/viewvc/llvm-project?rev=343583&view=rev
Log:
[OpenCL] Add block argument CodeGen test

r326937 ("[OpenCL] Remove block invoke function from emitted block
literal struct", 2018-03-07) broke block argument handling.  In
particular the commit was causing a crash during code generation, see
the discussion in https://reviews.llvm.org/D43783 .

The offending commit has just been reverted; add a test to avoid
breaking this again in the future.

Modified:
cfe/trunk/test/CodeGenOpenCL/blocks.cl

Modified: cfe/trunk/test/CodeGenOpenCL/blocks.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/blocks.cl?rev=343583&r1=343582&r2=343583&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/blocks.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/blocks.cl Tue Oct  2 06:02:27 2018
@@ -78,6 +78,26 @@ void foo(){
 
 // COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel
 
+// Test that we support block arguments.
+// COMMON-LABEL: define {{.*}} @blockArgFunc
+int blockArgFunc(int (^ bl)(void)) {
+  return bl();
+}
+
+// COMMON-LABEL: define {{.*}} @get21
+// COMMON: define {{.*}} @__get21_block_invoke
+// COMMON: ret i32 21
+int get21() {
+  return blockArgFunc(^{return 21;});
+}
+
+// COMMON-LABEL: define {{.*}} @get42
+// COMMON: define {{.*}} @__get42_block_invoke
+// COMMON: ret i32 42
+int get42() {
+  return blockArgFunc(^{return 42;});
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 


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


r353690 - [libclang] Add attribute support for 'convergent'.

2019-02-11 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Feb 11 03:00:56 2019
New Revision: 353690

URL: http://llvm.org/viewvc/llvm-project?rev=353690&view=rev
Log:
[libclang] Add attribute support for 'convergent'.

This bumps CINDEX_VERSION_MINOR up (to 51).

Patch by Hsin-Hsiao Lin.

Differential Revision: https://reviews.llvm.org/D57946

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/attributes.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=353690&r1=353689&r2=353690&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Feb 11 03:00:56 2019
@@ -1342,6 +1342,7 @@ CursorKind.VISIBILITY_ATTR = CursorKind(
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
+CursorKind.CONVERGENT_ATTR = CursorKind(420)
 
 ###
 # Preprocessing

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=353690&r1=353689&r2=353690&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Feb 11 03:00:56 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 50
+#define CINDEX_VERSION_MINOR 51
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2586,7 +2586,8 @@ enum CXCursorKind {
   CXCursor_ObjCRuntimeVisible= 435,
   CXCursor_ObjCBoxable   = 436,
   CXCursor_FlagEnum  = 437,
-  CXCursor_LastAttr  = CXCursor_FlagEnum,
+  CXCursor_ConvergentAttr= 438,
+  CXCursor_LastAttr  = CXCursor_ConvergentAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,

Modified: cfe/trunk/test/Index/attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes.c?rev=353690&r1=353689&r2=353690&view=diff
==
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Mon Feb 11 03:00:56 2019
@@ -12,6 +12,8 @@ enum __attribute((flag_enum)) FlagEnum {
   Foo
 };
 
+void convergent_fn() __attribute__((convergent));
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -24,3 +26,6 @@ enum __attribute((flag_enum)) FlagEnum {
 // CHECK: attributes.c:9:38: attribute(noduplicate)= Extent=[9:38 - 9:49]
 // CHECK: attributes.c:11:31: EnumDecl=FlagEnum:11:31 (Definition) 
Extent=[11:1 - 13:2]
 // CHECK: attributes.c:11:19: attribute(flag_enum)= Extent=[11:19 - 11:28]
+// CHECK: attributes.c:12:3: EnumConstantDecl=Foo:12:3 (Definition) 
Extent=[12:3 - 12:6]
+// CHECK: attributes.c:15:6: FunctionDecl=convergent_fn:15:6 Extent=[15:1 - 
15:49]
+// CHECK: attributes.c:15:37: attribute(convergent)= Extent=[15:37 - 15:47]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=353690&r1=353689&r2=353690&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Feb 11 03:00:56 2019
@@ -5474,7 +5474,9 @@ CXString clang_getCursorKindSpelling(enu
   case CXCursor_StaticAssert:
   return cxstring::createRef("StaticAssert");
   case CXCursor_FriendDecl:
-return cxstring::createRef("FriendDecl");
+  return cxstring::createRef("FriendDecl");
+  case CXCursor_ConvergentAttr:
+  return cxstring::createRef("attribute(convergent)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=353690&r1=353689&r2=353690&view=diff
==
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Mon Feb 11 03:00:56 2019
@@ -78,6 +78,7 @@ static CXCursorKind GetCursorKind(const
 case attr::ObjCRuntimeVisible: return CXCursor_ObjCRuntimeVisible;
 case attr::ObjCBoxable: return CXCursor_ObjCBoxable;
 case attr::FlagEnum: return CXCursor_FlagEnum;
+case attr::Convergent: return CXCursor_ConvergentAttr;
   }
 
   return CXCursor_UnexposedAttr

r362087 - [OpenCL] Support logical vector operators in C++ mode

2019-05-30 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu May 30 05:35:19 2019
New Revision: 362087

URL: http://llvm.org/viewvc/llvm-project?rev=362087&view=rev
Log:
[OpenCL] Support logical vector operators in C++ mode

Support logical operators on vectors in C++ for OpenCL mode, to
preserve backwards compatibility with OpenCL C.

Differential Revision: https://reviews.llvm.org/D62588

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenOpenCL/logical-ops.cl

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=362087&r1=362086&r2=362087&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu May 30 05:35:19 2019
@@ -10902,7 +10902,7 @@ QualType Sema::CheckVectorLogicalOperand
   if (vType.isNull())
 return InvalidOperands(Loc, LHS, RHS);
   if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
-  vType->hasFloatingRepresentation())
+  !getLangOpts().OpenCLCPlusPlus && 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
@@ -13165,7 +13165,8 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
   }
 } else if (resultType->isExtVectorType()) {
   if (Context.getLangOpts().OpenCL &&
-  Context.getLangOpts().OpenCLVersion < 120) {
+  Context.getLangOpts().OpenCLVersion < 120 &&
+  !Context.getLangOpts().OpenCLCPlusPlus) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on vector float types.
 QualType T = resultType->getAs()->getElementType();

Modified: cfe/trunk/test/CodeGenOpenCL/logical-ops.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/logical-ops.cl?rev=362087&r1=362086&r2=362087&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/logical-ops.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/logical-ops.cl Thu May 30 05:35:19 2019
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O1 -triple 
x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=c++ -O1 -triple 
x86_64-unknown-linux-gnu | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 


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


r362371 - [OpenCL] Declare builtin functions using TableGen

2019-06-03 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Jun  3 02:39:11 2019
New Revision: 362371

URL: http://llvm.org/viewvc/llvm-project?rev=362371&view=rev
Log:
[OpenCL] Declare builtin functions using TableGen

This patch adds a `-fdeclare-opencl-builtins` command line option to
the clang frontend.  This enables clang to verify OpenCL C builtin
function declarations using a fast StringMatcher lookup, instead of
including the opencl-c.h file with the `-finclude-default-header`
option.  This avoids the large parse time penalty of the header file.

This commit only adds the basic infrastructure and some of the OpenCL
builtins.  It does not cover all builtins defined by the various OpenCL
specifications.  As such, it is not a replacement for
`-finclude-default-header` yet.

RFC: http://lists.llvm.org/pipermail/cfe-dev/2018-November/060041.html

Co-authored-by: Pierre Gondois
Co-authored-by: Joey Gouly
Co-authored-by: Sven van Haastregt

Differential Revision: https://reviews.llvm.org/D60763

Added:
cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
Modified:
cfe/trunk/include/clang/Basic/CMakeLists.txt
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/utils/TableGen/CMakeLists.txt
cfe/trunk/utils/TableGen/TableGen.cpp
cfe/trunk/utils/TableGen/TableGenBackends.h

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=362371&r1=362370&r2=362371&view=diff
==
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Mon Jun  3 02:39:11 2019
@@ -41,6 +41,12 @@ clang_tablegen(AttrHasAttributeImpl.inc
   TARGET ClangAttrHasAttributeImpl
   )
 
+clang_tablegen(OpenCLBuiltins.inc
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ -gen-clang-opencl-builtins
+  SOURCE OpenCLBuiltins.td
+  TARGET ClangOpenCLBuiltinsImpl
+  )
+
 # ARM NEON
 clang_tablegen(arm_neon.inc -gen-arm-neon-sema
   SOURCE arm_neon.td

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=362371&r1=362370&r2=362371&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Jun  3 02:39:11 2019
@@ -256,6 +256,7 @@ LANGOPT(CFProtectionBranch , 1, 0, "Cont
 LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
 ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, 
"OpenCL address space map mangling mode")
 LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for OpenCL")
+LANGOPT(DeclareOpenCLBuiltins, 1, 0, "Declare OpenCL builtin functions")
 BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
 LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
 LANGOPT(

Added: cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLBuiltins.td?rev=362371&view=auto
==
--- cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (added)
+++ cfe/trunk/include/clang/Basic/OpenCLBuiltins.td Mon Jun  3 02:39:11 2019
@@ -0,0 +1,296 @@
+//==--- OpenCLBuiltins.td - OpenCL builtin declarations 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains TableGen definitions for OpenCL builtin function
+// declarations.  In case of an unresolved function name in OpenCL, Clang will
+// check for a function described in this file when -fdeclare-opencl-builtins
+// is specified.
+//
+//===--===//
+
+//===--===//
+//  Definitions of miscellaneous basic entities.
+//===--===//
+// Versions of OpenCL
+class Version {
+  int Version = _Version;
+}
+def CL10: Version<100>;
+def CL11: Version<110>;
+def CL12: Version<120>;
+def CL20: Version<200>;
+
+// Address spaces
+// Pointer types need to be assigned an address space.
+class AddressSpace {
+  string AddrSpace = _AS;
+}
+def default_as: AddressSpace<"clang::LangAS::

r363242 - [OpenCL] Move OpenCLBuiltins.td and remove unused include

2019-06-13 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Jun 13 02:54:22 2019
New Revision: 363242

URL: http://llvm.org/viewvc/llvm-project?rev=363242&view=rev
Log:
[OpenCL] Move OpenCLBuiltins.td and remove unused include

Patch by Pierre Gondois.

Differential revision: https://reviews.llvm.org/D62849

Added:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
  - copied, changed from r363241, 
cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
Removed:
cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
Modified:
cfe/trunk/include/clang/Basic/CMakeLists.txt
cfe/trunk/lib/Sema/CMakeLists.txt
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=363242&r1=363241&r2=363242&view=diff
==
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Thu Jun 13 02:54:22 2019
@@ -41,12 +41,6 @@ clang_tablegen(AttrHasAttributeImpl.inc
   TARGET ClangAttrHasAttributeImpl
   )
 
-clang_tablegen(OpenCLBuiltins.inc
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ -gen-clang-opencl-builtins
-  SOURCE OpenCLBuiltins.td
-  TARGET ClangOpenCLBuiltinsImpl
-  )
-
 # ARM NEON
 clang_tablegen(arm_neon.inc -gen-arm-neon-sema
   SOURCE arm_neon.td

Removed: cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLBuiltins.td?rev=363241&view=auto
==
--- cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (original)
+++ cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (removed)
@@ -1,296 +0,0 @@
-//==--- OpenCLBuiltins.td - OpenCL builtin declarations 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file contains TableGen definitions for OpenCL builtin function
-// declarations.  In case of an unresolved function name in OpenCL, Clang will
-// check for a function described in this file when -fdeclare-opencl-builtins
-// is specified.
-//
-//===--===//
-
-//===--===//
-//  Definitions of miscellaneous basic entities.
-//===--===//
-// Versions of OpenCL
-class Version {
-  int Version = _Version;
-}
-def CL10: Version<100>;
-def CL11: Version<110>;
-def CL12: Version<120>;
-def CL20: Version<200>;
-
-// Address spaces
-// Pointer types need to be assigned an address space.
-class AddressSpace {
-  string AddrSpace = _AS;
-}
-def default_as: AddressSpace<"clang::LangAS::Default">;
-def private_as: AddressSpace<"clang::LangAS::opencl_private">;
-def global_as : AddressSpace<"clang::LangAS::opencl_global">;
-def constant_as   : AddressSpace<"clang::LangAS::opencl_constant">;
-def local_as  : AddressSpace<"clang::LangAS::opencl_local">;
-def generic_as: AddressSpace<"clang::LangAS::opencl_generic">;
-
-
-// Qualified Type. Allow to retrieve one ASTContext QualType.
-class QualType {
-  // Name of the field or function in a clang::ASTContext
-  // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t
-  string Name = _Name;
-}
-
-// Helper class to store type access qualifiers (volatile, const, ...).
-class Qualifier {
-  string QualName = _QualName;
-}
-
-//===--===//
-//  OpenCL C classes for types
-//===--===//
-// OpenCL types (int, float, ...)
-class Type {
-  // Name of the Type
-  string Name = _Name;
-  // QualType associated with this type
-  QualType QTName = _QTName;
-  // Size of the vector (if applicable)
-  int VecWidth = 0;
-  // Is pointer
-  bit IsPointer = 0;
-  // List of qualifiers associated with the type (volatile, ...)
-  list QualList = [];
-  // Address space
-  string AddrSpace = "clang::LangAS::Default";
-  // Access qualifier. Must be one of ("RO", "WO", "RW").
-  string AccessQualifier = "";
-}
-
-// OpenCL vector types (e.g. int2, int3, int16, float8, ...)
-class VectorType : Type<_Ty.Name, _Ty.QTName> {
-  int VecWidth = _VecWidth;
-}
-
-// OpenCL pointer types (e.g. int*, float*, ...)
-class PointerType :
-  Type<_Ty.Name, _Ty.QTName> {
-  bit IsPointer = 1;
-  string AddrSpace = _AS.AddrSpace;
-}
-
-// OpenCL image types (e.g. image2d_t, ...)
-class ImageType :
- 

r363376 - Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"

2019-06-14 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri Jun 14 05:14:58 2019
New Revision: 363376

URL: http://llvm.org/viewvc/llvm-project?rev=363376&view=rev
Log:
Revert "[OpenCL] Move OpenCLBuiltins.td and remove unused include"

This reverts commit r363242 as it broke some builds with

  make[2]: *** No rule to make target 'ClangOpenCLBuiltinsImpl', needed by
  'tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLookup.cpp.o'.

Added:
cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
  - copied, changed from r363369, cfe/trunk/lib/Sema/OpenCLBuiltins.td
Removed:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
Modified:
cfe/trunk/include/clang/Basic/CMakeLists.txt
cfe/trunk/lib/Sema/CMakeLists.txt
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
==
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Fri Jun 14 05:14:58 2019
@@ -41,6 +41,12 @@ clang_tablegen(AttrHasAttributeImpl.inc
   TARGET ClangAttrHasAttributeImpl
   )
 
+clang_tablegen(OpenCLBuiltins.inc
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ -gen-clang-opencl-builtins
+  SOURCE OpenCLBuiltins.td
+  TARGET ClangOpenCLBuiltinsImpl
+  )
+
 # ARM NEON
 clang_tablegen(arm_neon.inc -gen-arm-neon-sema
   SOURCE arm_neon.td

Copied: cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (from r363369, 
cfe/trunk/lib/Sema/OpenCLBuiltins.td)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLBuiltins.td?p2=cfe/trunk/include/clang/Basic/OpenCLBuiltins.td&p1=cfe/trunk/lib/Sema/OpenCLBuiltins.td&r1=363369&r2=363376&rev=363376&view=diff
==
(empty)

Modified: cfe/trunk/lib/Sema/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CMakeLists.txt?rev=363376&r1=363375&r2=363376&view=diff
==
--- cfe/trunk/lib/Sema/CMakeLists.txt (original)
+++ cfe/trunk/lib/Sema/CMakeLists.txt Fri Jun 14 05:14:58 2019
@@ -66,10 +66,3 @@ add_clang_library(clangSema
   clangEdit
   clangLex
   )
-
-clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
-  SOURCE OpenCLBuiltins.td
-  TARGET ClangOpenCLBuiltinsImpl
-  )
-
-set_source_files_properties(SemaLookup.cpp OBJECT_DEPENDS 
ClangOpenCLBuiltinsImpl)

Removed: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=363375&view=auto
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td (removed)
@@ -1,296 +0,0 @@
-//==--- OpenCLBuiltins.td - OpenCL builtin declarations 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file contains TableGen definitions for OpenCL builtin function
-// declarations.  In case of an unresolved function name in OpenCL, Clang will
-// check for a function described in this file when -fdeclare-opencl-builtins
-// is specified.
-//
-//===--===//
-
-//===--===//
-//  Definitions of miscellaneous basic entities.
-//===--===//
-// Versions of OpenCL
-class Version {
-  int Version = _Version;
-}
-def CL10: Version<100>;
-def CL11: Version<110>;
-def CL12: Version<120>;
-def CL20: Version<200>;
-
-// Address spaces
-// Pointer types need to be assigned an address space.
-class AddressSpace {
-  string AddrSpace = _AS;
-}
-def default_as: AddressSpace<"clang::LangAS::Default">;
-def private_as: AddressSpace<"clang::LangAS::opencl_private">;
-def global_as : AddressSpace<"clang::LangAS::opencl_global">;
-def constant_as   : AddressSpace<"clang::LangAS::opencl_constant">;
-def local_as  : AddressSpace<"clang::LangAS::opencl_local">;
-def generic_as: AddressSpace<"clang::LangAS::opencl_generic">;
-
-
-// Qualified Type. Allow to retrieve one ASTContext QualType.
-class QualType {
-  // Name of the field or function in a clang::ASTContext
-  // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t
-  string Name = _Name;
-}
-
-// Helper class to store type access qualifiers (volatile, const, ...).
-class Qualifier {
-  string QualName = _QualName;
-}
-
-//===

r363541 - Recommit [OpenCL] Move OpenCLBuiltins.td and remove unused include

2019-06-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Jun 17 03:06:34 2019
New Revision: 363541

URL: http://llvm.org/viewvc/llvm-project?rev=363541&view=rev
Log:
Recommit [OpenCL] Move OpenCLBuiltins.td and remove unused include

Reland r363242 after fixing an issue with the tablegen dependence.

Patch by Pierre Gondois and Sven van Haastregt.

Differential revision: https://reviews.llvm.org/D62849

Added:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
  - copied, changed from r363529, 
cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
Removed:
cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
Modified:
cfe/trunk/include/clang/Basic/CMakeLists.txt
cfe/trunk/lib/Sema/CMakeLists.txt
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CMakeLists.txt?rev=363541&r1=363540&r2=363541&view=diff
==
--- cfe/trunk/include/clang/Basic/CMakeLists.txt (original)
+++ cfe/trunk/include/clang/Basic/CMakeLists.txt Mon Jun 17 03:06:34 2019
@@ -41,12 +41,6 @@ clang_tablegen(AttrHasAttributeImpl.inc
   TARGET ClangAttrHasAttributeImpl
   )
 
-clang_tablegen(OpenCLBuiltins.inc
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ -gen-clang-opencl-builtins
-  SOURCE OpenCLBuiltins.td
-  TARGET ClangOpenCLBuiltinsImpl
-  )
-
 # ARM NEON
 clang_tablegen(arm_neon.inc -gen-arm-neon-sema
   SOURCE arm_neon.td

Removed: cfe/trunk/include/clang/Basic/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLBuiltins.td?rev=363540&view=auto
==
--- cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (original)
+++ cfe/trunk/include/clang/Basic/OpenCLBuiltins.td (removed)
@@ -1,296 +0,0 @@
-//==--- OpenCLBuiltins.td - OpenCL builtin declarations 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file contains TableGen definitions for OpenCL builtin function
-// declarations.  In case of an unresolved function name in OpenCL, Clang will
-// check for a function described in this file when -fdeclare-opencl-builtins
-// is specified.
-//
-//===--===//
-
-//===--===//
-//  Definitions of miscellaneous basic entities.
-//===--===//
-// Versions of OpenCL
-class Version {
-  int Version = _Version;
-}
-def CL10: Version<100>;
-def CL11: Version<110>;
-def CL12: Version<120>;
-def CL20: Version<200>;
-
-// Address spaces
-// Pointer types need to be assigned an address space.
-class AddressSpace {
-  string AddrSpace = _AS;
-}
-def default_as: AddressSpace<"clang::LangAS::Default">;
-def private_as: AddressSpace<"clang::LangAS::opencl_private">;
-def global_as : AddressSpace<"clang::LangAS::opencl_global">;
-def constant_as   : AddressSpace<"clang::LangAS::opencl_constant">;
-def local_as  : AddressSpace<"clang::LangAS::opencl_local">;
-def generic_as: AddressSpace<"clang::LangAS::opencl_generic">;
-
-
-// Qualified Type. Allow to retrieve one ASTContext QualType.
-class QualType {
-  // Name of the field or function in a clang::ASTContext
-  // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t
-  string Name = _Name;
-}
-
-// Helper class to store type access qualifiers (volatile, const, ...).
-class Qualifier {
-  string QualName = _QualName;
-}
-
-//===--===//
-//  OpenCL C classes for types
-//===--===//
-// OpenCL types (int, float, ...)
-class Type {
-  // Name of the Type
-  string Name = _Name;
-  // QualType associated with this type
-  QualType QTName = _QTName;
-  // Size of the vector (if applicable)
-  int VecWidth = 0;
-  // Is pointer
-  bit IsPointer = 0;
-  // List of qualifiers associated with the type (volatile, ...)
-  list QualList = [];
-  // Address space
-  string AddrSpace = "clang::LangAS::Default";
-  // Access qualifier. Must be one of ("RO", "WO", "RW").
-  string AccessQualifier = "";
-}
-
-// OpenCL vector types (e.g. int2, int3, int16, float8, ...)
-class VectorType : Type<_Ty.Name, _Ty.QTName> {
-  int VecWidth = _VecWidth;
-}
-
-// OpenCL pointer types (e.g. int*, float*, ...)
-class PointerType :
-  Type<_Ty.Name, _Ty.QTName> {
-  bit IsPointer = 1;
-  string AddrSpace 

r363794 - [OpenCL] Split type and macro definitions into opencl-c-base.h

2019-06-19 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed Jun 19 05:48:22 2019
New Revision: 363794

URL: http://llvm.org/viewvc/llvm-project?rev=363794&view=rev
Log:
[OpenCL] Split type and macro definitions into opencl-c-base.h

Using the -fdeclare-opencl-builtins option will require a way to
predefine types and macros such as `int4`, `CLK_GLOBAL_MEM_FENCE`,
etc.  Move these out of opencl-c.h into opencl-c-base.h such that the
latter can be shared by -fdeclare-opencl-builtins and
-finclude-default-header.

This changes the behaviour of -finclude-default-header when
-fdeclare-opencl-builtins is specified: instead of including the full
header, it will include the header with only the base definitions.

Differential revision: https://reviews.llvm.org/D63256

Added:
cfe/trunk/lib/Headers/opencl-c-base.h
Modified:
cfe/trunk/include/clang/Basic/SyncScope.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/module.modulemap
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Modified: cfe/trunk/include/clang/Basic/SyncScope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SyncScope.h?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/include/clang/Basic/SyncScope.h (original)
+++ cfe/trunk/include/clang/Basic/SyncScope.h Wed Jun 19 05:48:22 2019
@@ -95,7 +95,7 @@ class AtomicScopeOpenCLModel : public At
 public:
   /// The enum values match the pre-defined macros
   /// __OPENCL_MEMORY_SCOPE_*, which are used to define memory_scope_*
-  /// enums in opencl-c.h.
+  /// enums in opencl-c-base.h.
   enum ID {
 WorkGroup = 1,
 Device = 2,

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jun 19 05:48:22 2019
@@ -2194,9 +2194,15 @@ void CompilerInvocation::setLangDefaults
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
+
 // Include default header file for OpenCL.
-if (Opts.IncludeDefaultHeader && !Opts.DeclareOpenCLBuiltins) {
-  PPOpts.Includes.push_back("opencl-c.h");
+if (Opts.IncludeDefaultHeader) {
+  if (Opts.DeclareOpenCLBuiltins) {
+// Only include base header file for builtin types and constants.
+PPOpts.Includes.push_back("opencl-c-base.h");
+  } else {
+PPOpts.Includes.push_back("opencl-c.h");
+  }
 }
   }
 

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Wed Jun 19 05:48:22 2019
@@ -77,6 +77,7 @@ set(files
   mwaitxintrin.h
   nmmintrin.h
   opencl-c.h
+  opencl-c-base.h
   pkuintrin.h
   pmmintrin.h
   pconfigintrin.h

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=363794&r1=363793&r2=363794&view=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Wed Jun 19 05:48:22 2019
@@ -154,4 +154,5 @@ module _Builtin_stddef_max_align_t [syst
 module opencl_c {
   requires opencl
   header "opencl-c.h"
+  header "opencl-c-base.h"
 }

Added: cfe/trunk/lib/Headers/opencl-c-base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c-base.h?rev=363794&view=auto
==
--- cfe/trunk/lib/Headers/opencl-c-base.h (added)
+++ cfe/trunk/lib/Headers/opencl-c-base.h Wed Jun 19 05:48:22 2019
@@ -0,0 +1,573 @@
+//===- opencl-c-base.h - OpenCL C language base definitions 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _OPENCL_BASE_H_
+#define _OPENCL_BASE_H_
+
+// built-in scalar data types:
+
+/**
+ * An unsigned 8-bit integer.
+ */
+typedef unsigned char uchar;
+
+/**
+ * An unsigned 16-bit integer.
+ */
+typedef unsigned short ushort;
+
+/**
+ * An unsigned 32-bit integer.
+ */
+typedef unsigned int uint;
+
+/**
+ * An unsigned 64-bit integer.
+ */
+typedef unsigned long ulong;
+
+/**
+ * The unsigned integer type of the 

r366546 - [OpenCL] Define CLK_NULL_EVENT without cast

2019-07-19 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri Jul 19 02:11:48 2019
New Revision: 366546

URL: http://llvm.org/viewvc/llvm-project?rev=366546&view=rev
Log:
[OpenCL] Define CLK_NULL_EVENT without cast

Defining CLK_NULL_EVENT with a `(void*)` cast has the (unintended?)
side-effect that the address space will be fixed (as generic in OpenCL
2.0 mode).  The consequence is that any target specific address space
for the clk_event_t type will not be applied.

It is not clear why the void pointer cast was needed in the first
place, and it seems we can do without it.

Differential Revision: https://reviews.llvm.org/D63876

Modified:
cfe/trunk/lib/Headers/opencl-c-base.h
cfe/trunk/test/SemaOpenCL/clk_event_t.cl

Modified: cfe/trunk/lib/Headers/opencl-c-base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c-base.h?rev=366546&r1=366545&r2=366546&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c-base.h (original)
+++ cfe/trunk/lib/Headers/opencl-c-base.h Fri Jul 19 02:11:48 2019
@@ -413,7 +413,7 @@ typedef enum memory_order
 #define CLK_OUT_OF_RESOURCES-5
 
 #define CLK_NULL_QUEUE  0
-#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+#define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t))
 
 // execution model related definitions
 #define CLK_ENQUEUE_FLAGS_NO_WAIT   0x0

Modified: cfe/trunk/test/SemaOpenCL/clk_event_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clk_event_t.cl?rev=366546&r1=366545&r2=366546&view=diff
==
--- cfe/trunk/test/SemaOpenCL/clk_event_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/clk_event_t.cl Fri Jul 19 02:11:48 2019
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
 
 // Taken from opencl-c.h
-#define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
+#define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t))
 
 global clk_event_t ce; // expected-error {{the '__global clk_event_t' type 
cannot be used to declare a program scope variable}}
 
@@ -10,6 +10,7 @@ int clk_event_tests() {
   event_t e;
   clk_event_t ce1;
   clk_event_t ce2;
+  clk_event_t ce3 = CLK_NULL_EVENT;
 
   if (e == ce1) { // expected-error {{invalid operands to binary expression 
('event_t' and 'clk_event_t')}}
 return 9;


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


r367229 - [OpenCL] Rename builtin definition classes

2019-07-29 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Jul 29 07:55:29 2019
New Revision: 367229

URL: http://llvm.org/viewvc/llvm-project?rev=367229&view=rev
Log:
[OpenCL] Rename builtin definition classes

Factor out some of the renames from D63434 and D63442, and generate
half type convert_ builtins.

Patch by Pierre Gondois and Sven van Haastregt.

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=367229&r1=367228&r2=367229&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Mon Jul 29 07:55:29 2019
@@ -30,14 +30,14 @@ def CL20: Version<200>;
 // Address spaces
 // Pointer types need to be assigned an address space.
 class AddressSpace {
-  string AddrSpace = _AS;
+  string Name = _AS;
 }
-def default_as: AddressSpace<"clang::LangAS::Default">;
-def private_as: AddressSpace<"clang::LangAS::opencl_private">;
-def global_as : AddressSpace<"clang::LangAS::opencl_global">;
-def constant_as   : AddressSpace<"clang::LangAS::opencl_constant">;
-def local_as  : AddressSpace<"clang::LangAS::opencl_local">;
-def generic_as: AddressSpace<"clang::LangAS::opencl_generic">;
+def DefaultAS: AddressSpace<"clang::LangAS::Default">;
+def PrivateAS: AddressSpace<"clang::LangAS::opencl_private">;
+def GlobalAS : AddressSpace<"clang::LangAS::opencl_global">;
+def ConstantAS   : AddressSpace<"clang::LangAS::opencl_constant">;
+def LocalAS  : AddressSpace<"clang::LangAS::opencl_local">;
+def GenericAS: AddressSpace<"clang::LangAS::opencl_generic">;
 
 
 // Qualified Type. Allow to retrieve one ASTContext QualType.
@@ -79,10 +79,10 @@ class VectorType :
+class PointerType :
   Type<_Ty.Name, _Ty.QTName> {
   bit IsPointer = 1;
-  string AddrSpace = _AS.AddrSpace;
+  string AddrSpace = _AS.Name;
 }
 
 // OpenCL image types (e.g. image2d_t, ...)
@@ -156,37 +156,37 @@ multiclass Bif3
 // Definitions of OpenCL C types
 
//===--===//
 // OpenCL v1.2 s6.1.1: Built-in Scalar Data Types
-def bool_t  : Type<"bool", QualType<"BoolTy">>;
-def char_t  : Type<"char", QualType<"CharTy">>;
-def uchar_t : Type<"uchar", QualType<"UnsignedCharTy">>;
-def short_t : Type<"short", QualType<"ShortTy">>;
-def ushort_t: Type<"ushort", QualType<"UnsignedShortTy">>;
-def int_t   : Type<"int", QualType<"IntTy">>;
-def uint_t  : Type<"uint", QualType<"UnsignedIntTy">>;
-def long_t  : Type<"long", QualType<"LongTy">>;
-def ulong_t : Type<"ulong", QualType<"UnsignedLongTy">>;
-def float_t : Type<"float", QualType<"FloatTy">>;
-def double_t: Type<"double", QualType<"DoubleTy">>;
-def half_t  : Type<"half", QualType<"HalfTy">>;
-def size_t  : Type<"size_t",  QualType<"getSizeType()">>;
-def ptrdiff_t   : Type<"ptrdiff_t", QualType<"getPointerDiffType()">>;
-def intptr_t: Type<"intptr_t", QualType<"getIntPtrType()">>;
-def uintptr_t   : Type<"uintptr_t", QualType<"getUIntPtrType()">>;
-def void_t  : Type<"void", QualType<"VoidTy">>;
+def Bool  : Type<"bool",  QualType<"BoolTy">>;
+def Char  : Type<"char",  QualType<"CharTy">>;
+def UChar : Type<"uchar", QualType<"UnsignedCharTy">>;
+def Short : Type<"short", QualType<"ShortTy">>;
+def UShort: Type<"ushort",QualType<"UnsignedShortTy">>;
+def Int   : Type<"int",   QualType<"IntTy">>;
+def UInt  : Type<"uint",  QualType<"UnsignedIntTy">>;
+def Long  : Type<"long",  QualType<"LongTy">>;
+def ULong : Type<"ulong", QualType<"UnsignedLongTy">>;
+def Float : Type<"float", QualType<"FloatTy">>;
+def Double: Type<"double",QualType<"DoubleTy">>;
+def Half  : Type<"half",  QualType<"HalfTy">>;
+def Size  : Type<"size_t",QualType<"getSizeType()">>;
+def PtrDiff   : Type<"ptrdiff_t", QualType<"getPointerDiffType()">>;
+def IntPtr: Type<"intptr_t",  QualType<"getIntPtrType()">>;
+def UIntPtr   : Type<"uintPtr_t", QualType<"getUIntPtrType()">>;
+def Void  : Type<"void_t",QualType<"VoidTy">>;
 
 // OpenCL v1.2 s6.1.2: Built-in Vector Data Types
 foreach v = [2, 3, 4, 8, 16] in {
-  def char#v#_t: VectorType;
-  def uchar#v#_t   : VectorType;
-  def short#v#_t   : VectorType;
-  def ushort#v#_t  : VectorType;
-  def "int"#v#_t   : VectorType;
-  def uint#v#_t: VectorType;
-  def long#v#_t: VectorType;
-  def ulong#v#_t   : VectorType;
-  def float#v#_t   : VectorType;
-  def double#v#_t  : VectorType;
-  def half#v#_t: VectorType;
+  def char#v#_t: VectorType;
+  def uchar#v#_t   : VectorType;
+  def short#v#_t   : VectorType;
+  def ushort#v#_t  : VectorType;
+  def "int"#v#_t   : VectorType;
+  def uint#v#_t: VectorType;
+  def long#v#_t: 

r368561 - [OpenCL] Ignore parentheses for sampler initialization

2019-08-12 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Aug 12 05:44:26 2019
New Revision: 368561

URL: http://llvm.org/viewvc/llvm-project?rev=368561&view=rev
Log:
[OpenCL] Ignore parentheses for sampler initialization

The sampler handling logic in SemaInit.cpp would inadvertently treat
parentheses around sampler arguments as an implicit cast, leading to
an unreachable "can't implicitly cast lvalue to rvalue with
this cast kind".  Fix by ignoring parentheses once we are in the
sampler initializer case.

Differential Revision: https://reviews.llvm.org/D66080

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaOpenCL/sampler_t.cl

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=368561&r1=368560&r2=368561&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Aug 12 05:44:26 2019
@@ -8248,7 +8248,7 @@ ExprResult InitializationSequence::Perfo
   // argument passing.
   assert(Step->Type->isSamplerT() &&
  "Sampler initialization on non-sampler type.");
-  Expr *Init = CurInit.get();
+  Expr *Init = CurInit.get()->IgnoreParens();
   QualType SourceType = Init->getType();
   // Case 1
   if (Entity.isParameterKind()) {

Modified: cfe/trunk/test/SemaOpenCL/sampler_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/sampler_t.cl?rev=368561&r1=368560&r2=368561&view=diff
==
--- cfe/trunk/test/SemaOpenCL/sampler_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/sampler_t.cl Mon Aug 12 05:44:26 2019
@@ -10,6 +10,9 @@
 #define CLK_FILTER_NEAREST  0x10
 #define CLK_FILTER_LINEAR   0x20
 
+typedef float float4 __attribute__((ext_vector_type(4)));
+float4 read_imagef(read_only image1d_t, sampler_t, float);
+
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 constant sampler_t glb_smp2; // expected-error{{variable in constant address 
space must be initialized}}
 global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}} 
expected-error {{global sampler requires a const or constant address space 
qualifier}}
@@ -74,3 +77,7 @@ void bar() {
   foo(smp1+1); //expected-error{{invalid operands to binary expression 
('sampler_t' and 'int')}}
 }
 
+void smp_args(read_only image1d_t image) {
+  // Test that parentheses around sampler arguments are ignored.
+  float4 res = read_imagef(image, (glb_smp10), 0.0f);
+}


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


r368822 - Fix _WIN32 / _WIN64 Wundef warnings

2019-08-14 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed Aug 14 03:30:18 2019
New Revision: 368822

URL: http://llvm.org/viewvc/llvm-project?rev=368822&view=rev
Log:
Fix _WIN32 / _WIN64 Wundef warnings

For these macros it is the definedness that matters rather than
the value.  Make new uses of these macros consistent with existing
uses.

Modified:
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=368822&r1=368821&r2=368822&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Wed Aug 14 03:30:18 2019
@@ -23,7 +23,7 @@ using namespace clang::driver::tools;
 using namespace clang;
 using namespace llvm::opt;
 
-#if _WIN32 || _WIN64
+#if defined(_WIN32) || defined(_WIN64)
 #define NULL_FILE "nul"
 #else
 #define NULL_FILE "/dev/null"


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


r369253 - [OpenCL] Add generic type handling for builtin functions

2019-08-19 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Aug 19 04:56:03 2019
New Revision: 369253

URL: http://llvm.org/viewvc/llvm-project?rev=369253&view=rev
Log:
[OpenCL] Add generic type handling for builtin functions

Generic types are an abstraction of type sets.  It mimics the way
functions are defined in the OpenCL specification.  For example,
floatN can abstract all the vector sizes of the float type.

This allows to
 * stick more closely to the specification, which uses generic types;
 * factorize definitions of functions with numerous prototypes in the
   tablegen file; and
 * reduce the memory impact of functions with many overloads.

Patch by Pierre Gondois and Sven van Haastregt.

Differential Revision: https://reviews.llvm.org/D65456

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=369253&r1=369252&r2=369253&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Mon Aug 19 04:56:03 2019
@@ -40,11 +40,15 @@ def LocalAS  : AddressSpace<"clang::
 def GenericAS: AddressSpace<"clang::LangAS::opencl_generic">;
 
 
-// Qualified Type. Allow to retrieve one ASTContext QualType.
-class QualType {
+// Qualified Type.  These map to ASTContext::QualType.
+class QualType {
   // Name of the field or function in a clang::ASTContext
   // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t
   string Name = _Name;
+  // Some QualTypes in this file represent an abstract type for which there is
+  // no corresponding AST QualType, e.g. a GenType or an `image2d_t` type
+  // without access qualifiers.
+  bit IsAbstract = _IsAbstract;
 }
 
 // Helper class to store type access qualifiers (volatile, const, ...).
@@ -52,25 +56,35 @@ class Qualifier {
   string QualName = _QualName;
 }
 
+// List of integers.
+class IntList _List> {
+  string Name = _Name;
+  list List = _List;
+}
+
 
//===--===//
 //  OpenCL C classes for types
 
//===--===//
-// OpenCL types (int, float, ...)
+// OpenCL C basic data types (int, float, image2d_t, ...).
+// Its Child classes can represent concrete types (e.g.: VectorType) or
+// custom types (e.g.: GenType).
+// Instances of these child classes should be used in Builtin function
+// arguments.  See the definition of the "read_imagef" function as example.
 class Type {
-  // Name of the Type
+  // Name of the Type.
   string Name = _Name;
-  // QualType associated with this type
+  // QualType associated with this type.
   QualType QTName = _QTName;
-  // Size of the vector (if applicable)
-  int VecWidth = 0;
-  // Is pointer
+  // Size of the vector (if applicable).
+  int VecWidth = 1;
+  // Is a pointer.
   bit IsPointer = 0;
   // List of qualifiers associated with the type (volatile, ...)
   list QualList = [];
-  // Address space
-  string AddrSpace = "clang::LangAS::Default";
   // Access qualifier. Must be one of ("RO", "WO", "RW").
   string AccessQualifier = "";
+  // Address space.
+  string AddrSpace = "clang::LangAS::Default";
 }
 
 // OpenCL vector types (e.g. int2, int3, int16, float8, ...)
@@ -78,7 +92,7 @@ class VectorType :
   Type<_Ty.Name, _Ty.QTName> {
   bit IsPointer = 1;
@@ -91,6 +105,50 @@ class ImageType _Type> {
+  string Name = _Name;
+  list List = _Type;
+}
+
+// A GenericType is an abstract type that defines a set of types as a
+// combination of Types and vector sizes.
+//
+// E.g.: If TypeList =  and VectorList = <1, 2, 4>, then it
+//   represents .
+// _Ty  : Name of the GenType.
+// _TypeList: List of basic data Types.
+// _VectorList  : Sizes of the vector for each type of the _TypeList, 1 being a
+//scalar.
+//
+// Some rules apply when using multiple GenericType arguments in a declaration:
+//   1. The number of vector sizes must be equal or 1 for all gentypes in a
+//  declaration.
+//   2. The number of Types must be equal or 1 for all gentypes in a
+//  declaration.
+//   3. Generic types are combined by iterating over all generic types at once.
+//  For example, for the following GenericTypes
+//GenT1 = GenericType and
+//GenT2 = GenericType
+//  A declaration f(GenT1, GenT2) results in the combinations
+//f(half, float), f(half2, float2), f(half, int), f(half2, int2) .
+//   4. "sgentype" from the OpenCL specification is supported by specifying
+//  a single vector size.
+//  For example, for the following GenericTypes
+//GenT = GenericType and
+//

r369373 - [OpenCL] Add const, volatile and pointer builtin handling

2019-08-20 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Aug 20 05:21:03 2019
New Revision: 369373

URL: http://llvm.org/viewvc/llvm-project?rev=369373&view=rev
Log:
[OpenCL] Add const, volatile and pointer builtin handling

Const, volatile, and pointer types were previously available, but not
working.  This patch adds handling for OpenCL builtin functions.

Add TableGen definitions for some atomic and asynchronous builtins to
make use of the new functionality.

Patch by Pierre Gondois and Sven van Haastregt.

Differential Revision: https://reviews.llvm.org/D63442

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=369373&r1=369372&r2=369373&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Tue Aug 20 05:21:03 2019
@@ -51,11 +51,6 @@ class QualType {
-  string QualName = _QualName;
-}
-
 // List of integers.
 class IntList _List> {
   string Name = _Name;
@@ -79,24 +74,59 @@ class Type QualList = [];
+  // "const" qualifier.
+  bit IsConst = 0;
+  // "volatile" qualifier.
+  bit IsVolatile = 0;
   // Access qualifier. Must be one of ("RO", "WO", "RW").
   string AccessQualifier = "";
   // Address space.
-  string AddrSpace = "clang::LangAS::Default";
+  string AddrSpace = DefaultAS.Name;
 }
 
-// OpenCL vector types (e.g. int2, int3, int16, float8, ...)
+// OpenCL vector types (e.g. int2, int3, int16, float8, ...).
 class VectorType : Type<_Ty.Name, _Ty.QTName> {
-  int VecWidth = _VecWidth;
+  let VecWidth = _VecWidth;
+  // Inherited fields
+  let IsPointer = _Ty.IsPointer;
+  let IsConst = _Ty.IsConst;
+  let IsVolatile = _Ty.IsVolatile;
+  let AccessQualifier = _Ty.AccessQualifier;
+  let AddrSpace = _Ty.AddrSpace;
 }
 
 // OpenCL pointer types (e.g. int*, float*, ...).
-class PointerType :
+class PointerType :
   Type<_Ty.Name, _Ty.QTName> {
-  bit IsPointer = 1;
-  string AddrSpace = _AS.Name;
+  let AddrSpace = _AS.Name;
+  // Inherited fields
+  let VecWidth = _Ty.VecWidth;
+  let IsPointer = 1;
+  let IsConst = _Ty.IsConst;
+  let IsVolatile = _Ty.IsVolatile;
+  let AccessQualifier = _Ty.AccessQualifier;
+}
+
+// OpenCL const types (e.g. const int).
+class ConstType : Type<_Ty.Name, _Ty.QTName> {
+  let IsConst = 1;
+  // Inherited fields
+  let VecWidth = _Ty.VecWidth;
+  let IsPointer = _Ty.IsPointer;
+  let IsVolatile = _Ty.IsVolatile;
+  let AccessQualifier = _Ty.AccessQualifier;
+  let AddrSpace = _Ty.AddrSpace;
+}
+
+// OpenCL volatile types (e.g. volatile int).
+class VolatileType : Type<_Ty.Name, _Ty.QTName> {
+  let IsVolatile = 1;
+  // Inherited fields
+  let VecWidth = _Ty.VecWidth;
+  let IsPointer = _Ty.IsPointer;
+  let IsConst = _Ty.IsConst;
+  let AccessQualifier = _Ty.AccessQualifier;
+  let AddrSpace = _Ty.AddrSpace;
 }
 
 // OpenCL image types (e.g. image2d_t, ...)
@@ -242,12 +272,16 @@ def VecNoScalar : IntList<"VecNoScalar",
 def Vec1: IntList<"Vec1", [1]>;
 
 // Type lists.
+def TLAll   : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, 
ULong, Float, Double, Half]>;
 def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>;
 
 def TLAllInts : TypeList<"TLAllInts", [Char, UChar, Short, UShort, Int, UInt, 
Long, ULong]>;
 
 // GenType definitions for multiple base types (e.g. all floating point types,
 // or all integer types).
+// All types
+def AGenTypeN  : GenericType<"AGenTypeN", TLAll, VecAndScalar>;
+def AGenTypeNNoScalar  : GenericType<"AGenTypeNNoScalar", TLAll, 
VecNoScalar>;
 // All integer
 def AIGenType1 : GenericType<"AIGenType1", TLAllInts, Vec1>;
 def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, 
VecAndScalar>;
@@ -294,6 +328,44 @@ foreach RType = [Float, Double, Half, Ch
   }
 }
 
+//
+// OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10: Async Copies from 
Global to Local Memory, Local to Global Memory, and Prefetch
+// OpenCL Extension v2.0 s5.1.7 and s6.1.7: Async Copies from Global to Local 
Memory, Local to Global Memory, and Prefetch
+// --- Table 18 ---
+foreach name = ["async_work_group_copy"] in {
+  def : Builtin, 
PointerType, GlobalAS>, Size, Event]>;
+  def : Builtin, 
PointerType, LocalAS>, Size, Event]>;
+}
+foreach name = ["async_work_group_strided_copy"] in {
+  def : Builtin, 
PointerType, GlobalAS>, Size, Size, Event]>;
+  def : Builtin, 
PointerType, LocalAS>, Size, Size, Event]>;
+}
+foreach name = ["wait_group_events"] in {
+  def : Builtin]>;
+}
+foreach name = ["prefetch"] in {
+  def : Builtin, GlobalAS>, 
Size]>;
+}
+
+//
+// OpenCL v2.0 s6.13.11 - Atomics

r364021 - [cmake] Add llvm-dwarfdump to clang test dependencies

2019-06-21 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri Jun 21 03:26:20 2019
New Revision: 364021

URL: http://llvm.org/viewvc/llvm-project?rev=364021&view=rev
Log:
[cmake] Add llvm-dwarfdump to clang test dependencies

Commit r363496 ("[Clang] Harmonize Split DWARF options with llc",
2019-06-15) introduced the use of llvm-dwarfdump in the clang tests,
so ensure the clang tests are dependent on llvm-dwarfdump.

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=364021&r1=364020&r2=364021&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Fri Jun 21 03:26:20 2019
@@ -106,6 +106,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-cat
 llvm-cxxfilt
 llvm-dis
+llvm-dwarfdump
 llvm-lto2
 llvm-modextract
 llvm-nm


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


r364020 - [OpenCL] Remove duplicate read_image declarations

2019-06-21 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri Jun 21 03:26:10 2019
New Revision: 364020

URL: http://llvm.org/viewvc/llvm-project?rev=364020&view=rev
Log:
[OpenCL] Remove duplicate read_image declarations

Patch by Pierre Gondois.

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=364020&r1=364019&r2=364020&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Fri Jun 21 03:26:10 2019
@@ -14390,30 +14390,6 @@ float4 __purefn __ovld read_imagef(read_
 int4 __purefn __ovld read_imagei(read_only image3d_t image, sampler_t sampler, 
float4 coord, float4 gradientX, float4 gradientY);
 uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t 
sampler, float4 coord, float4 gradientX, float4 gradientY);
 
-float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t 
sampler, float coord, float lod);
-int4 __purefn __ovld read_imagei(read_only image1d_t image, sampler_t sampler, 
float coord, float lod);
-uint4 __purefn __ovld read_imageui(read_only image1d_t image, sampler_t 
sampler, float coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_only image1d_array_t image_array, 
sampler_t sampler, float2 coord, float lod);
-int4 __purefn __ovld read_imagei(read_only image1d_array_t image_array, 
sampler_t sampler, float2 coord, float lod);
-uint4 __purefn __ovld read_imageui(read_only image1d_array_t image_array, 
sampler_t sampler, float2 coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t 
sampler, float2 coord, float lod);
-int4 __purefn __ovld read_imagei(read_only image2d_t image, sampler_t sampler, 
float2 coord, float lod);
-uint4 __purefn __ovld read_imageui(read_only image2d_t image, sampler_t 
sampler, float2 coord, float lod);
-
-float __purefn __ovld read_imagef(read_only image2d_depth_t image, sampler_t 
sampler, float2 coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord, float lod);
-int4 __purefn __ovld read_imagei(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord, float lod);
-uint4 __purefn __ovld read_imageui(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord, float lod);
-
-float __purefn __ovld read_imagef(read_only image2d_array_depth_t image, 
sampler_t sampler, float4 coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_only image3d_t image, sampler_t 
sampler, float4 coord, float lod);
-int4 __purefn __ovld read_imagei(read_only image3d_t image, sampler_t sampler, 
float4 coord, float lod);
-uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t 
sampler, float4 coord, float lod);
-
 #endif //cl_khr_mipmap_image
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
@@ -14573,29 +14549,6 @@ float4 __purefn __ovld read_imagef(read_
 int4 __purefn __ovld read_imagei(read_write image3d_t image, sampler_t 
sampler, float4 coord, float4 gradientX, float4 gradientY);
 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t 
sampler, float4 coord, float4 gradientX, float4 gradientY);
 
-float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t 
sampler, float coord, float lod);
-int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t 
sampler, float coord, float lod);
-uint4 __purefn __ovld read_imageui(read_write image1d_t image, sampler_t 
sampler, float coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_write image1d_array_t image_array, 
sampler_t sampler, float2 coord, float lod);
-int4 __purefn __ovld read_imagei(read_write image1d_array_t image_array, 
sampler_t sampler, float2 coord, float lod);
-uint4 __purefn __ovld read_imageui(read_write image1d_array_t image_array, 
sampler_t sampler, float2 coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_write image2d_t image, sampler_t 
sampler, float2 coord, float lod);
-int4 __purefn __ovld read_imagei(read_write image2d_t image, sampler_t 
sampler, float2 coord, float lod);
-uint4 __purefn __ovld read_imageui(read_write image2d_t image, sampler_t 
sampler, float2 coord, float lod);
-
-float __purefn __ovld read_imagef(read_write image2d_depth_t image, sampler_t 
sampler, float2 coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_write image2d_array_t image_array, 
sampler_t sampler, float4 coord, float lod);
-int4 __purefn __ovld read_imagei(read_write image2d_array_t image_array, 
sampler_t sampler, float4 coord, float lod);
-uint4 __purefn __ovld read_imageui(read_write image2d_array_t image_array, 
sampler_t sampler, float4 coord, float lod);
-
-float __purefn __ovld read_imagef(read_write image2d_array_depth_t image, 
sampler_t sampler, float4 coord, float lod);
-
-float4 __purefn __ovld read_imagef(read_write image3d_t image, sample

r364174 - [OpenCL] Restore ATOMIC_VAR_INIT

2019-06-24 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Jun 24 03:06:40 2019
New Revision: 364174

URL: http://llvm.org/viewvc/llvm-project?rev=364174&view=rev
Log:
[OpenCL] Restore ATOMIC_VAR_INIT

We accidentally lost the ATOMIC_VAR_INIT and ATOMIC_FLAG_INIT macros
in r363794.

Also put the `memory_order` typedef back inside a `>= CL2.0` guard.

Modified:
cfe/trunk/lib/Headers/opencl-c-base.h
cfe/trunk/test/Headers/opencl-c-header.cl

Modified: cfe/trunk/lib/Headers/opencl-c-base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c-base.h?rev=364174&r1=364173&r2=364174&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c-base.h (original)
+++ cfe/trunk/lib/Headers/opencl-c-base.h Mon Jun 24 03:06:40 2019
@@ -297,8 +297,11 @@ typedef enum memory_scope {
  * image memory.
  */
 #define CLK_IMAGE_MEM_FENCE  0x04
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
+#ifndef ATOMIC_VAR_INIT
+#define ATOMIC_VAR_INIT(x) (x)
+#endif //ATOMIC_VAR_INIT
+#define ATOMIC_FLAG_INIT 0
 
 // enum values aligned with what clang uses in EmitAtomicExpr()
 typedef enum memory_order
@@ -310,6 +313,8 @@ typedef enum memory_order
   memory_order_seq_cst = __ATOMIC_SEQ_CST
 } memory_order;
 
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
+
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write 
Functions
 
 // These values need to match the runtime equivalent

Modified: cfe/trunk/test/Headers/opencl-c-header.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/opencl-c-header.cl?rev=364174&r1=364173&r2=364174&view=diff
==
--- cfe/trunk/test/Headers/opencl-c-header.cl (original)
+++ cfe/trunk/test/Headers/opencl-c-header.cl Mon Jun 24 03:06:40 2019
@@ -80,6 +80,10 @@ void test_atomics(__generic volatile uns
 }
 #endif
 
+// Verify that ATOMIC_VAR_INIT is defined.
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+global atomic_int z = ATOMIC_VAR_INIT(99);
+#endif //__OPENCL_C_VERSION__
 
 // Verify that non-builtin cl_intel_planar_yuv extension is defined from
 // OpenCL 1.2 onwards.


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


r364173 - [OpenCL] Remove more duplicates from opencl-c.h

2019-06-24 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Jun 24 03:06:34 2019
New Revision: 364173

URL: http://llvm.org/viewvc/llvm-project?rev=364173&view=rev
Log:
[OpenCL] Remove more duplicates from opencl-c.h

Identified the duplicate declarations using

  sort lib/Headers/opencl-c.h | uniq -c | grep '  2'

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=364173&r1=364172&r2=364173&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Mon Jun 24 03:06:34 2019
@@ -9347,8 +9347,6 @@ long8 __ovld __cnfn clamp(long8 x, long8
 ulong8 __ovld __cnfn clamp(ulong8 x, ulong8 minval, ulong8 maxval);
 long16 __ovld __cnfn clamp(long16 x, long16 minval, long16 maxval);
 ulong16 __ovld __cnfn clamp(ulong16 x, ulong16 minval, ulong16 maxval);
-char __ovld __cnfn clamp(char x, char minval, char maxval);
-uchar __ovld __cnfn clamp(uchar x, uchar minval, uchar maxval);
 char2 __ovld __cnfn clamp(char2 x, char minval, char maxval);
 uchar2 __ovld __cnfn clamp(uchar2 x, uchar minval, uchar maxval);
 char3 __ovld __cnfn clamp(char3 x, char minval, char maxval);
@@ -9359,8 +9357,6 @@ char8 __ovld __cnfn clamp(char8 x, char
 uchar8 __ovld __cnfn clamp(uchar8 x, uchar minval, uchar maxval);
 char16 __ovld __cnfn clamp(char16 x, char minval, char maxval);
 uchar16 __ovld __cnfn clamp(uchar16 x, uchar minval, uchar maxval);
-short __ovld __cnfn clamp(short x, short minval, short maxval);
-ushort __ovld __cnfn clamp(ushort x, ushort minval, ushort maxval);
 short2 __ovld __cnfn clamp(short2 x, short minval, short maxval);
 ushort2 __ovld __cnfn clamp(ushort2 x, ushort minval, ushort maxval);
 short3 __ovld __cnfn clamp(short3 x, short minval, short maxval);
@@ -9371,8 +9367,6 @@ short8 __ovld __cnfn clamp(short8 x, sho
 ushort8 __ovld __cnfn clamp(ushort8 x, ushort minval, ushort maxval);
 short16 __ovld __cnfn clamp(short16 x, short minval, short maxval);
 ushort16 __ovld __cnfn clamp(ushort16 x, ushort minval, ushort maxval);
-int __ovld __cnfn clamp(int x, int minval, int maxval);
-uint __ovld __cnfn clamp(uint x, uint minval, uint maxval);
 int2 __ovld __cnfn clamp(int2 x, int minval, int maxval);
 uint2 __ovld __cnfn clamp(uint2 x, uint minval, uint maxval);
 int3 __ovld __cnfn clamp(int3 x, int minval, int maxval);
@@ -9383,8 +9377,6 @@ int8 __ovld __cnfn clamp(int8 x, int min
 uint8 __ovld __cnfn clamp(uint8 x, uint minval, uint maxval);
 int16 __ovld __cnfn clamp(int16 x, int minval, int maxval);
 uint16 __ovld __cnfn clamp(uint16 x, uint minval, uint maxval);
-long __ovld __cnfn clamp(long x, long minval, long maxval);
-ulong __ovld __cnfn clamp(ulong x, ulong minval, ulong maxval);
 long2 __ovld __cnfn clamp(long2 x, long minval, long maxval);
 ulong2 __ovld __cnfn clamp(ulong2 x, ulong minval, ulong maxval);
 long3 __ovld __cnfn clamp(long3 x, long minval, long maxval);
@@ -9660,8 +9652,6 @@ long8 __ovld __cnfn max(long8 x, long8 y
 ulong8 __ovld __cnfn max(ulong8 x, ulong8 y);
 long16 __ovld __cnfn max(long16 x, long16 y);
 ulong16 __ovld __cnfn max(ulong16 x, ulong16 y);
-char __ovld __cnfn max(char x, char y);
-uchar __ovld __cnfn max(uchar x, uchar y);
 char2 __ovld __cnfn max(char2 x, char y);
 uchar2 __ovld __cnfn max(uchar2 x, uchar y);
 char3 __ovld __cnfn max(char3 x, char y);
@@ -9672,8 +9662,6 @@ char8 __ovld __cnfn max(char8 x, char y)
 uchar8 __ovld __cnfn max(uchar8 x, uchar y);
 char16 __ovld __cnfn max(char16 x, char y);
 uchar16 __ovld __cnfn max(uchar16 x, uchar y);
-short __ovld __cnfn max(short x, short y);
-ushort __ovld __cnfn max(ushort x, ushort y);
 short2 __ovld __cnfn max(short2 x, short y);
 ushort2 __ovld __cnfn max(ushort2 x, ushort y);
 short3 __ovld __cnfn max(short3 x, short y);
@@ -9684,8 +9672,6 @@ short8 __ovld __cnfn max(short8 x, short
 ushort8 __ovld __cnfn max(ushort8 x, ushort y);
 short16 __ovld __cnfn max(short16 x, short y);
 ushort16 __ovld __cnfn max(ushort16 x, ushort y);
-int __ovld __cnfn max(int x, int y);
-uint __ovld __cnfn max(uint x, uint y);
 int2 __ovld __cnfn max(int2 x, int y);
 uint2 __ovld __cnfn max(uint2 x, uint y);
 int3 __ovld __cnfn max(int3 x, int y);
@@ -9696,8 +9682,6 @@ int8 __ovld __cnfn max(int8 x, int y);
 uint8 __ovld __cnfn max(uint8 x, uint y);
 int16 __ovld __cnfn max(int16 x, int y);
 uint16 __ovld __cnfn max(uint16 x, uint y);
-long __ovld __cnfn max(long x, long y);
-ulong __ovld __cnfn max(ulong x, ulong y);
 long2 __ovld __cnfn max(long2 x, long y);
 ulong2 __ovld __cnfn max(ulong2 x, ulong y);
 long3 __ovld __cnfn max(long3 x, long y);
@@ -9760,8 +9744,6 @@ long8 __ovld __cnfn min(long8 x, long8 y
 ulong8 __ovld __cnfn min(ulong8 x, ulong8 y);
 long16 __ovld __cnfn min(long16 x, long16 y);
 ulong16 __ovld __cnfn min(ulong16 x, ulong16 y);
-char __ovld __cnfn min(char x, char y);
-uchar __ovld __cnfn min(uchar x, uchar y);
 char

r364423 - [OpenCL] Improve diagnostic for placement new

2019-06-26 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed Jun 26 06:31:24 2019
New Revision: 364423

URL: http://llvm.org/viewvc/llvm-project?rev=364423&view=rev
Log:
[OpenCL] Improve diagnostic for placement new

Without an explicit declaration for placement new, clang would reject
uses of placement new with "'default new' is not supported in OpenCL
C++".  This may mislead users into thinking that placement new is not
supported, see e.g. PR42060.

Clarify that placement new requires an explicit declaration.

Differential Revision: https://reviews.llvm.org/D63561

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaOpenCLCXX/newdelete.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=364423&r1=364422&r2=364423&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 26 06:31:24 
2019
@@ -8809,6 +8809,9 @@ def ext_opencl_ext_vector_type_rgba_sele
   "vector component name '%0' is an OpenCL version 2.2 feature">,
   InGroup;
 
+def err_openclcxx_placement_new : Error<
+  "use of placement new requires explicit declaration">;
+
 // MIG routine annotations.
 def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
   "'mig_server_routine' attribute only applies to routines that return a 
kern_return_t">,

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=364423&r1=364422&r2=364423&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jun 26 06:31:24 2019
@@ -2413,7 +2413,11 @@ bool Sema::FindAllocationFunctions(Sourc
 }
 
 if (getLangOpts().OpenCLCPlusPlus && R.empty()) {
-  Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  if (PlaceArgs.empty()) {
+Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  } else {
+Diag(StartLoc, diag::err_openclcxx_placement_new);
+  }
   return true;
 }
 

Modified: cfe/trunk/test/SemaOpenCLCXX/newdelete.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/newdelete.cl?rev=364423&r1=364422&r2=364423&view=diff
==
--- cfe/trunk/test/SemaOpenCLCXX/newdelete.cl (original)
+++ cfe/trunk/test/SemaOpenCLCXX/newdelete.cl Wed Jun 26 06:31:24 2019
@@ -21,7 +21,7 @@ class B {
 void test_default_new_delete(void *buffer, A **pa) {
   A *a = new A; // expected-error {{'default new' is not supported in 
OpenCL C++}}
   delete a; // expected-error {{'default delete' is not supported 
in OpenCL C++}}
-  *pa = new (buffer) A; // expected-error {{'default new' is not supported in 
OpenCL C++}}
+  *pa = new (buffer) A; // expected-error {{use of placement new requires 
explicit declaration}}
 }
 
 // expected-note@+1 {{candidate function not viable: requires 2 arguments, but 
1 was provided}}


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


r361004 - [NFC] Fix line endings in OpenCL tests

2019-05-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri May 17 02:25:38 2019
New Revision: 361004

URL: http://llvm.org/viewvc/llvm-project?rev=361004&view=rev
Log:
[NFC] Fix line endings in OpenCL tests

Modified:
cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
cfe/trunk/test/SemaOpenCL/array-init.cl

Modified: cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl?rev=361004&r1=361003&r2=361004&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/no-signed-zeros.cl Fri May 17 02:25:38 2019
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NORMAL
-// RUN: %clang_cc1 %s -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s 
-check-prefix=NO-SIGNED-ZEROS
-
-float signedzeros(float a) {
-  return a;
-}
-
-// CHECK: attributes
-// NORMAL: "no-signed-zeros-fp-math"="false"
-// NO-SIGNED-ZEROS: "no-signed-zeros-fp-math"="true"
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NORMAL
+// RUN: %clang_cc1 %s -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s 
-check-prefix=NO-SIGNED-ZEROS
+
+float signedzeros(float a) {
+  return a;
+}
+
+// CHECK: attributes
+// NORMAL: "no-signed-zeros-fp-math"="false"
+// NO-SIGNED-ZEROS: "no-signed-zeros-fp-math"="true"

Modified: cfe/trunk/test/SemaOpenCL/array-init.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/array-init.cl?rev=361004&r1=361003&r2=361004&view=diff
==
--- cfe/trunk/test/SemaOpenCL/array-init.cl (original)
+++ cfe/trunk/test/SemaOpenCL/array-init.cl Fri May 17 02:25:38 2019
@@ -1,20 +1,20 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
-// expected-no-diagnostics
-
-__kernel void k1(queue_t q1, queue_t q2) {
-  queue_t q[] = {q1, q2};
-}
-
-__kernel void k2(read_only pipe int p) {
-  reserve_id_t i1 = reserve_read_pipe(p, 1);
-  reserve_id_t i2 = reserve_read_pipe(p, 1);
-  reserve_id_t i[] = {i1, i2};
-}
-
-event_t create_event();
-__kernel void k3() {
-  event_t e1 = create_event();
-  event_t e2 = create_event();
-  event_t e[] = {e1, e2};
-}
-
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// expected-no-diagnostics
+
+__kernel void k1(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};
+}
+
+__kernel void k2(read_only pipe int p) {
+  reserve_id_t i1 = reserve_read_pipe(p, 1);
+  reserve_id_t i2 = reserve_read_pipe(p, 1);
+  reserve_id_t i[] = {i1, i2};
+}
+
+event_t create_event();
+__kernel void k3() {
+  event_t e1 = create_event();
+  event_t e2 = create_event();
+  event_t e[] = {e1, e2};
+}
+


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


r361382 - [OpenCL] Support pipe keyword in C++ mode

2019-05-22 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed May 22 06:12:20 2019
New Revision: 361382

URL: http://llvm.org/viewvc/llvm-project?rev=361382&view=rev
Log:
[OpenCL] Support pipe keyword in C++ mode

Support the OpenCL C pipe feature in C++ for OpenCL mode, to preserve
backwards compatibility with OpenCL C.

Various changes had to be made in Parse and Sema to enable
pipe-specific diagnostics, so enable a SemaOpenCL test for C++.

Differential Revision: https://reviews.llvm.org/D62181

Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Basic/Builtins.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=361382&r1=361381&r2=361382&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed May 22 06:12:20 2019
@@ -568,7 +568,7 @@ KEYWORD(vec_step, KE
 // OpenMP Type Traits
 KEYWORD(__builtin_omp_required_simd_align, KEYALL)
 
-KEYWORD(pipe, KEYOPENCLC)
+KEYWORD(pipe, KEYOPENCLC | KEYOPENCLCXX)
 
 // Borland Extensions.
 KEYWORD(__pascal, KEYALL)

Modified: cfe/trunk/lib/Basic/Builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Builtins.cpp?rev=361382&r1=361381&r2=361382&view=diff
==
--- cfe/trunk/lib/Basic/Builtins.cpp (original)
+++ cfe/trunk/lib/Basic/Builtins.cpp Wed May 22 06:12:20 2019
@@ -70,8 +70,9 @@ bool Builtin::Context::builtinIsSupporte
   bool ObjCUnsupported = !LangOpts.ObjC && BuiltinInfo.Langs == OBJC_LANG;
   bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 &&
   (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES ) ==  
OCLC1X_LANG;
-  bool OclC2Unsupported = LangOpts.OpenCLVersion != 200 &&
-  (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == 
OCLC20_LANG;
+  bool OclC2Unsupported =
+  (LangOpts.OpenCLVersion != 200 && !LangOpts.OpenCLCPlusPlus) &&
+  (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC20_LANG;
   bool OclCUnsupported = !LangOpts.OpenCL &&
  (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES);
   bool OpenMPUnsupported = !LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG;

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=361382&r1=361381&r2=361382&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed May 22 06:12:20 2019
@@ -2560,6 +2560,11 @@ bool Parser::ParseImplicitInt(DeclSpec &
 return false;
   }
 
+  // Early exit as Sema has a dedicated missing_actual_pipe_type diagnostic
+  // for incomplete declarations such as `pipe p`.
+  if (getLangOpts().OpenCLCPlusPlus && DS.isTypeSpecPipe())
+return false;
+
   if (getLangOpts().CPlusPlus &&
   DS.getStorageClassSpec() == DeclSpec::SCS_auto) {
 // Don't require a type specifier if we have the 'auto' storage class
@@ -3769,7 +3774,8 @@ void Parser::ParseDeclarationSpecifiers(
   isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy);
   break;
 case tok::kw_pipe:
-  if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200)) {
+  if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200 &&
+!getLangOpts().OpenCLCPlusPlus)) {
 // OpenCL 2.0 defined this keyword. OpenCL 1.2 and earlier should
 // support the "pipe" word as identifier.
 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
@@ -4896,7 +4902,8 @@ bool Parser::isDeclarationSpecifier(bool
   default: return false;
 
   case tok::kw_pipe:
-return getLangOpts().OpenCL && (getLangOpts().OpenCLVersion >= 200);
+return (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) ||
+   getLangOpts().OpenCLCPlusPlus;
 
   case tok::identifier:   // foo::bar
 // Unfortunate hack to support "Class.factoryMethod" notation.
@@ -5384,7 +5391,8 @@ static bool isPtrOperatorToken(tok::Toke
   if (Kind == tok::star || Kind == tok::caret)
 return true;
 
-  if ((Kind == tok::kw_pipe) && Lang.OpenCL && (Lang.OpenCLVersion >= 200))
+  if (Kind == tok::kw_pipe &&
+  ((Lang.OpenCL && Lang.OpenCLVersion >= 200) || Lang.OpenCLCPlusPlus))
 return true;
 
   if (!Lang.CPlusPlus)

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=361382&r1=361381&r2=361382&view=diff
===

r361467 - Enable queue_t and clk_event_t comparisons in C++ mode

2019-05-23 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu May 23 02:20:08 2019
New Revision: 361467

URL: http://llvm.org/viewvc/llvm-project?rev=361467&view=rev
Log:
Enable queue_t and clk_event_t comparisons in C++ mode

Support queue_t and clk_event_t comparisons in C++ for OpenCL mode, to
preserve backwards compatibility with OpenCL C.

Differential Revision: https://reviews.llvm.org/D62208

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaOpenCL/clk_event_t.cl

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=361467&r1=361466&r2=361467&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu May 23 02:20:08 2019
@@ -10808,7 +10808,7 @@ QualType Sema::CheckCompareOperands(Expr
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200) {
+  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }

Modified: cfe/trunk/test/SemaOpenCL/clk_event_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clk_event_t.cl?rev=361467&r1=361466&r2=361467&view=diff
==
--- cfe/trunk/test/SemaOpenCL/clk_event_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/clk_event_t.cl Thu May 23 02:20:08 2019
@@ -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=c++
 
 // Taken from opencl-c.h
 #define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))


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


r372119 - [OpenCL] Tidy up some comments; NFC

2019-09-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Sep 17 06:32:56 2019
New Revision: 372119

URL: http://llvm.org/viewvc/llvm-project?rev=372119&view=rev
Log:
[OpenCL] Tidy up some comments; NFC

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=372119&r1=372118&r2=372119&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Tue Sep 17 06:32:56 2019
@@ -61,10 +61,8 @@ class IntList _L
 //  OpenCL C classes for types
 
//===--===//
 // OpenCL C basic data types (int, float, image2d_t, ...).
-// Its Child classes can represent concrete types (e.g.: VectorType) or
-// custom types (e.g.: GenType).
-// Instances of these child classes should be used in Builtin function
-// arguments.  See the definition of the "read_imagef" function as example.
+// Its child classes can represent concrete types (e.g. VectorType) or
+// abstract types (e.g. GenType).
 class Type {
   // Name of the Type.
   string Name = _Name;
@@ -150,12 +148,8 @@ class TypeList
 // A GenericType is an abstract type that defines a set of types as a
 // combination of Types and vector sizes.
 //
-// E.g.: If TypeList =  and VectorList = <1, 2, 4>, then it
-//   represents .
-// _Ty  : Name of the GenType.
-// _TypeList: List of basic data Types.
-// _VectorList  : Sizes of the vector for each type of the _TypeList, 1 being a
-//scalar.
+// For example, if TypeList =  and VectorList = <1, 2, 4>, then it
+// represents .
 //
 // Some rules apply when using multiple GenericType arguments in a declaration:
 //   1. The number of vector sizes must be equal or 1 for all gentypes in a


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


r372321 - [OpenCL] Add version handling and add vector ld/st builtins

2019-09-19 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Sep 19 06:41:51 2019
New Revision: 372321

URL: http://llvm.org/viewvc/llvm-project?rev=372321&view=rev
Log:
[OpenCL] Add version handling and add vector ld/st builtins

Allow setting a MinVersion, stating from which OpenCL version a
builtin function is available, and a MaxVersion, stating from which
OpenCL version a builtin function should not be available anymore.

Guard some definitions of the "work-item" builtin functions according
to the OpenCL versions from which they are available.

Add the "vector data load and store" builtin functions (e.g.
vload/vstore), whose signatures differ before and after OpenCL 2.0 in
the pointer argument address spaces.

Patch by Pierre Gondois and Sven van Haastregt.

Differential Revision: https://reviews.llvm.org/D63504

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=372321&r1=372320&r2=372321&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Thu Sep 19 06:41:51 2019
@@ -20,12 +20,13 @@
 
//===--===//
 // Versions of OpenCL
 class Version {
-  int Version = _Version;
+  int ID = _Version;
 }
-def CL10: Version<100>;
-def CL11: Version<110>;
-def CL12: Version<120>;
-def CL20: Version<200>;
+def CLAll : Version<  0>;
+def CL10  : Version<100>;
+def CL11  : Version<110>;
+def CL12  : Version<120>;
+def CL20  : Version<200>;
 
 // Address spaces
 // Pointer types need to be assigned an address space.
@@ -191,8 +192,13 @@ class Builtin _
   list Signature = _Signature;
   // OpenCL Extension to which the function belongs (cl_khr_subgroups, ...)
   string Extension = "";
-  // OpenCL Version to which the function belongs (CL10, ...)
-  Version Version = CL10;
+  // Version of OpenCL from which the function is available (e.g.: CL10).
+  // MinVersion is inclusive.
+  Version MinVersion = CL10;
+  // Version of OpenCL from which the function is not supported anymore.
+  // MaxVersion is exclusive.
+  // CLAll makes the function available for all versions.
+  Version MaxVersion = CLAll;
 }
 
 
//===--===//
@@ -313,6 +319,137 @@ foreach RType = [Float, Double, Half, Ch
 }
 
 //
+// OpenCL v1.1 s6.11.1, v1.2 s6.12.1, v2.0 s6.13.1 - Work-item Functions
+// --- Table 7 ---
+def : Builtin<"get_work_dim", [UInt]>;
+foreach name = ["get_global_size", "get_global_id", "get_local_size",
+"get_local_id", "get_num_groups", "get_group_id",
+"get_global_offset"] in {
+  def : Builtin;
+}
+
+let MinVersion = CL20 in {
+  def : Builtin<"get_enqueued_local_size", [Size, UInt]>;
+  foreach name = ["get_global_linear_id", "get_local_linear_id"] in {
+def : Builtin;
+  }
+}
+
+//
+// OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and 
Store Functions
+// OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s9.4.6, v2.0 
s5.1.6 and 6.1.6 - Vector Data Load and Store Functions
+// --- Table 15 ---
+// Variants for OpenCL versions below 2.0, using pointers to the global, local
+// and private address spaces.
+let MaxVersion = CL20 in {
+  foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
+foreach VSize = [2, 3, 4, 8, 16] in {
+  foreach name = ["vload" # VSize] in {
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+  }
+  foreach name = ["vstore" # VSize] in {
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+def : Builtin, Size, 
PointerType, AS>]>;
+

r372614 - [docs] Fix some typos in InternalsManual

2019-09-23 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Sep 23 07:24:29 2019
New Revision: 372614

URL: http://llvm.org/viewvc/llvm-project?rev=372614&view=rev
Log:
[docs] Fix some typos in InternalsManual

Modified:
cfe/trunk/docs/InternalsManual.rst

Modified: cfe/trunk/docs/InternalsManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.rst?rev=372614&r1=372613&r2=372614&view=diff
==
--- cfe/trunk/docs/InternalsManual.rst (original)
+++ cfe/trunk/docs/InternalsManual.rst Mon Sep 23 07:24:29 2019
@@ -859,7 +859,7 @@ benefits:
 
 There are unfortunately exceptions to this general approach, such as:
 
-  * A the first declaration of a redeclarable entity maintains a pointer to the
+  * The first declaration of a redeclarable entity maintains a pointer to the
 most recent declaration of that entity, which naturally needs to change as
 more declarations are parsed.
   * Name lookup tables in declaration contexts change after the namespace
@@ -1913,7 +1913,7 @@ declarations like enums, classes, etc. i
 Therefore, we filter the lookup results and consider only those which have the
 same visibility as the declaration we currently import.
 
-We consider two declarations in two anonymous namsepaces to have the same
+We consider two declarations in two anonymous namespaces to have the same
 visibility only if they are imported from the same AST context.
 
 Strategies to Handle Conflicting Names
@@ -2134,7 +2134,7 @@ about them.
 
 Finally, this is not just a problem for semantic analysis.  The code generator
 and other clients have to be able to fold constants (e.g., to initialize global
-variables) and has to handle a superset of what C99 allows.  Further, these
+variables) and have to handle a superset of what C99 allows.  Further, these
 clients can benefit from extended information.  For example, we know that
 "``foo() || 1``" always evaluates to ``true``, but we can't replace the
 expression with ``true`` because it has side effects.


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


r372833 - [OpenCL] Add image query builtin functions

2019-09-25 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed Sep 25 02:12:59 2019
New Revision: 372833

URL: http://llvm.org/viewvc/llvm-project?rev=372833&view=rev
Log:
[OpenCL] Add image query builtin functions

Add the image query builtin functions from the OpenCL C specification.

Patch by Pierre Gondois and Sven van Haastregt.

Differential Revision: https://reviews.llvm.org/D67713

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=372833&r1=372832&r2=372833&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Wed Sep 25 02:12:59 2019
@@ -593,6 +593,31 @@ foreach aQual = ["WO", "RW"] in {
   def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Float]>;
 }
 
+// --- Table 25: Image Query Functions ---
+foreach aQual = ["RO", "WO", "RW"] in {
+  foreach imgTy = [Image1d, Image1dBuffer, Image2d, Image3d,
+   Image1dArray, Image2dArray, Image2dDepth,
+   Image2dArrayDepth] in {
+foreach name = ["get_image_width", "get_image_channel_data_type",
+"get_image_channel_order"] in {
+  def : Builtin]>;
+}
+  }
+  foreach imgTy = [Image2d, Image3d, Image2dArray, Image2dDepth,
+   Image2dArrayDepth] in {
+def : Builtin<"get_image_height", [Int, ImageType]>;
+  }
+  def : Builtin<"get_image_depth", [Int, ImageType]>;
+  foreach imgTy = [Image2d, Image2dArray, Image2dDepth,
+   Image2dArrayDepth] in {
+def : Builtin<"get_image_dim", [VectorType, ImageType]>;
+  }
+  def : Builtin<"get_image_dim", [VectorType, ImageType]>;
+  foreach imgTy = [Image1dArray, Image2dArray, Image2dArrayDepth] in {
+def : Builtin<"get_image_array_size", [Size, ImageType]>;
+  }
+}
+
 // OpenCL extension v2.0 s5.1.9: Built-in Image Read Functions
 // --- Table 8 ---
 foreach aQual = ["RO"] in {

Modified: cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl?rev=372833&r1=372832&r2=372833&view=diff
==
--- cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl (original)
+++ cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl Wed Sep 25 02:12:59 
2019
@@ -71,6 +71,8 @@ kernel void basic_image_readonly(read_on
   resf = read_imagef(image_read_only_image2d, i2);
   res = read_imageh(image_read_only_image2d, i2);
   res = read_imageh(image_read_only_image2d, sampler, i2);
+
+  int imgWidth = get_image_width(image_read_only_image2d);
 }
 
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
@@ -79,6 +81,8 @@ kernel void basic_image_readwrite(read_w
   int4 i4;
 
   write_imageh(image_read_write_image3d, i4, h4);
+
+  int imgDepth = get_image_depth(image_read_write_image3d);
 }
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 


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


r372975 - [OpenCL] Add -Wconversion to fdeclare-opencl-builtins test

2019-09-26 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Sep 26 06:31:36 2019
New Revision: 372975

URL: http://llvm.org/viewvc/llvm-project?rev=372975&view=rev
Log:
[OpenCL] Add -Wconversion to fdeclare-opencl-builtins test

Add the -Wconversion -Werror options to check no unexpected conversion
is done.

Patch by Pierre Gondois and Sven van Haastregt.

Differential Revision: https://reviews.llvm.org/D67714

Modified:
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Modified: cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl?rev=372975&r1=372974&r2=372975&view=diff
==
--- cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl (original)
+++ cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl Thu Sep 26 06:31:36 
2019
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL 
-fdeclare-opencl-builtins -DNO_HEADER
-// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL 
-fdeclare-opencl-builtins -finclude-default-header
-// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only 
-cl-std=CL1.2 -fdeclare-opencl-builtins -DNO_HEADER
-// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only 
-cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
-// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only 
-cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
-// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only 
-cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
 
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 // expected-no-diagnostics
@@ -99,6 +99,7 @@ kernel void basic_subgroup(global uint *
   out[0] = get_sub_group_size();
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is 
invalid in OpenCL}}
+// expected-error@-3{{implicit conversion changes signedness: 'int' to 'uint' 
(aka 'unsigned int')}}
 #endif
 }
 


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


r373088 - [OpenCL] Pass LangOptions as const ref

2019-09-27 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri Sep 27 06:31:29 2019
New Revision: 373088

URL: http://llvm.org/viewvc/llvm-project?rev=373088&view=rev
Log:
[OpenCL] Pass LangOptions as const ref

Modified:
cfe/trunk/include/clang/Basic/OpenCLOptions.h

Modified: cfe/trunk/include/clang/Basic/OpenCLOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLOptions.h?rev=373088&r1=373087&r2=373088&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLOptions.h (original)
+++ cfe/trunk/include/clang/Basic/OpenCLOptions.h Fri Sep 27 06:31:29 2019
@@ -42,7 +42,7 @@ public:
 
   // Is supported as either an extension or an (optional) core feature for
   // OpenCL version \p CLVer.
-  bool isSupported(llvm::StringRef Ext, LangOptions LO) const {
+  bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const {
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
 auto I = OptMap.find(Ext)->getValue();
@@ -51,7 +51,7 @@ public:
 
   // Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
   // For supported extension, return false.
-  bool isSupportedCore(llvm::StringRef Ext, LangOptions LO) const {
+  bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const {
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
 auto I = OptMap.find(Ext)->getValue();
@@ -60,7 +60,7 @@ public:
 
   // Is supported OpenCL extension for OpenCL version \p CLVer.
   // For supported (optional) core feature, return false.
-  bool isSupportedExtension(llvm::StringRef Ext, LangOptions LO) const {
+  bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const {
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
 auto I = OptMap.find(Ext)->getValue();


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


r330579 - [OpenCL] Reject virtual functions for OpenCL C++

2018-04-23 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Apr 23 04:23:47 2018
New Revision: 330579

URL: http://llvm.org/viewvc/llvm-project?rev=330579&view=rev
Log:
[OpenCL] Reject virtual functions for OpenCL C++

Differential Revision: https://reviews.llvm.org/D45873

Added:
cfe/trunk/test/Parser/opencl-cxx-virtual.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr 23 04:23:47 
2018
@@ -1073,6 +1073,10 @@ def err_opencl_taking_function_address_p
 def err_opencl_logical_exclusive_or : Error<
   "^^ is a reserved operator in OpenCL">;
 
+// OpenCL C++.
+def err_openclcxx_virtual_function : Error<
+  "virtual functions are not supported in OpenCL C++">;
+
 // OpenMP support.
 def warn_pragma_omp_ignored : Warning<
   "unexpected '#pragma omp ...' in program">, InGroup, 
DefaultIgnore;

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Apr 23 04:23:47 2018
@@ -189,6 +189,7 @@ LANGOPT(ShortEnums, 1, 0, "short
 
 LANGOPT(OpenCL, 1, 0, "OpenCL")
 LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
+LANGOPT(OpenCLCPlusPlus   , 1, 0, "OpenCL C++")
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "OpenCL C++ version")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")
 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Apr 23 04:23:47 2018
@@ -1927,6 +1927,7 @@ void CompilerInvocation::setLangDefaults
 Opts.setDefaultFPContractMode(LangOptions::FPC_On);
 Opts.NativeHalfType = 1;
 Opts.NativeHalfArgsAndReturns = 1;
+Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
 // Include default header file for OpenCL.
 if (Opts.IncludeDefaultHeader) {
   PPOpts.Includes.push_back("opencl-c.h");

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=330579&r1=330578&r2=330579&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 23 04:23:47 2018
@@ -3466,7 +3466,15 @@ void Parser::ParseDeclarationSpecifiers(
   isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID);
   break;
 case tok::kw_virtual:
-  isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID);
+  // OpenCL C++ v1.0 s2.9: the virtual function qualifier is not supported.
+  if (getLangOpts().OpenCLCPlusPlus) {
+DiagID = diag::err_openclcxx_virtual_function;
+PrevSpec = Tok.getIdentifierInfo()->getNameStart();
+isInvalid = true;
+  }
+  else {
+isInvalid = DS.setFunctionSpecVirtual(Loc, PrevSpec, DiagID);
+  }
   break;
 case tok::kw_explicit:
   isInvalid = DS.setFunctionSpecExplicit(Loc, PrevSpec, DiagID);

Added: cfe/trunk/test/Parser/opencl-cxx-virtual.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-cxx-virtual.cl?rev=330579&view=auto
==
--- cfe/trunk/test/Parser/opencl-cxx-virtual.cl (added)
+++ cfe/trunk/test/Parser/opencl-cxx-virtual.cl Mon Apr 23 04:23:47 2018
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -fsyntax-only 
-verify
+
+// Test that virtual functions and abstract classes are rejected.
+class virtual_functions {
+  virtual void bad1() {}
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+
+  virtual void bad2() = 0;
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+  //expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}}
+};
+
+template 
+class X {
+  virtual T f();
+  //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
+};
+
+// Test 

r330721 - [OpenCL] Fix diagnostic of thread_local

2018-04-24 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Apr 24 07:47:29 2018
New Revision: 330721

URL: http://llvm.org/viewvc/llvm-project?rev=330721&view=rev
Log:
[OpenCL] Fix diagnostic of thread_local

Commit 08c258670c ("[OpenCL] Generic address space has been added in
OpenCL v2.0.", 2014-11-26) did not mark the thread_local keyword as a
storage class specifier, whereas it did mark _Thread_local as such.
According to the C++14 spec s7.1.1, thread_local is a storage class
specifier, so mark it as such.

I will add a test for this in a follow-up commit that adds keyword
restrictions to the OpenCL C++ language mode.

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=330721&r1=330720&r2=330721&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Apr 24 07:47:29 2018
@@ -3454,6 +3454,7 @@ void Parser::ParseDeclarationSpecifiers(
 case tok::kw_thread_local:
   isInvalid = DS.SetStorageClassSpecThread(DeclSpec::TSCS_thread_local, 
Loc,
PrevSpec, DiagID);
+  isStorageClass = true;
   break;
 case tok::kw__Thread_local:
   isInvalid = DS.SetStorageClassSpecThread(DeclSpec::TSCS__Thread_local,


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


r331026 - [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-27 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Fri Apr 27 03:37:04 2018
New Revision: 331026

URL: http://llvm.org/viewvc/llvm-project?rev=331026&view=rev
Log:
[OpenCL] Add separate read_only and write_only pipe IR types

SPIR-V encodes the read_only and write_only access qualifiers of pipes,
so separate LLVM IR types are required to target SPIR-V.  Other backends
may also find this useful.

These new types are `opencl.pipe_ro_t` and `opencl.pipe_wo_t`, which
replace `opencl.pipe_t`.

This replaces __get_pipe_num_packets(...) and __get_pipe_max_packets(...)
which took a read_only pipe with separate versions for read_only and
write_only pipes, namely:

 * __get_pipe_num_packets_ro(...)
 * __get_pipe_num_packets_wo(...)
 * __get_pipe_max_packets_ro(...)
 * __get_pipe_max_packets_wo(...)

These separate versions exist to avoid needing a bitcast to one of the
two qualified pipe types.

Patch by Stuart Brady.

Differential Revision: https://reviews.llvm.org/D46015

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
cfe/trunk/test/CodeGenOpenCL/pipe_types.cl
cfe/trunk/test/Index/pipe-size.cl

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=331026&r1=331025&r2=331026&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Apr 27 03:37:04 2018
@@ -3051,11 +3051,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   // OpenCL v2.0 s6.13.16.4 Built-in pipe query functions
   case Builtin::BIget_pipe_num_packets:
   case Builtin::BIget_pipe_max_packets: {
-const char *Name;
+const char *BaseName;
+const PipeType *PipeTy = E->getArg(0)->getType()->getAs();
 if (BuiltinID == Builtin::BIget_pipe_num_packets)
-  Name = "__get_pipe_num_packets";
+  BaseName = "__get_pipe_num_packets";
 else
-  Name = "__get_pipe_max_packets";
+  BaseName = "__get_pipe_max_packets";
+auto Name = std::string(BaseName) +
+std::string(PipeTy->isReadOnly() ? "_ro" : "_wo");
 
 // Building the generic function prototype.
 Value *Arg0 = EmitScalarExpr(E->getArg(0));

Modified: cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp?rev=331026&r1=331025&r2=331026&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp Fri Apr 27 03:37:04 2018
@@ -66,13 +66,19 @@ llvm::Type *CGOpenCLRuntime::convertOpen
 }
 
 llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T) {
-  if (!PipeTy){
-uint32_t PipeAddrSpc = CGM.getContext().getTargetAddressSpace(
-CGM.getContext().getOpenCLTypeAddrSpace(T));
-PipeTy = llvm::PointerType::get(llvm::StructType::create(
-  CGM.getLLVMContext(), "opencl.pipe_t"), PipeAddrSpc);
-  }
+  if (T->isReadOnly())
+return getPipeType(T, "opencl.pipe_ro_t", PipeROTy);
+  else
+return getPipeType(T, "opencl.pipe_wo_t", PipeWOTy);
+}
 
+llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T, StringRef Name,
+ llvm::Type *&PipeTy) {
+  if (!PipeTy)
+PipeTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), Name),
+  CGM.getContext().getTargetAddressSpace(
+  CGM.getContext().getOpenCLTypeAddrSpace(T)));
   return PipeTy;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h?rev=331026&r1=331025&r2=331026&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h Fri Apr 27 03:37:04 2018
@@ -35,7 +35,8 @@ class CodeGenModule;
 class CGOpenCLRuntime {
 protected:
   CodeGenModule &CGM;
-  llvm::Type *PipeTy;
+  llvm::Type *PipeROTy;
+  llvm::Type *PipeWOTy;
   llvm::PointerType *SamplerTy;
 
   /// Structure for enqueued block information.
@@ -47,9 +48,12 @@ protected:
   /// Maps block expression to block information.
   llvm::DenseMap EnqueuedBlockMap;
 
+  virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name,
+  llvm::Type *&PipeTy);
+
 public:
-  CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM), PipeTy(nullptr),
-SamplerTy(nullptr) {}
+  CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM),
+PipeROTy(nullptr), PipeWOTy(nullptr), SamplerTy(nullptr) {}
   virtual ~CGOpenCLRuntime();
 
   /// Emit the IR required for a work-group-local variable declaration, and add

Modified: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
URL: 
http:/

r331766 - [OpenCL] Factor out language version printing

2018-05-08 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue May  8 06:47:43 2018
New Revision: 331766

URL: http://llvm.org/viewvc/llvm-project?rev=331766&view=rev
Log:
[OpenCL] Factor out language version printing

Generate a printable OpenCL language version number in a single place
and select between the OpenCL C or OpenCL C++ version accordingly.

Differential Revision: https://reviews.llvm.org/D46382

Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/Basic/LangOptions.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=331766&r1=331765&r2=331766&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Tue May  8 06:47:43 2018
@@ -254,6 +254,9 @@ public:
   bool assumeFunctionsAreConvergent() const {
 return (CUDA && CUDAIsDevice) || OpenCL;
   }
+
+  /// \brief Return the OpenCL C or C++ version as a VersionTuple.
+  VersionTuple getOpenCLVersionTuple() const;
 };
 
 /// \brief Floating point control options

Modified: cfe/trunk/lib/Basic/LangOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/LangOptions.cpp?rev=331766&r1=331765&r2=331766&view=diff
==
--- cfe/trunk/lib/Basic/LangOptions.cpp (original)
+++ cfe/trunk/lib/Basic/LangOptions.cpp Tue May  8 06:47:43 2018
@@ -43,3 +43,8 @@ bool LangOptions::isNoBuiltinFunc(String
   return true;
   return false;
 }
+
+VersionTuple LangOptions::getOpenCLVersionTuple() const {
+  const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  return VersionTuple(Ver / 100, (Ver % 100) / 10);
+}

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=331766&r1=331765&r2=331766&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue May  8 06:47:43 2018
@@ -76,7 +76,6 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Regex.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetOptions.h"
 #include 
@@ -2157,11 +2156,9 @@ static void ParseLangArgs(LangOptions &O
   // this option was added for compatibility with OpenCL 1.0.
   if (Args.getLastArg(OPT_cl_strict_aliasing)
&& Opts.OpenCLVersion > 100) {
-std::string VerSpec = llvm::to_string(Opts.OpenCLVersion / 100) +
-  std::string(".") +
-  llvm::to_string((Opts.OpenCLVersion % 100) / 10);
 Diags.Report(diag::warn_option_invalid_ocl_version)
-  << VerSpec << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
+<< Opts.getOpenCLVersionTuple().getAsString()
+<< Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args);
   }
 
   // We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=331766&r1=331765&r2=331766&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue May  8 06:47:43 2018
@@ -29,7 +29,6 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/ScopedPrinter.h"
 
 using namespace clang;
 
@@ -3806,11 +3805,8 @@ void Parser::ParseDeclarationSpecifiers(
 Diag(Tok, DiagID)
   << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
   else if (DiagID == diag::err_opencl_unknown_type_specifier) {
-const int OpenCLVer = getLangOpts().OpenCLVersion;
-std::string VerSpec = llvm::to_string(OpenCLVer / 100) +
-  std::string (".") +
-  llvm::to_string((OpenCLVer % 100) / 10);
-Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;
+Diag(Tok, DiagID) << 
getLangOpts().getOpenCLVersionTuple().getAsString()
+  << PrevSpec << isStorageClass;
   } else
 Diag(Tok, DiagID) << PrevSpec;
 }


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


r375111 - [OpenCL] Add doc to describe OpenCL support

2019-10-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Oct 17 05:56:02 2019
New Revision: 375111

URL: http://llvm.org/viewvc/llvm-project?rev=375111&view=rev
Log:
[OpenCL] Add doc to describe OpenCL support

The idea of this page is to document work in progress functionality
and also describe the plan of future development work.

Patch by Anastasia Stulova.

Differential Revision: https://reviews.llvm.org/D69072

Added:
cfe/trunk/docs/OpenCLSupport.rst
Modified:
cfe/trunk/docs/index.rst

Added: cfe/trunk/docs/OpenCLSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenCLSupport.rst?rev=375111&view=auto
==
--- cfe/trunk/docs/OpenCLSupport.rst (added)
+++ cfe/trunk/docs/OpenCLSupport.rst Thu Oct 17 05:56:02 2019
@@ -0,0 +1,47 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+.. contents::
+   :local:
+
+==
+OpenCL Support
+==
+
+Clang fully supports all OpenCL C versions from 1.1 to 2.0.
+
+Please refer to `Bugzilla
+`_
+for the most up to date bug reports.
+
+
+C++ for OpenCL Implementation Status
+
+
+Bugzilla bugs for this functionality are typically prefixed
+with '[C++]'.
+
+Differences to OpenCL C
+---
+
+TODO!
+
+Missing features or with limited support
+
+
+- Use of ObjC blocks is disabled.
+
+- Global destructor invocation is not generated correctly.
+
+- Initialization of objects in `__constant` address spaces is not guaranteed 
to work.
+
+- `addrspace_cast` operator is not supported.

Modified: cfe/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/index.rst?rev=375111&r1=375110&r2=375111&view=diff
==
--- cfe/trunk/docs/index.rst (original)
+++ cfe/trunk/docs/index.rst Thu Oct 17 05:56:02 2019
@@ -41,6 +41,7 @@ Using Clang as a Compiler
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenCLSupport
OpenMPSupport
ThinLTO
CommandGuide/index


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


r375118 - [OpenCL] Preserve addrspace in CGClass (PR43145)

2019-10-17 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Oct 17 07:12:51 2019
New Revision: 375118

URL: http://llvm.org/viewvc/llvm-project?rev=375118&view=rev
Log:
[OpenCL] Preserve addrspace in CGClass (PR43145)

PR43145 revealed two places where Clang was attempting to create a
bitcast without considering the address space of class types during
C++ class code generation.

Differential Revision: https://reviews.llvm.org/D68403

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=375118&r1=375117&r2=375118&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Oct 17 07:12:51 2019
@@ -246,7 +246,8 @@ ApplyNonVirtualAndVirtualOffset(CodeGenF
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@ CodeGenFunction::GetAddressOfDerivedClas
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo(AddrSpace);
 
   llvm::Value *NonVirtualOffset =
 CGM.GetNonVirtualBaseClassOffset(Derived, PathBegin, PathEnd);

Modified: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl?rev=375118&r1=375117&r2=375118&view=diff
==
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl (original)
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-derived-base.cl Thu Oct 17 
07:12:51 2019
@@ -11,6 +11,7 @@ public:
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@ void foo() {
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D 
addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*


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


[clang] bd46a56 - [OpenCL] Reject block arguments

2020-06-29 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-06-29T14:13:12+01:00
New Revision: bd46a56474d3b27a4fb520503d5714e23097d495

URL: 
https://github.com/llvm/llvm-project/commit/bd46a56474d3b27a4fb520503d5714e23097d495
DIFF: 
https://github.com/llvm/llvm-project/commit/bd46a56474d3b27a4fb520503d5714e23097d495.diff

LOG: [OpenCL] Reject block arguments

OpenCL 2.0 does not allow block arguments, primarily because it is
difficult to support function pointers on the various architectures
that OpenCL targets.  Clang was still accepting them.

Rename and reuse the `err_opencl_half_param` diagnostic.

Fixes PR46324.

Differential Revision: https://reviews.llvm.org/D82313

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaType.cpp
clang/test/CodeGenOpenCL/blocks.cl
clang/test/Frontend/opencl.cl
clang/test/SemaOpenCL/invalid-block.cl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 70b43f5abc4b..f0921337f312 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -830,8 +830,8 @@ def err_opencl_half_load_store : Error<
 def err_opencl_cast_to_half : Error<"casting to type %0 is not allowed">;
 def err_opencl_half_declaration : Error<
   "declaring variable of type %0 is not allowed">;
-def err_opencl_half_param : Error<
-  "declaring function parameter of type %0 is not allowed; did you forget * 
?">;
+def err_opencl_invalid_param : Error<
+  "declaring function parameter of type %0 is not allowed%select{; did you 
forget * ?|}1">;
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
 def warn_enum_value_overflow : Warning<"overflow in enumeration value">;

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 08d12fc25bf7..52fe292ce113 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5139,8 +5139,8 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
 // FIXME: This really should be in BuildFunctionType.
 if (S.getLangOpts().OpenCL) {
   if (!S.getOpenCLOptions().isEnabled("cl_khr_fp16")) {
-S.Diag(Param->getLocation(),
-  diag::err_opencl_half_param) << ParamTy;
+S.Diag(Param->getLocation(), diag::err_opencl_invalid_param)
+<< ParamTy << 0;
 D.setInvalidType();
 Param->setInvalidDecl();
   }
@@ -5159,6 +5159,11 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
 Param->setKNRPromoted(true);
   }
 }
+  } else if (S.getLangOpts().OpenCL && ParamTy->isBlockPointerType()) {
+// OpenCL 2.0 s6.12.5: A block cannot be a parameter of a function.
+S.Diag(Param->getLocation(), diag::err_opencl_invalid_param)
+<< ParamTy << 1 /*hint off*/;
+D.setInvalidType();
   }
 
   if (LangOpts.ObjCAutoRefCount && Param->hasAttr()) {

diff  --git a/clang/test/CodeGenOpenCL/blocks.cl 
b/clang/test/CodeGenOpenCL/blocks.cl
index c3e26855dfe0..f8315515f1d9 100644
--- a/clang/test/CodeGenOpenCL/blocks.cl
+++ b/clang/test/CodeGenOpenCL/blocks.cl
@@ -70,26 +70,6 @@ void foo(){
 
 // COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel
 
-// Test that we support block arguments.
-// COMMON-LABEL: define {{.*}} @blockArgFunc
-int blockArgFunc(int (^ bl)(void)) {
-  return bl();
-}
-
-// COMMON-LABEL: define {{.*}} @get21
-// COMMON: define {{.*}} @__get21_block_invoke
-// COMMON: ret i32 21
-int get21() {
-  return blockArgFunc(^{return 21;});
-}
-
-// COMMON-LABEL: define {{.*}} @get42
-// COMMON: define {{.*}} @__get42_block_invoke
-// COMMON: ret i32 42
-int get42() {
-  return blockArgFunc(^{return 42;});
-}
-
 // COMMON-LABEL: define {{.*}}@call_block
 // call {{.*}}@__call_block_block_invoke
 int call_block() {

diff  --git a/clang/test/Frontend/opencl.cl b/clang/test/Frontend/opencl.cl
index ea7d3d4c8731..e25a4b8fac6a 100644
--- a/clang/test/Frontend/opencl.cl
+++ b/clang/test/Frontend/opencl.cl
@@ -21,7 +21,7 @@ int member;
 #endif
 #endif
 
-void f(void (^g)(void)) {
+typedef int (^bl_t)(void);
 #if defined(__OPENCL_C_VERSION__) || defined(__OPENCL_CPP_VERSION__)
 #if !defined(BLOCKS) && (defined(__OPENCL_CPP_VERSION__)  || 
__OPENCL_C_VERSION__ != CL_VERSION_2_0)
   // expected-error@-3{{blocks support disabled - compile with -fblocks or for 
OpenCL 2.0}}
@@ -29,7 +29,6 @@ void f(void (^g)(void)) {
 #else
   // 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 doe

r319658 - [OpenCL] Define __IMAGE_SUPPORT__ macro for SPIR

2017-12-04 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Dec  4 07:01:08 2017
New Revision: 319658

URL: http://llvm.org/viewvc/llvm-project?rev=319658&view=rev
Log:
[OpenCL] Define __IMAGE_SUPPORT__ macro for SPIR

Add #define __IMAGE_SUPPORT__ 1 for SPIR targets to indicate that SPIR
supports images.

Patch by Dmitry Borisenkov.

Differential Revision: https://reviews.llvm.org/D40252

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=319658&r1=319657&r2=319658&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Dec  4 07:01:08 2017
@@ -1034,6 +1034,10 @@ static void InitializePredefinedMacros(c
 LangOpts.OpenCLVersion)) \
   Builder.defineMacro(#Ext);
 #include "clang/Basic/OpenCLExtensions.def"
+
+auto Arch = TI.getTriple().getArch();
+if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64)
+  Builder.defineMacro("__IMAGE_SUPPORT__");
   }
 
   if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) {

Modified: cfe/trunk/test/Preprocessor/predefined-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-macros.c?rev=319658&r1=319657&r2=319658&view=diff
==
--- cfe/trunk/test/Preprocessor/predefined-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-macros.c Mon Dec  4 07:01:08 2017
@@ -267,3 +267,7 @@
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
 // CHECK-ARM64-MINGW: #define __aarch64__ 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
+// CHECK-SPIR: #define __IMAGE_SUPPORT__ 1


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


r319883 - [OpenCL] Fix layering violation by getOpenCLTypeAddrSpace

2017-12-06 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Wed Dec  6 02:11:28 2017
New Revision: 319883

URL: http://llvm.org/viewvc/llvm-project?rev=319883&view=rev
Log:
[OpenCL] Fix layering violation by getOpenCLTypeAddrSpace

Commit 7ac28eb0a5 / r310911 ("[OpenCL] Allow targets to select address
space per type", 2017-08-15) made Basic depend on AST, introducing a
circular dependency.  Break this dependency by adding the
OpenCLTypeKind enum in Basic and map from AST types to this enum in
ASTContext.

Differential Revision: https://reviews.llvm.org/D40838

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=319883&r1=319882&r2=319883&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Dec  6 02:11:28 2017
@@ -1224,6 +1224,12 @@ public:
   /// pointer to blocks.
   QualType getBlockDescriptorExtendedType() const;
 
+  /// Map an AST Type to an OpenCLTypeKind enum value.
+  TargetInfo::OpenCLTypeKind getOpenCLTypeKind(const Type *T) const;
+
+  /// Get address space for OpenCL type.
+  LangAS getOpenCLTypeAddrSpace(const Type *T) const;
+
   void setcudaConfigureCallDecl(FunctionDecl *FD) {
 cudaConfigureCallDecl = FD;
   }

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=319883&r1=319882&r2=319883&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Dec  6 02:11:28 2017
@@ -46,7 +46,6 @@ class MacroBuilder;
 class QualType;
 class SourceLocation;
 class SourceManager;
-class Type;
 
 namespace Builtin { struct Info; }
 
@@ -1057,8 +1056,19 @@ public:
   return getTargetOpts().SupportedOpenCLOptions;
   }
 
+  enum OpenCLTypeKind {
+OCLTK_Default,
+OCLTK_ClkEvent,
+OCLTK_Event,
+OCLTK_Image,
+OCLTK_Pipe,
+OCLTK_Queue,
+OCLTK_ReserveID,
+OCLTK_Sampler,
+  };
+
   /// \brief Get address space for OpenCL type.
-  virtual LangAS getOpenCLTypeAddrSpace(const Type *T) const;
+  virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const;
 
   /// \returns Target specific vtbl ptr address space.
   virtual unsigned getVtblPtrAddressSpace() const {

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=319883&r1=319882&r2=319883&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Dec  6 02:11:28 2017
@@ -1826,7 +1826,8 @@ TypeInfo ASTContext::getTypeInfoImpl(con
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
 case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-  AS = getTargetAddressSpace(Target->getOpenCLTypeAddrSpace(T));
+  AS = getTargetAddressSpace(
+  Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T)));
   Width = Target->getPointerWidth(AS);
   Align = Target->getPointerAlign(AS);
   break;
@@ -5720,6 +5721,46 @@ QualType ASTContext::getBlockDescriptorE
   return getTagDeclType(BlockDescriptorExtendedType);
 }
 
+TargetInfo::OpenCLTypeKind ASTContext::getOpenCLTypeKind(const Type *T) const {
+  auto BT = dyn_cast(T);
+
+  if (!BT) {
+if (isa(T))
+  return TargetInfo::OCLTK_Pipe;
+
+return TargetInfo::OCLTK_Default;
+  }
+
+  switch (BT->getKind()) {
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   
\
+  case BuiltinType::Id:
\
+return TargetInfo::OCLTK_Image;
+#include "clang/Basic/OpenCLImageTypes.def"
+
+  case BuiltinType::OCLClkEvent:
+return TargetInfo::OCLTK_ClkEvent;
+
+  case BuiltinType::OCLEvent:
+return TargetInfo::OCLTK_Event;
+
+  case BuiltinType::OCLQueue:
+return TargetInfo::OCLTK_Queue;
+
+  case BuiltinType::OCLReserveID:
+return TargetInfo::OCLTK_ReserveID;
+
+  case BuiltinType::OCLSampler:
+return TargetInfo::OCLTK_Sampler;
+
+  default:
+return TargetInfo::OCLTK_Default;
+  }
+}
+
+LangAS ASTContext::getOpenCLTypeAddrSpace(const Type *T) const {
+  return Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T));
+}
+
 /// BlockRequiresCopying - Returns true if byref variable "D" of type "Ty"
 /// requires copy/dispose. Note that this must match the logic
 /// in buildByrefHelpers.

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Bas

[clang] f2c17a1 - [OpenCL] Remove argument names from atomic/fence builtins

2022-09-06 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-09-06T10:50:57+01:00
New Revision: f2c17a130a27cadd9d204bef09fd4ad64518c9da

URL: 
https://github.com/llvm/llvm-project/commit/f2c17a130a27cadd9d204bef09fd4ad64518c9da
DIFF: 
https://github.com/llvm/llvm-project/commit/f2c17a130a27cadd9d204bef09fd4ad64518c9da.diff

LOG: [OpenCL] Remove argument names from atomic/fence builtins

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the argument name identifiers.

Continues the direction set out in D119560.

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 5cadb488b06cd..8499ee0120da0 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -12396,11 +12396,11 @@ void __ovld vstorea_half16_rtn(double16, size_t, 
__private half *);
  * image objects and then want to read the updated data.
  */
 
-void __ovld __conv barrier(cl_mem_fence_flags flags);
+void __ovld __conv barrier(cl_mem_fence_flags);
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-void __ovld __conv work_group_barrier(cl_mem_fence_flags flags, memory_scope);
-void __ovld __conv work_group_barrier(cl_mem_fence_flags flags);
+void __ovld __conv work_group_barrier(cl_mem_fence_flags, memory_scope);
+void __ovld __conv work_group_barrier(cl_mem_fence_flags);
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
 // OpenCL v1.1 s6.11.9, v1.2 s6.12.9 - Explicit Memory Fence Functions
@@ -12418,7 +12418,7 @@ void __ovld __conv 
work_group_barrier(cl_mem_fence_flags flags);
  * CLK_LOCAL_MEM_FENCE
  * CLK_GLOBAL_MEM_FENCE.
  */
-void __ovld mem_fence(cl_mem_fence_flags flags);
+void __ovld mem_fence(cl_mem_fence_flags);
 
 /**
  * Read memory barrier that orders only
@@ -12430,7 +12430,7 @@ void __ovld mem_fence(cl_mem_fence_flags flags);
  * CLK_LOCAL_MEM_FENCE
  * CLK_GLOBAL_MEM_FENCE.
  */
-void __ovld read_mem_fence(cl_mem_fence_flags flags);
+void __ovld read_mem_fence(cl_mem_fence_flags);
 
 /**
  * Write memory barrier that orders only
@@ -12442,7 +12442,7 @@ void __ovld read_mem_fence(cl_mem_fence_flags flags);
  * CLK_LOCAL_MEM_FENCE
  * CLK_GLOBAL_MEM_FENCE.
  */
-void __ovld write_mem_fence(cl_mem_fence_flags flags);
+void __ovld write_mem_fence(cl_mem_fence_flags);
 
 // OpenCL v2.0 s6.13.9 - Address Space Qualifier Functions
 
@@ -12891,29 +12891,29 @@ void __ovld prefetch(const __global half16 *, size_t);
  * (old + val) and store result at location
  * pointed by p. The function returns old.
  */
-int __ovld atomic_add(volatile __global int *p, int val);
-uint __ovld atomic_add(volatile __global uint *p, uint val);
-int __ovld atomic_add(volatile __local int *p, int val);
-uint __ovld atomic_add(volatile __local uint *p, uint val);
+int __ovld atomic_add(volatile __global int *, int);
+uint __ovld atomic_add(volatile __global uint *, uint);
+int __ovld atomic_add(volatile __local int *, int);
+uint __ovld atomic_add(volatile __local uint *, uint);
 #ifdef __OPENCL_CPP_VERSION__
-int __ovld atomic_add(volatile int *p, int val);
-uint __ovld atomic_add(volatile uint *p, uint val);
+int __ovld atomic_add(volatile int *, int);
+uint __ovld atomic_add(volatile uint *, uint);
 #endif
 
 #if defined(cl_khr_global_int32_base_atomics)
-int __ovld atom_add(volatile __global int *p, int val);
-uint __ovld atom_add(volatile __global uint *p, uint val);
+int __ovld atom_add(volatile __global int *, int);
+uint __ovld atom_add(volatile __global uint *, uint);
 #endif
 #if defined(cl_khr_local_int32_base_atomics)
-int __ovld atom_add(volatile __local int *p, int val);
-uint __ovld atom_add(volatile __local uint *p, uint val);
+int __ovld atom_add(volatile __local int *, int);
+uint __ovld atom_add(volatile __local uint *, uint);
 #endif
 
 #if defined(cl_khr_int64_base_atomics)
-long __ovld atom_add(volatile __global long *p, long val);
-ulong __ovld atom_add(volatile __global ulong *p, ulong val);
-long __ovld atom_add(volatile __local long *p, long val);
-ulong __ovld atom_add(volatile __local ulong *p, ulong val);
+long __ovld atom_add(volatile __global long *, long);
+ulong __ovld atom_add(volatile __global ulong *, ulong);
+long __ovld atom_add(volatile __local long *, long);
+ulong __ovld atom_add(volatile __local ulong *, ulong);
 #endif
 
 /**
@@ -12921,29 +12921,29 @@ ulong __ovld atom_add(volatile __local ulong *p, 
ulong val);
  * Compute (old - val) and store result at location pointed by p. The function
  * returns old.
  */
-int __ovld atomic_sub(volatile __global int *p, int val);
-uint __ovld atomic_sub(volatile __global uint *p, uint val);
-int __ovld atomic_sub(volatile __local int *p, int val);
-uint __ovld atomic_sub(volatile __local uint *p, uint val);
+int __ovld atomic_sub(volatile __global int *, int);
+uint 

[clang] 5a7764c - [OpenCL] Guard depth image builtins

2022-09-13 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-09-13T10:10:48+01:00
New Revision: 5a7764c9ff5db8c460b52bc2dec95d19df44d4c8

URL: 
https://github.com/llvm/llvm-project/commit/5a7764c9ff5db8c460b52bc2dec95d19df44d4c8
DIFF: 
https://github.com/llvm/llvm-project/commit/5a7764c9ff5db8c460b52bc2dec95d19df44d4c8.diff

LOG: [OpenCL] Guard depth image builtins

Ensure any uses of `image2d_depth_t` and `image2d_array_depth_t` are
guarded behind the `cl_khr_depth_images` extension in
`OpenCLBuiltins.td`.

Fix a few missing guards in `opencl-c.h`.

Added: 


Modified: 
clang/lib/Headers/opencl-c.h
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 8499ee0120da..2afe0231cd74 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -15257,13 +15257,17 @@ float4 __ovld __purefn read_imagef(read_only 
image2d_t, sampler_t, float2, float
 int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, float2, 
float);
 uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, float2, 
float);
 
+#ifdef cl_khr_depth_images
 float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, 
float2, float);
+#endif // cl_khr_depth_images
 
 float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, 
float4, float);
 int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4, 
float);
 uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, 
float4, float);
 
+#ifdef cl_khr_depth_images
 float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, 
float4, float);
+#endif // cl_khr_depth_images
 
 float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, float4, 
float);
 int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, float4, 
float);
@@ -15281,13 +15285,17 @@ float4 __ovld __purefn read_imagef(read_only 
image2d_t, sampler_t, float2, float
 int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, float2, 
float2, float2);
 uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, float2, 
float2, float2);
 
+#ifdef cl_khr_depth_images
 float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, 
float2, float2, float2);
+#endif // cl_khr_depth_images
 
 float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, 
float4, float2, float2);
 int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4, 
float2, float2);
 uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, 
float4, float2, float2);
 
+#ifdef cl_khr_depth_images
 float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, 
float4, float2, float2);
+#endif // cl_khr_depth_images
 
 float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, float4, 
float4, float4);
 int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, float4, 
float4, float4);
@@ -15829,19 +15837,25 @@ int __ovld get_image_num_mip_levels(read_write 
image3d_t);
 
 int __ovld get_image_num_mip_levels(read_only image1d_array_t);
 int __ovld get_image_num_mip_levels(read_only image2d_array_t);
+#ifdef cl_khr_depth_images
 int __ovld get_image_num_mip_levels(read_only image2d_array_depth_t);
 int __ovld get_image_num_mip_levels(read_only image2d_depth_t);
+#endif // cl_khr_depth_images
 
 int __ovld get_image_num_mip_levels(write_only image1d_array_t);
 int __ovld get_image_num_mip_levels(write_only image2d_array_t);
+#ifdef cl_khr_depth_images
 int __ovld get_image_num_mip_levels(write_only image2d_array_depth_t);
 int __ovld get_image_num_mip_levels(write_only image2d_depth_t);
+#endif // cl_khr_depth_images
 
 #if defined(__opencl_c_read_write_images)
 int __ovld get_image_num_mip_levels(read_write image1d_array_t);
 int __ovld get_image_num_mip_levels(read_write image2d_array_t);
+#ifdef cl_khr_depth_images
 int __ovld get_image_num_mip_levels(read_write image2d_array_depth_t);
 int __ovld get_image_num_mip_levels(read_write image2d_depth_t);
+#endif // cl_khr_depth_images
 #endif //defined(__opencl_c_read_write_images)
 
 #endif //cl_khr_mipmap_image

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index dc158454556a..0cceba090bd8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -246,6 +246,7 @@ class ImageType :
   let Extension = !cond(
   !and(!eq(_Ty.Name, "image3d_t"), !eq(_AccessQualifier, "WO")) : 
TypeExtension<"cl_khr_3d_image_writes">,
   !and(!eq(_Ty.Name, "image3d_t"), !eq(_AccessQualifier, "RW")) : 
TypeExtension<"cl_khr_3d_image_writes __opencl_c_read_write_images">,
+  !or(!eq(_Ty.Name, "image2d_depth_t"), !eq(_Ty.Name, 
"image2d_array_depth_t")) : TypeExtension<"cl_khr_depth_images">,
   !eq(_AccessQualifier, "RW") : 
TypeExtension<"__opencl_c_read_write_images">,
   true : _Ty.Ext

[clang] 663e47a - [OpenCL] Reduce emitting candidate notes for builtins

2022-06-27 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-06-27T09:55:44+01:00
New Revision: 663e47a50f50c9ff0da9ba805f804c06645638ed

URL: 
https://github.com/llvm/llvm-project/commit/663e47a50f50c9ff0da9ba805f804c06645638ed
DIFF: 
https://github.com/llvm/llvm-project/commit/663e47a50f50c9ff0da9ba805f804c06645638ed.diff

LOG: [OpenCL] Reduce emitting candidate notes for builtins

When overload resolution fails, clang emits a note diagnostic for each
candidate.  For OpenCL builtins this often leads to many repeated note
diagnostics with no new information.  Stop emitting such notes.

Update a test that was relying on counting those notes to check how
many builtins are available for certain extension configurations.

Differential Revision: https://reviews.llvm.org/D127961

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index c627d631714d5..c226ed6254790 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11266,6 +11266,13 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
   if (shouldSkipNotingLambdaConversionDecl(Fn))
 return;
 
+  // There is no physical candidate declaration to point to for OpenCL 
builtins.
+  // Except for failed conversions, the notes are identical for each candidate,
+  // so do not generate such notes.
+  if (S.getLangOpts().OpenCL && Fn->isImplicit() &&
+  Cand->FailureKind != ovl_fail_bad_conversion)
+return;
+
   // Note deleted candidates, but only if they're viable.
   if (Cand->Viable) {
 if (Fn->isDeleted()) {

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 737632fdf07b1..bf943a400320c 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -171,14 +171,14 @@ void test_atomic_fetch_with_address_space(volatile 
__generic atomic_float *a_flo
 // extension is disabled.  Test this by counting the number of notes about
 // candidate functions.
 void test_atomic_double_reporting(volatile __generic atomic_int *a) {
-  atomic_init(a);
+  atomic_init(a, a);
   // expected-error@-1{{no matching function for call to 'atomic_init'}}
 #if defined(NO_FP64)
   // Expecting 5 candidates: int, uint, long, ulong, float
-  // expected-note@-4 5 {{candidate function not viable: requires 2 arguments, 
but 1 was provided}}
+  // expected-note@-4 5 {{candidate function not viable: no known conversion}}
 #else
   // Expecting 6 candidates: int, uint, long, ulong, float, double
-  // expected-note@-7 6 {{candidate function not viable: requires 2 arguments, 
but 1 was provided}}
+  // expected-note@-7 6 {{candidate function not viable: no known conversion}}
 #endif
 }
 
@@ -198,7 +198,6 @@ void test_atomics_without_scope_device(volatile __generic 
atomic_int *a_int) {
 
   atomic_exchange_explicit(a_int, d, memory_order_seq_cst);
   // expected-error@-1{{no matching function for call to 
'atomic_exchange_explicit'}}
-  // expected-note@-2 + {{candidate function not viable}}
 
   atomic_exchange_explicit(a_int, d, memory_order_seq_cst, 
memory_scope_work_group);
 }
@@ -272,9 +271,7 @@ kernel void basic_image_readonly(read_only image2d_t 
image_read_only_image2d) {
   res = read_imageh(image_read_only_image2d, i2);
 #if __OPENCL_C_VERSION__ < CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
   // expected-error@-3{{no matching function for call to 'read_imagef'}}
-  // expected-note@-4 + {{candidate function not viable}}
-  // expected-error@-4{{no matching function for call to 'read_imageh'}}
-  // expected-note@-5 + {{candidate function not viable}}
+  // expected-error@-3{{no matching function for call to 'read_imageh'}}
 #endif
   res = read_imageh(image_read_only_image2d, sampler, i2);
 
@@ -304,7 +301,6 @@ kernel void basic_image_writeonly(write_only 
image1d_buffer_t image_write_only_i
   write_imagef(image3dwo, i4, i, f4);
 #if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
   // expected-error@-2{{no matching function for call to 'write_imagef'}}
-  // expected-note@-3 + {{candidate function not viable}}
 #endif
 }
 



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


[clang] 1d421e6 - [OpenCL] Remove half scalar vload/vstore builtins

2022-06-30 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-06-30T11:01:19+01:00
New Revision: 1d421e6e3b789ede2f61756a72e2b27456f868e3

URL: 
https://github.com/llvm/llvm-project/commit/1d421e6e3b789ede2f61756a72e2b27456f868e3
DIFF: 
https://github.com/llvm/llvm-project/commit/1d421e6e3b789ede2f61756a72e2b27456f868e3.diff

LOG: [OpenCL] Remove half scalar vload/vstore builtins

These are not mentioned in the OpenCL C Specification nor in the
OpenCL Extension Specification.

Differential Revision: https://reviews.llvm.org/D128434

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 1942da77f5e50..ed647d9e9c064 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -11255,7 +11255,6 @@ double16 __ovld __purefn vload16(size_t, const 
__constant double *);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __constant half *);
 half2 __ovld __purefn vload2(size_t, const __constant half *);
 half3 __ovld __purefn vload3(size_t, const __constant half *);
 half4 __ovld __purefn vload4(size_t, const __constant half *);
@@ -11319,7 +11318,6 @@ double16 __ovld __purefn vload16(size_t, const double 
*);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const half *);
 half2 __ovld __purefn vload2(size_t, const half *);
 half3 __ovld __purefn vload3(size_t, const half *);
 half4 __ovld __purefn vload4(size_t, const half *);
@@ -11484,19 +11482,16 @@ double16 __ovld __purefn vload16(size_t, const 
__private double *);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __global half *);
 half2 __ovld __purefn vload2(size_t, const __global half *);
 half3 __ovld __purefn vload3(size_t, const __global half *);
 half4 __ovld __purefn vload4(size_t, const __global half *);
 half8 __ovld __purefn vload8(size_t, const __global half *);
 half16 __ovld __purefn vload16(size_t, const __global half *);
-half __ovld __purefn vload(size_t, const __local half *);
 half2 __ovld __purefn vload2(size_t, const __local half *);
 half3 __ovld __purefn vload3(size_t, const __local half *);
 half4 __ovld __purefn vload4(size_t, const __local half *);
 half8 __ovld __purefn vload8(size_t, const __local half *);
 half16 __ovld __purefn vload16(size_t, const __local half *);
-half __ovld __purefn vload(size_t, const __private half *);
 half2 __ovld __purefn vload2(size_t, const __private half *);
 half3 __ovld __purefn vload3(size_t, const __private half *);
 half4 __ovld __purefn vload4(size_t, const __private half *);
@@ -11559,7 +11554,6 @@ void __ovld vstore8(double8, size_t, double *);
 void __ovld vstore16(double16, size_t, double *);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-void __ovld vstore(half, size_t, half *);
 void __ovld vstore2(half2, size_t, half *);
 void __ovld vstore3(half3, size_t, half *);
 void __ovld vstore4(half4, size_t, half *);
@@ -11722,19 +11716,16 @@ void __ovld vstore8(double8, size_t, __private double 
*);
 void __ovld vstore16(double16, size_t, __private double *);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-void __ovld vstore(half, size_t, __global half *);
 void __ovld vstore2(half2, size_t, __global half *);
 void __ovld vstore3(half3, size_t, __global half *);
 void __ovld vstore4(half4, size_t, __global half *);
 void __ovld vstore8(half8, size_t, __global half *);
 void __ovld vstore16(half16, size_t, __global half *);
-void __ovld vstore(half, size_t, __local half *);
 void __ovld vstore2(half2, size_t, __local half *);
 void __ovld vstore3(half3, size_t, __local half *);
 void __ovld vstore4(half4, size_t, __local half *);
 void __ovld vstore8(half8, size_t, __local half *);
 void __ovld vstore16(half16, size_t, __local half *);
-void __ovld vstore(half, size_t, __private half *);
 void __ovld vstore2(half2, size_t, __private half *);
 void __ovld vstore3(half3, size_t, __private half *);
 void __ovld vstore4(half4, size_t, __private half *);



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


[clang] f8e658e - [OpenCL] Remove fast_ half geometric builtins

2022-07-05 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-07-05T10:22:34+01:00
New Revision: f8e658ec9ff5b82d0c1f9d54d78c137b539319ca

URL: 
https://github.com/llvm/llvm-project/commit/f8e658ec9ff5b82d0c1f9d54d78c137b539319ca
DIFF: 
https://github.com/llvm/llvm-project/commit/f8e658ec9ff5b82d0c1f9d54d78c137b539319ca.diff

LOG: [OpenCL] Remove fast_ half geometric builtins

These are not mentioned in the OpenCL C Specification nor in the
OpenCL Extension Specification.

Differential Revision: https://reviews.llvm.org/D128436

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index ed647d9e9c064..72a6bfeafd6a2 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -10467,12 +10467,6 @@ float __ovld __cnfn fast_distance(float, float);
 float __ovld __cnfn fast_distance(float2, float2);
 float __ovld __cnfn fast_distance(float3, float3);
 float __ovld __cnfn fast_distance(float4, float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_distance(half, half);
-half __ovld __cnfn fast_distance(half2, half2);
-half __ovld __cnfn fast_distance(half3, half3);
-half __ovld __cnfn fast_distance(half4, half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns the length of vector p computed as:
@@ -10482,12 +10476,6 @@ float __ovld __cnfn fast_length(float);
 float __ovld __cnfn fast_length(float2);
 float __ovld __cnfn fast_length(float3);
 float __ovld __cnfn fast_length(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_length(half);
-half __ovld __cnfn fast_length(half2);
-half __ovld __cnfn fast_length(half3);
-half __ovld __cnfn fast_length(half4);
-#endif //cl_khr_fp16
 
 /**
  * Returns a vector in the same direction as p but with a
@@ -10514,12 +10502,6 @@ float __ovld __cnfn fast_normalize(float);
 float2 __ovld __cnfn fast_normalize(float2);
 float3 __ovld __cnfn fast_normalize(float3);
 float4 __ovld __cnfn fast_normalize(float4);
-#ifdef cl_khr_fp16
-half __ovld __cnfn fast_normalize(half);
-half2 __ovld __cnfn fast_normalize(half2);
-half3 __ovld __cnfn fast_normalize(half3);
-half4 __ovld __cnfn fast_normalize(half4);
-#endif //cl_khr_fp16
 
 // OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions
 



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


[clang] de30408 - [OpenCL] opencl-c.h: remove a/b/c/i/p/n/v arg names

2022-03-29 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-03-29T10:16:27+01:00
New Revision: de30408b3b0a012f902b8565fa0b7625c1d5fec6

URL: 
https://github.com/llvm/llvm-project/commit/de30408b3b0a012f902b8565fa0b7625c1d5fec6
DIFF: 
https://github.com/llvm/llvm-project/commit/de30408b3b0a012f902b8565fa0b7625c1d5fec6.diff

LOG: [OpenCL] opencl-c.h: remove a/b/c/i/p/n/v arg names

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" any single-letter identifiers.

Continues the direction set out in D119560.

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 1a5f7183a7f0a..71b0fbb3a691e 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -7121,27 +7121,27 @@ half16 __ovld __cnfn floor(half16);
  * intermediate products shall not occur. Edge case
  * behavior is per the IEEE 754-2008 standard.
  */
-float __ovld __cnfn fma(float a, float b, float c);
-float2 __ovld __cnfn fma(float2 a, float2 b, float2 c);
-float3 __ovld __cnfn fma(float3 a, float3 b, float3 c);
-float4 __ovld __cnfn fma(float4 a, float4 b, float4 c);
-float8 __ovld __cnfn fma(float8 a, float8 b, float8 c);
-float16 __ovld __cnfn fma(float16 a, float16 b, float16 c);
+float __ovld __cnfn fma(float, float, float);
+float2 __ovld __cnfn fma(float2, float2, float2);
+float3 __ovld __cnfn fma(float3, float3, float3);
+float4 __ovld __cnfn fma(float4, float4, float4);
+float8 __ovld __cnfn fma(float8, float8, float8);
+float16 __ovld __cnfn fma(float16, float16, float16);
 #ifdef cl_khr_fp64
-double __ovld __cnfn fma(double a, double b, double c);
-double2 __ovld __cnfn fma(double2 a, double2 b, double2 c);
-double3 __ovld __cnfn fma(double3 a, double3 b, double3 c);
-double4 __ovld __cnfn fma(double4 a, double4 b, double4 c);
-double8 __ovld __cnfn fma(double8 a, double8 b, double8 c);
-double16 __ovld __cnfn fma(double16 a, double16 b, double16 c);
+double __ovld __cnfn fma(double, double, double);
+double2 __ovld __cnfn fma(double2, double2, double2);
+double3 __ovld __cnfn fma(double3, double3, double3);
+double4 __ovld __cnfn fma(double4, double4, double4);
+double8 __ovld __cnfn fma(double8, double8, double8);
+double16 __ovld __cnfn fma(double16, double16, double16);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-half __ovld __cnfn fma(half a, half b, half c);
-half2 __ovld __cnfn fma(half2 a, half2 b, half2 c);
-half3 __ovld __cnfn fma(half3 a, half3 b, half3 c);
-half4 __ovld __cnfn fma(half4 a, half4 b, half4 c);
-half8 __ovld __cnfn fma(half8 a, half8 b, half8 c);
-half16 __ovld __cnfn fma(half16 a, half16 b, half16 c);
+half __ovld __cnfn fma(half, half, half);
+half2 __ovld __cnfn fma(half2, half2, half2);
+half3 __ovld __cnfn fma(half3, half3, half3);
+half4 __ovld __cnfn fma(half4, half4, half4);
+half8 __ovld __cnfn fma(half8, half8, half8);
+half16 __ovld __cnfn fma(half16, half16, half16);
 #endif //cl_khr_fp16
 
 /**
@@ -7496,42 +7496,42 @@ int16 __ovld __cnfn ilogb(half16);
 /**
  * Multiply x by 2 to the power n.
  */
-float __ovld __cnfn ldexp(float, int n);
-float2 __ovld __cnfn ldexp(float2, int2 n);
-float3 __ovld __cnfn ldexp(float3, int3 n);
-float4 __ovld __cnfn ldexp(float4, int4 n);
-float8 __ovld __cnfn ldexp(float8, int8 n);
-float16 __ovld __cnfn ldexp(float16, int16 n);
-float2 __ovld __cnfn ldexp(float2, int n);
-float3 __ovld __cnfn ldexp(float3, int n);
-float4 __ovld __cnfn ldexp(float4, int n);
-float8 __ovld __cnfn ldexp(float8, int n);
-float16 __ovld __cnfn ldexp(float16, int n);
+float __ovld __cnfn ldexp(float, int);
+float2 __ovld __cnfn ldexp(float2, int2);
+float3 __ovld __cnfn ldexp(float3, int3);
+float4 __ovld __cnfn ldexp(float4, int4);
+float8 __ovld __cnfn ldexp(float8, int8);
+float16 __ovld __cnfn ldexp(float16, int16);
+float2 __ovld __cnfn ldexp(float2, int);
+float3 __ovld __cnfn ldexp(float3, int);
+float4 __ovld __cnfn ldexp(float4, int);
+float8 __ovld __cnfn ldexp(float8, int);
+float16 __ovld __cnfn ldexp(float16, int);
 #ifdef cl_khr_fp64
-double __ovld __cnfn ldexp(double, int n);
-double2 __ovld __cnfn ldexp(double2, int2 n);
-double3 __ovld __cnfn ldexp(double3, int3 n);
-double4 __ovld __cnfn ldexp(double4, int4 n);
-double8 __ovld __cnfn ldexp(double8, int8 n);
-double16 __ovld __cnfn ldexp(double16, int16 n);
-double2 __ovld __cnfn ldexp(double2, int n);
-double3 __ovld __cnfn ldexp(double3, int n);
-double4 __ovld __cnfn ldexp(double4, int n);
-double8 __ovld __cnfn ldexp(double8, int n);
-double16 __ovld __cnfn ldexp(double16, int n);
+double __ovld __cnfn ldexp(double, int);
+double2 __ovld __cnfn ldexp(double2, int2);
+double3 __ovld __cnfn ldexp(double3, int3);
+double4 __ovld __cnfn ldexp(double4, int4);
+double8 __ovld __cnfn ldexp(double8, int8);
+double16 __ovld __cnfn ldexp(double16, int16);
+double2 __ovld __cnfn ldexp(doub

[clang] 4dfec37 - [OpenCL] Set MinVersion for sub_group_barrier with memory_scope

2022-03-31 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-03-31T16:41:40+01:00
New Revision: 4dfec37037f5f96db8898b79601c7a1d19177027

URL: 
https://github.com/llvm/llvm-project/commit/4dfec37037f5f96db8898b79601c7a1d19177027
DIFF: 
https://github.com/llvm/llvm-project/commit/4dfec37037f5f96db8898b79601c7a1d19177027.diff

LOG: [OpenCL] Set MinVersion for sub_group_barrier with memory_scope

The memory_scope enum is not available before OpenCL 2.0, so ensure
the sub_group_barrier overload with a memory_scope argument is
restricted to OpenCL 2.0 and above.  This is already the case in
opencl-c.h.

Fixes the issue revealed by https://reviews.llvm.org/D120254

Reported-by: Harald van Dijk (hvdijk)

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 9c1a39cdb1a56..a57b74430f694 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1698,7 +1698,9 @@ let Extension = FuncExtKhrSubgroups in {
 // --- Table 28.2.2 ---
 let Extension = FuncExtKhrSubgroups in {
   def : Builtin<"sub_group_barrier", [Void, MemFenceFlags], Attr.Convergent>;
-  def : Builtin<"sub_group_barrier", [Void, MemFenceFlags, MemoryScope], 
Attr.Convergent>;
+  let MinVersion = CL20 in {
+def : Builtin<"sub_group_barrier", [Void, MemFenceFlags, MemoryScope], 
Attr.Convergent>;
+  }
 }
 
 // --- Table 28.2.4 ---



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


[clang] 77c74fd - [OpenCL] Remove argument names from math builtins

2022-04-06 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-04-06T11:43:59+01:00
New Revision: 77c74fd877b27418171693f187b8db865567b8dc

URL: 
https://github.com/llvm/llvm-project/commit/77c74fd877b27418171693f187b8db865567b8dc
DIFF: 
https://github.com/llvm/llvm-project/commit/77c74fd877b27418171693f187b8db865567b8dc.diff

LOG: [OpenCL] Remove argument names from math builtins

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the argument name identifiers.

Continues the direction set out in D119560.

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 71b0fbb3a691e..cee3c680aff2e 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -6362,7 +6362,7 @@ uint __ovld __cnfn get_work_dim(void);
  * dimindx, get_global_size() returns 1.
  * For clEnqueueTask, this always returns 1.
  */
-size_t __ovld __cnfn get_global_size(uint dimindx);
+size_t __ovld __cnfn get_global_size(uint);
 
 /**
  * Returns the unique global work-item ID value for
@@ -6373,7 +6373,7 @@ size_t __ovld __cnfn get_global_size(uint dimindx);
  * other values of dimindx, get_global_id() returns 0.
  * For clEnqueueTask, this returns 0.
  */
-size_t __ovld __cnfn get_global_id(uint dimindx);
+size_t __ovld __cnfn get_global_id(uint);
 
 /**
  * Returns the number of local work-items specified in
@@ -6387,7 +6387,7 @@ size_t __ovld __cnfn get_global_id(uint dimindx);
  * get_local_size() returns 1.
  * For clEnqueueTask, this always returns 1.
  */
-size_t __ovld __cnfn get_local_size(uint dimindx);
+size_t __ovld __cnfn get_local_size(uint);
 
 /**
  * Returns the unique local work-item ID i.e. a work-item
@@ -6397,7 +6397,7 @@ size_t __ovld __cnfn get_local_size(uint dimindx);
  * get_local_id() returns 0.
  * For clEnqueueTask, this returns 0.
  */
-size_t __ovld __cnfn get_local_id(uint dimindx);
+size_t __ovld __cnfn get_local_id(uint);
 
 /**
  * Returns the number of work-groups that will execute a
@@ -6406,7 +6406,7 @@ size_t __ovld __cnfn get_local_id(uint dimindx);
  * For other values of dimindx, get_num_groups() returns 1.
  * For clEnqueueTask, this always returns 1.
  */
-size_t __ovld __cnfn get_num_groups(uint dimindx);
+size_t __ovld __cnfn get_num_groups(uint);
 
 /**
  * get_group_id returns the work-group ID which is a
@@ -6415,7 +6415,7 @@ size_t __ovld __cnfn get_num_groups(uint dimindx);
  * For other values, get_group_id() returns 0.
  * For clEnqueueTask, this returns 0.
  */
-size_t __ovld __cnfn get_group_id(uint dimindx);
+size_t __ovld __cnfn get_group_id(uint);
 
 /**
  * get_global_offset returns the offset values specified in
@@ -6425,10 +6425,10 @@ size_t __ovld __cnfn get_group_id(uint dimindx);
  * For other values, get_global_offset() returns 0.
  * For clEnqueueTask, this returns 0.
  */
-size_t __ovld __cnfn get_global_offset(uint dimindx);
+size_t __ovld __cnfn get_global_offset(uint);
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
-size_t __ovld get_enqueued_local_size(uint dimindx);
+size_t __ovld get_enqueued_local_size(uint);
 size_t __ovld get_global_linear_id(void);
 size_t __ovld get_local_linear_id(void);
 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
@@ -6594,27 +6594,27 @@ half16 __ovld __cnfn asinpi(half16);
 /**
  * Arc tangent function.
  */
-float __ovld __cnfn atan(float y_over_x);
-float2 __ovld __cnfn atan(float2 y_over_x);
-float3 __ovld __cnfn atan(float3 y_over_x);
-float4 __ovld __cnfn atan(float4 y_over_x);
-float8 __ovld __cnfn atan(float8 y_over_x);
-float16 __ovld __cnfn atan(float16 y_over_x);
+float __ovld __cnfn atan(float);
+float2 __ovld __cnfn atan(float2);
+float3 __ovld __cnfn atan(float3);
+float4 __ovld __cnfn atan(float4);
+float8 __ovld __cnfn atan(float8);
+float16 __ovld __cnfn atan(float16);
 #ifdef cl_khr_fp64
-double __ovld __cnfn atan(double y_over_x);
-double2 __ovld __cnfn atan(double2 y_over_x);
-double3 __ovld __cnfn atan(double3 y_over_x);
-double4 __ovld __cnfn atan(double4 y_over_x);
-double8 __ovld __cnfn atan(double8 y_over_x);
-double16 __ovld __cnfn atan(double16 y_over_x);
+double __ovld __cnfn atan(double);
+double2 __ovld __cnfn atan(double2);
+double3 __ovld __cnfn atan(double3);
+double4 __ovld __cnfn atan(double4);
+double8 __ovld __cnfn atan(double8);
+double16 __ovld __cnfn atan(double16);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-half __ovld __cnfn atan(half y_over_x);
-half2 __ovld __cnfn atan(half2 y_over_x);
-half3 __ovld __cnfn atan(half3 y_over_x);
-half4 __ovld __cnfn atan(half4 y_over_x);
-half8 __ovld __cnfn atan(half8 y_over_x);
-half16 __ovld __cnfn atan(half16 y_over_x);
+half __ovld __cnfn atan(half);
+half2 __ovld __cnfn atan(half2);
+half3 __ovld __cnfn atan(half3);
+half4 __ovld __cnfn atan(half4);
+hal

[clang] 724f0e2 - [OpenCL] Add cl_khr_extended_bit_ops

2021-07-21 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-07-21T10:01:19+01:00
New Revision: 724f0e2abb0ce327d2e82af5a61be25e2d2014ec

URL: 
https://github.com/llvm/llvm-project/commit/724f0e2abb0ce327d2e82af5a61be25e2d2014ec
DIFF: 
https://github.com/llvm/llvm-project/commit/724f0e2abb0ce327d2e82af5a61be25e2d2014ec.diff

LOG: [OpenCL] Add cl_khr_extended_bit_ops

Add the builtins defined by Section 40 "Extended Bit Operations" in
the OpenCL Extension Specification.

Differential Revision: https://reviews.llvm.org/D106267

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h
clang/lib/Sema/OpenCLBuiltins.td
clang/test/Headers/opencl-c-header.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index c9c1bda140384..ebc4b7a47925b 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -21,6 +21,7 @@
 #define cl_khr_subgroup_shuffle 1
 #define cl_khr_subgroup_shuffle_relative 1
 #define cl_khr_subgroup_clustered_reduce 1
+#define cl_khr_extended_bit_ops 1
 #endif // defined(__SPIR__)
 #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index d50f0b8d2e8f5..5b3cd05d4426d 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -16051,6 +16051,206 @@ double  __ovld sub_group_clustered_reduce_max( double 
value, uint clustersize );
 
 #endif // cl_khr_subgroup_clustered_reduce
 
+#if defined(cl_khr_extended_bit_ops)
+char __ovld __cnfn bitfield_insert(char, char, uint, uint);
+uchar __ovld __cnfn bitfield_insert(uchar, uchar, uint, uint);
+short __ovld __cnfn bitfield_insert(short, short, uint, uint);
+ushort __ovld __cnfn bitfield_insert(ushort, ushort, uint, uint);
+int __ovld __cnfn bitfield_insert(int, int, uint, uint);
+uint __ovld __cnfn bitfield_insert(uint, uint, uint, uint);
+long __ovld __cnfn bitfield_insert(long, long, uint, uint);
+ulong __ovld __cnfn bitfield_insert(ulong, ulong, uint, uint);
+char2 __ovld __cnfn bitfield_insert(char2, char2, uint, uint);
+uchar2 __ovld __cnfn bitfield_insert(uchar2, uchar2, uint, uint);
+short2 __ovld __cnfn bitfield_insert(short2, short2, uint, uint);
+ushort2 __ovld __cnfn bitfield_insert(ushort2, ushort2, uint, uint);
+int2 __ovld __cnfn bitfield_insert(int2, int2, uint, uint);
+uint2 __ovld __cnfn bitfield_insert(uint2, uint2, uint, uint);
+long2 __ovld __cnfn bitfield_insert(long2, long2, uint, uint);
+ulong2 __ovld __cnfn bitfield_insert(ulong2, ulong2, uint, uint);
+char3 __ovld __cnfn bitfield_insert(char3, char3, uint, uint);
+uchar3 __ovld __cnfn bitfield_insert(uchar3, uchar3, uint, uint);
+short3 __ovld __cnfn bitfield_insert(short3, short3, uint, uint);
+ushort3 __ovld __cnfn bitfield_insert(ushort3, ushort3, uint, uint);
+int3 __ovld __cnfn bitfield_insert(int3, int3, uint, uint);
+uint3 __ovld __cnfn bitfield_insert(uint3, uint3, uint, uint);
+long3 __ovld __cnfn bitfield_insert(long3, long3, uint, uint);
+ulong3 __ovld __cnfn bitfield_insert(ulong3, ulong3, uint, uint);
+char4 __ovld __cnfn bitfield_insert(char4, char4, uint, uint);
+uchar4 __ovld __cnfn bitfield_insert(uchar4, uchar4, uint, uint);
+short4 __ovld __cnfn bitfield_insert(short4, short4, uint, uint);
+ushort4 __ovld __cnfn bitfield_insert(ushort4, ushort4, uint, uint);
+int4 __ovld __cnfn bitfield_insert(int4, int4, uint, uint);
+uint4 __ovld __cnfn bitfield_insert(uint4, uint4, uint, uint);
+long4 __ovld __cnfn bitfield_insert(long4, long4, uint, uint);
+ulong4 __ovld __cnfn bitfield_insert(ulong4, ulong4, uint, uint);
+char8 __ovld __cnfn bitfield_insert(char8, char8, uint, uint);
+uchar8 __ovld __cnfn bitfield_insert(uchar8, uchar8, uint, uint);
+short8 __ovld __cnfn bitfield_insert(short8, short8, uint, uint);
+ushort8 __ovld __cnfn bitfield_insert(ushort8, ushort8, uint, uint);
+int8 __ovld __cnfn bitfield_insert(int8, int8, uint, uint);
+uint8 __ovld __cnfn bitfield_insert(uint8, uint8, uint, uint);
+long8 __ovld __cnfn bitfield_insert(long8, long8, uint, uint);
+ulong8 __ovld __cnfn bitfield_insert(ulong8, ulong8, uint, uint);
+char16 __ovld __cnfn bitfield_insert(char16, char16, uint, uint);
+uchar16 __ovld __cnfn bitfield_insert(uchar16, uchar16, uint, uint);
+short16 __ovld __cnfn bitfield_insert(short16, short16, uint, uint);
+ushort16 __ovld __cnfn bitfield_insert(ushort16, ushort16, uint, uint);
+int16 __ovld __cnfn bitfield_insert(int16, int16, uint, uint);
+uint16 __ovld __cnfn bitfield_insert(uint16, uint16, uint, uint);
+long16 __ovld __cnfn bitfield_insert(long16, long16, uint, uint);
+ulong16 __ovld __cnfn bitfield_insert(ulong16, ulong16, uint, uint);
+
+char __ovld __cnfn bitfield_extract_signed(char, uint, uint);
+short __ovld __cnfn bitfield_extract_signed(short, uint, uint);
+int __ovld __cnfn bitfield_extract_signed(int, uint, uint);
+long __o

[clang] 989bede - [OpenCL] Add cl_khr_integer_dot_product

2021-07-23 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-07-23T10:10:16+01:00
New Revision: 989bedec7a6ae95a0db865f23677047f78dc9257

URL: 
https://github.com/llvm/llvm-project/commit/989bedec7a6ae95a0db865f23677047f78dc9257
DIFF: 
https://github.com/llvm/llvm-project/commit/989bedec7a6ae95a0db865f23677047f78dc9257.diff

LOG: [OpenCL] Add cl_khr_integer_dot_product

Add the builtins defined by Section 42 "Integer dot product" in
the OpenCL Extension Specification.

Differential Revision: https://reviews.llvm.org/D106434

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h
clang/lib/Sema/OpenCLBuiltins.td
clang/test/Headers/opencl-c-header.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index ebc4b7a47925..1dc52ec75e03 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -22,6 +22,10 @@
 #define cl_khr_subgroup_shuffle_relative 1
 #define cl_khr_subgroup_clustered_reduce 1
 #define cl_khr_extended_bit_ops 1
+#define cl_khr_integer_dot_product 1
+#define __opencl_c_integer_dot_product_input_4x8bit 1
+#define __opencl_c_integer_dot_product_input_4x8bit_packed 1
+
 #endif // defined(__SPIR__)
 #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 5b3cd05d4426..4be57058b33f 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -16251,6 +16251,30 @@ long16 __ovld __cnfn bit_reverse(long16);
 ulong16 __ovld __cnfn bit_reverse(ulong16);
 #endif // cl_khr_extended_bit_ops
 
+#if defined(__opencl_c_integer_dot_product_input_4x8bit)
+uint __ovld __cnfn dot(uchar4, uchar4);
+int __ovld __cnfn dot(char4, char4);
+int __ovld __cnfn dot(uchar4, char4);
+int __ovld __cnfn dot(char4, uchar4);
+
+uint __ovld __cnfn dot_acc_sat(uchar4, uchar4, uint);
+int __ovld __cnfn dot_acc_sat(char4, char4, int);
+int __ovld __cnfn dot_acc_sat(uchar4, char4, int);
+int __ovld __cnfn dot_acc_sat(char4, uchar4, int);
+#endif // __opencl_c_integer_dot_product_input_4x8bit
+
+#if defined(__opencl_c_integer_dot_product_input_4x8bit_packed)
+uint __ovld __cnfn dot_4x8packed_uu_uint(uint, uint);
+int __ovld __cnfn dot_4x8packed_ss_int(uint, uint);
+int __ovld __cnfn dot_4x8packed_us_int(uint, uint);
+int __ovld __cnfn dot_4x8packed_su_int(uint, uint);
+
+uint __ovld __cnfn dot_acc_sat_4x8packed_uu_uint(uint, uint, uint);
+int __ovld __cnfn dot_acc_sat_4x8packed_ss_int(uint, uint, int);
+int __ovld __cnfn dot_acc_sat_4x8packed_us_int(uint, uint, int);
+int __ovld __cnfn dot_acc_sat_4x8packed_su_int(uint, uint, int);
+#endif // __opencl_c_integer_dot_product_input_4x8bit_packed
+
 #if defined(cl_intel_subgroups)
 // Intel-Specific Sub Group Functions
 float   __ovld __conv intel_sub_group_shuffle( float  x, uint c );

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 63def2bce8c2..cd704fe395a9 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1749,6 +1749,31 @@ let Extension = FuncExtKhrExtendedBitOps in {
   def : Builtin<"bit_reverse", [AIGenTypeN, AIGenTypeN], Attr.Const>;
 }
 
+// Section 42.3 - cl_khr_integer_dot_product
+let Extension = 
FunctionExtension<"__opencl_c_integer_dot_product_input_4x8bit"> in {
+  def : Builtin<"dot", [UInt, VectorType, VectorType], 
Attr.Const>;
+  def : Builtin<"dot", [Int, VectorType, VectorType], 
Attr.Const>;
+  def : Builtin<"dot", [Int, VectorType, VectorType], 
Attr.Const>;
+  def : Builtin<"dot", [Int, VectorType, VectorType], 
Attr.Const>;
+
+  def : Builtin<"dot_acc_sat", [UInt, VectorType, VectorType, UInt], Attr.Const>;
+  def : Builtin<"dot_acc_sat", [Int, VectorType, VectorType, 
Int], Attr.Const>;
+  def : Builtin<"dot_acc_sat", [Int, VectorType, VectorType, Int], Attr.Const>;
+  def : Builtin<"dot_acc_sat", [Int, VectorType, VectorType, Int], Attr.Const>;
+}
+
+let Extension = 
FunctionExtension<"__opencl_c_integer_dot_product_input_4x8bit_packed"> in {
+  def : Builtin<"dot_4x8packed_uu_uint", [UInt, UInt, UInt], Attr.Const>;
+  def : Builtin<"dot_4x8packed_ss_int", [Int, UInt, UInt], Attr.Const>;
+  def : Builtin<"dot_4x8packed_us_int", [Int, UInt, UInt], Attr.Const>;
+  def : Builtin<"dot_4x8packed_su_int", [Int, UInt, UInt], Attr.Const>;
+
+  def : Builtin<"dot_acc_sat_4x8packed_uu_uint", [UInt, UInt, UInt, UInt], 
Attr.Const>;
+  def : Builtin<"dot_acc_sat_4x8packed_ss_int", [Int, UInt, UInt, Int], 
Attr.Const>;
+  def : Builtin<"dot_acc_sat_4x8packed_us_int", [Int, UInt, UInt, Int], 
Attr.Const>;
+  def : Builtin<"dot_acc_sat_4x8packed_su_int", [Int, UInt, UInt, Int], 
Attr.Const>;
+}
+
 //
 // Arm extensions.
 let Extension = ArmIntegerDotProductInt8 in {

diff  --git a/clang/test/Headers/opencl-c-header.cl 
b/c

[clang] 73e1888 - [OpenCL] Guard write_only image3d_t with TypeExtension

2022-03-21 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-03-21T12:45:58Z
New Revision: 73e1888e530afefd4a9a774ef9c29bf24baca3d4

URL: 
https://github.com/llvm/llvm-project/commit/73e1888e530afefd4a9a774ef9c29bf24baca3d4
DIFF: 
https://github.com/llvm/llvm-project/commit/73e1888e530afefd4a9a774ef9c29bf24baca3d4.diff

LOG: [OpenCL] Guard write_only image3d_t with TypeExtension

Ensure that the TypeExtension of an `ImageType` is also taken into
account when generating `OpenCLBuiltins.inc`.

This aligns the handling of the `write_only image3d_t` type for
`-fdeclare-opencl-builtins` with opencl-c.h with respect to the
`cl_khr_3d_image_writes` extension.

Since the `write_only image3d_t` type is not available when the
extension is disabled, this commit does not add a test to
`SemaOpenCL/fdeclare-opencl-builtins.cl`.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index ff23a1c52ff38..9c1a39cdb1a56 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -134,9 +134,6 @@ def FuncExtFloatAtomicsFp64GenericASMinMax: 
FunctionExtension<"cl_ext_float_
 // Not a real extension, but a workaround to add C++ for OpenCL specific 
builtins.
 def FuncExtOpenCLCxx : FunctionExtension<"__cplusplus">;
 
-// Multiple extensions
-def FuncExtKhrMipmapWritesAndWrite3d : 
FunctionExtension<"cl_khr_mipmap_image_writes cl_khr_3d_image_writes">;
-
 // Arm extensions.
 def ArmIntegerDotProductInt8   : 
FunctionExtension<"cl_arm_integer_dot_product_int8">;
 def ArmIntegerDotProductAccumulateInt8 : 
FunctionExtension<"cl_arm_integer_dot_product_accumulate_int8">;
@@ -246,7 +243,10 @@ class ImageType :
   let IsConst = _Ty.IsConst;
   let IsVolatile = _Ty.IsVolatile;
   let AddrSpace = _Ty.AddrSpace;
-  let Extension = _Ty.Extension;
+  // Add TypeExtension for "write_only image3d_t".
+  let Extension = !cond(
+  !and(!eq(_Ty.Name, "image3d_t"), !eq(_AccessQualifier, "WO")) : 
TypeExtension<"cl_khr_3d_image_writes">,
+  true : _Ty.Extension);
 }
 
 // OpenCL enum type (e.g. memory_scope).
@@ -1625,12 +1625,10 @@ let Extension = FuncExtKhrMipmapImageWrites in {
   def : Builtin<"write_imageui", [Void, ImageType, 
VectorType, Int, VectorType]>;
 }
 def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, Float]>;
-let Extension = FuncExtKhrMipmapWritesAndWrite3d in {
-  foreach imgTy = [Image3d] in {
-def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, VectorType]>;
-def : Builtin<"write_imagei", [Void, ImageType, 
VectorType, Int, VectorType]>;
-def : Builtin<"write_imageui", [Void, ImageType, 
VectorType, Int, VectorType]>;
-  }
+foreach imgTy = [Image3d] in {
+  def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imagei", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imageui", [Void, ImageType, 
VectorType, Int, VectorType]>;
 }
   }
 }

diff  --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index a2d0cfb0b6ca9..dca9970444a73 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -822,15 +822,24 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
<< "case OCLAQ_None:\n"
<< "  llvm_unreachable(\"Image without access qualifier\");\n";
 for (const auto &Image : ITE.getValue()) {
+  StringRef Exts =
+  Image->getValueAsDef("Extension")->getValueAsString("ExtName");
   OS << StringSwitch(
 Image->getValueAsString("AccessQualifier"))
 .Case("RO", "case OCLAQ_ReadOnly:\n")
 .Case("WO", "case OCLAQ_WriteOnly:\n")
-.Case("RW", "case OCLAQ_ReadWrite:\n")
- << "  QT.push_back("
+.Case("RW", "case OCLAQ_ReadWrite:\n");
+  if (!Exts.empty()) {
+OS << "";
+EmitMacroChecks(OS, Exts);
+  }
+  OS << "  QT.push_back("
  << Image->getValueAsDef("QTExpr")->getValueAsString("TypeExpr")
- << ");\n"
- << "  break;\n";
+ << ");\n";
+  if (!Exts.empty()) {
+OS << "  }\n";
+  }
+  OS << "  break;\n";
 }
 OS << "  }\n"
<< "  break;\n";



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


[clang] 1331ad2 - [OpenCL] Add generic addrspace guards for get_fence

2022-04-08 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-04-08T12:08:10+01:00
New Revision: 1331ad22c31fc2ed6890fa046c1e2333e369251b

URL: 
https://github.com/llvm/llvm-project/commit/1331ad22c31fc2ed6890fa046c1e2333e369251b
DIFF: 
https://github.com/llvm/llvm-project/commit/1331ad22c31fc2ed6890fa046c1e2333e369251b.diff

LOG: [OpenCL] Add generic addrspace guards for get_fence

Align guards of these builtins with opencl-c.h.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index a57b74430f694..b64b50867ce59 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -923,7 +923,7 @@ def : Builtin<"write_mem_fence", [Void, MemFenceFlags]>;
 // OpenCL v3.0 s6.15.10 - Address Space Qualifier Functions.
 // to_global, to_local, to_private are declared in Builtins.def.
 
-let MinVersion = CL20 in {
+let Extension = FuncExtOpenCLCGenericAddressSpace in {
   // The OpenCL 3.0 specification defines these with a "gentype" argument 
indicating any builtin
   // type or user-defined type, which cannot be represented currently.  Hence 
we slightly diverge
   // by providing only the following overloads with a void pointer.



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


[clang] bb6f8d9 - [OpenCL] Add device enqueue guards for DSE builtins

2022-04-11 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-04-11T11:27:51+01:00
New Revision: bb6f8d9a93ef0172f227b04c92e7bbb703641a79

URL: 
https://github.com/llvm/llvm-project/commit/bb6f8d9a93ef0172f227b04c92e7bbb703641a79
DIFF: 
https://github.com/llvm/llvm-project/commit/bb6f8d9a93ef0172f227b04c92e7bbb703641a79.diff

LOG: [OpenCL] Add device enqueue guards for DSE builtins

Align guards of these builtins with opencl-c.h.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index b64b50867ce59..a7469d684bcc4 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -104,6 +104,7 @@ def FuncExtKhrMipmapImageWrites  : 
FunctionExtension<"cl_khr_mipmap_imag
 def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sharing">;
 def FuncExtKhrGlMsaaSharingReadWrite : 
FunctionExtension<"cl_khr_gl_msaa_sharing __opencl_c_read_write_images">;
 
+def FuncExtOpenCLCDeviceEnqueue  : 
FunctionExtension<"__opencl_c_device_enqueue">;
 def FuncExtOpenCLCGenericAddressSpace: 
FunctionExtension<"__opencl_c_generic_address_space">;
 def FuncExtOpenCLCNamedAddressSpaceBuiltins : 
FunctionExtension<"__opencl_c_named_address_space_builtins">;
 def FuncExtOpenCLCPipes  : 
FunctionExtension<"__opencl_c_pipes">;
@@ -1454,7 +1455,7 @@ let Extension = FuncExtOpenCLCPipes in {
 // Defined in Builtins.def
 
 // --- Table 33 ---
-let MinVersion = CL20 in {
+let Extension = FuncExtOpenCLCDeviceEnqueue in {
   def : Builtin<"enqueue_marker",
   [Int, Queue, UInt, PointerType, GenericAS>, 
PointerType]>;
 

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index e3602aa95e2a9..416f5342ef22e 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -73,6 +73,7 @@ typedef struct {int a;} ndrange_t;
 
 // Enable extensions that are enabled in opencl-c-base.h.
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#define __opencl_c_device_enqueue 1
 #define __opencl_c_generic_address_space 1
 #define cl_khr_subgroup_extended_types 1
 #define cl_khr_subgroup_ballot 1



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


[clang] f3ee0af - [OpenCL] opencl-c.h: Add const to get_image_num_samples

2022-04-19 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-04-19T10:16:44+01:00
New Revision: f3ee0afc6739bf2990f9d302ff6b28dbb0429e8d

URL: 
https://github.com/llvm/llvm-project/commit/f3ee0afc6739bf2990f9d302ff6b28dbb0429e8d
DIFF: 
https://github.com/llvm/llvm-project/commit/f3ee0afc6739bf2990f9d302ff6b28dbb0429e8d.diff

LOG: [OpenCL] opencl-c.h: Add const to get_image_num_samples

Align with the `-fdeclare-opencl-builtins` option and other
get_image_* builtins which have the const attribute.

Differential Revision: https://reviews.llvm.org/D122728

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index cee3c680aff2e..7ea835ae5c2de 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -16118,21 +16118,21 @@ size_t __ovld __cnfn get_image_array_size(read_write 
image2d_array_msaa_depth_t)
 * Return the number of samples associated with image
 */
 #if defined(cl_khr_gl_msaa_sharing)
-int __ovld get_image_num_samples(read_only image2d_msaa_t);
-int __ovld get_image_num_samples(read_only image2d_msaa_depth_t);
-int __ovld get_image_num_samples(read_only image2d_array_msaa_t);
-int __ovld get_image_num_samples(read_only image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_depth_t);
 
-int __ovld get_image_num_samples(write_only image2d_msaa_t);
-int __ovld get_image_num_samples(write_only image2d_msaa_depth_t);
-int __ovld get_image_num_samples(write_only image2d_array_msaa_t);
-int __ovld get_image_num_samples(write_only image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_depth_t);
 
 #if defined(__opencl_c_read_write_images)
-int __ovld get_image_num_samples(read_write image2d_msaa_t);
-int __ovld get_image_num_samples(read_write image2d_msaa_depth_t);
-int __ovld get_image_num_samples(read_write image2d_array_msaa_t);
-int __ovld get_image_num_samples(read_write image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_depth_t);
 #endif //defined(__opencl_c_read_write_images)
 #endif
 



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


[clang] e67b1b0 - [OpenCL] Add missing __opencl_c_atomic_scope_device guards

2022-04-20 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-04-20T11:02:50+01:00
New Revision: e67b1b0ccf520a0168758d116e88f63160812e99

URL: 
https://github.com/llvm/llvm-project/commit/e67b1b0ccf520a0168758d116e88f63160812e99
DIFF: 
https://github.com/llvm/llvm-project/commit/e67b1b0ccf520a0168758d116e88f63160812e99.diff

LOG: [OpenCL] Add missing __opencl_c_atomic_scope_device guards

Update opencl-c.h after the specification clarification in
https://github.com/KhronosGroup/OpenCL-Docs/pull/775

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 7ea835ae5c2de..8d9af52481957 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -14376,6 +14376,7 @@ bool __ovld atomic_compare_exchange_weak(volatile 
__local atomic_ulong *, __priv
 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 #endif
 
+#if defined(__opencl_c_atomic_scope_device)
 #if defined(__opencl_c_generic_address_space)
 bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *, int 
*, int, memory_order, memory_order);
 bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *, 
uint *, uint, memory_order, memory_order);
@@ -14472,6 +14473,7 @@ bool __ovld 
atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong
 bool __ovld atomic_compare_exchange_weak_explicit(volatile __local 
atomic_ulong *, __private ulong *, ulong, memory_order, memory_order);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
+#endif //defined(__opencl_c_atomic_scope_device)
 
 #if defined(__opencl_c_generic_address_space)
 bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *, int 
*, int, memory_order, memory_order, memory_scope);



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


[clang] 87a2583 - [OpenCL] Guard read_write images with TypeExtension

2022-04-21 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-04-21T10:52:41+01:00
New Revision: 87a258366e5d4f3786c6c2b9fe5dbeb736def909

URL: 
https://github.com/llvm/llvm-project/commit/87a258366e5d4f3786c6c2b9fe5dbeb736def909
DIFF: 
https://github.com/llvm/llvm-project/commit/87a258366e5d4f3786c6c2b9fe5dbeb736def909.diff

LOG: [OpenCL] Guard read_write images with TypeExtension

Ensure that any `read_write` image type carries the
`__opencl_c_read_write_images` upon construction of the `ImageType`.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index a7469d684bcc4..ece0b8866d942 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -99,10 +99,8 @@ def FuncExtKhrLocalInt32ExtendedAtomics  : 
FunctionExtension<"cl_khr_local_int32
 def FuncExtKhrInt64BaseAtomics   : 
FunctionExtension<"cl_khr_int64_base_atomics">;
 def FuncExtKhrInt64ExtendedAtomics   : 
FunctionExtension<"cl_khr_int64_extended_atomics">;
 def FuncExtKhrMipmapImage: 
FunctionExtension<"cl_khr_mipmap_image">;
-def FuncExtKhrMipmapImageReadWrite   : 
FunctionExtension<"cl_khr_mipmap_image __opencl_c_read_write_images">;
 def FuncExtKhrMipmapImageWrites  : 
FunctionExtension<"cl_khr_mipmap_image_writes">;
 def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sharing">;
-def FuncExtKhrGlMsaaSharingReadWrite : 
FunctionExtension<"cl_khr_gl_msaa_sharing __opencl_c_read_write_images">;
 
 def FuncExtOpenCLCDeviceEnqueue  : 
FunctionExtension<"__opencl_c_device_enqueue">;
 def FuncExtOpenCLCGenericAddressSpace: 
FunctionExtension<"__opencl_c_generic_address_space">;
@@ -244,9 +242,11 @@ class ImageType :
   let IsConst = _Ty.IsConst;
   let IsVolatile = _Ty.IsVolatile;
   let AddrSpace = _Ty.AddrSpace;
-  // Add TypeExtension for "write_only image3d_t".
+  // Add TypeExtensions for writable "image3d_t" and "read_write" image types.
   let Extension = !cond(
   !and(!eq(_Ty.Name, "image3d_t"), !eq(_AccessQualifier, "WO")) : 
TypeExtension<"cl_khr_3d_image_writes">,
+  !and(!eq(_Ty.Name, "image3d_t"), !eq(_AccessQualifier, "RW")) : 
TypeExtension<"cl_khr_3d_image_writes __opencl_c_read_write_images">,
+  !eq(_AccessQualifier, "RW") : 
TypeExtension<"__opencl_c_read_write_images">,
   true : _Ty.Extension);
 }
 
@@ -1594,9 +1594,6 @@ multiclass ImageQueryNumMipLevels {
 let Extension = FuncExtKhrMipmapImage in {
   defm : ImageQueryNumMipLevels<"RO">;
   defm : ImageQueryNumMipLevels<"WO">;
-}
-
-let Extension = FuncExtKhrMipmapImageReadWrite in {
   defm : ImageQueryNumMipLevels<"RW">;
 }
 
@@ -1673,9 +1670,6 @@ let Extension = FuncExtKhrGlMsaaSharing in {
   defm : ImageReadMsaa<"RO">;
   defm : ImageQueryMsaa<"RO">;
   defm : ImageQueryMsaa<"WO">;
-}
-
-let Extension = FuncExtKhrGlMsaaSharingReadWrite in {
   defm : ImageReadMsaa<"RW">;
   defm : ImageQueryMsaa<"RW">;
 }



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


[clang] d97a4df - [OpenCL] Move most _explicit atomics into multiclass; NFC

2022-02-03 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-03T11:09:41Z
New Revision: d97a4dfea6c2781494f6fe54ce265128f5c08dc2

URL: 
https://github.com/llvm/llvm-project/commit/d97a4dfea6c2781494f6fe54ce265128f5c08dc2
DIFF: 
https://github.com/llvm/llvm-project/commit/d97a4dfea6c2781494f6fe54ce265128f5c08dc2.diff

LOG: [OpenCL] Move most _explicit atomics into multiclass; NFC

This will simplify future conditionalization for OpenCL 3.0
optionality of atomic features.

The only set of atomic functions not using the multiclass is
atomic_compare_exchange_strong/weak, as these don't fit the common
pattern due to having 2 MemoryOrder arguments.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index cd704ba2df13d..516653681331e 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1040,6 +1040,18 @@ let Extension = FuncExtOpenCLCxx in {
   }
 }
 
+// An atomic builtin with 2 additional _explicit variants.
+multiclass BuiltinAtomicExplicit Types> {
+  // Without explicit MemoryOrder or MemoryScope.
+  def : Builtin;
+
+  // With an explicit MemoryOrder argument.
+  def : Builtin;
+
+  // With explicit MemoryOrder and MemoryScope arguments.
+  def : Builtin;
+}
+
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
   def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;
@@ -1049,24 +1061,12 @@ let MinVersion = CL20 in {
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
 def : Builtin<"atomic_init",
 [Void, PointerType, GenericAS>, 
TypePair[1]]>;
-def : Builtin<"atomic_store",
+defm : BuiltinAtomicExplicit<"atomic_store",
 [Void, PointerType, GenericAS>, 
TypePair[1]]>;
-def : Builtin<"atomic_store_explicit",
-[Void, PointerType, GenericAS>, TypePair[1], 
MemoryOrder]>;
-def : Builtin<"atomic_store_explicit",
-[Void, PointerType, GenericAS>, TypePair[1], 
MemoryOrder, MemoryScope]>;
-def : Builtin<"atomic_load",
+defm : BuiltinAtomicExplicit<"atomic_load",
 [TypePair[1], PointerType, GenericAS>]>;
-def : Builtin<"atomic_load_explicit",
-[TypePair[1], PointerType, GenericAS>, 
MemoryOrder]>;
-def : Builtin<"atomic_load_explicit",
-[TypePair[1], PointerType, GenericAS>, 
MemoryOrder, MemoryScope]>;
-def : Builtin<"atomic_exchange",
+defm : BuiltinAtomicExplicit<"atomic_exchange",
 [TypePair[1], PointerType, GenericAS>, 
TypePair[1]]>;
-def : Builtin<"atomic_exchange_explicit",
-[TypePair[1], PointerType, GenericAS>, 
TypePair[1], MemoryOrder]>;
-def : Builtin<"atomic_exchange_explicit",
-[TypePair[1], PointerType, GenericAS>, 
TypePair[1], MemoryOrder, MemoryScope]>;
 foreach Variant = ["weak", "strong"] in {
   def : Builtin<"atomic_compare_exchange_" # Variant,
   [Bool, PointerType, GenericAS>,
@@ -1084,249 +1084,125 @@ let MinVersion = CL20 in {
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
-  def : Builtin<"atomic_fetch_" # ModOp,
+  defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
   [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder, MemoryScope]>;
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] 
in {
 foreach ModOp = ["or", "xor", "and", "min", "max"] in {
-  def : Builtin<"atomic_fetch_" # ModOp,
+  defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
   [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder, MemoryScope]>;
 }
   }
 
-  def : Builtin<"atomic_flag_clear",
+  defm : BuiltinAtomicExplicit<"atomic_flag_clear",
   [Void, PointerType, GenericAS>]>;
-  def : Builtin<"atomic_flag_clear_explicit",
-  [Void, PointerType, GenericAS>, MemoryOrder]>;
-  def : Builtin<"atomic_flag_clear_explicit",
-  [Void, PointerType, GenericAS>, MemoryOrder, 
MemoryScope]>;
 
-  def : Builtin<"atomic_flag_test_and_set",
+  defm : BuiltinAtomicExplicit<"atomic_flag_test_and_set",
   [Bool, PointerType, GenericAS>]>;
-  def : Builtin<

[clang] 9694332 - [clang-format] Add missing newline in -style help

2022-02-03 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-03T12:12:29Z
New Revision: 9694332b81dd14a0a2ab5d9ea9977558fd5f53be

URL: 
https://github.com/llvm/llvm-project/commit/9694332b81dd14a0a2ab5d9ea9977558fd5f53be
DIFF: 
https://github.com/llvm/llvm-project/commit/9694332b81dd14a0a2ab5d9ea9977558fd5f53be.diff

LOG: [clang-format] Add missing newline in -style help

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1ee557079f6c..daa815106049 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3246,7 +3246,7 @@ const char *StyleOptionHelpDescription =
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
-"Use -style=file: to explicitly specify"
+"Use -style=file: to explicitly specify\n"
 "the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"



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


[clang] 31fa3a4 - [OpenCL] Move OpenCL 2.0 atomics into multiclass; NFC

2022-02-04 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-04T10:17:48Z
New Revision: 31fa3a4d44316fd36e11f92729ea9596ee3bf3f8

URL: 
https://github.com/llvm/llvm-project/commit/31fa3a4d44316fd36e11f92729ea9596ee3bf3f8
DIFF: 
https://github.com/llvm/llvm-project/commit/31fa3a4d44316fd36e11f92729ea9596ee3bf3f8.diff

LOG: [OpenCL] Move OpenCL 2.0 atomics into multiclass; NFC

This is in preparation for adding the OpenCL 3.0 builtins with named
address space arguments.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 516653681331e..08f8630a67e22 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1040,6 +1040,8 @@ let Extension = FuncExtOpenCLCxx in {
   }
 }
 
+// OpenCL v2.0 s6.13.11 - Atomic Functions.
+
 // An atomic builtin with 2 additional _explicit variants.
 multiclass BuiltinAtomicExplicit Types> {
   // Without explicit MemoryOrder or MemoryScope.
@@ -1052,31 +1054,29 @@ multiclass BuiltinAtomicExplicit Types> {
   def : Builtin;
 }
 
-// OpenCL v2.0 s6.13.11 - Atomic Functions.
-let MinVersion = CL20 in {
-  def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;
-
+// OpenCL 2.0 atomic functions that have a pointer argument in a given address 
space.
+multiclass OpenCL2Atomics {
   foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
   [AtomicLong, Long], [AtomicULong, ULong],
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
 def : Builtin<"atomic_init",
-[Void, PointerType, GenericAS>, 
TypePair[1]]>;
+[Void, PointerType, addrspace>, 
TypePair[1]]>;
 defm : BuiltinAtomicExplicit<"atomic_store",
-[Void, PointerType, GenericAS>, 
TypePair[1]]>;
+[Void, PointerType, addrspace>, 
TypePair[1]]>;
 defm : BuiltinAtomicExplicit<"atomic_load",
-[TypePair[1], PointerType, GenericAS>]>;
+[TypePair[1], PointerType, addrspace>]>;
 defm : BuiltinAtomicExplicit<"atomic_exchange",
-[TypePair[1], PointerType, GenericAS>, 
TypePair[1]]>;
+[TypePair[1], PointerType, addrspace>, 
TypePair[1]]>;
 foreach Variant = ["weak", "strong"] in {
   def : Builtin<"atomic_compare_exchange_" # Variant,
-  [Bool, PointerType, GenericAS>,
-   PointerType, TypePair[1]]>;
+  [Bool, PointerType, addrspace>,
+   PointerType, TypePair[1]]>;
   def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, GenericAS>,
-   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder]>;
+  [Bool, PointerType, addrspace>,
+   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder]>;
   def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, GenericAS>,
-   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder, MemoryScope]>;
+  [Bool, PointerType, addrspace>,
+   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder, MemoryScope]>;
 }
   }
 
@@ -1085,22 +1085,28 @@ let MinVersion = CL20 in {
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
+  [TypePair[1], PointerType, addrspace>, 
TypePair[2]]>;
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] 
in {
 foreach ModOp = ["or", "xor", "and", "min", "max"] in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
+  [TypePair[1], PointerType, addrspace>, 
TypePair[2]]>;
 }
   }
 
   defm : BuiltinAtomicExplicit<"atomic_flag_clear",
-  [Void, PointerType, GenericAS>]>;
+  [Void, PointerType, addrspace>]>;
 
   defm : BuiltinAtomicExplicit<"atomic_flag_test_and_set",
-  [Bool, PointerType, GenericAS>]>;
+  [Bool, PointerType, addrspace>]>;
+}
+
+let MinVersion = CL20 in {
+  def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;
+
+  defm : OpenCL2Atomics;
 }
 
 // The functionality added by cl_ext_float_atomics extension



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


[clang] c15782b - [OpenCL] opencl-c.h: make attribute order consistent; NFC

2022-02-07 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-07T10:54:55Z
New Revision: c15782bcf5c900fc43fd545c9572f77ef92c5f5e

URL: 
https://github.com/llvm/llvm-project/commit/c15782bcf5c900fc43fd545c9572f77ef92c5f5e
DIFF: 
https://github.com/llvm/llvm-project/commit/c15782bcf5c900fc43fd545c9572f77ef92c5f5e.diff

LOG: [OpenCL] opencl-c.h: make attribute order consistent; NFC

For most builtins, `__purefn` always comes after `__ovld`, but the
read_image functions did not follow this pattern.

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 059a2ec2371bd..6e5733249ee4c 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -15427,123 +15427,123 @@ half16 __ovld __cnfn shuffle2(half16 x, half16 y, 
ushort16 mask);
  * in the description above are undefined.
  */
 
-float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t 
sampler, int2 coord);
-float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t 
sampler, float2 coord);
+float4 __ovld __purefn read_imagef(read_only image2d_t image, sampler_t 
sampler, int2 coord);
+float4 __ovld __purefn read_imagef(read_only image2d_t image, sampler_t 
sampler, float2 coord);
 
-int4 __purefn __ovld read_imagei(read_only image2d_t image, sampler_t sampler, 
int2 coord);
-int4 __purefn __ovld read_imagei(read_only image2d_t image, sampler_t sampler, 
float2 coord);
-uint4 __purefn __ovld read_imageui(read_only image2d_t image, sampler_t 
sampler, int2 coord);
-uint4 __purefn __ovld read_imageui(read_only image2d_t image, sampler_t 
sampler, float2 coord);
+int4 __ovld __purefn read_imagei(read_only image2d_t image, sampler_t sampler, 
int2 coord);
+int4 __ovld __purefn read_imagei(read_only image2d_t image, sampler_t sampler, 
float2 coord);
+uint4 __ovld __purefn read_imageui(read_only image2d_t image, sampler_t 
sampler, int2 coord);
+uint4 __ovld __purefn read_imageui(read_only image2d_t image, sampler_t 
sampler, float2 coord);
 
-float4 __purefn __ovld read_imagef(read_only image3d_t image, sampler_t 
sampler, int4 coord);
-float4 __purefn __ovld read_imagef(read_only image3d_t image, sampler_t 
sampler, float4 coord);
+float4 __ovld __purefn read_imagef(read_only image3d_t image, sampler_t 
sampler, int4 coord);
+float4 __ovld __purefn read_imagef(read_only image3d_t image, sampler_t 
sampler, float4 coord);
 
-int4 __purefn __ovld read_imagei(read_only image3d_t image, sampler_t sampler, 
int4 coord);
-int4 __purefn __ovld read_imagei(read_only image3d_t image, sampler_t sampler, 
float4 coord);
-uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t 
sampler, int4 coord);
-uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t 
sampler, float4 coord);
+int4 __ovld __purefn read_imagei(read_only image3d_t image, sampler_t sampler, 
int4 coord);
+int4 __ovld __purefn read_imagei(read_only image3d_t image, sampler_t sampler, 
float4 coord);
+uint4 __ovld __purefn read_imageui(read_only image3d_t image, sampler_t 
sampler, int4 coord);
+uint4 __ovld __purefn read_imageui(read_only image3d_t image, sampler_t 
sampler, float4 coord);
 
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
-float4 __purefn __ovld read_imagef(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
-float4 __purefn __ovld read_imagef(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
+float4 __ovld __purefn read_imagef(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
+float4 __ovld __purefn read_imagef(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
 
-int4 __purefn __ovld read_imagei(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
-int4 __purefn __ovld read_imagei(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
-uint4 __purefn __ovld read_imageui(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
-uint4 __purefn __ovld read_imageui(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
+int4 __ovld __purefn read_imagei(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
+int4 __ovld __purefn read_imagei(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
+uint4 __ovld __purefn read_imageui(read_only image2d_array_t image_array, 
sampler_t sampler, int4 coord);
+uint4 __ovld __purefn read_imageui(read_only image2d_array_t image_array, 
sampler_t sampler, float4 coord);
 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)
 
-float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t 
sampler, int coord);
-float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t 
sampler, float coord);
+float4 __ovld __purefn read_imagef(read_on

[clang] 9b8a93e - [OpenCL] opencl-c.h: remove arg names from arm_dot; NFC

2022-02-08 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-08T13:42:24Z
New Revision: 9b8a93e3b6d36ad4f96c93a6c41ca4b0ef6d3d22

URL: 
https://github.com/llvm/llvm-project/commit/9b8a93e3b6d36ad4f96c93a6c41ca4b0ef6d3d22
DIFF: 
https://github.com/llvm/llvm-project/commit/9b8a93e3b6d36ad4f96c93a6c41ca4b0ef6d3d22.diff

LOG: [OpenCL] opencl-c.h: remove arg names from arm_dot; NFC

This simplifies completeness comparisons against OpenCLBuiltins.td.

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 6e5733249ee4c..98c92fd7ef0a3 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -18517,23 +18517,23 @@ uint16 __ovld amd_sadw(uint16 src0, uint16 src1, 
uint16 src2);
 #endif // cl_amd_media_ops2
 
 #if defined(cl_arm_integer_dot_product_int8)
-uint __ovld arm_dot(uchar4 a, uchar4 b);
-int __ovld arm_dot(char4 a, char4 b);
+uint __ovld arm_dot(uchar4, uchar4);
+int __ovld arm_dot(char4, char4);
 #endif // defined(cl_arm_integer_dot_product_int8)
 
 #if defined(cl_arm_integer_dot_product_accumulate_int8)
-uint __ovld arm_dot_acc(uchar4 a, uchar4 b, uint c);
-int __ovld arm_dot_acc(char4 a, char4 b, int c);
+uint __ovld arm_dot_acc(uchar4, uchar4, uint);
+int __ovld arm_dot_acc(char4, char4, int);
 #endif // defined(cl_arm_integer_dot_product_accumulate_int8)
 
 #if defined(cl_arm_integer_dot_product_accumulate_int16)
-uint __ovld arm_dot_acc(ushort2 a, ushort2 b, uint c);
-int __ovld arm_dot_acc(short2 a, short2 b, int c);
+uint __ovld arm_dot_acc(ushort2, ushort2, uint);
+int __ovld arm_dot_acc(short2, short2, int);
 #endif // defined(cl_arm_integer_dot_product_accumulate_int16)
 
 #if defined(cl_arm_integer_dot_product_accumulate_saturate_int8)
-uint __ovld arm_dot_acc_sat(uchar4 a, uchar4 b, uint c);
-int __ovld arm_dot_acc_sat(char4 a, char4 b, int c);
+uint __ovld arm_dot_acc_sat(uchar4, uchar4, uint);
+int __ovld arm_dot_acc_sat(char4, char4, int);
 #endif // defined(cl_arm_integer_dot_product_accumulate_saturate_int8)
 
 // Disable any extensions we may have enabled previously.



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


[clang] fe69058 - [OpenCL] Fix atomic_fetch_add/sub with half type

2022-02-09 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-09T10:47:45Z
New Revision: fe690587bedb23dec2753549d4216059a7f894a1

URL: 
https://github.com/llvm/llvm-project/commit/fe690587bedb23dec2753549d4216059a7f894a1
DIFF: 
https://github.com/llvm/llvm-project/commit/fe690587bedb23dec2753549d4216059a7f894a1.diff

LOG: [OpenCL] Fix atomic_fetch_add/sub with half type

An error in the tablegen description affects the declarations
provided by `-fdeclare-opencl-builtins` for `atomic_fetch_add` and
`atomic_fetch_sub`.

The atomic argument should be an atomic_half, not an atomic_float.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 08f8630a67e22..60a05f95fbec8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1138,7 +1138,7 @@ let MinVersion = CL20 in {
   foreach ModOp = ["add", "sub"] in {
 let Extension = FuncExtFloatAtomicsFp16GlobalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [Half, PointerType, GlobalAS>, Half]>;
+  [Half, PointerType, GlobalAS>, Half]>;
 }
 let Extension = FuncExtFloatAtomicsFp32GlobalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
@@ -1150,7 +1150,7 @@ let MinVersion = CL20 in {
 }
 let Extension = FuncExtFloatAtomicsFp16LocalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [Half, PointerType, LocalAS>, Half]>;
+  [Half, PointerType, LocalAS>, Half]>;
 }
 let Extension = FuncExtFloatAtomicsFp32LocalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
@@ -1162,7 +1162,7 @@ let MinVersion = CL20 in {
 }
 let Extension = FuncExtFloatAtomicsFp16GenericAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [Half, PointerType, GenericAS>, Half]>;
+  [Half, PointerType, GenericAS>, Half]>;
 }
 let Extension = FuncExtFloatAtomicsFp32GenericAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,



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


[clang] a464444 - [OpenCL][Docs] Update OpenCL 3.0 status info

2022-02-09 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-09T15:12:49Z
New Revision: a46b2888b9d0fcfb712897f0110cadb84d93

URL: 
https://github.com/llvm/llvm-project/commit/a46b2888b9d0fcfb712897f0110cadb84d93
DIFF: 
https://github.com/llvm/llvm-project/commit/a46b2888b9d0fcfb712897f0110cadb84d93.diff

LOG: [OpenCL][Docs] Update OpenCL 3.0 status info

Update the table to reflect recently committed work.

Added: 


Modified: 
clang/docs/OpenCLSupport.rst

Removed: 




diff  --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst
index c1202601d48d3..7303c2b4e645b 100644
--- a/clang/docs/OpenCLSupport.rst
+++ b/clang/docs/OpenCLSupport.rst
@@ -382,17 +382,17 @@ implementation status.
 
+--+-+-+--+--+
 | Feature optionality  | Generic address space 
| :good:`done` | https://reviews.llvm.org/D95778 
and https://reviews.llvm.org/D103401 |
 
+--+-+-+--+--+
-| Feature optionality  | Builtin function overloads with generic 
address space | :good:`done` | 
https://reviews.llvm.org/D105526
 |
+| Feature optionality  | Builtin function overloads with generic 
address space | :good:`done` | 
https://reviews.llvm.org/D105526 and https://reviews.llvm.org/D107769   
 |
 
+--+-+-+--+--+
 | Feature optionality  | Program scope variables in global memory  
| :good:`done` | https://reviews.llvm.org/D103191   
  |
 
+--+-+-+--+--+
 | Feature optionality  | 3D image writes including builtin functions   
| :part:`worked on`| https://reviews.llvm.org/D106260 
(frontend)  |
 
+--+-+-+--+--+
-| Feature optionality  | read_write images including builtin functions 
| :part:`worked on`| https://reviews.llvm.org/D104915 
(frontend) and https://reviews.llvm.org/D107539 (functions) |
+| Feature optionality  | read_write images including builtin functions 
| :good:`done` | https://reviews.llvm.org/D104915 
(frontend) and https://reviews.llvm.org/D107539 (functions) |
 
+--+-+-+--+--+
 | Feature optionality  | C11 atomics memory scopes, ordering and 
builtin function  | :good:`done` | 
https://reviews.llvm.org/D106111
 |
 
+--+-+-+--+--+
-| Feature optionality  | Blocks and Device-side kernel enqueue 
including builtin functions | :none:`unclaimed`|
  |
+| Feature optionality  | Blocks and Device-side kernel enqueue 
including builtin functions | :part:`worked on`| 
https://reviews.llvm.org/D118605
 |
 
+--+-+-+--+--+
 | Feature optionality  | Pipes including builtin functions 
| :good:`done` | https://reviews.llvm.org/D107154 
(frontend) and https://reviews.llvm.org/D105858 (funct

[clang] 8d37043 - [OpenCL] Refactor cl_ext_float_atomics declarations; NFC

2022-02-10 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-10T09:43:32Z
New Revision: 8d37043520f57e63e032c9d0ba4cba8701a3cd35

URL: 
https://github.com/llvm/llvm-project/commit/8d37043520f57e63e032c9d0ba4cba8701a3cd35
DIFF: 
https://github.com/llvm/llvm-project/commit/8d37043520f57e63e032c9d0ba4cba8701a3cd35.diff

LOG: [OpenCL] Refactor cl_ext_float_atomics declarations; NFC

Reduce the amount of repetition in the declarations by leveraging more
TableGen constructs.  This is in preparation for adding the OpenCL 3.0
atomics feature optionality.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 60a05f95fbec8..4d36df352d5ec 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -90,27 +90,27 @@ def FuncExtOpenCLCNamedAddressSpaceBuiltins : 
FunctionExtension<"__opencl_c_name
 def FuncExtOpenCLCPipes  : 
FunctionExtension<"__opencl_c_pipes">;
 def FuncExtOpenCLCWGCollectiveFunctions  : 
FunctionExtension<"__opencl_c_work_group_collective_functions">;
 def FuncExtOpenCLCReadWriteImages: 
FunctionExtension<"__opencl_c_read_write_images">;
-def FuncExtFloatAtomicsFp16GlobalLoadStore  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store">;
-def FuncExtFloatAtomicsFp16LocalLoadStore   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_load_store">;
-def FuncExtFloatAtomicsFp16GenericLoadStore : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store 
__opencl_c_ext_fp16_local_atomic_load_store">;
-def FuncExtFloatAtomicsFp16GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_global_atomic_add">;
-def FuncExtFloatAtomicsFp32GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_global_atomic_add">;
-def FuncExtFloatAtomicsFp64GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_global_atomic_add">;
-def FuncExtFloatAtomicsFp16LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_local_atomic_add">;
-def FuncExtFloatAtomicsFp32LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_local_atomic_add">;
-def FuncExtFloatAtomicsFp64LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_local_atomic_add">;
-def FuncExtFloatAtomicsFp16GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_local_atomic_add 
__opencl_c_ext_fp16_global_atomic_add">;
-def FuncExtFloatAtomicsFp32GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_local_atomic_add 
__opencl_c_ext_fp32_global_atomic_add">;
-def FuncExtFloatAtomicsFp64GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_local_atomic_add 
__opencl_c_ext_fp64_global_atomic_add">;
-def FuncExtFloatAtomicsFp16GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp32GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp64GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp16LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp32LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp64LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp16GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_min_max 
__opencl_c_ext_fp16_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp32GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_local_atomic_min_max 
__opencl_c_ext_fp32_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp64GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_local_atomic_min_max 
__opencl_c_ext_fp64_global_atomic_min_max">;
+def FuncExtFloatAtomicsFp16GlobalASLoadStore  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store">;
+def FuncExtFloatAtomicsFp16LocalASLoadStore   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_load_store">;
+def FuncExtFloatAtomicsFp16GenericASLoadStore : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store 
__opencl_c_ext_fp16_local_atomic_load_store">;
+def FuncExtFloatAtomicsFp16GlobalASAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_global_atomic_add">;
+def FuncExtFloatAtomicsFp32GlobalASAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_glob

[clang] 50f8abb - [OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins

2022-02-11 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-11T10:14:14Z
New Revision: 50f8abb9f40a6c4974ec71e760773a711732648f

URL: 
https://github.com/llvm/llvm-project/commit/50f8abb9f40a6c4974ec71e760773a711732648f
DIFF: 
https://github.com/llvm/llvm-project/commit/50f8abb9f40a6c4974ec71e760773a711732648f.diff

LOG: [OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins

Add the atomic overloads for the `global` and `local` address spaces,
which are new in OpenCL 3.0.  Ensure the preexisting `generic`
overloads are guarded by the generic address space feature macro.

Ensure a subset of the atomic builtins are guarded by the
`__opencl_c_atomic_order_seq_cst` and `__opencl_c_atomic_scope_device`
feature macros, and enable those macros for SPIR/SPIR-V targets in
`opencl-c-base.h`.

Also guard the `cl_ext_float_atomics` builtins with the atomic order
and scope feature macros.

Differential Revision: https://reviews.llvm.org/D119420

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index ad276dc0f6aae..5191c41bcd057 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -67,6 +67,8 @@
 #if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 // For the SPIR and SPIR-V target all features are supported.
 #if defined(__SPIR__) || defined(__SPIRV__)
+#define __opencl_c_atomic_order_seq_cst 1
+#define __opencl_c_atomic_scope_device 1
 #define __opencl_c_atomic_scope_all_devices 1
 #define __opencl_c_read_write_images 1
 #endif // defined(__SPIR__)

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 4d36df352d5ec..ab30553005729 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -57,6 +57,23 @@ class FunctionExtension : 
AbstractExtension<_Ext>;
 // disabled.
 class TypeExtension : AbstractExtension<_Ext>;
 
+// Concatenate zero or more space-separated extensions in NewExts to Base and
+// return the resulting FunctionExtension in ret.
+class concatExtension {
+  FunctionExtension ret = FunctionExtension<
+!cond(
+  // Return Base extension if NewExts is empty,
+  !empty(NewExts) : Base.ExtName,
+
+  // otherwise, return NewExts if Base extension is empty,
+  !empty(Base.ExtName) : NewExts,
+
+  // otherwise, concatenate NewExts to Base.
+  true : Base.ExtName # " " # NewExts
+)
+  >;
+}
+
 // TypeExtension definitions.
 def NoTypeExt   : TypeExtension<"">;
 def Fp16TypeExt : TypeExtension<"cl_khr_fp16">;
@@ -1043,40 +1060,57 @@ let Extension = FuncExtOpenCLCxx in {
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 
 // An atomic builtin with 2 additional _explicit variants.
-multiclass BuiltinAtomicExplicit Types> {
+multiclass BuiltinAtomicExplicit Types, 
FunctionExtension BaseExt> {
   // Without explicit MemoryOrder or MemoryScope.
-  def : Builtin;
+  let Extension = concatExtension.ret in {
+def : Builtin;
+  }
 
   // With an explicit MemoryOrder argument.
-  def : Builtin;
+  let Extension = concatExtension.ret in {
+def : Builtin;
+  }
 
   // With explicit MemoryOrder and MemoryScope arguments.
-  def : Builtin;
+  let Extension = BaseExt in {
+def : Builtin;
+  }
 }
 
 // OpenCL 2.0 atomic functions that have a pointer argument in a given address 
space.
-multiclass OpenCL2Atomics {
+multiclass OpenCL2Atomics {
   foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
   [AtomicLong, Long], [AtomicULong, ULong],
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
 def : Builtin<"atomic_init",
 [Void, PointerType, addrspace>, 
TypePair[1]]>;
 defm : BuiltinAtomicExplicit<"atomic_store",
-[Void, PointerType, addrspace>, 
TypePair[1]]>;
+[Void, PointerType, addrspace>, 
TypePair[1]], BaseExt>;
 defm : BuiltinAtomicExplicit<"atomic_load",
-[TypePair[1], PointerType, addrspace>]>;
+[TypePair[1], PointerType, addrspace>], 
BaseExt>;
 defm : BuiltinAtomicExplicit<"atomic_exchange",
-[TypePair[1], PointerType, addrspace>, 
TypePair[1]]>;
+[TypePair[1], PointerType, addrspace>, 
TypePair[1]], BaseExt>;
 foreach Variant = ["weak", "strong"] in {
-  def : Builtin<"atomic_compare_exchange_" # Variant,
-  [Bool, PointerType, addrspace>,
-   PointerType, TypePair[1]]>;
-  def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, addrspace>,
-   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder]>;
-  def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, addrspace>,
-   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder, MemoryScope]>;
+ 

[clang] 074451b - [OpenCL] opencl-c.h: fix atomic_fetch_max with addrspace

2022-02-15 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-15T12:12:03Z
New Revision: 074451bd3352e022d015545e9091002d052daaa3

URL: 
https://github.com/llvm/llvm-project/commit/074451bd3352e022d015545e9091002d052daaa3
DIFF: 
https://github.com/llvm/llvm-project/commit/074451bd3352e022d015545e9091002d052daaa3.diff

LOG: [OpenCL] opencl-c.h: fix atomic_fetch_max with addrspace

Commit 3c7d2f1b67d1 ("[OpenCL] opencl-c.h: add CL 3.0 non-generic
address space atomics", 2021-07-30) added some atomic_fetch_add/sub
overloads with uintptr_t arguments twice.  Instead, they should have
been atomic_fetch_max overloads with non-generic address spaces.

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 98c92fd7ef0a3..7a2ddc47c9a1b 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -13424,8 +13424,8 @@ long __ovld atomic_fetch_max(volatile __global 
atomic_long *object, long operand
 long __ovld atomic_fetch_max(volatile __local atomic_long *object, long 
operand);
 ulong __ovld atomic_fetch_max(volatile __global atomic_ulong *object, ulong 
operand);
 ulong __ovld atomic_fetch_max(volatile __local atomic_ulong *object, ulong 
operand);
-uintptr_t __ovld atomic_fetch_add(volatile __global atomic_uintptr_t *object, 
ptr
diff _t operand);
-uintptr_t __ovld atomic_fetch_sub(volatile __local atomic_uintptr_t *object, 
ptr
diff _t operand);
+uintptr_t __ovld atomic_fetch_max(volatile __global atomic_uintptr_t *object, 
uintptr_t operand);
+uintptr_t __ovld atomic_fetch_max(volatile __local atomic_uintptr_t *object, 
uintptr_t operand);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 #endif
@@ -13543,8 +13543,8 @@ long __ovld atomic_fetch_max_explicit(volatile __global 
atomic_long *object, lon
 long __ovld atomic_fetch_max_explicit(volatile __local atomic_long *object, 
long operand, memory_order order);
 ulong __ovld atomic_fetch_max_explicit(volatile __global atomic_ulong *object, 
ulong operand, memory_order order);
 ulong __ovld atomic_fetch_max_explicit(volatile __local atomic_ulong *object, 
ulong operand, memory_order order);
-uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t 
*object, ptr
diff _t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t 
*object, ptr
diff _t operand, memory_order order);
+uintptr_t __ovld atomic_fetch_max_explicit(volatile __global atomic_uintptr_t 
*object, uintptr_t operand, memory_order order);
+uintptr_t __ovld atomic_fetch_max_explicit(volatile __local atomic_uintptr_t 
*object, uintptr_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 || __OPENCL_CPP_VERSION__ >= 
202100)
 #endif
@@ -13661,8 +13661,8 @@ long __ovld atomic_fetch_max_explicit(volatile __global 
atomic_long *object, lon
 long __ovld atomic_fetch_max_explicit(volatile __local atomic_long *object, 
long operand, memory_order order, memory_scope scope);
 ulong __ovld atomic_fetch_max_explicit(volatile __global atomic_ulong *object, 
ulong operand, memory_order order, memory_scope scope);
 ulong __ovld atomic_fetch_max_explicit(volatile __local atomic_ulong *object, 
ulong operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t 
*object, ptr
diff _t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t 
*object, ptr
diff _t operand, memory_order order, memory_scope scope);
+uintptr_t __ovld atomic_fetch_max_explicit(volatile __global atomic_uintptr_t 
*object, uintptr_t operand, memory_order order, memory_scope scope);
+uintptr_t __ovld atomic_fetch_max_explicit(volatile __local atomic_uintptr_t 
*object, uintptr_t operand, memory_order order, memory_scope scope);
 #endif //defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 
202100)
 



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


[clang] 477bc8e - [OpenCL] Guard atomic_double with cl_khr_int64_*

2022-02-16 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-16T10:07:35Z
New Revision: 477bc8e8b9311fdac4c360b1fe7d29d0d10aac6c

URL: 
https://github.com/llvm/llvm-project/commit/477bc8e8b9311fdac4c360b1fe7d29d0d10aac6c
DIFF: 
https://github.com/llvm/llvm-project/commit/477bc8e8b9311fdac4c360b1fe7d29d0d10aac6c.diff

LOG: [OpenCL] Guard atomic_double with cl_khr_int64_*

It is necessary to guard atomic_double type according to
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#_footnotedef_54.
Platform that disable cl_khr_int64_base_atomics and
cl_khr_int64_extended_atomics will have compiling errors even if
atomic_double is not used.

Patch by Haonan Yang.

Differential Revision: https://reviews.llvm.org/D119398

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 7a2ddc47c9a1b..bf3f01253df32 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -13832,6 +13832,7 @@ float __ovld atomic_fetch_max_explicit(volatile 
atomic_float *object,
 #endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) &&
\
 defined(__opencl_c_ext_fp32_local_atomic_min_max)
 
+#if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #if defined(__opencl_c_ext_fp64_global_atomic_min_max)
 double __ovld atomic_fetch_min(volatile __global atomic_double *object,
double operand);
@@ -13882,6 +13883,8 @@ double __ovld atomic_fetch_max_explicit(volatile 
atomic_double *object,
 memory_scope scope);
 #endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) &&
\
 defined(__opencl_c_ext_fp64_local_atomic_min_max)
+#endif // defined(cl_khr_int64_base_atomics) &&
\
+defined(cl_khr_int64_extended_atomics)
 
 #if defined(__opencl_c_ext_fp16_global_atomic_add)
 half __ovld atomic_fetch_add(volatile __global atomic_half *object,
@@ -13985,6 +13988,7 @@ float __ovld atomic_fetch_sub_explicit(volatile 
atomic_float *object,
 #endif // defined(__opencl_c_ext_fp32_global_atomic_add) &&
\
 defined(__opencl_c_ext_fp32_local_atomic_add)
 
+#if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #if defined(__opencl_c_ext_fp64_global_atomic_add)
 double __ovld atomic_fetch_add(volatile __global atomic_double *object,
double operand);
@@ -14035,6 +14039,8 @@ double __ovld atomic_fetch_sub_explicit(volatile 
atomic_double *object,
 memory_scope scope);
 #endif // defined(__opencl_c_ext_fp64_global_atomic_add) &&
\
 defined(__opencl_c_ext_fp64_local_atomic_add)
+#endif // defined(cl_khr_int64_base_atomics) &&
\
+defined(cl_khr_int64_extended_atomics)
 
 #endif // cl_ext_float_atomics
 



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


[clang] 6690b7d - [OpenCL] Ensure atomic_init is guarded with extension

2022-02-16 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-16T15:12:23Z
New Revision: 6690b7d3ac9ab6410b7909207552ce4edbe2147b

URL: 
https://github.com/llvm/llvm-project/commit/6690b7d3ac9ab6410b7909207552ce4edbe2147b
DIFF: 
https://github.com/llvm/llvm-project/commit/6690b7d3ac9ab6410b7909207552ce4edbe2147b.diff

LOG: [OpenCL] Ensure atomic_init is guarded with extension

The named and generic address space overloads for atomic_init added
by 50f8abb9f40a ("[OpenCL] Add OpenCL 3.0 atomics to
-fdeclare-opencl-builtins", 2022-02-11) were not guarded by the
corresponding extensions.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index ab30553005729..556d1778625e7 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1082,8 +1082,10 @@ multiclass OpenCL2Atomics {
   foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
   [AtomicLong, Long], [AtomicULong, ULong],
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
-def : Builtin<"atomic_init",
-[Void, PointerType, addrspace>, 
TypePair[1]]>;
+let Extension = BaseExt in {
+  def : Builtin<"atomic_init",
+  [Void, PointerType, addrspace>, 
TypePair[1]]>;
+}
 defm : BuiltinAtomicExplicit<"atomic_store",
 [Void, PointerType, addrspace>, 
TypePair[1]], BaseExt>;
 defm : BuiltinAtomicExplicit<"atomic_load",



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


[clang] 9798b33 - [OpenCL] Guard 64-bit atomic types

2022-02-17 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-17T10:58:52Z
New Revision: 9798b33d1dc14f5334e2cc117e3896510fa57b82

URL: 
https://github.com/llvm/llvm-project/commit/9798b33d1dc14f5334e2cc117e3896510fa57b82
DIFF: 
https://github.com/llvm/llvm-project/commit/9798b33d1dc14f5334e2cc117e3896510fa57b82.diff

LOG: [OpenCL] Guard 64-bit atomic types

Until now, overloads with a 64-bit atomic type argument were always
made available with `-fdeclare-opencl-builtins`.  Ensure these
overloads are only available when both the `cl_khr_int64_base_atomics`
and `cl_khr_int64_extended_atomics` extensions have been enabled, as
required by the OpenCL specification.

Differential Revision: https://reviews.llvm.org/D119858

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 556d1778625e7..e6da5e34f7091 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -78,6 +78,8 @@ class concatExtension 
{
 def NoTypeExt   : TypeExtension<"">;
 def Fp16TypeExt : TypeExtension<"cl_khr_fp16">;
 def Fp64TypeExt : TypeExtension<"cl_khr_fp64">;
+def Atomic64TypeExt : TypeExtension<"cl_khr_int64_base_atomics 
cl_khr_int64_extended_atomics">;
+def AtomicFp64TypeExt : TypeExtension<"cl_khr_int64_base_atomics 
cl_khr_int64_extended_atomics cl_khr_fp64">;
 
 // FunctionExtension definitions.
 def FuncExtNone  : FunctionExtension<"">;
@@ -389,10 +391,14 @@ def NDRange   : TypedefType<"ndrange_t">;
 // OpenCL v2.0 s6.13.11: Atomic integer and floating-point types.
 def AtomicInt : Type<"atomic_int", 
QualType<"Context.getAtomicType(Context.IntTy)">>;
 def AtomicUInt: Type<"atomic_uint", 
QualType<"Context.getAtomicType(Context.UnsignedIntTy)">>;
-def AtomicLong: Type<"atomic_long", 
QualType<"Context.getAtomicType(Context.LongTy)">>;
-def AtomicULong   : Type<"atomic_ulong", 
QualType<"Context.getAtomicType(Context.UnsignedLongTy)">>;
+let Extension = Atomic64TypeExt in {
+  def AtomicLong: Type<"atomic_long", 
QualType<"Context.getAtomicType(Context.LongTy)">>;
+  def AtomicULong   : Type<"atomic_ulong", 
QualType<"Context.getAtomicType(Context.UnsignedLongTy)">>;
+}
 def AtomicFloat   : Type<"atomic_float", 
QualType<"Context.getAtomicType(Context.FloatTy)">>;
-def AtomicDouble  : Type<"atomic_double", 
QualType<"Context.getAtomicType(Context.DoubleTy)">>;
+let Extension = AtomicFp64TypeExt in {
+  def AtomicDouble  : Type<"atomic_double", 
QualType<"Context.getAtomicType(Context.DoubleTy)">>;
+}
 def AtomicHalf: Type<"atomic_half", 
QualType<"Context.getAtomicType(Context.HalfTy)">>;
 def AtomicIntPtr  : Type<"atomic_intptr_t", 
QualType<"Context.getAtomicType(Context.getIntPtrType())">>;
 def AtomicUIntPtr : Type<"atomic_uintptr_t", 
QualType<"Context.getAtomicType(Context.getUIntPtrType())">>;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index d526c32d65a92..d2d7fff02efaa 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -163,6 +163,25 @@ void test_atomic_fetch_with_address_space(volatile 
__generic atomic_float *a_flo
 }
 #endif // !defined(NO_HEADER) && __OPENCL_C_VERSION__ >= 200
 
+#if !defined(NO_HEADER) && __OPENCL_C_VERSION__ == 200 && 
defined(__opencl_c_generic_address_space)
+
+// Test that overloads that use atomic_double are not available when the fp64
+// extension is disabled.  Test this by counting the number of notes about
+// candidate functions.
+void test_atomic_double_reporting(volatile __generic atomic_int *a) {
+  atomic_init(a);
+  // expected-error@-1{{no matching function for call to 'atomic_init'}}
+#if defined(NO_FP64)
+  // Expecting 5 candidates: int, uint, long, ulong, float
+  // expected-note@-4 5 {{candidate function not viable: requires 2 arguments, 
but 1 was provided}}
+#else
+  // Expecting 6 candidates: int, uint, long, ulong, float, double
+  // expected-note@-7 6 {{candidate function not viable: requires 2 arguments, 
but 1 was provided}}
+#endif
+}
+
+#endif
+
 #if defined(NO_ATOMSCOPE) && __OPENCL_C_VERSION__ >= 300
 // Disable the feature by undefining the feature macro.
 #undef __opencl_c_atomic_scope_device

diff  --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index 4795b008dda3c..34ca6cb36738c 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -733,6 +733,20 @@ static std::pair 
isOpenCLBuiltin(llvm::StringRef Name) {
   OS << "} // isOpenCLB

[clang] b250cca - [OpenCL] Do not guard vload/store_half builtins

2022-05-17 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-05-17T10:57:23+01:00
New Revision: b250cca11d5996ed01d72cb1f933867da0e8d5e0

URL: 
https://github.com/llvm/llvm-project/commit/b250cca11d5996ed01d72cb1f933867da0e8d5e0
DIFF: 
https://github.com/llvm/llvm-project/commit/b250cca11d5996ed01d72cb1f933867da0e8d5e0.diff

LOG: [OpenCL] Do not guard vload/store_half builtins

The vload*_half* and vstore*_half* builtins do not require the
cl_khr_fp16 extension: pointers to `half` can be declared without the
extension and the _half variants of vload and vstore should be
available without the extension.

This aligns the guards for these builtins for
`-fdeclare-opencl-builtins` with `opencl-c.h`.

Fixes https://github.com/llvm/llvm-project/issues/55275

Differential Revision: https://reviews.llvm.org/D125401

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/half.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index d0a0d5bdbf4f5..4e87afad84bf7 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -202,6 +202,9 @@ typedef double double8 __attribute__((ext_vector_type(8)));
 typedef double double16 __attribute__((ext_vector_type(16)));
 #endif
 
+// An internal alias for half, for use by OpenCLBuiltins.td.
+#define __half half
+
 #if defined(__OPENCL_CPP_VERSION__)
 #define NULL nullptr
 #elif defined(__OPENCL_C_VERSION__)

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index ece0b8866d942..220daf05acf94 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -352,9 +352,22 @@ def Float : Type<"float", 
QualType<"Context.FloatTy">>;
 let Extension = Fp64TypeExt in {
   def Double: Type<"double",QualType<"Context.DoubleTy">>;
 }
+
+// The half type for builtins that require the cl_khr_fp16 extension.
 let Extension = Fp16TypeExt in {
   def Half  : Type<"half",  QualType<"Context.HalfTy">>;
 }
+
+// Without the cl_khr_fp16 extension, the half type can only be used to declare
+// a pointer.  Define const and non-const pointer types in all address spaces.
+// Use the "__half" alias to allow the TableGen emitter to distinguish the
+// (extensionless) pointee type of these pointer-to-half types from the "half"
+// type defined above that already carries the cl_khr_fp16 extension.
+foreach AS = [PrivateAS, GlobalAS, ConstantAS, LocalAS, GenericAS] in {
+  def "HalfPtr" # AS  : PointerType>, AS>;
+  def "HalfPtrConst" # AS : PointerType>>, AS>;
+}
+
 def Size  : Type<"size_t",QualType<"Context.getSizeType()">>;
 def PtrDiff   : Type<"ptr
diff _t", QualType<"Context.getPointerDiffType()">>;
 def IntPtr: Type<"intptr_t",  QualType<"Context.getIntPtrType()">>;
@@ -877,22 +890,22 @@ defm : VloadVstore<[ConstantAS], 0>;
 
 multiclass VloadVstoreHalf addrspaces, bit defStores> {
   foreach AS = addrspaces in {
-def : Builtin<"vload_half", [Float, Size, PointerType, 
AS>], Attr.Pure>;
+def : Builtin<"vload_half", [Float, Size, !cast("HalfPtrConst" # 
AS)], Attr.Pure>;
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vload_half" # VSize, "vloada_half" # VSize] in {
-def : Builtin, Size, 
PointerType, AS>], Attr.Pure>;
+def : Builtin, Size, 
!cast("HalfPtrConst" # AS)], Attr.Pure>;
   }
 }
 if defStores then {
   foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
 foreach name = ["vstore_half" # rnd] in {
-  def : Builtin]>;
-  def : Builtin]>;
+  def : Builtin("HalfPtr" # 
AS)]>;
+  def : Builtin("HalfPtr" # 
AS)]>;
 }
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vstore_half" # VSize # rnd, "vstorea_half" # VSize 
# rnd] in {
-def : Builtin, Size, 
PointerType]>;
-def : Builtin, Size, 
PointerType]>;
+def : Builtin, Size, 
!cast("HalfPtr" # AS)]>;
+def : Builtin, Size, 
!cast("HalfPtr" # AS)]>;
   }
 }
   }

diff  --git a/clang/test/SemaOpenCL/half.cl b/clang/test/SemaOpenCL/half.cl
index e3e558995b21c..d0cd529a8f9af 100644
--- a/clang/test/SemaOpenCL/half.cl
+++ b/clang/test/SemaOpenCL/half.cl
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header 
-DHAVE_BUILTINS
 
 constant float f = 1.0h; // expected-error{{half precision constant requires 
cl_khr_fp16}}
 
@@ -22,6 +22,11 @@ half half_disabled(half *p, // expected-error

[clang] 21c29a8 - [OpenCL] Add cl_khr_subgroup_rotate builtins

2022-05-18 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-05-18T13:02:17+01:00
New Revision: 21c29a8ae053cb436141ee636333c4f816cc20c4

URL: 
https://github.com/llvm/llvm-project/commit/21c29a8ae053cb436141ee636333c4f816cc20c4
DIFF: 
https://github.com/llvm/llvm-project/commit/21c29a8ae053cb436141ee636333c4f816cc20c4.diff

LOG: [OpenCL] Add cl_khr_subgroup_rotate builtins

Differential Revision: https://reviews.llvm.org/D124256

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h
clang/lib/Sema/OpenCLBuiltins.td
clang/test/Headers/opencl-c-header.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index 4e87afad84bf..20048d97bc74 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -21,6 +21,7 @@
 #define cl_khr_subgroup_shuffle 1
 #define cl_khr_subgroup_shuffle_relative 1
 #define cl_khr_subgroup_clustered_reduce 1
+#define cl_khr_subgroup_rotate 1
 #define cl_khr_extended_bit_ops 1
 #define cl_khr_integer_dot_product 1
 #define __opencl_c_integer_dot_product_input_4x8bit 1

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 8d9af5248195..69e2c85610ba 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -17275,6 +17275,40 @@ int __ovld __cnfn dot_acc_sat_4x8packed_us_int(uint, 
uint, int);
 int __ovld __cnfn dot_acc_sat_4x8packed_su_int(uint, uint, int);
 #endif // __opencl_c_integer_dot_product_input_4x8bit_packed
 
+#if defined(cl_khr_subgroup_rotate)
+char __ovld __conv sub_group_rotate(char, int);
+uchar __ovld __conv sub_group_rotate(uchar, int);
+short __ovld __conv sub_group_rotate(short, int);
+ushort __ovld __conv sub_group_rotate(ushort, int);
+int __ovld __conv sub_group_rotate(int, int);
+uint __ovld __conv sub_group_rotate(uint, int);
+long __ovld __conv sub_group_rotate(long, int);
+ulong __ovld __conv sub_group_rotate(ulong, int);
+float __ovld __conv sub_group_rotate(float, int);
+#if defined(cl_khr_fp64)
+double __ovld __conv sub_group_rotate(double, int);
+#endif // cl_khr_fp64
+#if defined(cl_khr_fp16)
+half __ovld __conv sub_group_rotate(half, int);
+#endif // cl_khr_fp16
+
+char __ovld __conv sub_group_clustered_rotate(char, int, uint);
+uchar __ovld __conv sub_group_clustered_rotate(uchar, int, uint);
+short __ovld __conv sub_group_clustered_rotate(short, int, uint);
+ushort __ovld __conv sub_group_clustered_rotate(ushort, int, uint);
+int __ovld __conv sub_group_clustered_rotate(int, int, uint);
+uint __ovld __conv sub_group_clustered_rotate(uint, int, uint);
+long __ovld __conv sub_group_clustered_rotate(long, int, uint);
+ulong __ovld __conv sub_group_clustered_rotate(ulong, int, uint);
+float __ovld __conv sub_group_clustered_rotate(float, int, uint);
+#if defined(cl_khr_fp64)
+double __ovld __conv sub_group_clustered_rotate(double, int, uint);
+#endif // cl_khr_fp64
+#if defined(cl_khr_fp16)
+half __ovld __conv sub_group_clustered_rotate(half, int, uint);
+#endif // cl_khr_fp16
+#endif // cl_khr_subgroup_rotate
+
 #if defined(cl_intel_subgroups)
 // Intel-Specific Sub Group Functions
 float   __ovld __conv intel_sub_group_shuffle( float , uint );

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 220daf05acf9..75cea2ffc19c 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1845,6 +1845,12 @@ let Extension = 
FunctionExtension<"__opencl_c_integer_dot_product_input_4x8bit_p
   def : Builtin<"dot_acc_sat_4x8packed_su_int", [Int, UInt, UInt, Int], 
Attr.Const>;
 }
 
+// Section 48.3 - cl_khr_subgroup_rotate
+let Extension = FunctionExtension<"cl_khr_subgroup_rotate"> in {
+  def : Builtin<"sub_group_rotate", [AGenType1, AGenType1, Int], 
Attr.Convergent>;
+  def : Builtin<"sub_group_clustered_rotate", [AGenType1, AGenType1, Int, 
UInt], Attr.Convergent>;
+}
+
 //
 // Arm extensions.
 let Extension = ArmIntegerDotProductInt8 in {

diff  --git a/clang/test/Headers/opencl-c-header.cl 
b/clang/test/Headers/opencl-c-header.cl
index be185ff8dcf1..455842412fd0 100644
--- a/clang/test/Headers/opencl-c-header.cl
+++ b/clang/test/Headers/opencl-c-header.cl
@@ -127,6 +127,9 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #if cl_khr_subgroup_clustered_reduce != 1
 #error "Incorrectly defined cl_khr_subgroup_clustered_reduce"
 #endif
+#if cl_khr_subgroup_rotate != 1
+#error "Incorrectly defined cl_khr_subgroup_rotate"
+#endif
 #if cl_khr_extended_bit_ops != 1
 #error "Incorrectly defined cl_khr_extended_bit_ops"
 #endif
@@ -208,6 +211,9 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #ifdef cl_khr_subgroup_clustered_reduce
 #error "Incorrect cl_khr_subgroup_clustered_reduce define"
 #endif
+#ifdef cl_khr_subgroup_rotate
+#error "Incorrect cl_khr_subgroup_rotate define"
+#endif
 #ifdef cl_khr_extende

[clang] [OpenCL] Fix BIenqueue_kernel fallthrough (PR #83238)

2024-04-02 Thread Sven van Haastregt via cfe-commits

https://github.com/svenvh closed https://github.com/llvm/llvm-project/pull/83238
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use CPlusPlus language option instead of Bool (PR #80975)

2024-02-08 Thread Sven van Haastregt via cfe-commits

https://github.com/svenvh approved this pull request.

The side-effect on OpenCL looks good to me; thanks!

https://github.com/llvm/llvm-project/pull/80975
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c7f1a98 - [OpenCL] Elaborate about BIenqueue_kernel expansion; NFC

2024-03-12 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2024-03-12T12:53:22Z
New Revision: c7f1a987a66a1ba0865ecc18adbe4dc8dbc0c788

URL: 
https://github.com/llvm/llvm-project/commit/c7f1a987a66a1ba0865ecc18adbe4dc8dbc0c788
DIFF: 
https://github.com/llvm/llvm-project/commit/c7f1a987a66a1ba0865ecc18adbe4dc8dbc0c788.diff

LOG: [OpenCL] Elaborate about BIenqueue_kernel expansion; NFC

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 20c35757939152..93ab465079777b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5460,7 +5460,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   }
 
   // OpenCL v2.0, s6.13.17 - Enqueue kernel function.
-  // It contains four 
diff erent overload formats specified in Table 6.13.17.1.
+  // Table 6.13.17.1 specifies four overload forms of enqueue_kernel.
+  // The code below expands the builtin call to a call to one of the following
+  // functions that an OpenCL runtime library will have to provide:
+  //   __enqueue_kernel_basic
+  //   __enqueue_kernel_varargs
+  //   __enqueue_kernel_basic_events
+  //   __enqueue_kernel_events_varargs
   case Builtin::BIenqueue_kernel: {
 StringRef Name; // Generated function call name
 unsigned NumArgs = E->getNumArgs();



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


[clang] [OpenCL] Fix BIenqueue_kernel fallthrough (PR #83238)

2024-02-28 Thread Sven van Haastregt via cfe-commits

https://github.com/svenvh created 
https://github.com/llvm/llvm-project/pull/83238

Handling of the `BIenqueue_kernel` builtin must not fallthrough to the 
`BIget_kernel_work_group_size` builtin, as these builtins have no common 
functionality.

>From a7375b651a2ec392e0edf4cbe3658981f56ea67a Mon Sep 17 00:00:00 2001
From: Sven van Haastregt 
Date: Wed, 28 Feb 2024 08:37:22 +
Subject: [PATCH] [OpenCL] Fix BIenqueue_kernel fallthrough

Handling of the `BIenqueue_kernel` builtin must not fallthrough to
the `BIget_kernel_work_group_size` builtin, as these builtins have
no common functionality.
---
 clang/lib/CodeGen/CGBuiltin.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2d16e7cdc06053..7a42174d7ec692 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5640,7 +5640,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 EmitLifetimeEnd(TmpSize, TmpPtr);
   return Call;
 }
-[[fallthrough]];
+llvm_unreachable("Unexpected enqueue_kernel signature");
   }
   // OpenCL v2.0 s6.13.17.6 - Kernel query functions need bitcast of block
   // parameter.

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


r370322 - [OpenCL] Fix diagnosing enqueue_kernel call with too few args

2019-08-29 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Aug 29 03:21:06 2019
New Revision: 370322

URL: http://llvm.org/viewvc/llvm-project?rev=370322&view=rev
Log:
[OpenCL] Fix diagnosing enqueue_kernel call with too few args

The err_typecheck_call_too_few_args diagnostic takes arguments, but
none were provided causing clang to crash when attempting to diagnose
an enqueue_kernel call with too few arguments.

Fixes llvm.org/PR42045

Differential Revision: https://reviews.llvm.org/D66883

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=370322&r1=370321&r2=370322&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Aug 29 03:21:06 2019
@@ -629,7 +629,9 @@ static bool SemaOpenCLBuiltinEnqueueKern
   unsigned NumArgs = TheCall->getNumArgs();
 
   if (NumArgs < 4) {
-S.Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_few_args);
+S.Diag(TheCall->getBeginLoc(),
+   diag::err_typecheck_call_too_few_args_at_least)
+<< 0 << 4 << NumArgs;
 return true;
   }
 

Modified: cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl?rev=370322&r1=370321&r2=370322&view=diff
==
--- cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl (original)
+++ cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl Thu Aug 29 03:21:06 
2019
@@ -158,6 +158,8 @@ kernel void enqueue_kernel_tests() {
   enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt); // 
expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
 
   enqueue_kernel(default_queue, flags, ndrange, 1, 1); // 
expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
+
+  enqueue_kernel(default_queue, ndrange, ^{}); // expected-error{{too few 
arguments to function call, expected at least 4, have 3}}
 }
 
 // Diagnostic tests for get_kernel_work_group_size and allowed block parameter 
types in dynamic parallelism.


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


r370744 - [OpenCL] Drop spurious semicolon in generated file; NFC

2019-09-03 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Sep  3 04:23:24 2019
New Revision: 370744

URL: http://llvm.org/viewvc/llvm-project?rev=370744&view=rev
Log:
[OpenCL] Drop spurious semicolon in generated file; NFC

Modified:
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp?rev=370744&r1=370743&r2=370744&view=diff
==
--- cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp Tue Sep  3 04:23:24 
2019
@@ -473,7 +473,7 @@ static void OCL2Qual(ASTContext &Context
<< T->getValueAsDef("QTName")->getValueAsString("Name") << ", ";
   }
 }
-OS << "});\n;";
+OS << "});\n";
 // GenTypeNumTypes is the number of types in the GenType
 // (e.g. float/double/half).
 OS << "  GenTypeNumTypes = "


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


r371046 - [OpenCL] Add image type handling for builtins

2019-09-05 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Sep  5 03:01:24 2019
New Revision: 371046

URL: http://llvm.org/viewvc/llvm-project?rev=371046&view=rev
Log:
[OpenCL] Add image type handling for builtins

Image types were previously available, but not working.  This patch
adds image type handling.

Rename the image type definitions in the .td file to make them
consistent with other type names.  Use abstract types to represent the
unqualified types.  Instantiate access-qualified image types at the
point of use using, e.g. `ImageType`.

Add/update TableGen definitions for the read_image/write_image
builtin functions.

Patch by Pierre Gondois and Sven van Haastregt.

Differential Revision: https://reviews.llvm.org/D63480

Modified:
cfe/trunk/lib/Sema/OpenCLBuiltins.td
cfe/trunk/test/SemaOpenCL/fdeclare-opencl-builtins.cl
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/lib/Sema/OpenCLBuiltins.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/OpenCLBuiltins.td?rev=371046&r1=371045&r2=371046&view=diff
==
--- cfe/trunk/lib/Sema/OpenCLBuiltins.td (original)
+++ cfe/trunk/lib/Sema/OpenCLBuiltins.td Thu Sep  5 03:01:24 2019
@@ -87,11 +87,11 @@ class Type : Type<_Ty.Name, _Ty.QTName> {
   let VecWidth = _VecWidth;
+  let AccessQualifier = "";
   // Inherited fields
   let IsPointer = _Ty.IsPointer;
   let IsConst = _Ty.IsConst;
   let IsVolatile = _Ty.IsVolatile;
-  let AccessQualifier = _Ty.AccessQualifier;
   let AddrSpace = _Ty.AddrSpace;
 }
 
@@ -129,10 +129,16 @@ class VolatileType : Type<_Ty.
   let AddrSpace = _Ty.AddrSpace;
 }
 
-// OpenCL image types (e.g. image2d_t, ...)
-class ImageType :
-  Type<_Ty.Name, _QTName> {
+// OpenCL image types (e.g. image2d).
+class ImageType :
+  Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> {
+  let VecWidth = 0;
   let AccessQualifier = _AccessQualifier;
+  // Inherited fields
+  let IsPointer = _Ty.IsPointer;
+  let IsConst = _Ty.IsConst;
+  let IsVolatile = _Ty.IsVolatile;
+  let AddrSpace = _Ty.AddrSpace;
 }
 
 // List of Types.
@@ -221,37 +227,21 @@ def Void  : Type<"void_t",QualTy
 // OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types.
 // Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter.
 
-// OpenCL v1.2 s6.1.3: Other Built-in Data Types
-// These definitions with a "null" name are "abstract". They should not
-// be used in definitions of Builtin functions.
-def image2d_t : Type<"image2d_t", QualType<"null", 1>>;
-def image3d_t : Type<"image3d_t", QualType<"null", 1>>;
-def image2d_array_t   : Type<"image2d_array_t", QualType<"null", 1>>;
-def image1d_t : Type<"image1d_t", QualType<"null", 1>>;
-def image1d_buffer_t  : Type<"image1d_buffer_t", QualType<"null", 1>>;
-def image1d_array_t   : Type<"image1d_array_t", QualType<"null", 1>>;
-// Unlike the few functions above, the following definitions can be used
-// in definitions of Builtin functions (they have a QualType with a name).
-foreach v = ["RO", "WO", "RW"] in {
-  def image2d_#v#_t   : ImageType,
-  v>;
-  def image3d_#v#_t   : ImageType,
-  v>;
-  def image2d_array#v#_t  : ImageType,
-  v>;
-  def image1d_#v#_t   : ImageType,
-  v>;
-  def image1d_buffer#v#_t : ImageType,
-  v>;
-  def image1d_array#v#_t  : ImageType,
-  v>;
-}
+// OpenCL v1.0/1.2/2.0 s6.1.3: Other Built-in Data Types.
+// The image definitions are "abstract".  They should not be used without
+// specifying an access qualifier (RO/WO/RW).
+def Image1d   : Type<"Image1d", QualType<"OCLImage1d", 1>>;
+def Image2d   : Type<"Image2d", QualType<"OCLImage2d", 1>>;
+def Image3d   : Type<"Image3d", QualType<"OCLImage3d", 1>>;
+def Image1dArray  : Type<"Image1dArray", QualType<"OCLImage1dArray", 
1>>;
+def Image1dBuffer : Type<"Image1dBuffer", QualType<"OCLImage1dBuffer", 
1>>;
+def Image2dArray  : Type<"Image2dArray", QualType<"OCLImage2dArray", 
1>>;
+def Image2dDepth  : Type<"Image2dDepth", QualType<"OCLImage2dDepth", 
1>>;
+def Image2dArrayDepth : Type<"Image2dArrayDepth", 
QualType<"OCLImage2dArrayDepth", 1>>;
+def Image2dMsaa   : Type<"Image2dMsaa", QualType<"OCLImage2dMSAA", 1>>;
+def Image2dArrayMsaa  : Type<"Image2dArrayMsaa", 
QualType<"OCLImage2dArrayMSAA", 1>>;
+def Image2dMsaaDepth  : Type<"Image2dMsaaDepth", 
QualType<"OCLImage2dMSAADepth", 1>>;
+def Image2dArrayMsaaDepth : Type<"Image2dArrayMsaaDepth", 
QualType<"OCLImage2dArrayMSAADepth", 1>>;
 
 def Sampler   : Type<"Sampler", QualType<"OCLSamplerTy">>;
 def Event : Type<"Event", QualType<"OCLEventTy">>;
@@ -398,14 +388

r371403 - Merge note_ovl_builtin_candidate diagnostics; NFC

2019-09-09 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Sep  9 07:39:20 2019
New Revision: 371403

URL: http://llvm.org/viewvc/llvm-project?rev=371403&view=rev
Log:
Merge note_ovl_builtin_candidate diagnostics; NFC

There is no difference between the unary and binary case, so
merge them.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371403&r1=371402&r2=371403&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep  9 07:39:20 
2019
@@ -3920,10 +3920,7 @@ def note_implicit_member_target_infer_co
 
 def note_ambiguous_type_conversion: Note<
 "because of ambiguity in conversion %diff{of $ to $|between types}0,1">;
-def note_ovl_builtin_binary_candidate : Note<
-"built-in candidate %0">;
-def note_ovl_builtin_unary_candidate : Note<
-"built-in candidate %0">;
+def note_ovl_builtin_candidate : Note<"built-in candidate %0">;
 def err_ovl_no_viable_function_in_init : Error<
   "no matching constructor for initialization of %0">;
 def err_ovl_no_conversion_in_cast : Error<

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=371403&r1=371402&r2=371403&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Sep  9 07:39:20 2019
@@ -10547,12 +10547,12 @@ static void NoteBuiltinOperatorCandidate
   TypeStr += Cand->BuiltinParamTypes[0].getAsString();
   if (Cand->Conversions.size() == 1) {
 TypeStr += ")";
-S.Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
+S.Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
   } else {
 TypeStr += ", ";
 TypeStr += Cand->BuiltinParamTypes[1].getAsString();
 TypeStr += ")";
-S.Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
+S.Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
   }
 }
 


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


r310911 - [OpenCL] Allow targets to select address space per type

2017-08-15 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Aug 15 02:38:18 2017
New Revision: 310911

URL: http://llvm.org/viewvc/llvm-project?rev=310911&view=rev
Log:
[OpenCL] Allow targets to select address space per type

Generalize getOpenCLImageAddrSpace into getOpenCLTypeAddrSpace, such
that targets can select the address space per type.

No functional changes intended.

Initial patch by Simon Perretta.

Differential Revision: https://reviews.llvm.org/D33989

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/test/CodeGenOpenCL/opencl_types.cl

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=310911&r1=310910&r2=310911&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Aug 15 02:38:18 2017
@@ -46,6 +46,7 @@ class MacroBuilder;
 class QualType;
 class SourceLocation;
 class SourceManager;
+class Type;
 
 namespace Builtin { struct Info; }
 
@@ -1050,10 +1051,8 @@ public:
   return getTargetOpts().SupportedOpenCLOptions;
   }
 
-  /// \brief Get OpenCL image type address space.
-  virtual LangAS::ID getOpenCLImageAddrSpace() const {
-return LangAS::opencl_global;
-  }
+  /// \brief Get address space for OpenCL type.
+  virtual LangAS::ID getOpenCLTypeAddrSpace(const Type *T) const;
 
   /// \returns Target specific vtbl ptr address space.
   virtual unsigned getVtblPtrAddressSpace() const {

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=310911&r1=310910&r2=310911&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Aug 15 02:38:18 2017
@@ -1631,6 +1631,7 @@ TypeInfo ASTContext::getTypeInfoImpl(con
   uint64_t Width = 0;
   unsigned Align = 8;
   bool AlignIsRequired = false;
+  unsigned AS = 0;
   switch (T->getTypeClass()) {
 #define TYPE(Class, Base)
 #define ABSTRACT_TYPE(Class, Base)
@@ -1777,28 +1778,18 @@ TypeInfo ASTContext::getTypeInfoImpl(con
   Width = Target->getPointerWidth(0); 
   Align = Target->getPointerAlign(0);
   break;
-case BuiltinType::OCLSampler: {
-  auto AS = getTargetAddressSpace(LangAS::opencl_constant);
-  Width = Target->getPointerWidth(AS);
-  Align = Target->getPointerAlign(AS);
-  break;
-}
+case BuiltinType::OCLSampler:
 case BuiltinType::OCLEvent:
 case BuiltinType::OCLClkEvent:
 case BuiltinType::OCLQueue:
 case BuiltinType::OCLReserveID:
-  // Currently these types are pointers to opaque types.
-  Width = Target->getPointerWidth(0);
-  Align = Target->getPointerAlign(0);
-  break;
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
 case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-  {
-auto AS = getTargetAddressSpace(Target->getOpenCLImageAddrSpace());
-Width = Target->getPointerWidth(AS);
-Align = Target->getPointerAlign(AS);
-  }
+  AS = getTargetAddressSpace(Target->getOpenCLTypeAddrSpace(T));
+  Width = Target->getPointerWidth(AS);
+  Align = Target->getPointerAlign(AS);
+  break;
 }
 break;
   case Type::ObjCObjectPointer:
@@ -1806,8 +1797,7 @@ TypeInfo ASTContext::getTypeInfoImpl(con
 Align = Target->getPointerAlign(0);
 break;
   case Type::BlockPointer: {
-unsigned AS = getTargetAddressSpace(
-cast(T)->getPointeeType());
+AS = getTargetAddressSpace(cast(T)->getPointeeType());
 Width = Target->getPointerWidth(AS);
 Align = Target->getPointerAlign(AS);
 break;
@@ -1816,14 +1806,13 @@ TypeInfo ASTContext::getTypeInfoImpl(con
   case Type::RValueReference: {
 // alignof and sizeof should never enter this code path here, so we go
 // the pointer route.
-unsigned AS = getTargetAddressSpace(
-cast(T)->getPointeeType());
+AS = getTargetAddressSpace(cast(T)->getPointeeType());
 Width = Target->getPointerWidth(AS);
 Align = Target->getPointerAlign(AS);
 break;
   }
   case Type::Pointer: {
-unsigned AS = 
getTargetAddressSpace(cast(T)->getPointeeType());
+AS = getTargetAddressSpace(cast(T)->getPointeeType());
 Width = Target->getPointerWidth(AS);
 Align = Target->getPointerAlign(AS);
 break;

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=310911&r1=310910&r2=310911&view=diff

[clang] 4a188fd - [OpenCL] Add mipmap builtin functions

2019-12-30 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-12-30T10:47:58Z
New Revision: 4a188fdfa79b4c1044cbb6fe0ede79583c71a56f

URL: 
https://github.com/llvm/llvm-project/commit/4a188fdfa79b4c1044cbb6fe0ede79583c71a56f
DIFF: 
https://github.com/llvm/llvm-project/commit/4a188fdfa79b4c1044cbb6fe0ede79583c71a56f.diff

LOG: [OpenCL] Add mipmap builtin functions

Add the mipmap builtin functions from the OpenCL extension
specification.

Patch by Pierre Gondois and Sven van Haastregt.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 38e07b21cb85..72b72f60a662 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -59,6 +59,10 @@ def FuncExtKhrLocalInt32BaseAtomics  : 
FunctionExtension<"cl_khr_local_int32
 def FuncExtKhrLocalInt32ExtendedAtomics  : 
FunctionExtension<"cl_khr_local_int32_extended_atomics">;
 def FuncExtKhrInt64BaseAtomics   : 
FunctionExtension<"cl_khr_int64_base_atomics">;
 def FuncExtKhrInt64ExtendedAtomics   : 
FunctionExtension<"cl_khr_int64_extended_atomics">;
+def FuncExtKhrMipmapImage: 
FunctionExtension<"cl_khr_mipmap_image">;
+
+// Multiple extensions
+def FuncExtKhrMipmapAndWrite3d   : 
FunctionExtension<"cl_khr_mipmap_image cl_khr_3d_image_writes">;
 
 // Qualified Type.  These map to ASTContext::QualType.
 class QualType {
@@ -1179,3 +1183,176 @@ let MinVersion = CL20 in {
 def get_num_sub_groups : Builtin<"get_num_sub_groups", [UInt]>;
   }
 }
+
+//
+// End of the builtin functions defined in the OpenCL C specification.
+// Builtin functions defined in the OpenCL C Extension are below.
+//
+
+
+// OpenCL Extension v2.0 s9.18 - Mipmaps
+let Extension = FuncExtKhrMipmapImage in {
+  // Added to section 6.13.14.2.
+  foreach aQual = ["RO"] in {
+foreach imgTy = [Image2d] in {
+  foreach name = ["read_imagef"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, VectorType, VectorType], 
Attr.Pure>;
+  }
+  foreach name = ["read_imagei"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, VectorType, VectorType], 
Attr.Pure>;
+  }
+  foreach name = ["read_imageui"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, VectorType, VectorType], 
Attr.Pure>;
+  }
+}
+foreach imgTy = [Image2dDepth] in {
+  foreach name = ["read_imagef"] in {
+def : Builtin, Sampler, 
VectorType, Float], Attr.Pure>;
+def : Builtin, Sampler, 
VectorType, VectorType, VectorType], Attr.Pure>;
+  }
+}
+foreach imgTy = [Image1d] in {
+  foreach name = ["read_imagef"] in {
+def : Builtin, ImageType, 
Sampler, Float, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, Float, Float, Float], Attr.Pure>;
+  }
+  foreach name = ["read_imagei"] in {
+def : Builtin, ImageType, 
Sampler, Float, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, Float, Float, Float], Attr.Pure>;
+  }
+  foreach name = ["read_imageui"] in {
+def : Builtin, ImageType, 
Sampler, Float, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, Float, Float, Float], Attr.Pure>;
+  }
+}
+foreach imgTy = [Image3d] in {
+  foreach name = ["read_imagef"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, VectorType, VectorType], 
Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+  }
+  foreach name = ["read_imagei"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, VectorType, VectorType], 
Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+  }
+  foreach name = ["read_imageui"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, VectorType, VectorType], 
Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+  }
+}
+foreach imgTy = [Image1dArray] in {
+  foreach name = ["read_imagef"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, Float, Float], Attr.Pure>;
+  }
+  foreach name = ["read_imagei"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, Float], Attr.Pure>;
+def : Builtin, ImageType, 
Sampler, VectorType, Float, Float], Attr.Pure>;
+  }
+  foreach name = ["read_imageui"] in {
+def : Builtin, ImageType, 
Sampler, VectorType, Float]

[clang] ff429c5 - [OpenCL] Remove redundant foreach in OpenCLBuiltins.td; NFC

2019-12-31 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-12-31T15:30:02Z
New Revision: ff429c5eaf79529aacdc15582c90c0915080e082

URL: 
https://github.com/llvm/llvm-project/commit/ff429c5eaf79529aacdc15582c90c0915080e082
DIFF: 
https://github.com/llvm/llvm-project/commit/ff429c5eaf79529aacdc15582c90c0915080e082.diff

LOG: [OpenCL] Remove redundant foreach in OpenCLBuiltins.td; NFC

Remove various `foreach` declarations where the iterator is used only
once.  This makes the .td file more compact.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 72b72f60a662..d4c473e2a68f 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -979,25 +979,21 @@ foreach AS = [GlobalAS, LocalAS] in {
 //
 // OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector 
Functions
 // --- Table 19 ---
-foreach name = ["shuffle"] in {
-  foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
-foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
-  def : Builtin,
-   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
-   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
-  Attr.Const>;
-}
+foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
+  foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
+def : Builtin<"shuffle", [GenericType<"TLAll" # VSize1.Name, TLAll, 
VSize1>,
+  GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
+  GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
+  Attr.Const>;
   }
 }
-foreach name = ["shuffle2"] in {
-  foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
-foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
-  def : Builtin,
-   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
-   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
-   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
-  Attr.Const>;
-}
+foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
+  foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
+def : Builtin<"shuffle2", [GenericType<"TLAll" # VSize1.Name, TLAll, 
VSize1>,
+   GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
+   GenericType<"TLAll" # VSize2.Name, TLAll, 
VSize2>,
+   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
+  Attr.Const>;
   }
 }
 
@@ -1280,79 +1276,39 @@ let Extension = FuncExtKhrMipmapImage in {
   // Added to section 6.13.14.4.
   foreach aQual = ["WO"] in {
 foreach imgTy = [Image2d] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imagei"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imageui"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-}
-foreach imgTy = [Image2dDepth] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, VectorType, Int, Float]>;
-  }
+  def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imagei", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imageui", [Void, ImageType, 
VectorType, Int, VectorType]>;
 }
+def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, Float]>;
 foreach imgTy = [Image1d] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, Int, Int, 
VectorType]>;
-  }
-  foreach name = ["write_imagei"] in {
-def : Builtin, Int, Int, 
VectorType]>;
-  }
-  foreach name = ["write_imageui"] in {
-def : Builtin, Int, Int, 
VectorType]>;
-  }
+  def : Builtin<"write_imagef", [Void, ImageType, Int, Int, 
VectorType]>;
+  def : Builtin<"write_imagei", [Void, ImageType, Int, Int, 
VectorType]>;
+  def : Builtin<"write_imageui", [Void, ImageType, Int, Int, 
VectorType]>;
 }
 foreach imgTy = [Image1dArray] in {
-  foreach name = ["write_imagef"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imagei"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
-  foreach name = ["write_imageui"] in {
-def : Builtin, VectorType, Int, VectorType]>;
-  }
+  def : Builtin<"write_imagef", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imagei", [Void, ImageType, 
VectorType, Int, VectorType]>;
+  def : Builtin<"write_imageui", [Void,

[clang] 241f335 - [OpenCL][Docs] Rename C++ for OpenCL label

2020-01-09 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-01-09T16:31:45Z
New Revision: 241f335b268dc19a0dfb85686a7c82fb339421a8

URL: 
https://github.com/llvm/llvm-project/commit/241f335b268dc19a0dfb85686a7c82fb339421a8
DIFF: 
https://github.com/llvm/llvm-project/commit/241f335b268dc19a0dfb85686a7c82fb339421a8.diff

LOG: [OpenCL][Docs] Rename C++ for OpenCL label

To avoid potential confusion with OpenCL C++.

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f55ffccc84d0..856d5e34bbcc 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2661,7 +2661,8 @@ This will produce a generic test.bc file that can be used 
in vendor toolchains
 to perform machine code generation.
 
 Clang currently supports OpenCL C language standards up to v2.0. Starting from
-clang 9 a C++ mode is available for OpenCL (see :ref:`C++ for OpenCL 
`).
+clang 9 a C++ mode is available for OpenCL (see
+:ref:`C++ for OpenCL `).
 
 OpenCL Specific Options
 ---
@@ -3024,7 +3025,7 @@ There are some standard OpenCL functions that are 
implemented as Clang builtins:
   enqueue query functions from `section 6.13.17.5
   `_.
 
-.. _opencl_cpp:
+.. _cxx_for_opencl:
 
 C++ for OpenCL
 --



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


[clang] 92451f0 - [OpenCL] Add MSAA sharing extension builtin functions

2020-01-14 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-01-14T14:46:42Z
New Revision: 92451f0904ceab1d81d71a9f17ab366bf57eddc7

URL: 
https://github.com/llvm/llvm-project/commit/92451f0904ceab1d81d71a9f17ab366bf57eddc7
DIFF: 
https://github.com/llvm/llvm-project/commit/92451f0904ceab1d81d71a9f17ab366bf57eddc7.diff

LOG: [OpenCL] Add MSAA sharing extension builtin functions

Add the MSAA sharing builtin functions from the OpenCL Extension
Specification.

Patch by Pierre Gondois and Sven van Haastregt.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index d4c473e2a68f..9d6bb411eff8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -60,6 +60,7 @@ def FuncExtKhrLocalInt32ExtendedAtomics  : 
FunctionExtension<"cl_khr_local_int32
 def FuncExtKhrInt64BaseAtomics   : 
FunctionExtension<"cl_khr_int64_base_atomics">;
 def FuncExtKhrInt64ExtendedAtomics   : 
FunctionExtension<"cl_khr_int64_extended_atomics">;
 def FuncExtKhrMipmapImage: 
FunctionExtension<"cl_khr_mipmap_image">;
+def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sharing">;
 
 // Multiple extensions
 def FuncExtKhrMipmapAndWrite3d   : 
FunctionExtension<"cl_khr_mipmap_image cl_khr_3d_image_writes">;
@@ -1312,3 +1313,39 @@ let Extension = FuncExtKhrMipmapImage in {
 }
   }
 }
+
+
+//
+// OpenCL Extension v2.0 s18.3 - Creating OpenCL Memory Objects from OpenGL 
MSAA Textures
+let Extension = FuncExtKhrGlMsaaSharing in {
+  // --- Table 6.13.14.3 ---
+  foreach aQual = ["RO", "RW"] in {
+foreach imgTy = [Image2dMsaa] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+}
+foreach imgTy = [Image2dArrayMsaa] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+}
+foreach name = ["read_imagef"] in {
+  def : Builtin, 
VectorType, Int], Attr.Pure>;
+  def : Builtin, 
VectorType, Int], Attr.Pure>;
+}
+  }
+
+  // --- Table 6.13.14.5 ---
+  foreach aQual = ["RO", "WO", "RW"] in {
+foreach imgTy = [Image2dMsaa, Image2dArrayMsaa, Image2dMsaaDepth, 
Image2dArrayMsaaDepth] in {
+  foreach name = ["get_image_width", "get_image_height",
+  "get_image_channel_data_type", "get_image_channel_order",
+  "get_image_num_samples"] in {
+def : Builtin], Attr.Const>;
+  }
+  def : Builtin<"get_image_dim", [VectorType, ImageType], Attr.Const>;
+}
+def : Builtin<"get_image_array_size", [Size, 
ImageType], Attr.Const>;
+  }
+}



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


[clang] 8ac9bcc - [OpenCL] Support vec_step in C++ for OpenCL mode

2020-11-05 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-11-05T12:02:59Z
New Revision: 8ac9bcc746b9bb4b0ccdd71c6cbeda3b406e7b46

URL: 
https://github.com/llvm/llvm-project/commit/8ac9bcc746b9bb4b0ccdd71c6cbeda3b406e7b46
DIFF: 
https://github.com/llvm/llvm-project/commit/8ac9bcc746b9bb4b0ccdd71c6cbeda3b406e7b46.diff

LOG: [OpenCL] Support vec_step in C++ for OpenCL mode

Enable the vec_step builtin in C++ for OpenCL mode for compatibility
with OpenCL C.

Differential Revision: https://reviews.llvm.org/D90766

Added: 


Modified: 
clang/include/clang/Basic/TokenKinds.def
clang/test/CodeGenOpenCLCXX/constexpr.cl

Removed: 




diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 7664269fb8da..d8a2016e9caa 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -586,7 +586,7 @@ ALIAS("write_only", __write_only, KEYOPENCLC | 
KEYOPENCLCXX)
 ALIAS("read_write", __read_write, KEYOPENCLC | KEYOPENCLCXX)
 // OpenCL builtins
 KEYWORD(__builtin_astype, KEYOPENCLC | KEYOPENCLCXX)
-UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYALTIVEC | 
KEYZVECTOR)
+UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYOPENCLCXX | 
KEYALTIVEC | KEYZVECTOR)
 #define GENERIC_IMAGE_TYPE(ImgType, Id) KEYWORD(ImgType##_t, KEYOPENCLC | 
KEYOPENCLCXX)
 #include "clang/Basic/OpenCLImageTypes.def"
 KEYWORD(pipe, KEYOPENCLC | KEYOPENCLCXX)

diff  --git a/clang/test/CodeGenOpenCLCXX/constexpr.cl 
b/clang/test/CodeGenOpenCLCXX/constexpr.cl
index 8c3fad08ea76..8eb9218c8f44 100644
--- a/clang/test/CodeGenOpenCLCXX/constexpr.cl
+++ b/clang/test/CodeGenOpenCLCXX/constexpr.cl
@@ -52,3 +52,13 @@ const int2 fromConstexprFunc = addOne(int2(2));
 kernel void vecEval2(global int2 *x) {
   *x = fromConstexprFunc;
 }
+
+// Test evaluation of vec_step
+// CHECK-LABEL: define spir_kernel void @vec_step_test
+// CHECK: store i32 6
+constexpr int vsize1 = vec_step(fromConstexprFunc);
+constexpr int vsize2 = vec_step(int4);
+
+kernel void vec_step_test(global int *x) {
+  *x = vsize1 + vsize2;
+}



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


[clang] f0c6900 - [OpenCL] Stop opencl-c-base.h leaking extension enabling

2020-11-17 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-11-17T12:07:40Z
New Revision: f0c690018ad1fb4746da3aca26a443c0f96530fa

URL: 
https://github.com/llvm/llvm-project/commit/f0c690018ad1fb4746da3aca26a443c0f96530fa
DIFF: 
https://github.com/llvm/llvm-project/commit/f0c690018ad1fb4746da3aca26a443c0f96530fa.diff

LOG: [OpenCL] Stop opencl-c-base.h leaking extension enabling

opencl-c.h disables all extensions at its end, but opencl-c-base.h
does not, and that causes any inclusion of only opencl-c-base.h to
leave some extensions (such as cl_khr_fp16) enabled.  This affects the
-fdeclare-opencl-builtins option for example.

This violates the OpenCL Extension Specification which specifies that
"The initial state of the compiler is as if the directive #pragma
OPENCL EXTENSION all : disable was issued".

Fix by disabling all extensions at the end of opencl-c-base.h and
enable extensions inside opencl.h which relied on opencl-c-base.h
enabling the cl_khr_fp16/64 extensions.

Differential Revision: https://reviews.llvm.org/D91429

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h
clang/test/SemaOpenCL/half.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index 430e07d36f62..4c52ebed1709 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -568,4 +568,7 @@ typedef struct {
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
+// Disable any extensions we may have enabled previously.
+#pragma OPENCL EXTENSION all : disable
+
 #endif //_OPENCL_BASE_H_

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 66e18bdd47bb..ab665628c8e1 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -4633,6 +4633,7 @@ float16 __ovld __cnfn convert_float16(float16);
 // Conversions with double data type parameters or return value.
 
 #ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 char __ovld __cnfn convert_char(double);
 char __ovld __cnfn convert_char_rte(double);
 char __ovld __cnfn convert_char_rtn(double);
@@ -5455,6 +5456,7 @@ double16 __ovld __cnfn convert_double16_rtz(ushort16);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 // Convert half types to non-double types.
 uchar __ovld __cnfn convert_uchar(half);
 uchar __ovld __cnfn convert_uchar_rte(half);

diff  --git a/clang/test/SemaOpenCL/half.cl b/clang/test/SemaOpenCL/half.cl
index 2ea971c08510..50bbd745d2af 100644
--- a/clang/test/SemaOpenCL/half.cl
+++ b/clang/test/SemaOpenCL/half.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
 
-#pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires 
cl_khr_fp16}}
 
 half half_disabled(half *p, // expected-error{{declaring function return value 
of type 'half' is not allowed}}



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


[clang] 633cae3 - [OpenCL] Move kernel arg type tests into one file

2020-11-25 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-11-25T10:20:30Z
New Revision: 633cae30599cc5ec99f679079499a1f2ca4d3af3

URL: 
https://github.com/llvm/llvm-project/commit/633cae30599cc5ec99f679079499a1f2ca4d3af3
DIFF: 
https://github.com/llvm/llvm-project/commit/633cae30599cc5ec99f679079499a1f2ca4d3af3.diff

LOG: [OpenCL] Move kernel arg type tests into one file

Keep all kernel parameter type diagnostic tests in
invalid-kernel-parameters.cl .

Differential Revision: https://reviews.llvm.org/D92033

Added: 


Modified: 
clang/test/SemaOpenCL/invalid-kernel-parameters.cl
clang/test/SemaOpenCL/invalid-kernel.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 48de39d0f87e..26859ee62cae 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,9 +1,21 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown 
-cl-std=CL2.0
 
 kernel void half_arg(half x) { } // expected-error{{declaring function 
parameter of type '__private half' is not allowed; did you forget * ?}}
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
+// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+kernel void no_ptrptr(global int * global *i) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_privateptr(__private int *i) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_privatearray(__private int i[]) { }
+
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_addrsp_ptr(int *ptr) { }
 
 // Disallowed: parameters with type
 // bool, half, size_t, ptr
diff _t, intptr_t, and uintptr_t
@@ -65,14 +77,14 @@ kernel void image_in_struct_arg(FooImage2D arg) { } // 
expected-error{{struct ke
 
 typedef struct Foo // expected-note{{within field of type 'Foo' declared here}}
 {
-  int* ptrField; // expected-note{{field of illegal pointer type '__private 
int *' declared here}}
+  int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
 } Foo;
 
 kernel void pointer_in_struct_arg(Foo arg) { } // expected-error{{struct 
kernel parameters may not contain pointers}}
 
 typedef union FooUnion // expected-note{{within field of type 'FooUnion' 
declared here}}
 {
-  int* ptrField; // expected-note{{field of illegal pointer type '__private 
int *' declared here}}
+  int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
 } FooUnion;
 
 kernel void pointer_in_union_arg(FooUnion arg) { }// expected-error{{union 
kernel parameters may not contain pointers}}
@@ -82,7 +94,7 @@ typedef struct NestedPointer // expected-note 2 {{within 
field of type 'NestedPo
   int x;
   struct InnerNestedPointer
   {
-int* ptrField; // expected-note 3 {{field of illegal pointer type 
'__private int *' declared here}}
+int* ptrField; // expected-note-re 3 {{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
   } inner; // expected-note 3 {{within field of type 'struct 
InnerNestedPointer' declared here}}
 } NestedPointer;
 
@@ -96,7 +108,7 @@ struct NestedPointerComplex // expected-note{{within field 
of type 'NestedPointe
   struct InnerNestedPointerComplex
   {
 int innerFoo;
-int* innerPtrField; // expected-note{{field of illegal pointer type 
'__private int *' declared here}}
+int* innerPtrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
   } inner; // expected-note{{within field of type 'struct 
InnerNestedPointerComplex' declared here}}
 
   float y;
@@ -167,8 +179,7 @@ kernel void pointer_in_nested_struct_arg_2(struct Valid 
valid, struct NestedPoin
 
 struct ArrayOfPtr // expected-note{{within field of type 'ArrayOfPtr' declared 
here}}
 {
-  float *arr[3]; // expected-note{{field of illegal type '__private float 
*[3]' declared here}}
- // expected-note@-1{{field of illegal type '__private float 
*[3]' declared here}}
+  float *arr[3]; // expected-note-re 2{{field of illegal type 
'__{{private|generic}} float *[3]' declared here}}
 };
 kernel void array_of_ptr(struct ArrayOfPtr arr) {} // expected-error{{struct 
kernel parameters may not contain pointers}}
 

diff  --git a/clang/test/SemaOpenCL/invalid-kernel.cl 
b/clang/test/SemaOpenCL/invalid-kernel.cl
index 031f6061a3b9..fd9cd6def00e 100644
--- a/clang/test/SemaOpenCL/invalid-kernel.cl
+++ b/clang/test/SemaOpenCL/invalid-k

[clang] 523775f - [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

2020-12-01 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-12-01T11:33:10Z
New Revision: 523775f96742e6f099b3498b6606b7250c0af841

URL: 
https://github.com/llvm/llvm-project/commit/523775f96742e6f099b3498b6606b7250c0af841
DIFF: 
https://github.com/llvm/llvm-project/commit/523775f96742e6f099b3498b6606b7250c0af841.diff

LOG: [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2

The restriction on pointer-to-pointer kernel arguments has been
relaxed in OpenCL 2.0.  Apply the same address space restrictions for
pointer argument types to the inner pointer types.

Differential Revision: https://reviews.llvm.org/D92091

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaOpenCL/invalid-kernel-parameters.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9c282a73e0ed..2116b3f7b78e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8591,12 +8591,21 @@ static bool isOpenCLSizeDependentType(ASTContext &C, 
QualType Ty) {
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
-if (PointeeType->isPointerType())
-  return PtrPtrKernelParam;
 if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
 PointeeType.getAddressSpace() == LangAS::opencl_private ||
 PointeeType.getAddressSpace() == LangAS::Default)
   return InvalidAddrSpacePtrKernelParam;
+
+if (PointeeType->isPointerType()) {
+  // This is a pointer to pointer parameter.
+  // Recursively check inner type.
+  OpenCLParamType ParamKind = getOpenCLKernelParameterType(S, PointeeType);
+  if (ParamKind == InvalidAddrSpacePtrKernelParam ||
+  ParamKind == InvalidKernelParam)
+return ParamKind;
+
+  return PtrPtrKernelParam;
+}
 return PtrKernelParam;
   }
 
@@ -8649,11 +8658,17 @@ static void checkIsValidOpenCLKernelParameter(
 
   switch (getOpenCLKernelParameterType(S, PT)) {
   case PtrPtrKernelParam:
-// OpenCL v1.2 s6.9.a:
-// A kernel function argument cannot be declared as a
-// pointer to a pointer type.
-S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
-D.setInvalidType();
+// 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) {
+  S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
+  D.setInvalidType();
+  return;
+}
+
+ValidTypes.insert(PT.getTypePtr());
 return;
 
   case InvalidAddrSpacePtrKernelParam:

diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 26859ee62cae..9fce92dbd6c3 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -5,8 +5,14 @@ kernel void half_arg(half x) { } // expected-error{{declaring 
function parameter
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-// expected-error@+1{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+// expected-error@+4{{kernel parameter cannot be declared as a pointer to a 
pointer}}
+#endif
 kernel void no_ptrptr(global int * global *i) { }
+kernel void no_lptrcptr(constant int * local *i) { }
+kernel void no_ptrptrptr(global int * global * global *i) { }
 
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_privateptr(__private int *i) { }
@@ -17,6 +23,15 @@ __kernel void no_privatearray(__private int i[]) { }
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_ptr_private_ptr(private int * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+kernel void no_ptr_private_ptr_ptr(global int * private * global *i) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+#endif
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptr

[clang] 7ec6188 - [OpenCL] Add some more kernel argument tests

2020-12-03 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-12-03T10:21:29Z
New Revision: 7ec61889214d98f09eec7f18d0db66dcfdc68323

URL: 
https://github.com/llvm/llvm-project/commit/7ec61889214d98f09eec7f18d0db66dcfdc68323
DIFF: 
https://github.com/llvm/llvm-project/commit/7ec61889214d98f09eec7f18d0db66dcfdc68323.diff

LOG: [OpenCL] Add some more kernel argument tests

Differential Revision: https://reviews.llvm.org/D92406

Added: 


Modified: 
clang/test/SemaOpenCL/invalid-kernel-parameters.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 9fce92dbd6c3..96e6f7886b73 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -23,7 +23,12 @@ __kernel void no_privatearray(__private int i[]) { }
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_defaultarray(int i[]) { }
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_genericptr(generic int *ptr) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_private_ptr(private int * global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
@@ -32,6 +37,8 @@ kernel void no_ptr_private_ptr_ptr(global int * private * 
global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 #endif
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not 
be qualified with an address space}}
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptr
diff _t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them



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


[clang] ba0fe85 - [OpenCL] Include header for atomic-ops test

2021-05-26 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-05-26T12:32:07+01:00
New Revision: ba0fe85ec0e93db44f9babaace84cb9ab29ff5f4

URL: 
https://github.com/llvm/llvm-project/commit/ba0fe85ec0e93db44f9babaace84cb9ab29ff5f4
DIFF: 
https://github.com/llvm/llvm-project/commit/ba0fe85ec0e93db44f9babaace84cb9ab29ff5f4.diff

LOG: [OpenCL] Include header for atomic-ops test

Avoid duplicating the memory_order and memory_scope enum definitions.

Added: 


Modified: 
clang/test/SemaOpenCL/atomic-ops.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/atomic-ops.cl 
b/clang/test/SemaOpenCL/atomic-ops.cl
index 302cd79dd8a86..8d150d0fd9297 100644
--- a/clang/test/SemaOpenCL/atomic-ops.cl
+++ b/clang/test/SemaOpenCL/atomic-ops.cl
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify=expected,spir \
-// RUN:   -fsyntax-only -triple=spir64
+// RUN:   -fsyntax-only -triple=spir64 -fdeclare-opencl-builtins 
-finclude-default-header
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \
-// RUN:   -triple=amdgcn-amd-amdhsa
+// RUN:   -triple=amdgcn-amd-amdhsa -fdeclare-opencl-builtins 
-finclude-default-header
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
@@ -9,27 +9,6 @@
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-typedef __INTPTR_TYPE__ intptr_t;
-typedef int int8 __attribute__((ext_vector_type(8)));
-
-typedef enum memory_order {
-  memory_order_relaxed = __ATOMIC_RELAXED,
-  memory_order_acquire = __ATOMIC_ACQUIRE,
-  memory_order_release = __ATOMIC_RELEASE,
-  memory_order_acq_rel = __ATOMIC_ACQ_REL,
-  memory_order_seq_cst = __ATOMIC_SEQ_CST
-} memory_order;
-
-typedef enum memory_scope {
-  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
-  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
-  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
-  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
-  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
-#endif
-} memory_scope;
-
 struct S { char c[3]; };
 
 char i8;



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


[clang] 85f5272 - [OpenCL][NFC] Fix typos in test

2021-05-27 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-05-27T16:06:33+01:00
New Revision: 85f5272ffc58d73089bf77f0451b37176aa6b64f

URL: 
https://github.com/llvm/llvm-project/commit/85f5272ffc58d73089bf77f0451b37176aa6b64f
DIFF: 
https://github.com/llvm/llvm-project/commit/85f5272ffc58d73089bf77f0451b37176aa6b64f.diff

LOG: [OpenCL][NFC] Fix typos in test

Added: 


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

Removed: 




diff  --git a/clang/test/Headers/opencl-c-header.cl 
b/clang/test/Headers/opencl-c-header.cl
index f97a089e744a4..2ab5c5af1facb 100644
--- a/clang/test/Headers/opencl-c-header.cl
+++ b/clang/test/Headers/opencl-c-header.cl
@@ -190,46 +190,46 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #elif (__OPENCL_C_VERSION__ < 200)
 
 #ifdef  __opencl_c_pipes
-#error "Incorret feature macro __opencl_c_pipes define"
+#error "Incorrect feature macro __opencl_c_pipes define"
 #endif
 #ifdef __opencl_c_generic_address_space
-#error "Incorret feature macro __opencl_c_generic_address_space define"
+#error "Incorrect feature macro __opencl_c_generic_address_space define"
 #endif
 #ifdef __opencl_c_work_group_collective_functions
-#error "Incorret feature macro __opencl_c_work_group_collective_functions 
define"
+#error "Incorrect feature macro __opencl_c_work_group_collective_functions 
define"
 #endif
 #ifdef __opencl_c_atomic_order_acq_rel
-#error "Incorret feature macro __opencl_c_atomic_order_acq_rel define"
+#error "Incorrect feature macro __opencl_c_atomic_order_acq_rel define"
 #endif
 #ifdef __opencl_c_atomic_order_seq_cst
-#error "Incorret feature macro __opencl_c_atomic_order_seq_cst define"
+#error "Incorrect feature macro __opencl_c_atomic_order_seq_cst define"
 #endif
 #ifdef __opencl_c_atomic_scope_device
-#error "Incorret feature macro __opencl_c_atomic_scope_device define"
+#error "Incorrect feature macro __opencl_c_atomic_scope_device define"
 #endif
 #ifdef __opencl_c_atomic_scope_all_devices
-#error "Incorret feature macro __opencl_c_atomic_scope_all_devices define"
+#error "Incorrect feature macro __opencl_c_atomic_scope_all_devices define"
 #endif
 #ifdef __opencl_c_device_enqueue
-#error "Incorret feature macro __opencl_c_device_enqueue define"
+#error "Incorrect feature macro __opencl_c_device_enqueue define"
 #endif
 #ifdef __opencl_c_read_write_images
-#error "Incorret feature macro __opencl_c_read_write_images define"
+#error "Incorrect feature macro __opencl_c_read_write_images define"
 #endif
 #ifdef __opencl_c_program_scope_global_variables
-#error "Incorret feature macro __opencl_c_program_scope_global_variables 
define"
+#error "Incorrect feature macro __opencl_c_program_scope_global_variables 
define"
 #endif
 #ifdef __opencl_c_images
-#error "Incorret feature macro __opencl_c_images define"
+#error "Incorrect feature macro __opencl_c_images define"
 #endif
 #ifdef __opencl_c_3d_image_writes
-#error "Incorret feature macro __opencl_c_3d_image_writes define"
+#error "Incorrect feature macro __opencl_c_3d_image_writes define"
 #endif
 #ifdef __opencl_c_fp64
-#error "Incorret feature macro __opencl_c_fp64 define"
+#error "Incorrect feature macro __opencl_c_fp64 define"
 #endif
 #ifdef __opencl_c_subgroups
-#error "Incorret feature macro __opencl_c_subgroups define"
+#error "Incorrect feature macro __opencl_c_subgroups define"
 #endif
 
 #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)



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


  1   2   3   >