[llvm] [Offload] Introduce offload-tblgen and initial new API implementation (PR #108413)

Callum Fare via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 08:26:29 PDT 2024


================
@@ -0,0 +1,75 @@
+def : Macro {
+  let name = "OFFLOAD_APICALL";
+  let desc = "Calling convention for all API functions";
+  let condition = "defined(_WIN32)";
+  let value = "__cdecl";
+  let alt_value = "";
+}
+
+def : Macro {
+  let name = "OFFLOAD_APIEXPORT";
+  let desc = "Microsoft-specific dllexport storage-class attribute";
+  let condition = "defined(_WIN32)";
+  let value = "__declspec(dllexport)";
+  let alt_value = "";
+}
+
+def : Macro {
+  let name = "OFFLOAD_DLLEXPORT";
+  let desc = "Microsoft-specific dllexport storage-class attribute";
+  let condition = "defined(_WIN32)";
+  let value = "__declspec(dllexport)";
+}
+
+def : Macro {
+  let name = "OFFLOAD_DLLEXPORT";
+  let desc = "GCC-specific dllexport storage-class attribute";
+  let condition = "__GNUC__ >= 4";
+  let value = "__attribute__ ((visibility (\"default\")))";
+  let alt_value = "";
+}
+
+def : Typedef {
+  let name = "offload_bool_t";
+  let value = "uint8_t";
+  let desc = "compiler-independent type";
+}
+
+def : Handle {
+  let name = "offload_platform_handle_t";
----------------
callumfare wrote:

Yes, the idea of this is that `platform` is roughly equivalent to a plugin (with a big caveat*).

In SYCL, the platforms are exposed to the user (see [here](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_platform_interface)), so we can't hide these completely from the interface. Obviously that's not important to OpenMP, so anything omp related built on top of this wouldn't expose them, but in general we need something in the new API.

*In UR we actually split the concept of a plugin (called an `adapter` in UR) from the platform. This is because the OpenCL adapter can contain multiple platforms (one for every valid OpenCL driver on the system). For other adapters it's just a 1:1 relationship and not important. I didn't want to introduce this complication at this point though, especially since we don't even have an OpenCL plugin.

https://github.com/llvm/llvm-project/pull/108413


More information about the llvm-commits mailing list