diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td --- a/clang/lib/Sema/OpenCLBuiltins.td +++ b/clang/lib/Sema/OpenCLBuiltins.td @@ -311,6 +311,7 @@ def ReserveId : Type<"reserve_id_t", QualType<"Context.OCLReserveIDTy">>; def MemFenceFlags : TypedefType<"cl_mem_fence_flags">; def ClkProfilingInfo : TypedefType<"clk_profiling_info">; +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)">>; @@ -1353,21 +1354,38 @@ // Defined in Builtins.def // --- Table 33 --- -def : Builtin<"enqueue_marker", - [Int, Queue, UInt, PointerType, GenericAS>, PointerType]>; - -// --- Table 34 --- -def : Builtin<"retain_event", [Void, ClkEvent]>; -def : Builtin<"release_event", [Void, ClkEvent]>; -def : Builtin<"create_user_event", [ClkEvent]>; -def : Builtin<"is_valid_event", [Bool, ClkEvent]>; -def : Builtin<"set_user_event_status", [Void, ClkEvent, Int]>; -def : Builtin<"capture_event_profiling_info", - [Void, ClkEvent, ClkProfilingInfo, PointerType]>; - -// --- Table 35 --- -def : Builtin<"get_default_queue", [Queue]>; -// TODO: ndrange functions +let MinVersion = CL20 in { + def : Builtin<"enqueue_marker", + [Int, Queue, UInt, PointerType, GenericAS>, PointerType]>; + + // --- Table 34 --- + def : Builtin<"retain_event", [Void, ClkEvent]>; + def : Builtin<"release_event", [Void, ClkEvent]>; + def : Builtin<"create_user_event", [ClkEvent]>; + def : Builtin<"is_valid_event", [Bool, ClkEvent]>; + def : Builtin<"set_user_event_status", [Void, ClkEvent, Int]>; + def : Builtin<"capture_event_profiling_info", + [Void, ClkEvent, ClkProfilingInfo, PointerType]>; + + // --- Table 35 --- + def : Builtin<"get_default_queue", [Queue]>; + + def : Builtin<"ndrange_1D", [NDRange, Size]>; + def : Builtin<"ndrange_1D", [NDRange, Size, Size]>; + def : Builtin<"ndrange_1D", [NDRange, Size, Size, Size]>; + def : Builtin<"ndrange_2D", [NDRange, PointerType, PrivateAS>]>; + def : Builtin<"ndrange_2D", [NDRange, PointerType, PrivateAS>, + PointerType, PrivateAS>]>; + def : Builtin<"ndrange_2D", [NDRange, PointerType, PrivateAS>, + PointerType, PrivateAS>, + PointerType, PrivateAS>]>; + def : Builtin<"ndrange_3D", [NDRange, PointerType, PrivateAS>]>; + def : Builtin<"ndrange_3D", [NDRange, PointerType, PrivateAS>, + PointerType, PrivateAS>]>; + def : Builtin<"ndrange_3D", [NDRange, PointerType, PrivateAS>, + PointerType, PrivateAS>, + PointerType, PrivateAS>]>; +} //-------------------------------------------------------------------- diff --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl --- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl +++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl @@ -51,6 +51,8 @@ typedef uint cl_mem_fence_flags; #define CLK_GLOBAL_MEM_FENCE 0x02 +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 cl_khr_subgroup_extended_types 1 @@ -88,6 +90,9 @@ atomic_flag_clear(flg); bool result = atomic_flag_test_and_set(flg); + + size_t ws[2] = {2, 8}; + ndrange_t r = ndrange_2D(ws); } #endif