xref: /llvm-project/offload/liboffload/API/Common.td (revision fd3907ccb583df99e9c19d2fe84e4e7c52d75de9)
1def : Macro {
2  let name = "OL_VERSION_MAJOR";
3  let desc = "Major version of the Offload API";
4  let value = "0";
5}
6
7def : Macro {
8  let name = "OL_VERSION_MINOR";
9  let desc = "Minor version of the Offload API";
10  let value = "0";
11}
12
13def : Macro {
14  let name = "OL_VERSION_PATCH";
15  let desc = "Patch version of the Offload API";
16  let value = "1";
17}
18
19def : Macro {
20  let name = "OL_APICALL";
21  let desc = "Calling convention for all API functions";
22  let condition = "defined(_WIN32)";
23  let value = "__cdecl";
24  let alt_value = "";
25}
26
27def : Macro {
28  let name = "OL_APIEXPORT";
29  let desc = "Microsoft-specific dllexport storage-class attribute";
30  let condition = "defined(_WIN32)";
31  let value = "__declspec(dllexport)";
32  let alt_value = "";
33}
34
35def : Macro {
36  let name = "OL_DLLEXPORT";
37  let desc = "Microsoft-specific dllexport storage-class attribute";
38  let condition = "defined(_WIN32)";
39  let value = "__declspec(dllexport)";
40}
41
42def : Macro {
43  let name = "OL_DLLEXPORT";
44  let desc = "GCC-specific dllexport storage-class attribute";
45  let condition = "__GNUC__ >= 4";
46  let value = "__attribute__ ((visibility (\"default\")))";
47  let alt_value = "";
48}
49
50def : Handle {
51  let name = "ol_platform_handle_t";
52  let desc = "Handle of a platform instance";
53}
54
55def : Handle {
56  let name = "ol_device_handle_t";
57  let desc = "Handle of platform's device object";
58}
59
60def : Handle {
61  let name = "ol_context_handle_t";
62  let desc = "Handle of context object";
63}
64
65def : Enum {
66  let name = "ol_errc_t";
67  let desc = "Defines Return/Error codes";
68  let etors =[
69    Etor<"SUCCESS", "Success">,
70    Etor<"INVALID_VALUE", "Invalid Value">,
71    Etor<"INVALID_PLATFORM", "Invalid platform">,
72    Etor<"DEVICE_NOT_FOUND", "Device not found">,
73    Etor<"INVALID_DEVICE", "Invalid device">,
74    Etor<"DEVICE_LOST", "Device hung, reset, was removed, or driver update occurred">,
75    Etor<"UNINITIALIZED", "plugin is not initialized or specific entry-point is not implemented">,
76    Etor<"OUT_OF_RESOURCES", "Out of resources">,
77    Etor<"UNSUPPORTED_VERSION", "generic error code for unsupported versions">,
78    Etor<"UNSUPPORTED_FEATURE", "generic error code for unsupported features">,
79    Etor<"INVALID_ARGUMENT", "generic error code for invalid arguments">,
80    Etor<"INVALID_NULL_HANDLE", "handle argument is not valid">,
81    Etor<"INVALID_NULL_POINTER", "pointer argument may not be nullptr">,
82    Etor<"INVALID_SIZE", "invalid size or dimensions (e.g., must not be zero, or is out of bounds)">,
83    Etor<"INVALID_ENUMERATION", "enumerator argument is not valid">,
84    Etor<"UNSUPPORTED_ENUMERATION", "enumerator argument is not supported by the device">,
85    Etor<"UNKNOWN", "Unknown or internal error">
86  ];
87}
88
89def : Struct {
90  let name = "ol_error_struct_t";
91  let desc = "Details of the error condition returned by an API call";
92  let members = [
93    StructMember<"ol_errc_t", "Code", "The error code">,
94    StructMember<"const char*", "Details", "String containing error details">
95  ];
96}
97
98def : Typedef {
99  let name = "ol_result_t";
100  let desc = "Result type returned by all entry points.";
101  let value = "const ol_error_struct_t*";
102}
103
104def : Macro {
105  let name = "OL_SUCCESS";
106  let desc = "Success condition";
107  let value = "NULL";
108}
109
110def : Struct {
111  let name = "ol_code_location_t";
112  let desc = "Code location information that can optionally be associated with an API call";
113  let members = [
114    StructMember<"const char*", "FunctionName", "Function name">,
115    StructMember<"const char*", "SourceFile", "Source code file">,
116    StructMember<"uint32_t", "LineNumber", "Source code line number">,
117    StructMember<"uint32_t", "ColumnNumber", "Source code column number">
118  ];
119}
120
121def : Function {
122  let name = "olInit";
123  let desc = "Perform initialization of the Offload library and plugins";
124  let details = [
125    "This must be the first API call made by a user of the Offload library",
126    "Each call will increment an internal reference count that is decremented by `olShutDown`"
127  ];
128  let params = [];
129  let returns = [];
130}
131
132def : Function {
133  let name = "olShutDown";
134  let desc = "Release the resources in use by Offload";
135  let details = [
136    "This decrements an internal reference count. When this reaches 0, all resources will be released",
137    "Subsequent API calls made after this are not valid"
138  ];
139  let params = [];
140  let returns = [];
141}
142