[PATCH] D97060: [OpenCL] Add ndrange builtin functions to TableGen
Sven van Haastregt via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 24 01:33:18 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0344aea6ea37: [OpenCL] Add ndrange builtin functions to TableGen (authored by svenvh).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97060/new/
https://reviews.llvm.org/D97060
Files:
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===================================================================
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ 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
Index: clang/lib/Sema/OpenCLBuiltins.td
===================================================================
--- clang/lib/Sema/OpenCLBuiltins.td
+++ 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<ConstType<ClkEvent>, GenericAS>, PointerType<ClkEvent, GenericAS>]>;
-
-// --- 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<Void, GlobalAS>]>;
-
-// --- Table 35 ---
-def : Builtin<"get_default_queue", [Queue]>;
-// TODO: ndrange functions
+let MinVersion = CL20 in {
+ def : Builtin<"enqueue_marker",
+ [Int, Queue, UInt, PointerType<ConstType<ClkEvent>, GenericAS>, PointerType<ClkEvent, GenericAS>]>;
+
+ // --- 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<Void, GlobalAS>]>;
+
+ // --- 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<ConstType<Size>, PrivateAS>]>;
+ def : Builtin<"ndrange_2D", [NDRange, PointerType<ConstType<Size>, PrivateAS>,
+ PointerType<ConstType<Size>, PrivateAS>]>;
+ def : Builtin<"ndrange_2D", [NDRange, PointerType<ConstType<Size>, PrivateAS>,
+ PointerType<ConstType<Size>, PrivateAS>,
+ PointerType<ConstType<Size>, PrivateAS>]>;
+ def : Builtin<"ndrange_3D", [NDRange, PointerType<ConstType<Size>, PrivateAS>]>;
+ def : Builtin<"ndrange_3D", [NDRange, PointerType<ConstType<Size>, PrivateAS>,
+ PointerType<ConstType<Size>, PrivateAS>]>;
+ def : Builtin<"ndrange_3D", [NDRange, PointerType<ConstType<Size>, PrivateAS>,
+ PointerType<ConstType<Size>, PrivateAS>,
+ PointerType<ConstType<Size>, PrivateAS>]>;
+}
//--------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97060.326016.patch
Type: text/x-patch
Size: 3965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210224/0b35fc75/attachment-0001.bin>
More information about the cfe-commits
mailing list