[llvm] [Offload] Add Error Codes to PluginInterface (PR #138258)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 07:16:53 PDT 2025


================
@@ -83,26 +83,30 @@ def : Typedef {
   let value = "void *";
 }
 
-def : Enum {
+def ErrorCode : Enum {
   let name = "ol_errc_t";
   let desc = "Defines Return/Error codes";
   let etors =[
-    Etor<"SUCCESS", "Success">,
-    Etor<"INVALID_VALUE", "Invalid Value">,
+    Etor<"SUCCESS", "Success", 0>,
+
+    // Universal errors
+    Etor<"INVALID_NULL_POINTER", "A pointer argument is null when it should not be">,
+    Etor<"INVALID_ARGUMENT", "An argument is invalid">,
+    Etor<"OUT_OF_RESOURCES", "Out of resources">,
+    Etor<"UNSUPPORTED", "generic error code for unsupported features and enums">,
+
+    // Liboffload specific errors
+    Etor<"INVALID_VALUE", "Invalid Value", 0x1000>,
     Etor<"INVALID_PLATFORM", "Invalid platform">,
     Etor<"INVALID_DEVICE", "Invalid device">,
     Etor<"INVALID_QUEUE", "Invalid queue">,
     Etor<"INVALID_EVENT", "Invalid event">,
     Etor<"INVALID_KERNEL_NAME", "Named kernel not found in the program binary">,
-    Etor<"OUT_OF_RESOURCES", "Out of resources">,
-    Etor<"UNSUPPORTED_FEATURE", "generic error code for unsupported features">,
-    Etor<"INVALID_ARGUMENT", "generic error code for invalid arguments">,
     Etor<"INVALID_NULL_HANDLE", "handle argument is not valid">,
-    Etor<"INVALID_NULL_POINTER", "pointer argument may not be nullptr">,
     Etor<"INVALID_SIZE", "invalid size or dimensions (e.g., must not be zero, or is out of bounds)">,
     Etor<"INVALID_ENUMERATION", "enumerator argument is not valid">,
-    Etor<"UNSUPPORTED_ENUMERATION", "enumerator argument is not supported by the device">,
-    Etor<"UNKNOWN", "Unknown or internal error">
+
+    Etor<"UNKNOWN", "Unknown or internal error", 0x10000>
----------------
jhuber6 wrote:

There is some concept of interop, but I don't really remember how fleshed out it is. The idea with interop is that you'd get the underlying object for that platform and then you could do you own error handling on it. I don't think that requires us to forward their error codes, since we already convert from the CUDA / HSA error codes to the LLVM error type ASAP currently.

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


More information about the llvm-commits mailing list