Skip to content

Commit 17dbb92

Browse files
authored
[Offload][NFC] Use tablegen names rather than name parameter for API (#154736)
1 parent 8439777 commit 17dbb92

File tree

12 files changed

+88
-163
lines changed

12 files changed

+88
-163
lines changed

offload/liboffload/API/APIDefs.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ defvar DefaultReturns = [Return<PREFIX#"_RESULT_SUCCESS">,
145145
Return<PREFIX#"_ERRC_DEVICE_LOST">];
146146

147147
class APIObject {
148-
string name;
149148
string desc;
150149
}
151150

offload/liboffload/API/Common.td

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,77 +10,64 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
def : Macro {
14-
let name = "OL_VERSION_MAJOR";
13+
def OL_VERSION_MAJOR : Macro {
1514
let desc = "Major version of the Offload API";
1615
let value = "0";
1716
}
1817

19-
def : Macro {
20-
let name = "OL_VERSION_MINOR";
18+
def OL_VERSION_MINOR : Macro {
2119
let desc = "Minor version of the Offload API";
2220
let value = "0";
2321
}
2422

25-
def : Macro {
26-
let name = "OL_VERSION_PATCH";
23+
def OL_VERSION_PATCH : Macro {
2724
let desc = "Patch version of the Offload API";
2825
let value = "1";
2926
}
3027

31-
def : Macro {
32-
let name = "OL_APICALL";
28+
def OL_APICALL : Macro {
3329
let desc = "Calling convention for all API functions";
3430
let condition = "defined(_WIN32)";
3531
let value = "__cdecl";
3632
let alt_value = "";
3733
}
3834

39-
def : Macro {
40-
let name = "OL_APIEXPORT";
35+
def OL_APIEXPORT : Macro {
4136
let desc = "Microsoft-specific dllexport storage-class attribute";
4237
let condition = "defined(_WIN32)";
4338
let value = "__declspec(dllexport)";
4439
let alt_value = "";
4540
}
4641

47-
def : Handle {
48-
let name = "ol_platform_handle_t";
42+
def ol_platform_handle_t : Handle {
4943
let desc = "Handle of a platform instance";
5044
}
5145

52-
def : Handle {
53-
let name = "ol_device_handle_t";
46+
def ol_device_handle_t : Handle {
5447
let desc = "Handle of platform's device object";
5548
}
5649

57-
def : Handle {
58-
let name = "ol_context_handle_t";
50+
def ol_context_handle_t : Handle {
5951
let desc = "Handle of context object";
6052
}
6153

62-
def : Handle {
63-
let name = "ol_queue_handle_t";
54+
def ol_queue_handle_t : Handle {
6455
let desc = "Handle of queue object";
6556
}
6657

67-
def : Handle {
68-
let name = "ol_event_handle_t";
58+
def ol_event_handle_t : Handle {
6959
let desc = "Handle of event object";
7060
}
7161

72-
def : Handle {
73-
let name = "ol_program_handle_t";
62+
def ol_program_handle_t : Handle {
7463
let desc = "Handle of program object";
7564
}
7665

77-
def : Handle {
78-
let name = "ol_symbol_handle_t";
66+
def ol_symbol_handle_t : Handle {
7967
let desc = "Handle of an object in a device's memory for a specific program";
8068
}
8169

82-
def ErrorCode : Enum {
83-
let name = "ol_errc_t";
70+
def ol_errc_t : Enum {
8471
let desc = "Defines Return/Error codes";
8572
let etors =[
8673
Etor<"SUCCESS", "success">,
@@ -115,29 +102,25 @@ def ErrorCode : Enum {
115102
];
116103
}
117104

118-
def : Struct {
119-
let name = "ol_error_struct_t";
105+
def ol_error_struct_t : Struct {
120106
let desc = "Details of the error condition returned by an API call";
121107
let members = [
122108
StructMember<"ol_errc_t", "Code", "The error code">,
123109
StructMember<"const char*", "Details", "String containing error details">
124110
];
125111
}
126112

127-
def : Typedef {
128-
let name = "ol_result_t";
113+
def ol_result_t : Typedef {
129114
let desc = "Result type returned by all entry points.";
130115
let value = "const struct ol_error_struct_t*";
131116
}
132117

133-
def : Macro {
134-
let name = "OL_SUCCESS";
118+
def OL_SUCCESS : Macro {
135119
let desc = "Success condition";
136120
let value = "NULL";
137121
}
138122

139-
def : Struct {
140-
let name = "ol_code_location_t";
123+
def ol_code_location_t : Struct {
141124
let desc = "Code location information that can optionally be associated with an API call";
142125
let members = [
143126
StructMember<"const char*", "FunctionName", "Function name">,
@@ -147,8 +130,7 @@ def : Struct {
147130
];
148131
}
149132

150-
def : Struct {
151-
let name = "ol_dimensions_t";
133+
def ol_dimensions_t : Struct {
152134
let desc = "A three element vector";
153135
let members = [
154136
StructMember<"uint32_t", "x", "X">,
@@ -157,8 +139,7 @@ def : Struct {
157139
];
158140
}
159141

160-
def : Function {
161-
let name = "olInit";
142+
def olInit : Function {
162143
let desc = "Perform initialization of the Offload library and plugins";
163144
let details = [
164145
"This must be the first API call made by a user of the Offload library",
@@ -168,8 +149,7 @@ def : Function {
168149
let returns = [];
169150
}
170151

171-
def : Function {
172-
let name = "olShutDown";
152+
def olShutDown : Function {
173153
let desc = "Release the resources in use by Offload";
174154
let details = [
175155
"This decrements an internal reference count. When this reaches 0, all resources will be released",

offload/liboffload/API/Device.td

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
def : Enum {
14-
let name = "ol_device_type_t";
13+
def ol_device_type_t : Enum {
1514
let desc = "Supported device types.";
1615
let etors =[
1716
Etor<"DEFAULT", "The default device type as preferred by the runtime">,
@@ -22,8 +21,7 @@ def : Enum {
2221
];
2322
}
2423

25-
def DeviceInfo : Enum {
26-
let name = "ol_device_info_t";
24+
def ol_device_info_t : Enum {
2725
let desc = "Supported device info.";
2826
let is_typed = 1;
2927
list<TaggedEtor> basic_etors =[
@@ -47,8 +45,7 @@ def DeviceInfo : Enum {
4745
let etors = !listconcat(basic_etors, fp_configs, native_vec_widths);
4846
}
4947

50-
def : Enum {
51-
let name = "ol_device_fp_capability_flag_t";
48+
def ol_device_fp_capability_flag_t : Enum {
5249
let desc = "Device floating-point capability flags";
5350
let is_bit_field = 1;
5451
let etors =[
@@ -63,14 +60,12 @@ def : Enum {
6360
];
6461
}
6562

66-
def : Typedef {
67-
let name = "ol_device_fp_capability_flags_t";
63+
def ol_device_fp_capability_flags_t : Typedef {
6864
let desc = "Device floating-point capability flags";
6965
let value = "uint32_t";
7066
}
7167

72-
def : FptrTypedef {
73-
let name = "ol_device_iterate_cb_t";
68+
def ol_device_iterate_cb_t : FptrTypedef {
7469
let desc = "User-provided function to be used with `olIterateDevices`";
7570
let params = [
7671
Param<"ol_device_handle_t", "Device", "the device handle of the current iteration", PARAM_IN>,
@@ -79,8 +74,7 @@ def : FptrTypedef {
7974
let return = "bool";
8075
}
8176

82-
def : Function {
83-
let name = "olIterateDevices";
77+
def olIterateDevices : Function {
8478
let desc = "Iterates over all available devices, calling the callback for each device.";
8579
let details = [
8680
"If the user-provided callback returns `false`, the iteration is stopped."
@@ -94,8 +88,7 @@ def : Function {
9488
];
9589
}
9690

97-
def : Function {
98-
let name = "olGetDeviceInfo";
91+
def olGetDeviceInfo : Function {
9992
let desc = "Queries the given property of the device.";
10093
let details = [];
10194
let params = [
@@ -118,8 +111,7 @@ def : Function {
118111
];
119112
}
120113

121-
def : Function {
122-
let name = "olGetDeviceInfoSize";
114+
def olGetDeviceInfoSize : Function {
123115
let desc = "Returns the storage size of the given device query.";
124116
let details = [];
125117
let params = [

offload/liboffload/API/Event.td

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
def : Function {
14-
let name = "olCreateEvent";
13+
def olCreateEvent : Function {
1514
let desc = "Enqueue an event to `Queue` and return it.";
1615
let details = [
1716
"This event can be used with `olSyncEvent` and `olWaitEvents` and will be complete once all enqueued work prior to the `olCreateEvent` call is complete.",
@@ -23,8 +22,7 @@ def : Function {
2322
let returns = [];
2423
}
2524

26-
def : Function {
27-
let name = "olDestroyEvent";
25+
def olDestroyEvent : Function {
2826
let desc = "Destroy the event and free all underlying resources.";
2927
let details = [];
3028
let params = [
@@ -33,8 +31,7 @@ def : Function {
3331
let returns = [];
3432
}
3533

36-
def : Function {
37-
let name = "olSyncEvent";
34+
def olSyncEvent : Function {
3835
let desc = "Block the calling thread until the event is complete.";
3936
let details = [];
4037
let params = [
@@ -43,17 +40,15 @@ def : Function {
4340
let returns = [];
4441
}
4542

46-
def : Enum {
47-
let name = "ol_event_info_t";
43+
def ol_event_info_t : Enum {
4844
let desc = "Supported event info.";
4945
let is_typed = 1;
5046
let etors = [
5147
TaggedEtor<"QUEUE", "ol_queue_handle_t", "The handle of the queue associated with the device.">
5248
];
5349
}
5450

55-
def : Function {
56-
let name = "olGetEventInfo";
51+
def olGetEventInfo : Function {
5752
let desc = "Queries the given property of the event.";
5853
let details = [
5954
"`olGetEventInfoSize` can be used to query the storage size "
@@ -77,8 +72,7 @@ def : Function {
7772
];
7873
}
7974

80-
def : Function {
81-
let name = "olGetEventInfoSize";
75+
def olGetEventInfoSize : Function {
8276
let desc = "Returns the storage size of the given event query.";
8377
let details = [];
8478
let params = [

offload/liboffload/API/Kernel.td

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
def : Struct {
14-
let name = "ol_kernel_launch_size_args_t";
13+
def ol_kernel_launch_size_args_t : Struct {
1514
let desc = "Size-related arguments for a kernel launch.";
1615
let members = [
1716
StructMember<"size_t", "Dimensions", "Number of work dimensions">,
@@ -21,8 +20,7 @@ def : Struct {
2120
];
2221
}
2322

24-
def : Function {
25-
let name = "olLaunchKernel";
23+
def olLaunchKernel : Function {
2624
let desc = "Enqueue a kernel launch with the specified size and parameters.";
2725
let details = [
2826
"If a queue is not specified, kernel execution happens synchronously",
@@ -43,8 +41,7 @@ def : Function {
4341
];
4442
}
4543

46-
def : Function {
47-
let name = "olCalculateOptimalOccupancy";
44+
def olCalculateOptimalOccupancy : Function {
4845
let desc = "Given dynamic memory size, query the device for a workgroup size that will result in optimal occupancy.";
4946
let details = [
5047
"For most devices, this will be the largest workgroup size that will result in all work items fitting on the device at once.",

offload/liboffload/API/Memory.td

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
def : Enum {
14-
let name = "ol_alloc_type_t";
13+
def ol_alloc_type_t : Enum {
1514
let desc = "Represents the type of allocation made with olMemAlloc.";
1615
let etors = [
1716
Etor<"HOST", "Host allocation">,
@@ -20,8 +19,7 @@ def : Enum {
2019
];
2120
}
2221

23-
def : Function {
24-
let name = "olMemAlloc";
22+
def olMemAlloc : Function {
2523
let desc = "Creates a memory allocation on the specified device.";
2624
let params = [
2725
Param<"ol_device_handle_t", "Device", "handle of the device to allocate on", PARAM_IN>,
@@ -36,17 +34,15 @@ def : Function {
3634
];
3735
}
3836

39-
def : Function {
40-
let name = "olMemFree";
37+
def olMemFree : Function {
4138
let desc = "Frees a memory allocation previously made by olMemAlloc.";
4239
let params = [
4340
Param<"void*", "Address", "address of the allocation to free", PARAM_IN>,
4441
];
4542
let returns = [];
4643
}
4744

48-
def : Function {
49-
let name = "olMemcpy";
45+
def olMemcpy : Function {
5046
let desc = "Enqueue a memcpy operation.";
5147
let details = [
5248
"For host pointers, use the host device belonging to the OL_PLATFORM_BACKEND_HOST platform.",

0 commit comments

Comments
 (0)