1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Dialect Declarations *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: TestOps.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10namespace test {
11
12
13class TestDialect : public ::mlir::ExtensibleDialect {
14 explicit TestDialect(::mlir::MLIRContext *context);
15
16 void initialize();
17 friend class ::mlir::MLIRContext;
18public:
19 ~TestDialect() override;
20 static constexpr ::llvm::StringLiteral getDialectNamespace() {
21 return ::llvm::StringLiteral("test");
22 }
23
24 /// Parse an attribute registered to this dialect.
25 ::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser,
26 ::mlir::Type type) const override;
27
28 /// Print an attribute registered to this dialect.
29 void printAttribute(::mlir::Attribute attr,
30 ::mlir::DialectAsmPrinter &os) const override;
31
32 /// Register canonicalization patterns.
33 void getCanonicalizationPatterns(
34 ::mlir::RewritePatternSet &results) const override;
35
36 /// Materialize a single constant operation from a given attribute value with
37 /// the desired resultant type.
38 ::mlir::Operation *materializeConstant(::mlir::OpBuilder &builder,
39 ::mlir::Attribute value,
40 ::mlir::Type type,
41 ::mlir::Location loc) override;
42
43 /// Provides a hook for verifying dialect attributes attached to the given
44 /// op.
45 ::llvm::LogicalResult verifyOperationAttribute(
46 ::mlir::Operation *op, ::mlir::NamedAttribute attribute) override;
47
48 /// Provides a hook for verifying dialect attributes attached to the given
49 /// op's region argument.
50 ::llvm::LogicalResult verifyRegionArgAttribute(
51 ::mlir::Operation *op, unsigned regionIndex, unsigned argIndex,
52 ::mlir::NamedAttribute attribute) override;
53
54 /// Provides a hook for verifying dialect attributes attached to the given
55 /// op's region result.
56 ::llvm::LogicalResult verifyRegionResultAttribute(
57 ::mlir::Operation *op, unsigned regionIndex, unsigned resultIndex,
58 ::mlir::NamedAttribute attribute) override;
59
60 /// Provides a hook for op interface.
61 void *getRegisteredInterfaceForOp(mlir::TypeID interfaceID,
62 mlir::OperationName opName) override;
63
64 /// Helper to manage the discardable attribute `discardable_attr_key`.
65 class DiscardableAttrKeyAttrHelper {
66 ::mlir::StringAttr name;
67 public:
68 static constexpr ::llvm::StringLiteral getNameStr() {
69 return "test.discardable_attr_key";
70 }
71 constexpr ::mlir::StringAttr getName() {
72 return name;
73 }
74
75 DiscardableAttrKeyAttrHelper(::mlir::MLIRContext *ctx)
76 : name(::mlir::StringAttr::get(context: ctx, bytes: getNameStr())) {}
77
78 mlir::IntegerAttr getAttr(::mlir::Operation *op) {
79 return op->getAttrOfType<mlir::IntegerAttr>(name);
80 }
81 void setAttr(::mlir::Operation *op, mlir::IntegerAttr val) {
82 op->setAttr(name, value: val);
83 }
84 bool isAttrPresent(::mlir::Operation *op) {
85 return op->hasAttrOfType<mlir::IntegerAttr>(name);
86 }
87 void removeAttr(::mlir::Operation *op) {
88 assert(op->hasAttrOfType<mlir::IntegerAttr>(name));
89 op->removeAttr(name);
90 }
91 };
92 DiscardableAttrKeyAttrHelper getDiscardableAttrKeyAttrHelper() {
93 return discardableAttrKeyAttrName;
94 }
95 private:
96 DiscardableAttrKeyAttrHelper discardableAttrKeyAttrName;
97 public:
98
99 /// Helper to manage the discardable attribute `other_discardable_attr_key`.
100 class OtherDiscardableAttrKeyAttrHelper {
101 ::mlir::StringAttr name;
102 public:
103 static constexpr ::llvm::StringLiteral getNameStr() {
104 return "test.other_discardable_attr_key";
105 }
106 constexpr ::mlir::StringAttr getName() {
107 return name;
108 }
109
110 OtherDiscardableAttrKeyAttrHelper(::mlir::MLIRContext *ctx)
111 : name(::mlir::StringAttr::get(context: ctx, bytes: getNameStr())) {}
112
113 SimpleAAttr getAttr(::mlir::Operation *op) {
114 return op->getAttrOfType<SimpleAAttr>(name);
115 }
116 void setAttr(::mlir::Operation *op, SimpleAAttr val) {
117 op->setAttr(name, value: val);
118 }
119 bool isAttrPresent(::mlir::Operation *op) {
120 return op->hasAttrOfType<SimpleAAttr>(name);
121 }
122 void removeAttr(::mlir::Operation *op) {
123 assert(op->hasAttrOfType<SimpleAAttr>(name));
124 op->removeAttr(name);
125 }
126 };
127 OtherDiscardableAttrKeyAttrHelper getOtherDiscardableAttrKeyAttrHelper() {
128 return otherDiscardableAttrKeyAttrName;
129 }
130 private:
131 OtherDiscardableAttrKeyAttrHelper otherDiscardableAttrKeyAttrName;
132 public:
133
134 void registerAttributes();
135 void registerInterfaces();
136 void registerTypes();
137 void registerOpsSyntax();
138
139 // Provides a custom printing/parsing for some operations.
140 ::std::optional<ParseOpHook>
141 getParseOperationHook(::llvm::StringRef opName) const override;
142 ::llvm::unique_function<void(::mlir::Operation *,
143 ::mlir::OpAsmPrinter &printer)>
144 getOperationPrinter(::mlir::Operation *op) const override;
145
146 ::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override;
147 void printType(::mlir::Type type,
148 ::mlir::DialectAsmPrinter &printer) const override;
149
150 private:
151 // Storage for a custom fallback interface.
152 void *fallbackEffectOpInterfaces;
153 };
154} // namespace test
155MLIR_DECLARE_EXPLICIT_TYPE_ID(::test::TestDialect)
156

source code of llvm_build/tools/mlir/test/lib/Dialect/Test/TestOpsDialect.h.inc