@@ -28,7 +28,7 @@ def DataLayoutEntryTrait
28
28
def DLTI_DataLayoutEntryAttr :
29
29
DLTIAttr<"DataLayoutEntry", [DataLayoutEntryTrait]> {
30
30
let summary = [{
31
- An attribute to represent an entry of a data layout specification
31
+ An attribute to represent an entry of a data layout specification.
32
32
}];
33
33
let description = [{
34
34
A data layout entry attribute is a key-value pair where the key is a type or
@@ -38,7 +38,7 @@ def DLTI_DataLayoutEntryAttr :
38
38
let parameters = (ins
39
39
"DataLayoutEntryKey":$key, "Attribute":$value
40
40
);
41
- // We do not generate storage class because llvm::PointerUnion
41
+ // TODO: We do not generate storage class because llvm::PointerUnion
42
42
// does not work with hash_key method.
43
43
let genStorageClass = 0;
44
44
let mnemonic = "dl_entry";
@@ -62,7 +62,9 @@ def DataLayoutSpecTrait
62
62
63
63
def DLTI_DataLayoutSpecAttr :
64
64
DLTIAttr<"DataLayoutSpec", [DataLayoutSpecTrait]> {
65
- let summary = [{An attribute to represent a data layout specification}];
65
+ let summary = [{
66
+ An attribute to represent a data layout specification.
67
+ }];
66
68
let description = [{
67
69
A data layout specification is a list of entries that specify (partial) data
68
70
layout information. It is expected to be attached to operations that serve
@@ -96,84 +98,57 @@ def DLTI_DataLayoutSpecAttr :
96
98
/// Returns the stack alignment identifier.
97
99
StringAttr getStackAlignmentIdentifier(MLIRContext *context) const;
98
100
}];
99
- let extraClassDefinition = [{
100
- StringAttr
101
- $cppClass::getEndiannessIdentifier(MLIRContext *context) const {
102
- return Builder(context).getStringAttr(DLTIDialect::kDataLayoutEndiannessKey);
103
- }
104
-
105
- StringAttr
106
- $cppClass::getAllocaMemorySpaceIdentifier(MLIRContext *context) const {
107
- return Builder(context).getStringAttr(
108
- DLTIDialect::kDataLayoutAllocaMemorySpaceKey);
109
- }
110
-
111
- StringAttr $cppClass::getProgramMemorySpaceIdentifier(
112
- MLIRContext *context) const {
113
- return Builder(context).getStringAttr(
114
- DLTIDialect::kDataLayoutProgramMemorySpaceKey);
115
- }
116
-
117
- StringAttr
118
- $cppClass::getGlobalMemorySpaceIdentifier(MLIRContext *context) const {
119
- return Builder(context).getStringAttr(
120
- DLTIDialect::kDataLayoutGlobalMemorySpaceKey);
121
- }
122
-
123
- StringAttr
124
- $cppClass::getStackAlignmentIdentifier(MLIRContext *context) const {
125
- return Builder(context).getStringAttr(
126
- DLTIDialect::kDataLayoutStackAlignmentKey);
127
- }
128
- }];
129
101
}
130
102
131
103
//===----------------------------------------------------------------------===//
132
- // TargetSystemDescSpecAttr
104
+ // TargetSystemSpecAttr
133
105
//===----------------------------------------------------------------------===//
134
106
135
- def TargetSystemDescSpecTrait
136
- : NativeAttrTrait<"TargetSystemDescSpecInterface ::Trait"> {
107
+ def TargetSystemSpecTrait
108
+ : NativeAttrTrait<"TargetSystemSpecInterface ::Trait"> {
137
109
let cppNamespace = "::mlir";
138
110
}
139
111
140
- def DLTI_TargetSystemDescSpecAttr :
141
- DLTIAttr<"TargetSystemDescSpec", [TargetSystemDescSpecTrait]> {
142
- let summary = [{An attribute to represent target system description}];
112
+ def DLTI_TargetSystemSpecAttr :
113
+ DLTIAttr<"TargetSystemSpec", [TargetSystemSpecTrait]> {
114
+ let summary = [{
115
+ An attribute to represent target system specification.
116
+ }];
143
117
let description = [{
144
- A system description specification describes the overall system
145
- containing multiple devices, with each device having a unique ID
146
- and its corresponding TargetDeviceDescSpec object.
118
+ A system specification describes the overall system containing
119
+ multiple devices, with each device having a unique ID
120
+ and its corresponding TargetDeviceSpec object.
147
121
148
122
Example:
149
- dlti.target_system_desc_spec =
150
- #dlti.target_device_desc_spec <
123
+ dlti.target_system_spec =
124
+ #dlti.target_device_spec <
151
125
#dlti.dl_entry<"dlti.device_id", 0: ui32>,
152
126
#dlti.dl_entry<"dlti.device_type", "CPU">>,
153
- #dlti.target_device_desc_spec <
127
+ #dlti.target_device_spec <
154
128
#dlti.dl_entry<"dlti.device_id", 1: ui32>,
155
129
#dlti.dl_entry<"dlti.device_type", "GPU">,
156
130
#dlti.dl_entry<"dlti.max_vector_op_width", 64 : ui32>>,
157
- #dlti.target_device_desc_spec <
131
+ #dlti.target_device_spec <
158
132
#dlti.dl_entry<"dlti.device_id", 2: ui32>,
159
133
#dlti.dl_entry<"dlti.device_type", "XPU">>>
160
134
}];
161
135
let parameters = (ins
162
- ArrayRefParameter<"TargetDeviceDescSpecInterface ", "">:$entries
136
+ ArrayRefParameter<"TargetDeviceSpecInterface ", "">:$entries
163
137
);
164
- let mnemonic = "target_system_desc_spec ";
138
+ let mnemonic = "target_system_spec ";
165
139
let genVerifyDecl = 1;
166
- let hasCustomAssemblyFormat = 1 ;
140
+ let assemblyFormat = "`<` $entries `>`" ;
167
141
let extraClassDeclaration = [{
168
- /// Return the device descriptor that matches the given device ID
169
- std::optional<TargetDeviceDescSpecInterface>
170
- getDeviceDescForDeviceID(uint32_t deviceID);
142
+ /// Return the device specification that matches the given device ID
143
+ std::optional<TargetDeviceSpecInterface>
144
+ getDeviceSpecForDeviceID(
145
+ TargetDeviceSpecInterface::DeviceID deviceID);
171
146
}];
172
147
let extraClassDefinition = [{
173
- std::optional<TargetDeviceDescSpecInterface >
174
- $cppClass::getDeviceDescForDeviceID (
175
- TargetDeviceDescSpecInterface ::DeviceID deviceID) {
176
- for (TargetDeviceDescSpecInterface entry : getEntries()) {
148
+ std::optional<TargetDeviceSpecInterface >
149
+ $cppClass::getDeviceSpecForDeviceID (
150
+ TargetDeviceSpecInterface ::DeviceID deviceID) {
151
+ for (TargetDeviceSpecInterface entry : getEntries()) {
177
152
if (entry.getDeviceID() == deviceID)
178
153
return entry;
179
154
}
@@ -183,35 +158,37 @@ def DLTI_TargetSystemDescSpecAttr :
183
158
}
184
159
185
160
//===----------------------------------------------------------------------===//
186
- // TargetDeviceDescSpecAttr
161
+ // TargetDeviceSpecAttr
187
162
//===----------------------------------------------------------------------===//
188
163
189
- def TargetDeviceDescSpecTrait
190
- : NativeAttrTrait<"TargetDeviceDescSpecInterface ::Trait"> {
164
+ def TargetDeviceSpecTrait
165
+ : NativeAttrTrait<"TargetDeviceSpecInterface ::Trait"> {
191
166
let cppNamespace = "::mlir";
192
167
}
193
168
194
- def DLTI_TargetDeviceDescSpecAttr :
195
- DLTIAttr<"TargetDeviceDescSpec", [TargetDeviceDescSpecTrait]> {
196
- let summary = [{An attribute to represent target device description}];
169
+ def DLTI_TargetDeviceSpecAttr :
170
+ DLTIAttr<"TargetDeviceSpec", [TargetDeviceSpecTrait]> {
171
+ let summary = [{
172
+ An attribute to represent target device specification.
173
+ }];
197
174
let description = [{
198
- Each device description specification describes a single device and
199
- its hardware properties. Each device description must have a device_id
200
- and a device_type. In addition, the description can contain any number
201
- of optional hardware properties (e.g., max_vector_op_width below).
175
+ Each device specification describes a single device and its
176
+ hardware properties. Each device specification must have a device_id
177
+ and a device_type. In addition, the specification can contain any number
178
+ of optional hardware properties (e.g., max_vector_op_width below).
202
179
203
- Example:
204
- #dlti.target_device_desc_spec <
205
- #dlti.dl_entry<"dlti.device_id", 1: ui32>,
206
- #dlti.dl_entry<"dlti.device_type", "GPU">,
207
- #dlti.dl_entry<"dlti.max_vector_op_width", 64 : ui32>>
208
- }];
180
+ Example:
181
+ #dlti.target_device_spec <
182
+ #dlti.dl_entry<"dlti.device_id", 1: ui32>,
183
+ #dlti.dl_entry<"dlti.device_type", "GPU">,
184
+ #dlti.dl_entry<"dlti.max_vector_op_width", 64 : ui32>>
185
+ }];
209
186
let parameters = (ins
210
187
ArrayRefParameter<"DataLayoutEntryInterface", "">:$entries
211
188
);
212
- let mnemonic = "target_device_desc_spec ";
189
+ let mnemonic = "target_device_spec ";
213
190
let genVerifyDecl = 1;
214
- let hasCustomAssemblyFormat = 1 ;
191
+ let assemblyFormat = "`<` $entries `>`" ;
215
192
let extraClassDeclaration = [{
216
193
/// Returns the device ID identifier.
217
194
StringAttr getDeviceIDIdentifier();
@@ -248,55 +225,7 @@ def DLTI_TargetDeviceDescSpecAttr :
248
225
DataLayoutEntryInterface getSpecForL1CacheSizeInBytes();
249
226
250
227
/// Return the value of device ID
251
- uint32_t getDeviceID();
252
- }];
253
-
254
- let extraClassDefinition = [{
255
- StringAttr
256
- $cppClass::getDeviceIDIdentifier() {
257
- return Builder(getContext()).getStringAttr(DLTIDialect::kTargetDeviceIDKey);
258
- }
259
-
260
- StringAttr
261
- $cppClass::getDeviceTypeIdentifier() {
262
- return Builder(getContext()).getStringAttr(DLTIDialect::kTargetDeviceTypeKey);
263
- }
264
-
265
- StringAttr
266
- $cppClass::getMaxVectorOpWidthIdentifier() {
267
- return Builder(getContext()).getStringAttr(
268
- DLTIDialect::kTargetDeviceMaxVectorOpWidthKey);
269
- }
270
-
271
- StringAttr $cppClass::getL1CacheSizeInBytesIdentifier() {
272
- return Builder(getContext()).getStringAttr(
273
- DLTIDialect::kTargetDeviceL1CacheSizeInBytesKey);
274
- }
275
-
276
- DataLayoutEntryInterface
277
- $cppClass::getSpecForDeviceID() {
278
- return getSpecForIdentifier(getDeviceIDIdentifier());
279
- }
280
-
281
- DataLayoutEntryInterface
282
- $cppClass::getSpecForDeviceType() {
283
- return getSpecForIdentifier(getDeviceTypeIdentifier());
284
- }
285
-
286
- DataLayoutEntryInterface
287
- $cppClass::getSpecForMaxVectorOpWidth() {
288
- return getSpecForIdentifier(getMaxVectorOpWidthIdentifier());
289
- }
290
-
291
- DataLayoutEntryInterface
292
- $cppClass::getSpecForL1CacheSizeInBytes() {
293
- return getSpecForIdentifier(getL1CacheSizeInBytesIdentifier());
294
- }
295
-
296
- uint32_t $cppClass::getDeviceID() {
297
- DataLayoutEntryInterface entry = getSpecForDeviceID();
298
- return llvm::cast<IntegerAttr>(entry.getValue()).getValue().getZExtValue();
299
- }
228
+ TargetDeviceSpecInterface::DeviceID getDeviceID();
300
229
}];
301
230
}
302
231
0 commit comments