@@ -21,6 +21,8 @@ namespace mlir {
21
21
namespace impl {
22
22
class DataLayoutEntryStorage ;
23
23
class DataLayoutSpecStorage ;
24
+ class TargetSystemDescSpecAttrStorage ;
25
+ class TargetDeviceDescSpecAttrStorage ;
24
26
} // namespace impl
25
27
26
28
// ===----------------------------------------------------------------------===//
@@ -124,6 +126,150 @@ class DataLayoutSpecAttr
124
126
static constexpr StringLiteral name = " builtin.data_layout_spec" ;
125
127
};
126
128
129
+ // ===----------------------------------------------------------------------===//
130
+ // TargetSystemDescSpecAttr
131
+ // ===----------------------------------------------------------------------===//
132
+
133
+ // / A system description attribute is a list of device descriptors, each
134
+ // / having a unique device ID
135
+ class TargetSystemDescSpecAttr
136
+ : public Attribute::AttrBase<TargetSystemDescSpecAttr, Attribute,
137
+ impl::TargetSystemDescSpecAttrStorage,
138
+ TargetSystemDescSpecInterface::Trait> {
139
+ public:
140
+ using Base::Base;
141
+
142
+ // / The keyword used for this attribute in custom syntax.
143
+ constexpr const static StringLiteral kAttrKeyword = " tsd_spec" ;
144
+
145
+ // / Returns a system descriptor attribute from the given system descriptor
146
+ static TargetSystemDescSpecAttr
147
+ get (MLIRContext *context, ArrayRef<TargetDeviceDescSpecInterface> entries);
148
+
149
+ // / Returns the list of entries.
150
+ TargetDeviceDescSpecListRef getEntries () const ;
151
+
152
+ // / Return the device descriptor that matches the given device ID
153
+ TargetDeviceDescSpecInterface getDeviceDescForDeviceID (uint32_t deviceID);
154
+
155
+ // / Returns the specification containing the given list of keys. If the list
156
+ // / contains duplicate keys or is otherwise invalid, reports errors using the
157
+ // / given callback and returns null.
158
+ static TargetSystemDescSpecAttr
159
+ getChecked (function_ref<InFlightDiagnostic()> emitError, MLIRContext *context,
160
+ ArrayRef<TargetDeviceDescSpecInterface> entries);
161
+
162
+ // / Checks that the given list of entries does not contain duplicate keys.
163
+ static LogicalResult verify (function_ref<InFlightDiagnostic()> emitError,
164
+ ArrayRef<TargetDeviceDescSpecInterface> entries);
165
+
166
+ // / Parses an instance of this attribute.
167
+ static TargetSystemDescSpecAttr parse (AsmParser &parser);
168
+
169
+ // / Prints this attribute.
170
+ void print (AsmPrinter &os) const ;
171
+
172
+ static constexpr StringLiteral name = " builtin.target_system_description" ;
173
+ };
174
+
175
+ // ===----------------------------------------------------------------------===//
176
+ // TargetDeviceDescSpecAttr
177
+ // ===----------------------------------------------------------------------===//
178
+
179
+ class TargetDeviceDescSpecAttr
180
+ : public Attribute::AttrBase<TargetDeviceDescSpecAttr, Attribute,
181
+ impl::TargetDeviceDescSpecAttrStorage,
182
+ TargetDeviceDescSpecInterface::Trait> {
183
+ public:
184
+ using Base::Base;
185
+
186
+ // / The keyword used for this attribute in custom syntax.
187
+ constexpr const static StringLiteral kAttrKeyword = " tdd_spec" ;
188
+
189
+ // / Returns a system descriptor attribute from the given system descriptor
190
+ static TargetDeviceDescSpecAttr
191
+ get (MLIRContext *context, ArrayRef<DataLayoutEntryInterface> entries);
192
+
193
+ // / Returns the specification containing the given list of keys. If the list
194
+ // / contains duplicate keys or is otherwise invalid, reports errors using the
195
+ // / given callback and returns null.
196
+ static TargetDeviceDescSpecAttr
197
+ getChecked (function_ref<InFlightDiagnostic()> emitError, MLIRContext *context,
198
+ ArrayRef<DataLayoutEntryInterface> entries);
199
+
200
+ // / Checks that the given list of entries does not contain duplicate keys.
201
+ static LogicalResult verify (function_ref<InFlightDiagnostic()> emitError,
202
+ ArrayRef<DataLayoutEntryInterface> entries);
203
+
204
+ // / Returns the list of entries.
205
+ DataLayoutEntryListRef getEntries () const ;
206
+
207
+ // / Parses an instance of this attribute.
208
+ static TargetDeviceDescSpecAttr parse (AsmParser &parser);
209
+
210
+ // / Prints this attribute.
211
+ void print (AsmPrinter &os) const ;
212
+
213
+ // / Returns the device ID identifier.
214
+ StringAttr getDeviceIDIdentifier (MLIRContext *context);
215
+
216
+ // / Returns the device type identifier.
217
+ StringAttr getDeviceTypeIdentifier (MLIRContext *context);
218
+
219
+ // / Returns max vector op width identifier.
220
+ StringAttr getMaxVectorOpWidthIdentifier (MLIRContext *context);
221
+
222
+ // / Returns canonicalizer max iterations identifier.
223
+ StringAttr getCanonicalizerMaxIterationsIdentifier (MLIRContext *context);
224
+
225
+ // / Returns canonicalizer max num rewrites identifier.
226
+ StringAttr getCanonicalizerMaxNumRewritesIdentifier (MLIRContext *context);
227
+
228
+ // / Returns L1 cache size identifier
229
+ StringAttr getL1CacheSizeInBytesIdentifier (MLIRContext *context);
230
+
231
+ // / Returns the interface spec for device ID
232
+ // / Since we verify that the spec contains device ID the function
233
+ // / will return a valid spec.
234
+ DataLayoutEntryInterface getSpecForDeviceID (MLIRContext *context);
235
+
236
+ // / Returns the interface spec for device type
237
+ // / Since we verify that the spec contains device type the function
238
+ // / will return a valid spec.
239
+ DataLayoutEntryInterface getSpecForDeviceType (MLIRContext *context);
240
+
241
+ // / Returns the interface spec for max vector op width
242
+ // / Since max vector op width is an optional property, this function will
243
+ // / return a valid spec if the property is defined, otherwise it
244
+ // / will return an empty spec.
245
+ DataLayoutEntryInterface getSpecForMaxVectorOpWidth (MLIRContext *context);
246
+
247
+ // / Returns the interface spec for L1 cache size
248
+ // / Since L1 cache size is an optional property, this function will
249
+ // / return a valid spec if the property is defined, otherwise it
250
+ // / will return an empty spec.
251
+ DataLayoutEntryInterface getSpecForL1CacheSizeInBytes (MLIRContext *context);
252
+
253
+ // / Returns the interface spec for canonicalizer max iterations.
254
+ // / Since this is an optional property, this function will
255
+ // / return a valid spec if the property is defined, otherwise it
256
+ // / will return an empty spec.
257
+ DataLayoutEntryInterface
258
+ getSpecForCanonicalizerMaxIterations (MLIRContext *context);
259
+
260
+ // / Returns the interface spec for canonicalizer max num rewrites.
261
+ // / Since this is an optional property, this function will
262
+ // / return a valid spec if the property is defined, otherwise it
263
+ // / will return an empty spec.
264
+ DataLayoutEntryInterface
265
+ getSpecForCanonicalizerMaxNumRewrites (MLIRContext *context);
266
+
267
+ // / Return the value of device ID
268
+ uint32_t getDeviceID (MLIRContext *context);
269
+
270
+ static constexpr StringLiteral name = " builtin.target_device_description" ;
271
+ };
272
+
127
273
} // namespace mlir
128
274
129
275
#include " mlir/Dialect/DLTI/DLTIDialect.h.inc"
0 commit comments