1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Interface Declarations *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9namespace mlir {
10class TestExternalOpInterface;
11namespace detail {
12struct TestExternalOpInterfaceInterfaceTraits {
13 struct Concept {
14 /// The methods defined by the interface.
15 unsigned (*getNameLengthPlusArg)(const Concept *impl, ::mlir::Operation *, unsigned);
16 unsigned (*getNameLengthPlusArgTwice)(unsigned);
17 unsigned (*getNameLengthTimesArg)(const Concept *impl, ::mlir::Operation *, unsigned);
18 unsigned (*getNameLengthMinusArg)(unsigned);
19 };
20 template<typename ConcreteOp>
21 class Model : public Concept {
22 public:
23 using Interface = ::mlir::TestExternalOpInterface;
24 Model() : Concept{.getNameLengthPlusArg: getNameLengthPlusArg, .getNameLengthPlusArgTwice: getNameLengthPlusArgTwice, .getNameLengthTimesArg: getNameLengthTimesArg, .getNameLengthMinusArg: getNameLengthMinusArg} {}
25
26 static inline unsigned getNameLengthPlusArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg);
27 static inline unsigned getNameLengthPlusArgTwice(unsigned arg);
28 static inline unsigned getNameLengthTimesArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg);
29 static inline unsigned getNameLengthMinusArg(unsigned arg);
30 };
31 template<typename ConcreteOp>
32 class FallbackModel : public Concept {
33 public:
34 using Interface = ::mlir::TestExternalOpInterface;
35 FallbackModel() : Concept{.getNameLengthPlusArg: getNameLengthPlusArg, .getNameLengthPlusArgTwice: getNameLengthPlusArgTwice, .getNameLengthTimesArg: getNameLengthTimesArg, .getNameLengthMinusArg: getNameLengthMinusArg} {}
36
37 static inline unsigned getNameLengthPlusArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg);
38 static inline unsigned getNameLengthPlusArgTwice(unsigned arg);
39 static inline unsigned getNameLengthTimesArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg);
40 static inline unsigned getNameLengthMinusArg(unsigned arg);
41 };
42 template<typename ConcreteModel, typename ConcreteOp>
43 class ExternalModel : public FallbackModel<ConcreteModel> {
44 public:
45 using ConcreteEntity = ConcreteOp;
46 unsigned getNameLengthTimesArg(::mlir::Operation *tablegen_opaque_val, unsigned arg) const;
47 static unsigned getNameLengthMinusArg(unsigned arg);
48 };
49};
50template <typename ConcreteOp>
51struct TestExternalOpInterfaceTrait;
52
53} // namespace detail
54class TestExternalOpInterface : public ::mlir::OpInterface<TestExternalOpInterface, detail::TestExternalOpInterfaceInterfaceTraits> {
55public:
56 using ::mlir::OpInterface<TestExternalOpInterface, detail::TestExternalOpInterfaceInterfaceTraits>::OpInterface;
57 template <typename ConcreteOp>
58 struct Trait : public detail::TestExternalOpInterfaceTrait<ConcreteOp> {};
59
60 /// Returns the length of the operation name plus arg.
61 unsigned getNameLengthPlusArg(unsigned arg);
62
63 /// Returns the length of the operation name plus arg twice.
64 unsigned getNameLengthPlusArgTwice(unsigned arg);
65
66 /// Returns the length of the product of the operation name and arg.
67 unsigned getNameLengthTimesArg(unsigned arg);
68
69 /// Returns the length of the operation name minus arg.
70 unsigned getNameLengthMinusArg(unsigned arg);
71};
72namespace detail {
73 template <typename ConcreteOp>
74 struct TestExternalOpInterfaceTrait : public ::mlir::OpInterface<TestExternalOpInterface, detail::TestExternalOpInterfaceInterfaceTraits>::Trait<ConcreteOp> {
75
76 /// Returns the length of the product of the operation name and arg.
77 unsigned getNameLengthTimesArg(unsigned arg) {
78 return arg * (*static_cast<ConcreteOp *>(this))->getName().getStringRef().size();
79 }
80
81 /// Returns the length of the operation name minus arg.
82 static unsigned getNameLengthMinusArg(unsigned arg) {
83 return ConcreteOp::getOperationName().size() - arg;
84 }
85 };
86}// namespace detail
87} // namespace mlir
88namespace mlir {
89class TestEffectOpInterface;
90namespace detail {
91struct TestEffectOpInterfaceInterfaceTraits {
92 struct Concept {
93 /// The methods defined by the interface.
94 void (*getEffects)(const Concept *impl, ::mlir::Operation *, ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::TestEffects::Effect>> &);
95 };
96 template<typename ConcreteOp>
97 class Model : public Concept {
98 public:
99 using Interface = ::mlir::TestEffectOpInterface;
100 Model() : Concept{.getEffects: getEffects} {}
101
102 static inline void getEffects(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::TestEffects::Effect>> & effects);
103 };
104 template<typename ConcreteOp>
105 class FallbackModel : public Concept {
106 public:
107 using Interface = ::mlir::TestEffectOpInterface;
108 FallbackModel() : Concept{.getEffects: getEffects} {}
109
110 static inline void getEffects(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::TestEffects::Effect>> & effects);
111 };
112 template<typename ConcreteModel, typename ConcreteOp>
113 class ExternalModel : public FallbackModel<ConcreteModel> {
114 public:
115 using ConcreteEntity = ConcreteOp;
116 };
117};
118template <typename ConcreteOp>
119struct TestEffectOpInterfaceTrait;
120
121} // namespace detail
122class TestEffectOpInterface : public ::mlir::OpInterface<TestEffectOpInterface, detail::TestEffectOpInterfaceInterfaceTraits> {
123public:
124 using ::mlir::OpInterface<TestEffectOpInterface, detail::TestEffectOpInterfaceInterfaceTraits>::OpInterface;
125 template <typename ConcreteOp>
126 struct Trait : public detail::TestEffectOpInterfaceTrait<ConcreteOp> {};
127
128 /// Collects all of the operation's effects into `effects`.
129 void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::TestEffects::Effect>> & effects);
130
131 /// Collect all of the effect instances that correspond to the given
132 /// `Effect` and place them in 'effects'.
133 template <typename Effect> void getEffects(
134 ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
135 ::mlir::TestEffects::Effect>> &effects) {
136 getEffects(effects);
137 ::llvm::erase_if(effects, [&](auto &it) {
138 return !::llvm::isa<Effect>(it.getEffect());
139 });
140 }
141
142 /// Returns true if this operation exhibits the given effect.
143 template <typename Effect> bool hasEffect() {
144 ::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
145 ::mlir::TestEffects::Effect>, 4> effects;
146 getEffects(effects);
147 return ::llvm::any_of(effects, [](const auto &it) {
148 return ::llvm::isa<Effect>(it.getEffect());
149 });
150 }
151
152 /// Returns true if this operation only has the given effect.
153 template <typename Effect> bool onlyHasEffect() {
154 ::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
155 ::mlir::TestEffects::Effect>, 4> effects;
156 getEffects(effects);
157 return !effects.empty() && ::llvm::all_of(effects, [](const auto &it) {
158 return ::llvm::isa<Effect>(it.getEffect());
159 });
160 }
161
162 /// Returns true if this operation has no effects.
163 bool hasNoEffect() {
164 ::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
165 ::mlir::TestEffects::Effect>, 4> effects;
166 getEffects(effects);
167 return effects.empty();
168 }
169
170 /// Collect all of the effect instances that operate on the provided value
171 /// and place them in 'effects'.
172 void getEffectsOnValue(::mlir::Value value,
173 ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
174 ::mlir::TestEffects::Effect>> & effects) {
175 getEffects(effects);
176 ::llvm::erase_if(C&: effects, P: [&](auto &it) { return it.getValue() != value; });
177 }
178
179 /// Return the effect of the given type `Effect` that is applied to the
180 /// given value, or std::nullopt if no effect exists.
181 template <typename Effect>
182 ::std::optional<::mlir::SideEffects::EffectInstance<::mlir::TestEffects::Effect>>
183 getEffectOnValue(::mlir::Value value) {
184 ::llvm::SmallVector<::mlir::SideEffects::EffectInstance<
185 ::mlir::TestEffects::Effect>, 4> effects;
186 getEffects(effects);
187 auto it = ::llvm::find_if(effects, [&](auto &it) {
188 return ::llvm::isa<Effect>(it.getEffect()) && it.getValue() == value;
189 });
190 if (it == effects.end())
191 return std::nullopt;
192 return *it;
193 }
194
195 /// Collect all of the effect instances that operate on the provided symbol
196 /// reference and place them in 'effects'.
197 void getEffectsOnSymbol(::mlir::SymbolRefAttr value,
198 ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
199 ::mlir::TestEffects::Effect>> & effects) {
200 getEffects(effects);
201 ::llvm::erase_if(C&: effects, P: [&](auto &it) {
202 return it.getSymbolRef() != value;
203 });
204 }
205
206 /// Collect all of the effect instances that operate on the provided
207 /// resource and place them in 'effects'.
208 void getEffectsOnResource(::mlir::SideEffects::Resource *resource,
209 ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<
210 ::mlir::TestEffects::Effect>> & effects) {
211 getEffects(effects);
212 ::llvm::erase_if(C&: effects, P: [&](auto &it) {
213 return it.getResource()->getResourceID() != resource->getResourceID();
214 });
215 }
216};
217namespace detail {
218 template <typename ConcreteOp>
219 struct TestEffectOpInterfaceTrait : public ::mlir::OpInterface<TestEffectOpInterface, detail::TestEffectOpInterfaceInterfaceTraits>::Trait<ConcreteOp> {
220 };
221}// namespace detail
222} // namespace mlir
223namespace mlir {
224class TestOptionallyImplementedOpInterface;
225namespace detail {
226struct TestOptionallyImplementedOpInterfaceInterfaceTraits {
227 struct Concept {
228 /// The methods defined by the interface.
229 bool (*getImplementsInterface)(const Concept *impl, ::mlir::Operation *);
230 };
231 template<typename ConcreteOp>
232 class Model : public Concept {
233 public:
234 using Interface = ::mlir::TestOptionallyImplementedOpInterface;
235 Model() : Concept{.getImplementsInterface: getImplementsInterface} {}
236
237 static inline bool getImplementsInterface(const Concept *impl, ::mlir::Operation *tablegen_opaque_val);
238 };
239 template<typename ConcreteOp>
240 class FallbackModel : public Concept {
241 public:
242 using Interface = ::mlir::TestOptionallyImplementedOpInterface;
243 FallbackModel() : Concept{.getImplementsInterface: getImplementsInterface} {}
244
245 static inline bool getImplementsInterface(const Concept *impl, ::mlir::Operation *tablegen_opaque_val);
246 };
247 template<typename ConcreteModel, typename ConcreteOp>
248 class ExternalModel : public FallbackModel<ConcreteModel> {
249 public:
250 using ConcreteEntity = ConcreteOp;
251 };
252};
253template <typename ConcreteOp>
254struct TestOptionallyImplementedOpInterfaceTrait;
255
256} // namespace detail
257class TestOptionallyImplementedOpInterface : public ::mlir::OpInterface<TestOptionallyImplementedOpInterface, detail::TestOptionallyImplementedOpInterfaceInterfaceTraits> {
258public:
259 using ::mlir::OpInterface<TestOptionallyImplementedOpInterface, detail::TestOptionallyImplementedOpInterfaceInterfaceTraits>::OpInterface;
260 template <typename ConcreteOp>
261 struct Trait : public detail::TestOptionallyImplementedOpInterfaceTrait<ConcreteOp> {};
262 bool getImplementsInterface();
263 static bool classof(::mlir::Operation * base) {
264 auto* interface = getInterfaceFor(op: base);
265 if (!interface)
266 return false;
267 TestOptionallyImplementedOpInterface odsInterfaceInstance(base, interface);
268 return odsInterfaceInstance.getImplementsInterface();
269 }
270};
271namespace detail {
272 template <typename ConcreteOp>
273 struct TestOptionallyImplementedOpInterfaceTrait : public ::mlir::OpInterface<TestOptionallyImplementedOpInterface, detail::TestOptionallyImplementedOpInterfaceInterfaceTraits>::Trait<ConcreteOp> {
274 };
275}// namespace detail
276} // namespace mlir
277namespace mlir {
278template<typename ConcreteOp>
279unsigned detail::TestExternalOpInterfaceInterfaceTraits::Model<ConcreteOp>::getNameLengthPlusArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg) {
280 return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getNameLengthPlusArg(arg);
281}
282template<typename ConcreteOp>
283unsigned detail::TestExternalOpInterfaceInterfaceTraits::Model<ConcreteOp>::getNameLengthPlusArgTwice(unsigned arg) {
284 return ConcreteOp::getNameLengthPlusArgTwice(arg);
285}
286template<typename ConcreteOp>
287unsigned detail::TestExternalOpInterfaceInterfaceTraits::Model<ConcreteOp>::getNameLengthTimesArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg) {
288 return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getNameLengthTimesArg(arg);
289}
290template<typename ConcreteOp>
291unsigned detail::TestExternalOpInterfaceInterfaceTraits::Model<ConcreteOp>::getNameLengthMinusArg(unsigned arg) {
292 return ConcreteOp::getNameLengthMinusArg(arg);
293}
294template<typename ConcreteOp>
295unsigned detail::TestExternalOpInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getNameLengthPlusArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg) {
296 return static_cast<const ConcreteOp *>(impl)->getNameLengthPlusArg(tablegen_opaque_val, arg);
297}
298template<typename ConcreteOp>
299unsigned detail::TestExternalOpInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getNameLengthPlusArgTwice(unsigned arg) {
300 return ConcreteOp::getNameLengthPlusArgTwice(arg);
301}
302template<typename ConcreteOp>
303unsigned detail::TestExternalOpInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getNameLengthTimesArg(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, unsigned arg) {
304 return static_cast<const ConcreteOp *>(impl)->getNameLengthTimesArg(tablegen_opaque_val, arg);
305}
306template<typename ConcreteOp>
307unsigned detail::TestExternalOpInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getNameLengthMinusArg(unsigned arg) {
308 return ConcreteOp::getNameLengthMinusArg(arg);
309}
310template<typename ConcreteModel, typename ConcreteOp>
311unsigned detail::TestExternalOpInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::getNameLengthTimesArg(::mlir::Operation *tablegen_opaque_val, unsigned arg) const {
312return arg * (llvm::cast<ConcreteOp>(tablegen_opaque_val))->getName().getStringRef().size();
313}
314template<typename ConcreteModel, typename ConcreteOp>
315unsigned detail::TestExternalOpInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::getNameLengthMinusArg(unsigned arg) {
316return ConcreteOp::getOperationName().size() - arg;
317}
318} // namespace mlir
319namespace mlir {
320template<typename ConcreteOp>
321void detail::TestEffectOpInterfaceInterfaceTraits::Model<ConcreteOp>::getEffects(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::TestEffects::Effect>> & effects) {
322 return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getEffects(effects);
323}
324template<typename ConcreteOp>
325void detail::TestEffectOpInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getEffects(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::TestEffects::Effect>> & effects) {
326 return static_cast<const ConcreteOp *>(impl)->getEffects(tablegen_opaque_val, effects);
327}
328} // namespace mlir
329namespace mlir {
330template<typename ConcreteOp>
331bool detail::TestOptionallyImplementedOpInterfaceInterfaceTraits::Model<ConcreteOp>::getImplementsInterface(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) {
332 return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getImplementsInterface();
333}
334template<typename ConcreteOp>
335bool detail::TestOptionallyImplementedOpInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getImplementsInterface(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) {
336 return static_cast<const ConcreteOp *>(impl)->getImplementsInterface(tablegen_opaque_val);
337}
338} // namespace mlir
339

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