MLIR 24.0.0git
Interfaces.cpp
Go to the documentation of this file.
1
2
3//===- Interfaces.cpp - C Interface for MLIR Interfaces -------------------===//
4//
5// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6// See https://llvm.org/LICENSE.txt for license information.
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8//
9//===----------------------------------------------------------------------===//
10
11#include "mlir-c/Interfaces.h"
12
13#include "mlir/CAPI/IR.h"
15#include "mlir/CAPI/Support.h"
16#include "mlir/CAPI/Wrap.h"
17#include "mlir/IR/ValueRange.h"
20#include "llvm/ADT/ScopeExit.h"
21#include <optional>
22
23using namespace mlir;
24
25namespace {
26
27std::optional<RegisteredOperationName>
28getRegisteredOperationName(MlirContext context, MlirStringRef opName) {
29 StringRef name(opName.data, opName.length);
30 std::optional<RegisteredOperationName> info =
32 return info;
33}
34
35std::optional<Location> maybeGetLocation(MlirLocation location) {
36 std::optional<Location> maybeLocation;
37 if (!mlirLocationIsNull(location))
38 maybeLocation = unwrap(location);
39 return maybeLocation;
40}
41
42SmallVector<Value> unwrapOperands(intptr_t nOperands, MlirValue *operands) {
43 SmallVector<Value> unwrappedOperands;
44 (void)unwrapList(nOperands, operands, unwrappedOperands);
45 return unwrappedOperands;
46}
47
48DictionaryAttr unwrapAttributes(MlirAttribute attributes) {
49 DictionaryAttr attributeDict;
50 if (!mlirAttributeIsNull(attributes))
51 attributeDict = llvm::cast<DictionaryAttr>(unwrap(attributes));
52 return attributeDict;
53}
54
55SmallVector<std::unique_ptr<Region>> unwrapRegions(intptr_t nRegions,
56 MlirRegion *regions) {
57 // Create a vector of unique pointers to regions and make sure they are not
58 // deleted when exiting the scope. This is a hack caused by C++ API expecting
59 // an list of unique pointers to regions (without ownership transfer
60 // semantics) and C API making ownership transfer explicit.
62 unwrappedRegions.reserve(nRegions);
63 for (intptr_t i = 0; i < nRegions; ++i)
64 unwrappedRegions.emplace_back(unwrap(*(regions + i)));
65 llvm::scope_exit cleaner([&]() {
66 for (auto &region : unwrappedRegions)
67 region.release();
68 });
69 return unwrappedRegions;
70}
71
72} // namespace
73
74bool mlirOperationImplementsInterface(MlirOperation operation,
75 MlirTypeID interfaceTypeID) {
76 std::optional<RegisteredOperationName> info =
77 unwrap(operation)->getRegisteredInfo();
78 return info && info->hasInterface(unwrap(interfaceTypeID));
79}
80
82 MlirContext context,
83 MlirTypeID interfaceTypeID) {
84 std::optional<RegisteredOperationName> info = RegisteredOperationName::lookup(
85 StringRef(operationName.data, operationName.length), unwrap(context));
86 return info && info->hasInterface(unwrap(interfaceTypeID));
87}
88
90 return wrap(InferTypeOpInterface::getInterfaceID());
91}
92
94 MlirStringRef opName, MlirContext context, MlirLocation location,
95 intptr_t nOperands, MlirValue *operands, MlirAttribute attributes,
96 void *properties, intptr_t nRegions, MlirRegion *regions,
97 MlirTypesCallback callback, void *userData) {
98 StringRef name(opName.data, opName.length);
99 std::optional<RegisteredOperationName> info =
100 getRegisteredOperationName(context, opName);
101 if (!info)
103
104 std::optional<Location> maybeLocation = maybeGetLocation(location);
105 SmallVector<Value> unwrappedOperands = unwrapOperands(nOperands, operands);
106 DictionaryAttr attributeDict = unwrapAttributes(attributes);
107 SmallVector<std::unique_ptr<Region>> unwrappedRegions =
108 unwrapRegions(nRegions, regions);
109
110 SmallVector<Type> inferredTypes;
111 // The C API passes an opaque void*; we trust the caller to pass the correct
112 // properties type for this operation.
113 // TODO: Create a C API that's more type-safe.
114 PropertyRef propertyRef =
115 properties ? PropertyRef(info->getOpPropertiesTypeID(), properties)
116 : PropertyRef();
117 if (failed(info->getInterface<InferTypeOpInterface>()->inferReturnTypes(
118 unwrap(context), maybeLocation, unwrappedOperands, attributeDict,
119 propertyRef, unwrappedRegions, inferredTypes)))
121
122 SmallVector<MlirType> wrappedInferredTypes;
123 wrappedInferredTypes.reserve(inferredTypes.size());
124 for (Type t : inferredTypes)
125 wrappedInferredTypes.push_back(wrap(t));
126 callback(wrappedInferredTypes.size(), wrappedInferredTypes.data(), userData);
128}
129
131 return wrap(InferShapedTypeOpInterface::getInterfaceID());
132}
133
135 MlirStringRef opName, MlirContext context, MlirLocation location,
136 intptr_t nOperands, MlirValue *operands, MlirAttribute attributes,
137 void *properties, intptr_t nRegions, MlirRegion *regions,
138 MlirShapedTypeComponentsCallback callback, void *userData) {
139 std::optional<RegisteredOperationName> info =
140 getRegisteredOperationName(context, opName);
141 if (!info)
143
144 std::optional<Location> maybeLocation = maybeGetLocation(location);
145 SmallVector<Value> unwrappedOperands = unwrapOperands(nOperands, operands);
146 DictionaryAttr attributeDict = unwrapAttributes(attributes);
147 SmallVector<std::unique_ptr<Region>> unwrappedRegions =
148 unwrapRegions(nRegions, regions);
149
150 SmallVector<ShapedTypeComponents> inferredTypeComponents;
151 // The C API passes an opaque void*; we trust the caller to pass the correct
152 // properties type for this operation.
153 PropertyRef propertyRef =
154 properties ? PropertyRef(info->getOpPropertiesTypeID(), properties)
155 : PropertyRef();
156 if (failed(info->getInterface<InferShapedTypeOpInterface>()
157 ->inferReturnTypeComponents(
158 unwrap(context), maybeLocation,
159 mlir::ValueRange(llvm::ArrayRef(unwrappedOperands)),
160 attributeDict, propertyRef, unwrappedRegions,
161 inferredTypeComponents)))
163
164 bool hasRank;
165 intptr_t rank;
166 const int64_t *shapeData;
167 for (const ShapedTypeComponents &t : inferredTypeComponents) {
168 if (t.hasRank()) {
169 hasRank = true;
170 rank = t.getDims().size();
171 shapeData = t.getDims().data();
172 } else {
173 hasRank = false;
174 rank = 0;
175 shapeData = nullptr;
176 }
177 callback(hasRank, rank, shapeData, wrap(t.getElementType()),
178 wrap(t.getAttribute()), userData);
179 }
181}
182
183//===---------------------------------------------------------------------===//
184// ConditionallySpeculatable
185//===---------------------------------------------------------------------===//
186
188 return wrap(ConditionallySpeculatable::getInterfaceID());
189}
190
191/// Fallback model for the ConditionallySpeculatable interface that uses C API
192/// callbacks.
195 ConditionallySpeculatableOpInterfaceFallbackModel> {
196public:
197 /// Sets the callbacks that this FallbackModel will use.
198 /// NB: the callbacks can only be set through this method as the
199 /// RegisteredOperationName::attachInterface mechanism default-constructs
200 /// the FallbackModel without being able to provide arguments.
201 void
203 this->callbacks = callbacks;
204 }
205
207 if (callbacks.destruct)
208 callbacks.destruct(callbacks.userData);
209 }
210
212 return ConditionallySpeculatable::getInterfaceID();
213 }
214
215 static bool classof(const mlir::ConditionallySpeculatable::Concept *op) {
216 // Enable casting back to the FallbackModel from the Interface. This is
217 // necessary as attachInterface(...) default-constructs the FallbackModel
218 // without being able to pass in the callbacks and returns just the Concept.
219 return true;
220 }
221
223 assert(callbacks.getSpeculatability &&
224 "getSpeculatability callback not set");
225
226 switch (callbacks.getSpeculatability(wrap(op), callbacks.userData)) {
233 }
234 llvm_unreachable("unknown speculatability");
235 }
236
237private:
239};
240
241/// Attach a ConditionallySpeculatable FallbackModel to the given named op.
242/// The FallbackModel uses the provided callbacks to implement the interface.
244 MlirContext ctx, MlirStringRef opName,
246 // Look up the operation definition in the context.
247 std::optional<RegisteredOperationName> opInfo =
249
250 assert(opInfo.has_value() && "operation not found in context");
251
252 // NB: the following default-constructs the FallbackModel _without_ being able
253 // to provide arguments.
254 opInfo->attachInterface<ConditionallySpeculatableOpInterfaceFallbackModel>();
255 // Cast to get the underlying FallbackModel and set the callbacks.
256 auto *model = cast<ConditionallySpeculatableOpInterfaceFallbackModel>(
257 opInfo
258 ->getInterface<ConditionallySpeculatableOpInterfaceFallbackModel>());
259 assert(model &&
260 "Failed to get ConditionallySpeculatableOpInterfaceFallbackModel");
261 model->setCallbacks(callbacks);
262}
263
265 MlirOperation operation) {
266 auto iface = dyn_cast<ConditionallySpeculatable>(unwrap(operation));
267 assert(iface && "operation does not implement ConditionallySpeculatable");
268
269 switch (iface.getSpeculatability()) {
276 }
277 llvm_unreachable("unknown speculatability");
278}
279
280//===---------------------------------------------------------------------===//
281// MemoryEffectOpInterface
282//===---------------------------------------------------------------------===//
283
285 return wrap(
287}
288
289MlirMemoryEffect mlirMemoryEffectsFreeGet() {
290 return wrap(static_cast<MemoryEffects::Effect *>(MemoryEffects::Free::get()));
291}
292
293MlirMemoryEffect mlirMemoryEffectsReadGet() {
294 return wrap(static_cast<MemoryEffects::Effect *>(MemoryEffects::Read::get()));
295}
296
297MlirMemoryEffect mlirMemoryEffectsWriteGet() {
298 return wrap(
300}
301
302MlirTypeID mlirMemoryEffectGetEffectID(MlirMemoryEffect effect) {
303 return wrap(unwrap(effect)->getEffectID());
304}
305
306MlirSideEffectResource mlirSideEffectsDefaultResourceGet() {
307 return wrap(static_cast<SideEffects::Resource *>(
309}
310
311MlirMemoryEffectInstance mlirMemoryEffectInstanceCreate(
312 MlirMemoryEffect effect, MlirAttribute parameters, int stage,
313 bool effectOnFullRegion, MlirSideEffectResource resource) {
315 unwrap(effect), unwrap(parameters), stage, effectOnFullRegion,
316 unwrap(resource)));
317}
318
320 MlirMemoryEffect effect, MlirOpOperand opOperand, MlirAttribute parameters,
321 int stage, bool effectOnFullRegion, MlirSideEffectResource resource) {
323 unwrap(effect), unwrap(opOperand), unwrap(parameters), stage,
324 effectOnFullRegion, unwrap(resource)));
325}
326
328 MlirMemoryEffect effect, MlirValue result, MlirAttribute parameters,
329 int stage, bool effectOnFullRegion, MlirSideEffectResource resource) {
331 unwrap(effect), cast<OpResult>(unwrap(result)), unwrap(parameters), stage,
332 effectOnFullRegion, unwrap(resource)));
333}
334
336 MlirMemoryEffect effect, MlirValue blockArgument, MlirAttribute parameters,
337 int stage, bool effectOnFullRegion, MlirSideEffectResource resource) {
339 unwrap(effect), cast<BlockArgument>(unwrap(blockArgument)),
340 unwrap(parameters), stage, effectOnFullRegion, unwrap(resource)));
341}
342
344 MlirMemoryEffect effect, MlirAttribute symbol, MlirAttribute parameters,
345 int stage, bool effectOnFullRegion, MlirSideEffectResource resource) {
347 unwrap(effect), cast<SymbolRefAttr>(unwrap(symbol)), unwrap(parameters),
348 stage, effectOnFullRegion, unwrap(resource)));
349}
350
351void mlirMemoryEffectInstanceDestroy(MlirMemoryEffectInstance instance) {
352 delete unwrap(instance);
353}
354
355MlirMemoryEffectInstance
356mlirMemoryEffectInstanceClone(MlirMemoryEffectInstance instance) {
357 return wrap(new MemoryEffects::EffectInstance(*unwrap(instance)));
358}
359
360MlirMemoryEffect
361mlirMemoryEffectInstanceGetEffect(MlirMemoryEffectInstance instance) {
362 return wrap(unwrap(instance)->getEffect());
363}
364
365MlirSideEffectResource
366mlirMemoryEffectInstanceGetResource(MlirMemoryEffectInstance instance) {
367 return wrap(unwrap(instance)->getResource());
368}
369
370int mlirMemoryEffectInstanceGetStage(MlirMemoryEffectInstance instance) {
371 return unwrap(instance)->getStage();
372}
373
375 MlirMemoryEffectInstance instance) {
376 return unwrap(instance)->getEffectOnFullRegion();
377}
378
379MlirAttribute
380mlirMemoryEffectInstanceGetParameters(MlirMemoryEffectInstance instance) {
381 return wrap(unwrap(instance)->getParameters());
382}
383
384MlirValue mlirMemoryEffectInstanceGetValue(MlirMemoryEffectInstance instance) {
385 return wrap(unwrap(instance)->getValue());
386}
387
388MlirAttribute
389mlirMemoryEffectInstanceGetSymbolRef(MlirMemoryEffectInstance instance) {
390 return wrap(unwrap(instance)->getSymbolRef());
391}
392
394 return wrap(MemoryEffectOpInterface::getInterfaceID());
395}
396
397/// Fallback model for the MemoryEffectsOpInterface that uses C API callbacks.
400 MemoryEffectOpInterfaceFallbackModel> {
401public:
402 /// Sets the callbacks that this FallbackModel will use.
403 /// NB: the callbacks can only be set through this method as the
404 /// RegisteredOperationName::attachInterface mechanism default-constructs
405 /// the FallbackModel without being able to provide arguments.
407 this->callbacks = callbacks;
408 }
409
411 if (callbacks.destruct)
412 callbacks.destruct(callbacks.userData);
413 }
414
416 return MemoryEffectOpInterface::getInterfaceID();
417 }
418
419 static bool classof(const mlir::MemoryEffectOpInterface::Concept *op) {
420 // Enable casting back to the FallbackModel from the Interface. This is
421 // necessary as attachInterface(...) default-constructs the FallbackModel
422 // without being able to pass in the callbacks and returns just the Concept.
423 return true;
424 }
425
426 void
429 assert(callbacks.getEffects && "getEffects callback not set");
430 callbacks.getEffects(
431 wrap(op),
432 [](intptr_t numEffects, MlirMemoryEffectInstance *effectInstances,
433 void *userData) {
434 auto *unwrappedEffects =
436 userData);
437 unwrappedEffects->reserve(unwrappedEffects->size() + numEffects);
438 for (intptr_t i = 0; i < numEffects; ++i)
439 unwrappedEffects->push_back(*unwrap(effectInstances[i]));
440 },
441 &effects, callbacks.userData);
442 }
443
444private:
446};
447
448/// Attach a MemoryEffectsOpInterface FallbackModel to the given named op.
449/// The FallbackModel uses the provided callbacks to implement the interface.
451 MlirContext ctx, MlirStringRef opName,
453 // Look up the operation definition in the context
454 std::optional<RegisteredOperationName> opInfo =
456
457 assert(opInfo.has_value() && "operation not found in context");
458
459 // NB: the following default-constructs the FallbackModel _without_ being able
460 // to provide arguments.
461 opInfo->attachInterface<MemoryEffectOpInterfaceFallbackModel>();
462 // Cast to get the underlying FallbackModel and set the callbacks.
463 auto *model = cast<MemoryEffectOpInterfaceFallbackModel>(
464 opInfo->getInterface<MemoryEffectOpInterfaceFallbackModel>());
465 assert(model && "Failed to get MemoryEffectOpInterfaceFallbackModel");
466 model->setCallbacks(callbacks);
467}
468
470 MlirOperation operation, MlirMemoryEffectInstancesCallback callback,
471 void *userData) {
472 auto iface = dyn_cast<MemoryEffectOpInterface>(unwrap(operation));
473 assert(iface && "operation does not implement MemoryEffectOpInterface");
474
476 iface.getEffects(effects);
478 wrappedEffects.reserve(effects.size());
479 for (MemoryEffects::EffectInstance &effect : effects)
480 wrappedEffects.push_back(wrap(&effect));
481 callback(wrappedEffects.size(), wrappedEffects.data(), userData);
482}
MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForOpOperand(MlirMemoryEffect effect, MlirOpOperand opOperand, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with an operation operand.
MlirLogicalResult mlirInferShapedTypeOpInterfaceInferReturnTypes(MlirStringRef opName, MlirContext context, MlirLocation location, intptr_t nOperands, MlirValue *operands, MlirAttribute attributes, void *properties, intptr_t nRegions, MlirRegion *regions, MlirShapedTypeComponentsCallback callback, void *userData)
Infers the return shaped type components of the operation.
MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForBlockArgument(MlirMemoryEffect effect, MlirValue blockArgument, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with a block argument.
MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForSymbol(MlirMemoryEffect effect, MlirAttribute symbol, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with a symbol.
void mlirMemoryEffectsOpInterfaceGetEffects(MlirOperation operation, MlirMemoryEffectInstancesCallback callback, void *userData)
Gets the memory effects of the given operation.
int mlirMemoryEffectInstanceGetStage(MlirMemoryEffectInstance instance)
Returns the stage of the given instance.
MlirSideEffectResource mlirSideEffectsDefaultResourceGet()
Returns the singleton instance of the default side effect resource.
MlirAttribute mlirMemoryEffectInstanceGetSymbolRef(MlirMemoryEffectInstance instance)
Returns the symbol reference of the given instance, or a null attribute if there is no associated sym...
MlirAttribute mlirMemoryEffectInstanceGetParameters(MlirMemoryEffectInstance instance)
Returns the parameters of the given instance, or a null attribute if there are no parameters.
MlirTypeID mlirConditionallySpeculatableOpInterfaceTypeID()
Returns the interface TypeID of the ConditionallySpeculatable interface.
MlirTypeID mlirMemoryEffectGetEffectID(MlirMemoryEffect effect)
Returns the TypeID identifying the concrete type of the given memory effect.
MlirMemoryEffectInstance mlirMemoryEffectInstanceClone(MlirMemoryEffectInstance instance)
Creates a copy of a memory effect instance.
void mlirMemoryEffectInstanceDestroy(MlirMemoryEffectInstance instance)
Destroys a memory effect instance created or cloned by APIs above.
MlirMemoryEffect mlirMemoryEffectsFreeGet()
Returns the singleton instance of the free memory effect.
MlirSideEffectResource mlirMemoryEffectInstanceGetResource(MlirMemoryEffectInstance instance)
Returns the side effect resource of the given instance.
bool mlirMemoryEffectInstanceGetEffectOnFullRegion(MlirMemoryEffectInstance instance)
Returns true if the given instance has effect on every single value of the resource.
MlirSpeculatability mlirConditionallySpeculatableOpInterfaceGetSpeculatability(MlirOperation operation)
Returns the speculatability of the given operation.
MlirMemoryEffect mlirMemoryEffectsReadGet()
Returns the singleton instance of the read memory effect.
bool mlirOperationImplementsInterface(MlirOperation operation, MlirTypeID interfaceTypeID)
Returns true if the given operation implements an interface identified by its TypeID.
MlirTypeID mlirMemoryEffectsOpInterfaceTypeID()
Returns the interface TypeID of the MemoryEffectsOpInterface.
MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForOpResult(MlirMemoryEffect effect, MlirValue result, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with an operation result.
MlirValue mlirMemoryEffectInstanceGetValue(MlirMemoryEffectInstance instance)
Returns the value (OpOperand, OpResult, or BlockArgument) of the given instance, or a null value if t...
bool mlirOperationImplementsInterfaceStatic(MlirStringRef operationName, MlirContext context, MlirTypeID interfaceTypeID)
Returns true if the operation identified by its canonical string name implements the interface identi...
void mlirConditionallySpeculatableOpInterfaceAttachFallbackModel(MlirContext ctx, MlirStringRef opName, MlirConditionallySpeculatableOpInterfaceCallbacks callbacks)
Attach a ConditionallySpeculatable FallbackModel to the given named op.
void mlirMemoryEffectsOpInterfaceAttachFallbackModel(MlirContext ctx, MlirStringRef opName, MlirMemoryEffectsOpInterfaceCallbacks callbacks)
Attach a MemoryEffectsOpInterface FallbackModel to the given named op.
MlirTypeID mlirInferTypeOpInterfaceTypeID()
Returns the interface TypeID of the InferTypeOpInterface.
MlirMemoryEffect mlirMemoryEffectsWriteGet()
Returns the singleton instance of the write memory effect.
MlirLogicalResult mlirInferTypeOpInterfaceInferReturnTypes(MlirStringRef opName, MlirContext context, MlirLocation location, intptr_t nOperands, MlirValue *operands, MlirAttribute attributes, void *properties, intptr_t nRegions, MlirRegion *regions, MlirTypesCallback callback, void *userData)
Infers the return types of the operation identified by its canonical given the arguments that will be...
MlirMemoryEffect mlirMemoryEffectsAllocateGet()
Returns the singleton instance of the allocate memory effect.
MlirTypeID mlirInferShapedTypeOpInterfaceTypeID()
Returns the interface TypeID of the InferShapedTypeOpInterface.
MlirMemoryEffectInstance mlirMemoryEffectInstanceCreate(MlirMemoryEffect effect, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance without an associated IR entity.
MlirMemoryEffect mlirMemoryEffectInstanceGetEffect(MlirMemoryEffectInstance instance)
Returns the memory effect of the given instance.
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
Definition Wrap.h:40
Fallback model for the ConditionallySpeculatable interface that uses C API callbacks.
static bool classof(const mlir::ConditionallySpeculatable::Concept *op)
Speculation::Speculatability getSpeculatability(Operation *op) const
void setCallbacks(MlirConditionallySpeculatableOpInterfaceCallbacks callbacks)
Sets the callbacks that this FallbackModel will use.
Fallback model for the MemoryEffectsOpInterface that uses C API callbacks.
void setCallbacks(MlirMemoryEffectsOpInterfaceCallbacks callbacks)
Sets the callbacks that this FallbackModel will use.
static bool classof(const mlir::MemoryEffectOpInterface::Concept *op)
void getEffects(Operation *op, SmallVectorImpl< MemoryEffects::EffectInstance > &effects) const
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Type-safe wrapper around a void* for passing properties, including the properties structs of operatio...
static std::optional< RegisteredOperationName > lookup(StringRef name, MLIRContext *ctx)
Lookup the registered operation information for the given operation.
ShapedTypeComponents that represents the components of a ShapedType.
This class represents a specific resource that an effect applies to.
This class provides an efficient unique identifier for a specific C++ type.
Definition TypeID.h:107
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
This class provides an abstraction over the different types of ranges over Values.
Definition ValueRange.h:389
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition Diagnostics.h:24
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition Diagnostics.h:19
static bool mlirLocationIsNull(MlirLocation location)
Checks if the location is null.
Definition IR.h:398
MlirSpeculatability
Enum representing the speculatability of an operation.
Definition Interfaces.h:107
@ MlirSpeculatabilityRecursivelySpeculatable
The operation is speculatable if all nested operations are speculatable.
Definition Interfaces.h:113
@ MlirSpeculatabilitySpeculatable
The operation is speculatable.
Definition Interfaces.h:111
@ MlirSpeculatabilityNotSpeculatable
The operation is not speculatable.
Definition Interfaces.h:109
void(* MlirShapedTypeComponentsCallback)(bool, intptr_t, const int64_t *, MlirType, MlirAttribute, void *)
These callbacks are used to return multiple shaped type components from functions while transferring ...
Definition Interfaces.h:89
void(* MlirMemoryEffectInstancesCallback)(intptr_t numEffects, MlirMemoryEffectInstance *effects, void *userData)
Callback for receiving a batch of memory effect instances.
Definition Interfaces.h:262
void(* MlirTypesCallback)(intptr_t, MlirType *, void *)
These callbacks are used to return multiple types from functions while transferring ownership to the ...
Definition Interfaces.h:63
static MlirLogicalResult mlirLogicalResultFailure(void)
Creates a logical result representing a failure.
Definition Support.h:143
static MlirLogicalResult mlirLogicalResultSuccess(void)
Creates a logical result representing a success.
Definition Support.h:137
SideEffects::EffectInstance< Effect > EffectInstance
constexpr auto RecursivelySpeculatable
Speculatability
This enum is returned from the getSpeculatability method in the ConditionallySpeculatable op interfac...
constexpr auto Speculatable
constexpr auto NotSpeculatable
Include the generated interface declarations.
Callbacks for implementing ConditionallySpeculatable from external code.
Definition Interfaces.h:121
A logical result value, essentially a boolean with named states.
Definition Support.h:121
Callbacks for implementing MemoryEffectsOpInterface from external code.
Definition Interfaces.h:269
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:78
const char * data
Pointer to the first symbol.
Definition Support.h:79
size_t length
Length of the fragment.
Definition Support.h:80
This class represents the base class used for memory effects.