25 #include "llvm/Support/Debug.h" 46 unwrap(context)->allowUnregisteredDialects(allow);
50 return unwrap(context)->allowsUnregisteredDialects();
53 return static_cast<intptr_t
>(
unwrap(context)->getAvailableDialects().size());
57 MlirDialectRegistry registry) {
64 return static_cast<intptr_t
>(
unwrap(context)->getLoadedDialects().size());
73 return unwrap(context)->isOperationRegistered(
unwrap(name));
77 return unwrap(context)->enableMultithreading(enable);
121 intptr_t largeElementLimit) {
122 unwrap(flags)->elideLargeElementsAttrs(largeElementLimit);
127 unwrap(flags)->enableDebugInfo(prettyForm);
131 unwrap(flags)->printGenericOpForm();
135 unwrap(flags)->useLocalScope();
146 FileLineColLoc::get(
unwrap(context),
unwrap(filename), line, col)));
154 MlirLocation
const *locations,
155 MlirAttribute metadata) {
162 MlirLocation childLoc) {
193 return wrap(ModuleOp::create(
unwrap(location)));
198 parseSourceString<ModuleOp>(
unwrap(module),
unwrap(context));
200 return MlirModule{
nullptr};
201 return MlirModule{owning.
release().getOperation()};
248 #define APPEND_ELEMS(type, sizeName, elemName) \ 250 (type *)realloc(state->elemName, (state->sizeName + n) * sizeof(type)); \ 251 memcpy(state->elemName + state->sizeName, elemName, n * sizeof(type)); \ 252 state->sizeName += n; 255 MlirType
const *results) {
260 MlirValue
const *operands) {
264 MlirRegion
const *regions) {
268 MlirBlock
const *successors) {
289 <<
"type inference was requested for the operation " << state.
name 290 <<
", but the operation was not registered. Ensure that the dialect " 291 "containing the operation is linked into MLIR and registered with " 297 auto *inferInterface = info->getInterface<InferTypeOpInterface>();
298 if (!inferInterface) {
300 <<
"type inference was requested for the operation " << state.
name 301 <<
", but the operation does not support type inference. Result " 302 "types must be specified explicitly.";
306 if (
succeeded(inferInterface->inferReturnTypes(
332 for (intptr_t i = 0; i < state->
nRegions; ++i)
343 assert(cppState.
types.empty() &&
344 "result type inference enabled and result types provided");
374 if (
auto info =
unwrap(op)->getRegisteredInfo())
375 return wrap(info->getTypeID());
380 return wrap(
unwrap(op)->getName().getIdentifier());
392 return static_cast<intptr_t
>(
unwrap(op)->getNumRegions());
396 return wrap(&
unwrap(op)->getRegion(static_cast<unsigned>(pos)));
402 return wrap(static_cast<Region *>(
nullptr));
412 return wrap(static_cast<Region *>(
nullptr));
420 return static_cast<intptr_t
>(
unwrap(op)->getNumOperands());
424 return wrap(
unwrap(op)->getOperand(static_cast<unsigned>(pos)));
428 MlirValue newValue) {
429 unwrap(op)->setOperand(static_cast<unsigned>(pos),
unwrap(newValue));
433 return static_cast<intptr_t
>(
unwrap(op)->getNumResults());
437 return wrap(
unwrap(op)->getResult(static_cast<unsigned>(pos)));
441 return static_cast<intptr_t
>(
unwrap(op)->getNumSuccessors());
445 return wrap(
unwrap(op)->getSuccessor(static_cast<unsigned>(pos)));
449 return static_cast<intptr_t
>(
unwrap(op)->getAttrs().size());
463 MlirAttribute attr) {
509 if (cppRegion->
empty())
510 return wrap(static_cast<Block *>(
nullptr));
520 auto &blockList =
unwrap(region)->getBlocks();
521 blockList.insert(std::next(blockList.begin(), pos),
unwrap(block));
532 assert(
unwrap(reference)->getParent() ==
unwrap(region) &&
533 "expected reference block to belong to the region");
543 assert(
unwrap(reference)->getParent() ==
unwrap(region) &&
544 "expected reference block to belong to the region");
550 delete static_cast<Region *
>(region.ptr);
558 MlirLocation
const *locs) {
560 for (intptr_t i = 0; i < nArgs; ++i)
583 if (cppBlock->
empty())
584 return wrap(static_cast<Operation *>(
nullptr));
590 if (cppBlock->
empty())
591 return wrap(static_cast<Operation *>(
nullptr));
594 return wrap(static_cast<Operation *>(
nullptr));
603 MlirOperation operation) {
604 auto &opList =
unwrap(block)->getOperations();
605 opList.insert(std::next(opList.begin(), pos),
unwrap(operation));
609 MlirOperation reference,
610 MlirOperation operation) {
617 assert(
unwrap(reference)->getBlock() ==
unwrap(block) &&
618 "expected reference operation to belong to the block");
624 MlirOperation reference,
625 MlirOperation operation) {
629 assert(
unwrap(reference)->getBlock() ==
unwrap(block) &&
630 "expected reference operation to belong to the block");
643 return static_cast<intptr_t
>(
unwrap(block)->getNumArguments());
652 return wrap(
unwrap(block)->getArgument(static_cast<unsigned>(pos)));
678 return wrap(
unwrap(value).cast<BlockArgument>().getOwner());
682 return static_cast<intptr_t
>(
691 return wrap(
unwrap(value).cast<OpResult>().getOwner());
695 return static_cast<intptr_t
>(
771 MlirAttribute attr) {
808 if (!
unwrap(operation)->hasTrait<OpTrait::SymbolTable>())
809 return wrap(static_cast<SymbolTable *>(
nullptr));
814 delete unwrap(symbolTable);
823 MlirOperation operation) {
828 MlirOperation operation) {
834 MlirOperation from) {
835 auto *cppFrom =
unwrap(from);
836 auto *context = cppFrom->getContext();
837 auto oldSymbolAttr = StringAttr::get(context,
unwrap(oldSymbol));
838 auto newSymbolAttr = StringAttr::get(context,
unwrap(newSymbol));
844 void (*callback)(MlirOperation,
bool,
848 [&](
Operation *foundOpCpp,
bool isVisible) {
849 callback(
wrap(foundOpCpp), isVisible,
MlirModule mlirModuleCreateEmpty(MlirLocation location)
Creates a new, empty module and transfers ownership to the caller.
MlirRegion mlirBlockGetParentRegion(MlirBlock block)
Returns the region that contains this block.
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
bool mlirContextIsRegisteredOperation(MlirContext context, MlirStringRef name)
Returns whether the given fully-qualified operation (i.e.
Attribute parseAttribute(llvm::StringRef attrStr, MLIRContext *context)
This parses a single MLIR attribute to an MLIR context if it was valid.
static Operation * create(Location location, OperationName name, TypeRange resultTypes, ValueRange operands, ArrayRef< NamedAttribute > attributes, BlockRange successors, unsigned numRegions)
Create a new Operation with the specific fields.
MlirOperation mlirOperationGetNextInBlock(MlirOperation op)
Returns an operation immediately following the given operation it its enclosing block.
This class contains a list of basic blocks and a link to the parent operation it is attached to...
void mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags)
Always print operations in the generic form.
MlirLocation mlirLocationUnknownGet(MlirContext context)
Creates a location with unknown position owned by the given context.
const char * data
Pointer to the first symbol.
static StringRef getSymbolAttrName()
Return the name of the attribute used for symbol names.
void mlirAttributePrint(MlirAttribute attr, MlirStringCallback callback, void *userData)
Prints an attribute by sending chunks of the string representation and forwarding userData tocallback...
bool mlirValueEqual(MlirValue value1, MlirValue value2)
Returns 1 if two values are equal, 0 otherwise.
void mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags, intptr_t largeElementLimit)
Enables the elision of large elements attributes by printing a lexically valid but otherwise meaningl...
Operation is a basic unit of execution within MLIR.
Attribute getValue() const
Return the value of the attribute.
MlirType mlirAttributeGetType(MlirAttribute attribute)
Gets the type of this attribute.
bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2)
Checks if two attributes are equal.
BlockListType & getBlocks()
MlirNamedAttribute * attributes
This is a value defined by a result of an operation.
void mlirRegionInsertOwnedBlockAfter(MlirRegion region, MlirBlock reference, MlirBlock block)
Takes a block owned by the caller and inserts it after the (non-owned) reference block in the given r...
MlirOperation mlirOpResultGetOwner(MlirValue value)
Returns an operation that produced this value as its result.
unsigned getNumRegions()
Returns the number of regions held by this operation.
MlirModule mlirModuleFromOperation(MlirOperation op)
Views the generic operation as a module.
bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2)
Checks if two contexts are equal.
Block represents an ordered list of Operations.
void mlirLocationPrint(MlirLocation location, MlirStringCallback callback, void *userData)
Prints a location by sending chunks of the string representation and forwarding userData tocallback`...
MlirContext mlirContextCreate()
Creates an MLIR context and transfers its ownership to the caller.
MlirAttribute mlirAttributeParseGet(MlirContext context, MlirStringRef attr)
Parses an attribute. The attribute is owned by the context.
void mlirRegionInsertOwnedBlockBefore(MlirRegion region, MlirBlock reference, MlirBlock block)
Takes a block owned by the caller and inserts it before the (non-owned) reference block in the given ...
OpListType & getOperations()
MlirNamedAttribute mlirNamedAttributeGet(MlirIdentifier name, MlirAttribute attr)
Associates an attribute with the name. Takes ownership of neither.
void mlirOperationStateAddOperands(MlirOperationState *state, intptr_t n, MlirValue const *operands)
OpTy release()
Release the referenced op.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value...
MlirTypeID mlirTypeGetTypeID(MlirType type)
Gets the type ID of the type.
MlirLocation mlirLocationFusedGet(MlirContext ctx, intptr_t nLocations, MlirLocation const *locations, MlirAttribute metadata)
Creates a fused location with an array of locations and metadata.
void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool prettyForm)
Enable printing of debug information.
void mlirBlockDestroy(MlirBlock block)
Takes a block owned by the caller and destroys it.
void mlirBlockDetach(MlirBlock block)
Detach a block from the owning region and assume ownership.
void mlirOperationMoveBefore(MlirOperation op, MlirOperation other)
Moves the given operation immediately before the other operation in its parent block.
BlockListType::iterator iterator
void reserve(size_type N)
MlirValue mlirOperationGetResult(MlirOperation op, intptr_t pos)
Returns pos-th result of the operation.
MlirRegion mlirOperationGetFirstRegion(MlirOperation op)
Returns first region attached to the operation.
static StringRef getVisibilityAttrName()
Return the name of the attribute used for symbol visibility.
DictionaryAttr getDictionary(MLIRContext *context) const
Return a dictionary attribute for the underlying dictionary.
MlirLocation mlirLocationCallSiteGet(MlirLocation callee, MlirLocation caller)
Creates a call site location with a callee and a caller.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value...
MlirValue mlirOperationGetOperand(MlirOperation op, intptr_t pos)
Returns pos-th operand of the operation.
This class provides the API for ops that are known to be terminators.
void mlirBlockArgumentSetType(MlirValue value, MlirType type)
Sets the type of the block argument to the given type.
MlirOpPrintingFlags mlirOpPrintingFlagsCreate()
Creates new printing flags with defaults, intended for customization.
A simple raw ostream subclass that forwards write_impl calls to the user-supplied callback together w...
bool mlirBlockEqual(MlirBlock block, MlirBlock other)
Checks whether two blocks handles point to the same block.
MlirContext mlirAttributeGetContext(MlirAttribute attribute)
Gets the context that an attribute was created with.
MlirLocation mlirOperationGetLocation(MlirOperation op)
Gets the location of the operation.
Region * getParent() const
Provide a 'getParent' method for ilist_node_with_parent methods.
static constexpr const bool value
intptr_t mlirContextGetNumLoadedDialects(MlirContext context)
Returns the number of dialects loaded by the context.
void mlirSymbolTableWalkSymbolTables(MlirOperation from, bool allSymUsesVisible, void(*callback)(MlirOperation, bool, void *userData), void *userData)
Walks all symbol table operations nested within, and including, op.
SmallVector< Value, 4 > operands
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
intptr_t mlirOpResultGetResultNumber(MlirValue value)
Returns the position of the value in the list of results of the operation that produced it...
intptr_t mlirOperationGetNumResults(MlirOperation op)
Returns the number of results of the operation.
NamedAttribute represents a combination of a name and an Attribute value.
MlirContext mlirDialectGetContext(MlirDialect dialect)
Returns the context that owns the dialect.
bool mlirContextGetAllowUnregisteredDialects(MlirContext context)
Returns whether the context allows unregistered dialects.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
MlirStringRef mlirSymbolTableGetSymbolAttributeName()
Returns the name of the attribute used to store symbol names compatible with symbol tables...
This class represents an efficient way to signal success or failure.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
MlirLogicalResult mlirSymbolTableReplaceAllSymbolUses(MlirStringRef oldSymbol, MlirStringRef newSymbol, MlirOperation from)
Attempt to replace all uses that are nested within the given operation of the given symbol 'oldSymbol...
void mlirContextSetAllowUnregisteredDialects(MlirContext context, bool allow)
Sets whether unregistered dialects are allowed in this context.
MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name, MlirLocation childLoc)
Creates a name location owned by the given context.
void mlirOperationStateAddResults(MlirOperationState *state, intptr_t n, MlirType const *results)
Adds a list of components to the operation state.
OpListType::iterator iterator
bool mlirValueIsABlockArgument(MlirValue value)
Returns 1 if the value is a block argument, 0 otherwise.
unsigned getRegionNumber()
Return the number of this region in the parent operation.
void mlirRegionDestroy(MlirRegion region)
Takes a region owned by the caller and destroys it.
void mlirDialectRegistryDestroy(MlirDialectRegistry registry)
Takes a dialect registry owned by the caller and destroys it.
MlirTypeID mlirAttributeGetTypeID(MlirAttribute attr)
Gets the type id of the attribute.
void addOperands(ValueRange newOperands)
void mlirOperationDestroy(MlirOperation op)
Takes an operation owned by the caller and destroys it.
void mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n, MlirNamedAttribute const *attributes)
void mlirOperationSetOperand(MlirOperation op, intptr_t pos, MlirValue newValue)
Sets the pos-th operand of the operation.
void mlirTypeDump(MlirType type)
Prints the type to the standard error stream.
void mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData)
Prints a block by sending chunks of the string representation and forwarding userData tocallback`...
intptr_t mlirBlockArgumentGetArgNumber(MlirValue value)
Returns the position of the value in the argument list of its block.
void print(raw_ostream &os) const
Outputs this diagnostic to a stream.
void mlirValueDump(MlirValue value)
Prints the value to the standard error stream.
MlirLocation mlirLocationFileLineColGet(MlirContext context, MlirStringRef filename, unsigned line, unsigned col)
Creates an File/Line/Column location owned by the given context.
MlirOperation mlirBlockGetFirstOperation(MlirBlock block)
Returns the first operation in the block.
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
void mlirModuleDestroy(MlirModule module)
Takes a module owned by the caller and deletes it.
Attributes are known-constant values of operations.
MlirContext mlirModuleGetContext(MlirModule module)
Gets the context that a module was created with.
void mlirSymbolTableDestroy(MlirSymbolTable symbolTable)
Destroys the symbol table created with mlirSymbolTableCreate.
void mlirSymbolTableErase(MlirSymbolTable symbolTable, MlirOperation operation)
Removes the given operation from the symbol table and erases it.
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
void mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n, MlirBlock const *successors)
MlirBlock mlirModuleGetBody(MlirModule module)
Gets the body of the module, i.e. the only block it contains.
StringAttr getName() const
Return the name of the attribute.
MlirAttribute mlirSymbolTableInsert(MlirSymbolTable symbolTable, MlirOperation operation)
Inserts the given operation into the given symbol table.
A logical result value, essentially a boolean with named states.
MlirStringRef mlirDialectGetNamespace(MlirDialect dialect)
Returns the namespace of the given dialect.
void addTypes(ArrayRef< Type > newTypes)
bool mlirOperationEqual(MlirOperation op, MlirOperation other)
Checks whether two operation handles point to the same operation.
MlirOperation mlirBlockGetParentOperation(MlirBlock block)
Returns the closest surrounding operation that contains this block.
bool mlirTypeEqual(MlirType t1, MlirType t2)
Checks if two types are equal.
bool mlirOperationRemoveAttributeByName(MlirOperation op, MlirStringRef name)
Removes an attribute by name.
void mlirBlockAppendOwnedOperation(MlirBlock block, MlirOperation operation)
Takes an operation owned by the caller and appends it to the block.
Optional< RegisteredOperationName > getRegisteredInfo() const
If this operation is registered, returns the registered information, None otherwise.
MlirOperation mlirBlockGetTerminator(MlirBlock block)
Returns the terminator operation in the block or null if no terminator.
This represents an operation in an abstracted form, suitable for use with the builder APIs...
MlirValue mlirBlockAddArgument(MlirBlock block, MlirType type, MlirLocation loc)
Appends an argument of the specified type to the block.
MlirOperation mlirOperationClone(MlirOperation op)
Creates a deep copy of an operation.
size_t length
Length of the fragment.
MlirNamedAttribute mlirOperationGetAttribute(MlirOperation op, intptr_t pos)
Return pos-th attribute of the operation.
void mlirContextDestroy(MlirContext context)
Takes an MLIR context owned by the caller and destroys it.
This class represents an argument of a Block.
static void walkSymbolTables(Operation *op, bool allSymUsesVisible, function_ref< void(Operation *, bool)> callback)
Walks all symbol table operations nested within, and including, op.
MlirStringRef mlirSymbolTableGetVisibilityAttributeName()
Returns the name of the attribute used to store symbol visibility.
intptr_t mlirOperationGetNumAttributes(MlirOperation op)
Returns the number of attributes attached to the operation.
MlirType mlirValueGetType(MlirValue value)
Returns the type of the value.
MlirContext mlirOperationGetContext(MlirOperation op)
Gets the context this operation is associated with.
MlirContext mlirLocationGetContext(MlirLocation location)
Gets the context that a location was created with.
bool mlirIdentifierEqual(MlirIdentifier ident, MlirIdentifier other)
Checks whether two identifiers are the same.
MlirContext mlirIdentifierGetContext(MlirIdentifier ident)
Returns the context associated with this identifier.
Type parseType(llvm::StringRef typeStr, MLIRContext *context)
This parses a single MLIR type to an MLIR context if it was valid.
A pointer to a sized fragment of a string, not necessarily null-terminated.
MlirBlock mlirOperationGetBlock(MlirOperation op)
Gets the block that owns this operation, returning null if the operation is not owned.
Operation * getParentOp()
Return the parent operation this region is attached to.
void addSuccessors(Block *successor)
MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType const *args, MlirLocation const *locs)
Creates a new empty block with the given argument types and transfers ownership to the caller...
void addAttribute(StringRef name, Attribute attr)
Add an attribute with the specified name.
intptr_t mlirOperationGetNumRegions(MlirOperation op)
Returns the number of regions attached to the given operation.
An auxiliary class for constructing operations.
MlirBlock mlirBlockArgumentGetOwner(MlirValue value)
Returns the block in which this value is defined as an argument.
MlirRegion mlirRegionCreate()
Creates a new empty region and transfers ownership to the caller.
void mlirOperationPrint(MlirOperation op, MlirStringCallback callback, void *userData)
Prints an operation by sending chunks of the string representation and forwarding userData tocallback...
void mlirContextAppendDialectRegistry(MlirContext ctx, MlirDialectRegistry registry)
Append the contents of the given dialect registry to the registry associated with the context...
MlirAttribute mlirOperationGetAttributeByName(MlirOperation op, MlirStringRef name)
Returns an attribute attached to the operation given its name.
MlirRegion mlirRegionGetNextInOperation(MlirRegion region)
Returns the region immediately following the given region in its parent operation.
MLIRContext * getContext() const
Get the context held by this operation state.
MlirOperation mlirModuleGetOperation(MlirModule module)
Views the module as a generic operation.
MlirBlock mlirRegionGetFirstBlock(MlirRegion region)
Gets the first block in the region.
MlirDialectRegistry mlirDialectRegistryCreate()
Creates a dialect registry and transfers its ownership to the caller.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
Set of flags used to control the behavior of the various IR print methods (e.g.
Region * addRegion()
Create a region that should be attached to the operation.
void mlirOperationDump(MlirOperation op)
Prints an operation to stderr.
static LogicalResult inferOperationTypes(OperationState &state)
void mlirBlockInsertOwnedOperation(MlirBlock block, intptr_t pos, MlirOperation operation)
Takes an operation owned by the caller and inserts it as pos to the block.
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
void mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags)
Use local scope when printing the operation.
MlirRegion mlirOperationGetRegion(MlirOperation op, intptr_t pos)
Returns pos-th region attached to the operation.
#define APPEND_ELEMS(type, sizeName, elemName)
void mlirAttributeDump(MlirAttribute attr)
Prints the attribute to the standard error stream.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
void mlirOperationSetAttributeByName(MlirOperation op, MlirStringRef name, MlirAttribute attr)
Sets an attribute by name, replacing the existing if it exists or adding a new one otherwise...
void(* MlirStringCallback)(MlirStringRef, void *)
A callback for returning string references.
void mlirBlockInsertOwnedOperationAfter(MlirBlock block, MlirOperation reference, MlirOperation operation)
Takes an operation owned by the caller and inserts it after the (non-owned) reference operation in th...
intptr_t mlirContextGetNumRegisteredDialects(MlirContext context)
Returns the number of dialects registered with the given context.
MlirContext mlirTypeGetContext(MlirType type)
Gets the context that a type was created with.
void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags)
Destroys printing flags created with mlirOpPrintingFlagsCreate.
MlirTypeID mlirOperationGetTypeID(MlirOperation op)
Gets the type id of the operation.
MlirStringRef mlirIdentifierStr(MlirIdentifier ident)
Gets the string value of the identifier.
MLIRContext is the top-level object for a collection of MLIR operations.
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
bool enableResultTypeInference
void mlirRegionAppendOwnedBlock(MlirRegion region, MlirBlock block)
Takes a block owned by the caller and appends it to the given region.
intptr_t mlirOperationGetNumSuccessors(MlirOperation op)
Returns the number of successor blocks of the operation.
MlirOperation mlirOperationGetParentOperation(MlirOperation op)
Gets the operation that owns this operation, returning null if the operation is not owned...
bool mlirValueIsAOpResult(MlirValue value)
Returns 1 if the value is an operation result, 0 otherwise.
void mlirBlockInsertOwnedOperationBefore(MlirBlock block, MlirOperation reference, MlirOperation operation)
Takes an operation owned by the caller and inserts it before the (non-owned) reference operation in t...
MlirDialect mlirContextGetOrLoadDialect(MlirContext context, MlirStringRef name)
Gets the dialect instance owned by the given context using the dialect namespace to identify it...
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.
MlirOperation mlirOperationCreate(MlirOperationState *state)
Creates an operation and transfers ownership to the caller.
MlirIdentifier mlirOperationGetName(MlirOperation op)
Gets the name of the operation as an identifier.
void mlirValuePrint(MlirValue value, MlirStringCallback callback, void *userData)
Prints a value by sending chunks of the string representation and forwarding userData tocallback`...
MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module)
Parses a module from the string and transfers ownership to the caller.
SmallVector< std::unique_ptr< Region >, 1 > regions
Regions that the op will hold.
static LogicalResult replaceAllSymbolUses(StringAttr oldSymbol, StringAttr newSymbol, Operation *from)
Attempt to replace all uses of the given symbol 'oldSymbol' with the provided symbol 'newSymbol' that...
MlirSymbolTable mlirSymbolTableCreate(MlirOperation operation)
Creates a symbol table for the given operation.
MlirBlock mlirOperationGetSuccessor(MlirOperation op, intptr_t pos)
Returns pos-th successor of the operation.
void mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData)
Prints a location by sending chunks of the string representation and forwarding userData tocallback`...
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
static bool mlirLocationIsNull(MlirLocation location)
Checks if the location is null.
MlirType mlirTypeParseGet(MlirContext context, MlirStringRef type)
Parses a type. The type is owned by the context.
void mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n, MlirRegion const *regions)
bool mlirRegionEqual(MlirRegion region, MlirRegion other)
Checks whether two region handles point to the same region.
bool mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2)
Checks if two dialects that belong to the same context are equal.
BlockArgument addArgument(Type type, Location loc)
Add one value to the argument list.
intptr_t mlirOperationGetNumOperands(MlirOperation op)
Returns the number of operands of the operation.
bool mlirLocationEqual(MlirLocation l1, MlirLocation l2)
Checks if two locations are equal.
void mlirContextEnableMultithreading(MlirContext context, bool enable)
Set threading mode (must be set to false to mlir-print-ir-after-all).
void mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos, MlirBlock block)
Takes a block owned by the caller and inserts it at pos to the given region.
static bool mlirBlockIsNull(MlirBlock block)
Checks whether a block is null.
bool mlirOperationVerify(MlirOperation op)
Verify the operation and return true if it passes, false if it fails.
MlirOperationState mlirOperationStateGet(MlirStringRef name, MlirLocation loc)
Constructs an operation state from a name and a location.
void mlirOperationPrintWithFlags(MlirOperation op, MlirOpPrintingFlags flags, MlirStringCallback callback, void *userData)
Same as mlirOperationPrint but accepts flags controlling the printing behavior.
Region & getRegion(unsigned index)
Returns the region held by this operation at position 'index'.
static bool mlirOperationIsNull(MlirOperation op)
Checks whether the underlying operation is null.
void mlirOperationMoveAfter(MlirOperation op, MlirOperation other)
Moves the given operation immediately after the other operation in its parent block.
intptr_t mlirBlockGetNumArguments(MlirBlock block)
Returns the number of arguments of the block.
MlirOperation mlirSymbolTableLookup(MlirSymbolTable symbolTable, MlirStringRef name)
Looks up a symbol with the given name in the given symbol table and returns the operation that corres...
MlirBlock mlirBlockGetNextInRegion(MlirBlock block)
Returns the block immediately following the given block in its parent region.
void mlirOperationRemoveFromParent(MlirOperation op)
Removes the given operation from its parent block.
MlirIdentifier mlirIdentifierGet(MlirContext context, MlirStringRef str)
Gets an identifier with the given string value.
void mlirOperationStateEnableResultTypeInference(MlirOperationState *state)
Enables result type inference for the operation under construction.
SmallVector< Type, 4 > types
Types of the results of this operation.
MlirValue mlirBlockGetArgument(MlirBlock block, intptr_t pos)
Returns pos-th argument of the block.