MLIR  16.0.0git
DLTI.h
Go to the documentation of this file.
1 //===- DLTI.h - Data Layout and Target Info MLIR Dialect --------*- C++ -*-===//
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 dialect containing the objects pertaining to target information.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_DLTI_DLTI_H
14 #define MLIR_DIALECT_DLTI_DLTI_H
15 
16 #include "mlir/IR/Attributes.h"
17 #include "mlir/IR/Dialect.h"
19 
20 namespace mlir {
21 namespace impl {
24 } // namespace impl
25 
26 //===----------------------------------------------------------------------===//
27 // DataLayoutEntryAttr
28 //===----------------------------------------------------------------------===//
29 
30 /// A data layout entry attribute is a key-value pair where the key is a type or
31 /// an identifier and the value is another attribute. These entries form a data
32 /// layout specification.
34  : public Attribute::AttrBase<DataLayoutEntryAttr, Attribute,
35  impl::DataLayoutEntryStorage,
36  DataLayoutEntryInterface::Trait> {
37 public:
38  using Base::Base;
39 
40  /// The keyword used for this attribute in custom syntax.
41  constexpr const static llvm::StringLiteral kAttrKeyword = "dl_entry";
42 
43  /// Returns the entry with the given key and value.
44  static DataLayoutEntryAttr get(StringAttr key, Attribute value);
45  static DataLayoutEntryAttr get(Type key, Attribute value);
46 
47  /// Returns the key of this entry.
48  DataLayoutEntryKey getKey() const;
49 
50  /// Returns the value of this entry.
51  Attribute getValue() const;
52 
53  /// Parses an instance of this attribute.
54  static DataLayoutEntryAttr parse(AsmParser &parser);
55 
56  /// Prints this attribute.
57  void print(AsmPrinter &os) const;
58 };
59 
60 //===----------------------------------------------------------------------===//
61 // DataLayoutSpecAttr
62 //===----------------------------------------------------------------------===//
63 
64 /// A data layout specification is a list of entries that specify (partial) data
65 /// layout information. It is expected to be attached to operations that serve
66 /// as scopes for data layout requests.
68  : public Attribute::AttrBase<DataLayoutSpecAttr, Attribute,
69  impl::DataLayoutSpecStorage,
70  DataLayoutSpecInterface::Trait> {
71 public:
72  using Base::Base;
73 
74  /// The keyword used for this attribute in custom syntax.
75  constexpr const static StringLiteral kAttrKeyword = "dl_spec";
76 
77  /// Returns the specification containing the given list of keys.
78  static DataLayoutSpecAttr get(MLIRContext *ctx,
80 
81  /// Returns the specification containing the given list of keys. If the list
82  /// contains duplicate keys or is otherwise invalid, reports errors using the
83  /// given callback and returns null.
84  static DataLayoutSpecAttr
85  getChecked(function_ref<InFlightDiagnostic()> emitError, MLIRContext *context,
87 
88  /// Checks that the given list of entries does not contain duplicate keys.
91 
92  /// Combines this specification with `specs`, enclosing specifications listed
93  /// from outermost to innermost. This overwrites the older entries with the
94  /// same key as the newer entries if the entries are compatible. Returns null
95  /// if the specifications are not compatible.
97 
98  /// Returns the list of entries.
99  DataLayoutEntryListRef getEntries() const;
100 
101  /// Parses an instance of this attribute.
102  static DataLayoutSpecAttr parse(AsmParser &parser);
103 
104  /// Prints this attribute.
105  void print(AsmPrinter &os) const;
106 };
107 
108 } // namespace mlir
109 
110 #include "mlir/Dialect/DLTI/DLTIDialect.h.inc"
111 
112 #endif // MLIR_DIALECT_DLTI_DLTI_H
Include the generated interface declarations.
A data layout entry attribute is a key-value pair where the key is a type or an identifier and the va...
Definition: DLTI.h:33
This class represents a diagnostic that is inflight and set to be reported.
Definition: Diagnostics.h:310
static constexpr const bool value
A data layout specification is a list of entries that specify (partial) data layout information...
Definition: DLTI.h:67
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26
Attributes are known-constant values of operations.
Definition: Attributes.h:24
static void print(spirv::VerCapExtAttr triple, DialectAsmPrinter &printer)
This base class exposes generic asm parser hooks, usable across the various derived parsers...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:72
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
Utility class for implementing users of storage classes uniqued by a StorageUniquer.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition: MLIRContext.h:55
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs, on this operation and any nested operations.
Definition: Verifier.cpp:372
This base class exposes generic asm printer hooks, usable across the various derived printers...