xref: /llvm-project/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (revision 4f4e2abb1a5ff1225d32410fd02b732d077aa056)
1//===- DataLayoutInterfaces.td - Data layout interfaces ----*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Defines the interfaces for the data layout specification, operations to which
10// they can be attached, and types that are subject to data layout.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_DATALAYOUTINTERFACES
15#define MLIR_DATALAYOUTINTERFACES
16
17include "mlir/IR/OpBase.td"
18
19//===----------------------------------------------------------------------===//
20// Attribute interfaces
21//===----------------------------------------------------------------------===//
22
23def DLTIQueryInterface : AttrInterface<"DLTIQueryInterface"> {
24  let cppNamespace = "::mlir";
25
26  let description = [{
27    Attribute interface exposing querying-mechanism for key-value associations.
28
29    The central feature of DLTI attributes is to allow looking up values at
30    keys. This interface represent the core functionality to do so - as such
31    most DLTI attributes should be implementing this interface.
32
33    Note that as the `query` method returns an attribute, this attribute can
34    be recursively queried when it also implements this interface.
35  }];
36  let methods = [
37    InterfaceMethod<
38      /*description=*/"Returns the attribute associated with the key.",
39      /*retTy=*/"::mlir::FailureOr<::mlir::Attribute>",
40      /*methodName=*/"query",
41      /*args=*/(ins "::mlir::DataLayoutEntryKey":$key)
42    >
43  ];
44}
45
46def DataLayoutEntryInterface : AttrInterface<"DataLayoutEntryInterface"> {
47  let cppNamespace = "::mlir";
48
49  let description = [{
50    Attribute interface describing an entry in a data layout specification.
51
52    A data layout specification entry is a key-value pair. Its key is either a
53    type, when the entry is related to a type or a class of types, or an
54    identifier, when it is not. `DataLayoutEntryKey` is an alias allowing one
55    to use both key types. Its value is an arbitrary attribute that is
56    interpreted either by the type for type keys or by the dialect containing
57    the identifier for identifier keys. The interface provides a hook that
58    can be used by specific implementations to delegate the verification of
59    attribute fitness for a particular key to the relevant type or dialect.
60  }];
61
62  let methods = [
63    InterfaceMethod<
64      /*description=*/"Returns the key of the this layout entry.",
65      /*retTy=*/"::mlir::DataLayoutEntryKey",
66      /*methodName=*/"getKey",
67      /*args=*/(ins)
68    >,
69    InterfaceMethod<
70      /*description=*/"Returns the value of this layout entry.",
71      /*retTy=*/"::mlir::Attribute",
72      /*methodName=*/"getValue",
73      /*args=*/(ins)
74    >,
75    InterfaceMethod<
76      /*description=*/"Checks that the entry is well-formed, reports errors "
77                      "at the provided location.",
78      /*retTy=*/"::llvm::LogicalResult",
79      /*methodName=*/"verifyEntry",
80      /*args=*/(ins "::mlir::Location":$loc),
81      /*methodBody=*/"",
82      /*defaultImplementation=*/[{ return ::mlir::success(); }]
83    >
84  ];
85
86  let extraClassDeclaration = [{
87    /// Returns `true` if the key of this entry is a type.
88    bool isTypeEntry() {
89      return llvm::isa<::mlir::Type>(getKey());
90    }
91  }];
92}
93
94def DataLayoutSpecInterface : AttrInterface<"DataLayoutSpecInterface", [DLTIQueryInterface]> {
95  let cppNamespace = "::mlir";
96
97  let description = [{
98    Attribute interface describing a data layout specification.
99
100    A data layout specification is seen as a sequence of entries, each of which
101    is an attribute implementing the data layout entry interface. It assumes
102    a contiguous underlying storage for entries. The interface provides a hook
103    for implementations to verify the well-formedness of the specification,
104    with a default implementation that verifies the absence of entries with
105    duplicate keys and the well-formedness of each individual entry before
106    dispatching to the type or dialect the entry is associated with.
107
108    Data layout specifications may need to be combined in case they appear on
109    nested operations subject to layout, or to ensure the validity of layout
110    modification. Concrete specification attributes must implement the
111    corresponding hook.
112  }];
113  // The underlying storage being contiguous may be revised in the future, but
114  // care must be taken to avoid materializing or copying the entire list of
115  // entries.
116
117  let methods = [
118    InterfaceMethod<
119      /*description=*/"Combines the current layout with the given list of "
120                      "layouts, provided from the outermost (oldest) to the "
121                      "innermost (newest). Returns null on failure.",
122      /*retTy=*/"::mlir::DataLayoutSpecInterface",
123      /*methodName=*/"combineWith",
124      /*args=*/(ins "::llvm::ArrayRef<::mlir::DataLayoutSpecInterface>":$specs)
125    >,
126    InterfaceMethod<
127      /*description=*/"Returns the list of layout entries.",
128      /*retTy=*/"::mlir::DataLayoutEntryListRef",
129      /*methodName=*/"getEntries",
130      /*args=*/(ins)
131    >,
132    InterfaceMethod<
133      /*description=*/"Returns the endianness identifier.",
134      /*retTy=*/"::mlir::StringAttr",
135      /*methodName=*/"getEndiannessIdentifier",
136      /*args=*/(ins "::mlir::MLIRContext *":$context)
137    >,
138    InterfaceMethod<
139      /*description=*/"Returns the alloca memory space identifier.",
140      /*retTy=*/"::mlir::StringAttr",
141      /*methodName=*/"getAllocaMemorySpaceIdentifier",
142      /*args=*/(ins "::mlir::MLIRContext *":$context)
143    >,
144    InterfaceMethod<
145      /*description=*/"Returns the program memory space identifier.",
146      /*retTy=*/"::mlir::StringAttr",
147      /*methodName=*/"getProgramMemorySpaceIdentifier",
148      /*args=*/(ins "::mlir::MLIRContext *":$context)
149    >,
150    InterfaceMethod<
151      /*description=*/"Returns the global memory space identifier.",
152      /*retTy=*/"::mlir::StringAttr",
153      /*methodName=*/"getGlobalMemorySpaceIdentifier",
154      /*args=*/(ins "::mlir::MLIRContext *":$context)
155    >,
156    InterfaceMethod<
157      /*description=*/"Returns the stack alignment identifier.",
158      /*retTy=*/"::mlir::StringAttr",
159      /*methodName=*/"getStackAlignmentIdentifier",
160      /*args=*/(ins "::mlir::MLIRContext *":$context)
161    >,
162    // Implementations may override this if they have an efficient lookup
163    // mechanism.
164    InterfaceMethod<
165      /*description=*/"Returns a copy of the entries related to a specific "
166                      "type class regardles of type parameters. ",
167      /*retTy=*/"::mlir::DataLayoutEntryList",
168      /*methodName=*/"getSpecForType",
169      /*args=*/(ins "::mlir::TypeID":$type),
170      /*methodBody=*/"",
171      /*defaultImplementation=*/[{
172        return ::mlir::detail::filterEntriesForType($_attr.getEntries(), type);
173      }]
174    >,
175    // Implementations may override this if they have an efficient lookup
176    // mechanism.
177    InterfaceMethod<
178      /*description=*/"Returns the entry related to the given identifier, if "
179                      "present.",
180      /*retTy=*/"::mlir::DataLayoutEntryInterface",
181      /*methodName=*/"getSpecForIdentifier",
182      /*args=*/(ins "::mlir::StringAttr":$identifier),
183      /*methodBody=*/"",
184      /*defaultImplementation=*/[{
185        return ::mlir::detail::filterEntryForIdentifier($_attr.getEntries(),
186                                                        identifier);
187      }]
188    >,
189    InterfaceMethod<
190      /*description=*/"Verifies the validity of the specification and reports "
191                      "any errors at the given location.",
192      /*retTy=*/"::llvm::LogicalResult",
193      /*methodName=*/"verifySpec",
194      /*args=*/(ins "::mlir::Location":$loc),
195      /*methodBody=*/"",
196      /*defaultImplementation=*/[{
197        return ::mlir::detail::verifyDataLayoutSpec($_attr, loc);
198      }]
199    >
200  ];
201
202  let extraClassDeclaration = [{
203    /// Returns a copy of the entries related to the type specified as template
204    /// parameter.
205    template <typename Ty>
206    DataLayoutEntryList getSpecForType() {
207      return getSpecForType(TypeID::get<Ty>());
208    }
209
210    /// Helper for default implementation of `DLTIQueryInterface`'s `query`.
211    inline ::mlir::FailureOr<::mlir::Attribute>
212    queryHelper(::mlir::DataLayoutEntryKey key) const {
213      for (DataLayoutEntryInterface entry : getEntries())
214        if (entry.getKey() == key)
215            return entry.getValue();
216      return ::mlir::failure();
217    }
218
219    /// Populates the given maps with lists of entries grouped by the type or
220    /// identifier they are associated with. Users are not expected to call this
221    /// method directly.
222    void bucketEntriesByType(
223        ::llvm::DenseMap<::mlir::TypeID, ::mlir::DataLayoutEntryList> &types,
224        ::llvm::DenseMap<::mlir::StringAttr,
225                         ::mlir::DataLayoutEntryInterface> &ids);
226  }];
227}
228
229def TargetDeviceSpecInterface : AttrInterface<"TargetDeviceSpecInterface", [DLTIQueryInterface]> {
230  let cppNamespace = "::mlir";
231
232  let description = [{
233    Attribute interface describing a target device description specification.
234
235    A target device description specification is a list of device properties (key)
236    and their values for a specific device. The device is identified using "device_id"
237    (as a key and ui32 value) and "device_type" key which must have a string value.
238    Both "device_id" and "device_type" are mandatory keys. As an example, L1 cache
239    size could be a device property, and its value would be a device specific size.
240
241    A target device description specification is attached to a module as a module level
242    attribute.
243  }];
244
245  let methods = [
246    InterfaceMethod<
247      /*description=*/"Returns the list of layout entries.",
248      /*retTy=*/"::mlir::DataLayoutEntryListRef",
249      /*methodName=*/"getEntries",
250      /*args=*/(ins)
251    >,
252    InterfaceMethod<
253      /*description=*/"Returns the entry related to the given identifier, if "
254                      "present.",
255      /*retTy=*/"::mlir::DataLayoutEntryInterface",
256      /*methodName=*/"getSpecForIdentifier",
257      /*args=*/(ins "::mlir::StringAttr":$identifier),
258      /*methodBody=*/"",
259      /*defaultImplementation=*/[{
260        return ::mlir::detail::filterEntryForIdentifier($_attr.getEntries(),
261                                                        identifier);
262      }]
263    >,
264    InterfaceMethod<
265      /*description=*/"Checks that the entry is well-formed, reports errors "
266                      "at the provided location.",
267      /*retTy=*/"::llvm::LogicalResult",
268      /*methodName=*/"verifyEntry",
269      /*args=*/(ins "::mlir::Location":$loc),
270      /*methodBody=*/"",
271      /*defaultImplementation=*/[{ return ::mlir::success(); }]
272    >
273  ];
274
275  let extraClassDeclaration = [{
276    /// Helper for default implementation of `DLTIQueryInterface`'s `query`.
277    ::mlir::FailureOr<::mlir::Attribute>
278    queryHelper(::mlir::DataLayoutEntryKey key) const {
279      if (auto strKey = ::llvm::dyn_cast<StringAttr>(key))
280        if (DataLayoutEntryInterface spec = getSpecForIdentifier(strKey))
281          return spec.getValue();
282      return ::mlir::failure();
283    }
284  }];
285}
286
287def TargetSystemSpecInterface : AttrInterface<"TargetSystemSpecInterface", [DLTIQueryInterface]> {
288  let cppNamespace = "::mlir";
289
290  let description = [{
291    Attribute interface describing a target system description specification.
292
293    A target system description specification is a list of target device
294    specifications, with one device specification for a device in the system. As
295    such, a target system description specification allows specifying a heterogenous
296    system, with devices of different types (e.g., CPU, GPU, etc.)
297
298    The only requirement on a valid target system description specification is that
299    the "device_id" in every target device description specification needs to be
300    unique. This is because, ultimately, this "device_id" is used by the user to
301    query a value of a device property.
302  }];
303
304  let methods = [
305    InterfaceMethod<
306      /*description=*/"Returns the list of layout entries.",
307      /*retTy=*/"::llvm::ArrayRef<DataLayoutEntryInterface>",
308      /*methodName=*/"getEntries",
309      /*args=*/(ins)
310    >,
311    InterfaceMethod<
312      /*description=*/"Returns the device description spec for given device "
313                      "ID",
314      /*retTy=*/"std::optional<::mlir::TargetDeviceSpecInterface>",
315      /*methodName=*/"getDeviceSpecForDeviceID",
316      /*args=*/(ins "StringAttr":$deviceID)
317    >,
318    InterfaceMethod<
319      /*description=*/"Verifies the validity of the specification and "
320                      "reports any errors at the given location.",
321      /*retTy=*/"::llvm::LogicalResult",
322      /*methodName=*/"verifySpec",
323      /*args=*/(ins "::mlir::Location":$loc),
324      /*methodBody=*/"",
325      /*defaultImplementation=*/[{
326        return ::mlir::detail::verifyTargetSystemSpec($_attr, loc);
327      }]
328    >
329  ];
330
331  let extraClassDeclaration = [{
332    using DeviceID = StringAttr;
333
334    /// Helper for default implementation of `DLTIQueryInterface`'s `query`.
335    ::mlir::FailureOr<::mlir::Attribute>
336    queryHelper(::mlir::DataLayoutEntryKey key) const {
337      if (auto strKey = ::llvm::dyn_cast<::mlir::StringAttr>(key))
338        if (auto deviceSpec = getDeviceSpecForDeviceID(strKey))
339          return *deviceSpec;
340      return ::mlir::failure();
341    }
342  }];
343}
344
345//===----------------------------------------------------------------------===//
346// Operation interface
347//===----------------------------------------------------------------------===//
348
349def DataLayoutOpInterface : OpInterface<"DataLayoutOpInterface"> {
350  let cppNamespace = "::mlir";
351
352  let description = [{
353    Interface for operations that can have a data layout specification attached.
354
355    The `DataLayout` object, which can be used for data layout queries, can be
356    constructed for such operations. The absence of a data layout specification
357    must be handled without failing.
358
359    Concrete operations must implement the hook returning the data layout
360    specification. They may optionally override the methods used in data layout
361    queries, default implementations of which provide predefined answers for
362    built-in types and dispatch to the type interface for all other types. These
363    methods must be idempotent, that is return the same result on repeated
364    queries with the same parameters. They are declared static and therefore
365    have no access to the operation or its attributes. Instead, they receive a
366    list of data layout entries relevant to the request. The entries are known
367    to have passed the spec and entry verifier.
368  }];
369
370  let methods = [
371    InterfaceMethod<
372      /*description=*/"Returns the data layout specification for this op, or "
373                      "null if it does not exist.",
374      /*retTy=*/"::mlir::DataLayoutSpecInterface",
375      /*methodName=*/"getDataLayoutSpec",
376      /*args=*/(ins)
377    >,
378    InterfaceMethod<
379      /*description=*/"Returns the target system desc specification for this "
380                      "op, or null if it does not exist.",
381      /*retTy=*/"::mlir::TargetSystemSpecInterface",
382      /*methodName=*/"getTargetSystemSpec",
383      /*args=*/(ins)
384    >,
385    StaticInterfaceMethod<
386      /*description=*/"Returns the size of the given type computed using the "
387                      "relevant entries. The data layout object can be used "
388                      "for recursive queries.",
389      /*retTy=*/"::llvm::TypeSize",
390      /*methodName=*/"getTypeSize",
391      /*args=*/(ins "::mlir::Type":$type,
392                    "const ::mlir::DataLayout &":$dataLayout,
393                    "::mlir::DataLayoutEntryListRef":$params),
394      /*methodBody=*/"",
395      /*defaultImplementation=*/[{
396        ::llvm::TypeSize bits = ConcreteOp::getTypeSizeInBits(type, dataLayout, params);
397        return ::mlir::detail::divideCeil(bits, 8u);
398      }]
399    >,
400    StaticInterfaceMethod<
401      /*description=*/"Returns the size of the given type in bits computed "
402                      "using the relevant entries. The data layout object can "
403                      "be used for recursive queries.",
404      /*retTy=*/"::llvm::TypeSize",
405      /*methodName=*/"getTypeSizeInBits",
406      /*args=*/(ins "::mlir::Type":$type,
407                    "const ::mlir::DataLayout &":$dataLayout,
408                    "::mlir::DataLayoutEntryListRef":$params),
409      /*methodBody=*/"",
410      /*defaultImplementation=*/[{
411        return ::mlir::detail::getDefaultTypeSizeInBits(type, dataLayout,
412                                                        params);
413      }]
414    >,
415    StaticInterfaceMethod<
416      /*description=*/"Returns the alignment required by the ABI for the given "
417                      "type computed using the relevant entries. The data "
418                      "layout object can be used for recursive queries.",
419      /*retTy=*/"uint64_t",
420      /*methodName=*/"getTypeABIAlignment",
421      /*args=*/(ins "::mlir::Type":$type,
422                    "const ::mlir::DataLayout &":$dataLayout,
423                    "::mlir::DataLayoutEntryListRef":$params),
424      /*methodBody=*/"",
425      /*defaultImplementation=*/[{
426        return ::mlir::detail::getDefaultABIAlignment(type, dataLayout, params);
427      }]
428    >,
429    StaticInterfaceMethod<
430      /*description=*/"Returns the alignment preferred by the given type "
431                      "computed using the relevant entries. The data layout"
432                      "object can be used for recursive queries.",
433      /*retTy=*/"uint64_t",
434      /*methodName=*/"getTypePreferredAlignment",
435      /*args=*/(ins "::mlir::Type":$type,
436                    "const ::mlir::DataLayout &":$dataLayout,
437                    "::mlir::DataLayoutEntryListRef":$params),
438      /*methodBody=*/"",
439      /*defaultImplementation=*/[{
440        return ::mlir::detail::getDefaultPreferredAlignment(type, dataLayout,
441                                                            params);
442      }]
443    >,
444    StaticInterfaceMethod<
445      /*description=*/"Returns the bitwidth that should be used when "
446                      "performing index computations for the type computed "
447                      "using the relevant entries. The data layout object can "
448                      "be used for recursive queries.",
449      /*retTy=*/"std::optional<uint64_t>",
450      /*methodName=*/"getIndexBitwidth",
451      /*args=*/(ins "::mlir::Type":$type,
452                    "const ::mlir::DataLayout &":$dataLayout,
453                    "::mlir::DataLayoutEntryListRef":$params),
454      /*methodBody=*/"",
455      /*defaultImplementation=*/[{
456        return ::mlir::detail::getDefaultIndexBitwidth(type, dataLayout,
457                                                       params);
458      }]
459    >,
460    StaticInterfaceMethod<
461      /*description=*/"Returns the endianness used by the ABI computed "
462                      "using the relevant entries. The data layout object "
463                      "can be used for recursive queries.",
464      /*retTy=*/"::mlir::Attribute",
465      /*methodName=*/"getEndianness",
466      /*args=*/(ins "::mlir::DataLayoutEntryInterface":$entry),
467      /*methodBody=*/"",
468      /*defaultImplementation=*/[{
469        return ::mlir::detail::getDefaultEndianness(entry);
470      }]
471    >,
472    StaticInterfaceMethod<
473      /*description=*/"Returns the memory space used by the ABI computed "
474                      "using the relevant entries. The data layout object "
475                      "can be used for recursive queries.",
476      /*retTy=*/"::mlir::Attribute",
477      /*methodName=*/"getAllocaMemorySpace",
478      /*args=*/(ins "::mlir::DataLayoutEntryInterface":$entry),
479      /*methodBody=*/"",
480      /*defaultImplementation=*/[{
481        return ::mlir::detail::getDefaultAllocaMemorySpace(entry);
482      }]
483    >,
484    StaticInterfaceMethod<
485      /*description=*/"Returns the memory space used by the ABI computed "
486                      "using the relevant entries. The data layout object "
487                      "can be used for recursive queries.",
488      /*retTy=*/"::mlir::Attribute",
489      /*methodName=*/"getProgramMemorySpace",
490      /*args=*/(ins "::mlir::DataLayoutEntryInterface":$entry),
491      /*methodBody=*/"",
492      /*defaultImplementation=*/[{
493        return ::mlir::detail::getDefaultProgramMemorySpace(entry);
494      }]
495    >,
496    StaticInterfaceMethod<
497      /*description=*/"Returns the memory space used by the ABI computed "
498                      "using the relevant entries. The data layout object "
499                      "can be used for recursive queries.",
500      /*retTy=*/"::mlir::Attribute",
501      /*methodName=*/"getGlobalMemorySpace",
502      /*args=*/(ins "::mlir::DataLayoutEntryInterface":$entry),
503      /*methodBody=*/"",
504      /*defaultImplementation=*/[{
505        return ::mlir::detail::getDefaultGlobalMemorySpace(entry);
506      }]
507    >,
508    StaticInterfaceMethod<
509      /*description=*/"Returns the natural stack alignment in bits computed "
510                      "using the relevant entries. The data layout object "
511                      "can be used for recursive queries.",
512      /*retTy=*/"uint64_t",
513      /*methodName=*/"getStackAlignment",
514      /*args=*/(ins "::mlir::DataLayoutEntryInterface":$entry),
515      /*methodBody=*/"",
516      /*defaultImplementation=*/[{
517        return ::mlir::detail::getDefaultStackAlignment(entry);
518      }]
519    >,
520    StaticInterfaceMethod<
521      /*description=*/"Returns the value of the property, if the property is "
522                      "defined. Otherwise, it returns std::nullopt.",
523      /*retTy=*/"std::optional<Attribute>",
524      /*methodName=*/"getDevicePropertyValue",
525      /*args=*/(ins "::mlir::DataLayoutEntryInterface":$entry),
526      /*methodBody=*/"",
527      /*defaultImplementation=*/[{
528        return ::mlir::detail::getDevicePropertyValue(entry);
529      }]
530    >
531  ];
532
533  let verify = [{ return ::mlir::detail::verifyDataLayoutOp($_op); }];
534}
535
536//===----------------------------------------------------------------------===//
537// Type interface
538//===----------------------------------------------------------------------===//
539
540def DataLayoutTypeInterface : TypeInterface<"DataLayoutTypeInterface"> {
541  let cppNamespace = "::mlir";
542
543  let description = [{
544    Interface for types subject to data layout.
545
546    Types willing to be supported by the data layout subsystem should implement
547    this interface by providing implementations of functions querying their
548    size, required and preferred alignment. Each of these functions accepts as
549    arguments a data layout object that can be used to perform recursive queries
550    in the same scope, and a list of data layout entries relevant to this type.
551    Specifically, the entries are those that have as key _any instance_ of the
552    same type class as the current type. For example, if IntegerType had
553    implemented this interface, it would have received the entries with keys i1,
554    i2, i8, etc. regardless of the bitwidth of this type. This mechanism allows
555    types to "interpolate" the results in a type-specific way instead of listing
556    all possible types in the specification.
557
558    The list of entries may be empty, in which case the type must provide a
559    reasonable default value. The entries in the list are known to have passed
560    the spec and the entry verifiers, as well as the type-specified verifier if
561    provided.
562
563    In case of nested layout specs or spec changes, the type can override a hook
564    indicating whether the outer (old) and the inner (new) spec are compatible.
565  }];
566
567  let methods = [
568    InterfaceMethod<
569      /*description=*/"Returns the size of this type in bytes.",
570      /*retTy=*/"::llvm::TypeSize",
571      /*methodName=*/"getTypeSize",
572      /*args=*/(ins "const ::mlir::DataLayout &":$dataLayout,
573                    "::mlir::DataLayoutEntryListRef":$params),
574      /*methodBody=*/"",
575      /*defaultImplementation=*/[{
576        ::llvm::TypeSize bits = $_type.getTypeSizeInBits(dataLayout, params);
577        return ::mlir::detail::divideCeil(bits, 8u);
578      }]
579    >,
580    InterfaceMethod<
581      /*description=*/"Returns the size of this type in bits.",
582      /*retTy=*/"::llvm::TypeSize",
583      /*methodName=*/"getTypeSizeInBits",
584      /*args=*/(ins "const ::mlir::DataLayout &":$dataLayout,
585                    "::mlir::DataLayoutEntryListRef":$params)
586    >,
587    InterfaceMethod<
588      /*description=*/"Returns the ABI-required alignment for this type, "
589                      "in bytes",
590      /*retTy=*/"uint64_t",
591      /*methodName=*/"getABIAlignment",
592      /*args=*/(ins "const ::mlir::DataLayout &":$dataLayout,
593                    "::mlir::DataLayoutEntryListRef":$params)
594    >,
595    InterfaceMethod<
596      /*description=*/"Returns the preferred alignment for this type, "
597                      "in bytes.",
598      /*retTy=*/"uint64_t",
599      /*methodName=*/"getPreferredAlignment",
600      /*args=*/(ins "const ::mlir::DataLayout &":$dataLayout,
601                    "::mlir::DataLayoutEntryListRef":$params)
602    >,
603    InterfaceMethod<
604      /*description=*/"Returns the bitwidth that should be used when "
605                      "performing index computations for the given "
606                      "pointer-like type. If the type is not a pointer-like "
607                      "type, returns std::nullopt.",
608      /*retTy=*/"std::optional<uint64_t>",
609      /*methodName=*/"getIndexBitwidth",
610      /*args=*/(ins "const ::mlir::DataLayout &":$dataLayout,
611                    "::mlir::DataLayoutEntryListRef":$params),
612      /*methodBody=*/"",
613      /*defaultImplementation=*/[{ return std::nullopt; }]
614    >,
615    InterfaceMethod<
616      /*desc=*/"Returns true if the two lists of entries are compatible, that "
617               "is, that `newLayout` spec entries can be nested in an op with "
618               "`oldLayout` spec entries.",
619      /*retTy=*/"bool",
620      /*methodName=*/"areCompatible",
621      /*args=*/(ins "::mlir::DataLayoutEntryListRef":$oldLayout,
622                    "::mlir::DataLayoutEntryListRef":$newLayout),
623      /*methodBody=*/"",
624      /*defaultImplementation=*/[{ return true; }]
625    >,
626    InterfaceMethod<
627      /*description=*/"Verifies that the given list of entries is valid for "
628                      "this type.",
629      /*retTy=*/"::llvm::LogicalResult",
630      /*methodName=*/"verifyEntries",
631      /*args=*/(ins "::mlir::DataLayoutEntryListRef":$entries,
632                    "::mlir::Location":$loc),
633      /*methodBody=*/"",
634      /*defaultImplementation=*/[{ return ::mlir::success(); }]
635    >,
636  ];
637}
638
639#endif // MLIR_DATALAYOUTINTERFACES
640