[llvm] [Offload] Introduce offload-tblgen and initial new API implementation (PR #108413)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 12 09:19:17 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";
+ let desc = "Handle of a platform instance";
+}
+
+def : Handle {
+ let name = "offload_device_handle_t";
+ let desc = "Handle of platform's device object";
+}
+
+def : Handle {
+ let name = "offload_context_handle_t";
+ let desc = "Handle of context object";
+}
+
+def : Enum {
+ let name = "offload_result_t";
----------------
jhuber6 wrote:
I think we talked a lot about error codes, where the returned value is actually an index into some table (zero is success / invalid index). The actual error code could be queried from that index or something. This is mostly because we want the library to provide more helpful error codes than generic "X went wrong" since we already do a lot of stuff like `return Error::("Something called %s failed on device %d", name, device)` instead of just returning failure.
https://github.com/llvm/llvm-project/pull/108413
More information about the llvm-commits
mailing list