1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Interface Declarations *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#include "mlir/IR/Attributes.h"
10
11namespace mlir::gpu {
12
13/// Interface for GPU target attributes. Attributes implementing this interface
14/// compile GPU modules into binary objects, providing an opaque interface to
15/// hide implementation details.
16class TargetAttrInterface;
17
18} // namespace mlir::gpu
19namespace mlir::gpu {
20
21/// Interface for GPU target attributes that verify the target attribute
22/// of a given GPU module.
23class TargetAttrVerifyInterface;
24
25} // namespace mlir::gpu
26namespace mlir::gpu {
27
28/// Interface for GPU offloading LLVM translation attributes. Attributes
29/// implementing this interface manage the interaction between GPU offloading
30/// operations and host IR.
31class OffloadingLLVMTranslationAttrInterface;
32
33} // namespace mlir::gpu
34namespace mlir::gpu {
35
36/// Interface for GPU target attributes. Attributes implementing this interface
37/// compile GPU modules into binary objects, providing an opaque interface to
38/// hide implementation details.
39namespace detail {
40struct TargetAttrInterfaceInterfaceTraits {
41 struct Concept {
42 /// The methods defined by the interface.
43 std::optional<SerializedObject> (*serializeToObject)(const Concept *impl, ::mlir::Attribute , ::mlir::Operation*, const ::mlir::gpu::TargetOptions&);
44 ::mlir::Attribute (*createObject)(const Concept *impl, ::mlir::Attribute , ::mlir::Operation *, const ::mlir::gpu::SerializedObject &, const ::mlir::gpu::TargetOptions &);
45 };
46 template<typename ConcreteAttr>
47 class Model : public Concept {
48 public:
49 using Interface = ::mlir::gpu::TargetAttrInterface;
50 using GeneratedModel = Model;
51 constexpr Model() : Concept{.serializeToObject: serializeToObject, .createObject: createObject} {}
52
53 static inline std::optional<SerializedObject> serializeToObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* module, const ::mlir::gpu::TargetOptions& options);
54 static inline ::mlir::Attribute createObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module, const ::mlir::gpu::SerializedObject & object, const ::mlir::gpu::TargetOptions & options);
55 };
56 template<typename ConcreteAttr>
57 class FallbackModel : public Concept {
58 public:
59 using Interface = ::mlir::gpu::TargetAttrInterface;
60 FallbackModel() : Concept{.serializeToObject: serializeToObject, .createObject: createObject} {}
61
62 static inline std::optional<SerializedObject> serializeToObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* module, const ::mlir::gpu::TargetOptions& options);
63 static inline ::mlir::Attribute createObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module, const ::mlir::gpu::SerializedObject & object, const ::mlir::gpu::TargetOptions & options);
64 };
65 template<typename ConcreteModel, typename ConcreteAttr>
66 class ExternalModel : public FallbackModel<ConcreteModel> {
67 public:
68 using ConcreteEntity = ConcreteAttr;
69 };
70};
71template <typename ConcreteAttr>
72struct TargetAttrInterfaceTrait;
73
74} // namespace detail
75class TargetAttrInterface : public ::mlir::AttributeInterface<TargetAttrInterface, detail::TargetAttrInterfaceInterfaceTraits> {
76public:
77 using ::mlir::AttributeInterface<TargetAttrInterface, detail::TargetAttrInterfaceInterfaceTraits>::AttributeInterface;
78 template <typename ConcreteAttr>
79 struct Trait : public detail::TargetAttrInterfaceTrait<ConcreteAttr> {};
80
81 /// Serializes a GPU module to a string containing a representation of the
82 /// module.
83 ///
84 /// If serialization fails then the method should return `std::nullopt`.
85 ///
86 /// The `module` parameter must be a GPU Module Op. The `options` parameter
87 /// is meant to be used for passing additional options that are not in the
88 /// attribute.
89 std::optional<SerializedObject> serializeToObject(::mlir::Operation* module, const ::mlir::gpu::TargetOptions& options) const;
90
91 /// Creates a GPU object attribute from a binary string.
92 ///
93 /// The `module` parameter must be a `GPUModuleOp` and can be used to
94 /// retrieve additional information like the list of kernels in the binary.
95 /// The `object` parameter is a binary string. The `options` parameter is
96 /// meant to be used for passing additional options that are not in the
97 /// attribute.
98 ::mlir::Attribute createObject(::mlir::Operation * module, const ::mlir::gpu::SerializedObject & object, const ::mlir::gpu::TargetOptions & options) const;
99};
100
101} // namespace mlir::gpu
102namespace mlir::gpu {
103
104/// Interface for GPU target attributes that verify the target attribute
105/// of a given GPU module.
106namespace detail {
107struct TargetAttrVerifyInterfaceInterfaceTraits {
108 struct Concept {
109 /// The methods defined by the interface.
110 ::mlir::LogicalResult (*verifyTarget)(const Concept *impl, ::mlir::Attribute , ::mlir::Operation *);
111 };
112 template<typename ConcreteAttr>
113 class Model : public Concept {
114 public:
115 using Interface = ::mlir::gpu::TargetAttrVerifyInterface;
116 using GeneratedModel = Model;
117 constexpr Model() : Concept{.verifyTarget: verifyTarget} {}
118
119 static inline ::mlir::LogicalResult verifyTarget(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module);
120 };
121 template<typename ConcreteAttr>
122 class FallbackModel : public Concept {
123 public:
124 using Interface = ::mlir::gpu::TargetAttrVerifyInterface;
125 FallbackModel() : Concept{.verifyTarget: verifyTarget} {}
126
127 static inline ::mlir::LogicalResult verifyTarget(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module);
128 };
129 template<typename ConcreteModel, typename ConcreteAttr>
130 class ExternalModel : public FallbackModel<ConcreteModel> {
131 public:
132 using ConcreteEntity = ConcreteAttr;
133 };
134};
135template <typename ConcreteAttr>
136struct TargetAttrVerifyInterfaceTrait;
137
138} // namespace detail
139class TargetAttrVerifyInterface : public ::mlir::AttributeInterface<TargetAttrVerifyInterface, detail::TargetAttrVerifyInterfaceInterfaceTraits> {
140public:
141 using ::mlir::AttributeInterface<TargetAttrVerifyInterface, detail::TargetAttrVerifyInterfaceInterfaceTraits>::AttributeInterface;
142 template <typename ConcreteAttr>
143 struct Trait : public detail::TargetAttrVerifyInterfaceTrait<ConcreteAttr> {};
144
145 /// Verifies that the target attribute is valid for the given GPU module.
146 ::mlir::LogicalResult verifyTarget(::mlir::Operation * module) const;
147};
148
149} // namespace mlir::gpu
150namespace mlir::gpu {
151
152/// Interface for GPU offloading LLVM translation attributes. Attributes
153/// implementing this interface manage the interaction between GPU offloading
154/// operations and host IR.
155namespace detail {
156struct OffloadingLLVMTranslationAttrInterfaceInterfaceTraits {
157 struct Concept {
158 /// The methods defined by the interface.
159 ::llvm::LogicalResult (*embedBinary)(const Concept *impl, ::mlir::Attribute , ::mlir::Operation*, ::llvm::IRBuilderBase&, ::mlir::LLVM::ModuleTranslation&);
160 ::llvm::LogicalResult (*launchKernel)(const Concept *impl, ::mlir::Attribute , ::mlir::Operation*, ::mlir::Operation*, ::llvm::IRBuilderBase&, ::mlir::LLVM::ModuleTranslation&);
161 };
162 template<typename ConcreteAttr>
163 class Model : public Concept {
164 public:
165 using Interface = ::mlir::gpu::OffloadingLLVMTranslationAttrInterface;
166 using GeneratedModel = Model;
167 constexpr Model() : Concept{.embedBinary: embedBinary, .launchKernel: launchKernel} {}
168
169 static inline ::llvm::LogicalResult embedBinary(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation);
170 static inline ::llvm::LogicalResult launchKernel(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* launchFunc, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation);
171 };
172 template<typename ConcreteAttr>
173 class FallbackModel : public Concept {
174 public:
175 using Interface = ::mlir::gpu::OffloadingLLVMTranslationAttrInterface;
176 FallbackModel() : Concept{.embedBinary: embedBinary, .launchKernel: launchKernel} {}
177
178 static inline ::llvm::LogicalResult embedBinary(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation);
179 static inline ::llvm::LogicalResult launchKernel(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* launchFunc, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation);
180 };
181 template<typename ConcreteModel, typename ConcreteAttr>
182 class ExternalModel : public FallbackModel<ConcreteModel> {
183 public:
184 using ConcreteEntity = ConcreteAttr;
185 };
186};
187template <typename ConcreteAttr>
188struct OffloadingLLVMTranslationAttrInterfaceTrait;
189
190} // namespace detail
191class OffloadingLLVMTranslationAttrInterface : public ::mlir::AttributeInterface<OffloadingLLVMTranslationAttrInterface, detail::OffloadingLLVMTranslationAttrInterfaceInterfaceTraits> {
192public:
193 using ::mlir::AttributeInterface<OffloadingLLVMTranslationAttrInterface, detail::OffloadingLLVMTranslationAttrInterfaceInterfaceTraits>::AttributeInterface;
194 template <typename ConcreteAttr>
195 struct Trait : public detail::OffloadingLLVMTranslationAttrInterfaceTrait<ConcreteAttr> {};
196
197 /// Translates a `gpu.binary` Op into a sequence of LLVM IR target-specific
198 /// instructions, embedding the binary into a host LLVM module.
199 ///
200 /// The LLVM translation mechanism invokes this function when translating a
201 /// `gpu.binary`.
202 ///
203 /// The first argument has to be a GPU binary operation.
204 /// If the function fails at any point, it must return `failure`.
205 ::llvm::LogicalResult embedBinary(::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation) const;
206
207 /// Translates a `gpu.launch_func` op into a sequence of LLVM IR
208 /// target-specific instructions, resulting in a kernel launch on host IR.
209 ///
210 /// The LLVM translation mechanism invokes this function when translating a
211 /// `gpu.launch_func` operation; it searches the appropriate binary and uses
212 /// its offloading handler.
213 ///
214 /// The first two arguments must be GPU launch and binary operations,
215 /// respectively. If the function fails at any point, it must return
216 /// `failure`.
217 ::llvm::LogicalResult launchKernel(::mlir::Operation* launchFunc, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation) const;
218};
219
220} // namespace mlir::gpu
221namespace mlir::gpu::detail {
222
223 template <typename ConcreteAttr>
224 struct TargetAttrInterfaceTrait : public ::mlir::AttributeInterface<TargetAttrInterface, detail::TargetAttrInterfaceInterfaceTraits>::Trait<ConcreteAttr> {
225 };
226
227} // namespace mlir::gpu::detail
228namespace mlir::gpu::detail {
229
230 template <typename ConcreteAttr>
231 struct TargetAttrVerifyInterfaceTrait : public ::mlir::AttributeInterface<TargetAttrVerifyInterface, detail::TargetAttrVerifyInterfaceInterfaceTraits>::Trait<ConcreteAttr> {
232 };
233
234} // namespace mlir::gpu::detail
235namespace mlir::gpu::detail {
236
237 template <typename ConcreteAttr>
238 struct OffloadingLLVMTranslationAttrInterfaceTrait : public ::mlir::AttributeInterface<OffloadingLLVMTranslationAttrInterface, detail::OffloadingLLVMTranslationAttrInterfaceInterfaceTraits>::Trait<ConcreteAttr> {
239 };
240
241} // namespace mlir::gpu::detail
242namespace mlir::gpu {
243
244template<typename ConcreteAttr>
245std::optional<SerializedObject> detail::TargetAttrInterfaceInterfaceTraits::Model<ConcreteAttr>::serializeToObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* module, const ::mlir::gpu::TargetOptions& options) {
246 return (::llvm::cast<ConcreteAttr>(tablegen_opaque_val)).serializeToObject(module, options);
247}
248template<typename ConcreteAttr>
249::mlir::Attribute detail::TargetAttrInterfaceInterfaceTraits::Model<ConcreteAttr>::createObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module, const ::mlir::gpu::SerializedObject & object, const ::mlir::gpu::TargetOptions & options) {
250 return (::llvm::cast<ConcreteAttr>(tablegen_opaque_val)).createObject(module, object, options);
251}
252template<typename ConcreteAttr>
253std::optional<SerializedObject> detail::TargetAttrInterfaceInterfaceTraits::FallbackModel<ConcreteAttr>::serializeToObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* module, const ::mlir::gpu::TargetOptions& options) {
254 return static_cast<const ConcreteAttr *>(impl)->serializeToObject(tablegen_opaque_val, module, options);
255}
256template<typename ConcreteAttr>
257::mlir::Attribute detail::TargetAttrInterfaceInterfaceTraits::FallbackModel<ConcreteAttr>::createObject(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module, const ::mlir::gpu::SerializedObject & object, const ::mlir::gpu::TargetOptions & options) {
258 return static_cast<const ConcreteAttr *>(impl)->createObject(tablegen_opaque_val, module, object, options);
259}
260
261} // namespace mlir::gpu
262namespace mlir::gpu {
263
264template<typename ConcreteAttr>
265::mlir::LogicalResult detail::TargetAttrVerifyInterfaceInterfaceTraits::Model<ConcreteAttr>::verifyTarget(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module) {
266 return (::llvm::cast<ConcreteAttr>(tablegen_opaque_val)).verifyTarget(module);
267}
268template<typename ConcreteAttr>
269::mlir::LogicalResult detail::TargetAttrVerifyInterfaceInterfaceTraits::FallbackModel<ConcreteAttr>::verifyTarget(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation * module) {
270 return static_cast<const ConcreteAttr *>(impl)->verifyTarget(tablegen_opaque_val, module);
271}
272
273} // namespace mlir::gpu
274namespace mlir::gpu {
275
276template<typename ConcreteAttr>
277::llvm::LogicalResult detail::OffloadingLLVMTranslationAttrInterfaceInterfaceTraits::Model<ConcreteAttr>::embedBinary(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation) {
278 return (::llvm::cast<ConcreteAttr>(tablegen_opaque_val)).embedBinary(binaryOp, hostBuilder, hostModuleTranslation);
279}
280template<typename ConcreteAttr>
281::llvm::LogicalResult detail::OffloadingLLVMTranslationAttrInterfaceInterfaceTraits::Model<ConcreteAttr>::launchKernel(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* launchFunc, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation) {
282 return (::llvm::cast<ConcreteAttr>(tablegen_opaque_val)).launchKernel(launchFunc, binaryOp, hostBuilder, hostModuleTranslation);
283}
284template<typename ConcreteAttr>
285::llvm::LogicalResult detail::OffloadingLLVMTranslationAttrInterfaceInterfaceTraits::FallbackModel<ConcreteAttr>::embedBinary(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation) {
286 return static_cast<const ConcreteAttr *>(impl)->embedBinary(tablegen_opaque_val, binaryOp, hostBuilder, hostModuleTranslation);
287}
288template<typename ConcreteAttr>
289::llvm::LogicalResult detail::OffloadingLLVMTranslationAttrInterfaceInterfaceTraits::FallbackModel<ConcreteAttr>::launchKernel(const Concept *impl, ::mlir::Attribute tablegen_opaque_val, ::mlir::Operation* launchFunc, ::mlir::Operation* binaryOp, ::llvm::IRBuilderBase& hostBuilder, ::mlir::LLVM::ModuleTranslation& hostModuleTranslation) {
290 return static_cast<const ConcreteAttr *>(impl)->launchKernel(tablegen_opaque_val, launchFunc, binaryOp, hostBuilder, hostModuleTranslation);
291}
292
293} // namespace mlir::gpu
294