MLIR 24.0.0git
mlir::MLIRContext Class Reference

MLIRContext is the top-level object for a collection of MLIR operations. More...

#include "mlir/IR/MLIRContext.h"

Classes

class  TransientScope
 RAII scope guard that calls beginTransientScope() on construction and endTransientScope() on destruction. More...

Public Types

enum class  Threading { DISABLED , ENABLED }
using HandlerTy
 Signatures for the action handler that can be registered with the context.

Public Member Functions

 MLIRContext (Threading multithreading=Threading::ENABLED)
 Create a new Context.
 MLIRContext (const DialectRegistry &registry, Threading multithreading=Threading::ENABLED)
 ~MLIRContext ()
std::vector< Dialect * > getLoadedDialects ()
 Return information about all IR dialects loaded in the context.
const DialectRegistry & getDialectRegistry ()
 Return the dialect registry associated with this context.
void appendDialectRegistry (const DialectRegistry &registry)
 Append the contents of the given dialect registry to the registry associated with this context.
std::vector< StringRef > getAvailableDialects ()
 Return information about all available dialects in the registry in this context.
Dialect * getLoadedDialect (StringRef name)
 Get a registered IR dialect with the given namespace.
template<typename T>
T * getLoadedDialect ()
 Get a registered IR dialect for the given derived dialect type.
template<typename T>
T * getOrLoadDialect ()
 Get (or create) a dialect for the given derived dialect type.
template<typename Dialect>
void loadDialect ()
 Load a dialect in the context.
template<typename Dialect, typename OtherDialect, typename... MoreDialects>
void loadDialect ()
 Load a list dialects in the context.
DynamicDialect * getOrLoadDynamicDialect (StringRef dialectNamespace, function_ref< void(DynamicDialect *)> ctor)
 Get (or create) a dynamic dialect for the given name.
void loadAllAvailableDialects ()
 Load all dialects available in the registry in this context.
Dialect * getOrLoadDialect (StringRef name)
 Get (or create) a dialect for the given derived dialect name.
bool allowsUnregisteredDialects ()
 Return true if we allow to create operation for unregistered dialects.
void allowUnregisteredDialects (bool allow=true)
 Enables creating operations in unregistered dialects.
void beginTransientScope ()
 Begins a transient scope on the context, freezing the current state (all loaded dialects, registered operations, types, attributes, affine expressions, and singletons) as the base state.
void endTransientScope ()
 Ends the transient scope and resets the context to the base state, pruning all types, attributes, affine expressions, distinct attributes, and unregistered operations created during the transient scope.
bool isInTransientScope () const
 Returns true if the context is currently in a transient scope.
bool isMultithreadingEnabled ()
 Return true if multi-threading is enabled by the context.
void disableMultithreading (bool disable=true)
 Set the flag specifying if multi-threading is disabled by the context.
void enableMultithreading (bool enable=true)
bool isThreadSafeLockingEnabled ()
 Return true if thread-safe locking is enabled for context access.
void enableThreadSafeLocking ()
 Enable thread-safe locking for context access, including uniquing types, attributes, affine expressions, and operation names.
void setThreadPool (llvm::ThreadPoolInterface &pool)
 Set a new thread pool to be used in this context.
unsigned getNumThreads ()
 Return the number of threads used by the thread pool in this context.
llvm::ThreadPoolInterface & getThreadPool ()
 Return the thread pool used by this context.
bool shouldPrintOpOnDiagnostic ()
 Return true if we should attach the operation to diagnostics emitted via Operation::emit.
void printOpOnDiagnostic (bool enable)
 Set the flag specifying if we should attach the operation to diagnostics emitted via Operation::emit.
bool shouldPrintStackTraceOnDiagnostic ()
 Return true if we should attach the current stacktrace to diagnostics when emitted.
void printStackTraceOnDiagnostic (bool enable)
 Set the flag specifying if we should attach the current stacktrace when emitting diagnostics.
ArrayRef< RegisteredOperationName > getRegisteredOperations ()
 Return a sorted array containing the information about all registered operations.
ArrayRef< RegisteredOperationName > getRegisteredOperationsByDialect (StringRef dialectName)
 Return a sorted array containing the information for registered operations filtered by dialect name.
bool isOperationRegistered (StringRef name)
 Return true if this operation name is registered in this context.
MLIRContextImpl & getImpl ()
const MLIRContextImpl & getImpl () const
DiagnosticEngine & getDiagEngine ()
 Returns the diagnostic engine for this context.
remark::detail::RemarkEngine * getRemarkEngine ()
 Returns the remark engine for this context, or nullptr if none has been set.
void setRemarkEngine (std::unique_ptr< remark::detail::RemarkEngine > engine)
 Set the remark engine for this context.
StorageUniquer & getAffineUniquer ()
 Returns the storage uniquer used for creating affine constructs.
StorageUniquer & getTypeUniquer ()
 Returns the storage uniquer used for constructing type storage instances.
StorageUniquer & getAttributeUniquer ()
 Returns the storage uniquer used for constructing attribute storage instances.
void enterMultiThreadedExecution ()
 These APIs are tracking whether the context will be used in a multithreading environment: this has no effect other than enabling assertions on misuses of some APIs.
void exitMultiThreadedExecution ()
Dialect * getOrLoadDialect (StringRef dialectNamespace, TypeID dialectID, function_ref< std::unique_ptr< Dialect >()> ctor)
 Get a dialect for the provided namespace and TypeID: abort the program if a dialect exist for this namespace with different TypeID.
llvm::hash_code getRegistryHash ()
 Returns a hash of the registry of the context that may be used to give a rough indicator of if the state of the context registry has changed.
void registerActionHandler (HandlerTy handler)
 Register a handler for handling actions that are dispatched through this context.
const HandlerTy & getActionHandler () const
 Return a reference to the currently registered action handler.
HandlerTy & getActionHandler ()
bool hasActionHandler ()
 Return true if a valid ActionHandler is set.
void executeAction (function_ref< void()> actionFn, const tracing::Action &action)
 Dispatch the provided action to the handler if any, or just execute it.
template<typename ActionTy, typename... Args>
void executeAction (function_ref< void()> actionFn, ArrayRef< IRUnit > irUnits, Args &&...args)
 Dispatch the provided action to the handler if any, or just execute it.

Detailed Description

MLIRContext is the top-level object for a collection of MLIR operations.

It holds immortal uniqued objects like types, and the tables used to unique them.

MLIRContext gets a redundant "MLIR" prefix because otherwise it ends up with a very generic name ("Context") and because it is uncommon for clients to interact with it.

The context wrap some multi-threading facilities, and in particular by default it will implicitly create a thread pool. This can be undesirable if multiple context exists at the same time or if a process will be long-lived and create and destroy contexts. To control better thread spawning, an externally owned ThreadPool can be injected in the context. For example:

llvm::DefaultThreadPool myThreadPool; while (auto *request = nextCompilationRequests()) { MLIRContext ctx(registry, MLIRContext::Threading::DISABLED); ctx.setThreadPool(myThreadPool); processRequest(request, ctx); }

Clients that manage their own threads can enable thread-safe context access without creating a thread pool or enabling parallel execution within MLIR. Required dialects must be loaded before accessing the context concurrently:

MLIRContext ctx(registry, MLIRContext::Threading::DISABLED); ctx.enableThreadSafeLocking();

Definition at line 71 of file MLIRContext.h.

Member Typedef Documentation

◆ HandlerTy

Initial value:
std::function<void(function_ref<void()>, const tracing::Action &)>
An action is a specific action that is to be taken by the compiler, that can be toggled and controlle...
Definition Action.h:38
llvm::function_ref< Fn > function_ref
Definition LLVM.h:155

Signatures for the action handler that can be registered with the context.

Definition at line 345 of file MLIRContext.h.

Member Enumeration Documentation

◆ Threading

enum class mlir::MLIRContext::Threading
strong
Enumerator
DISABLED 
ENABLED 

Definition at line 73 of file MLIRContext.h.

Constructor & Destructor Documentation

◆ MLIRContext() [1/2]

MLIRContext::MLIRContext ( Threading multithreading = Threading::ENABLED)
explicit

◆ MLIRContext() [2/2]

MLIRContext::MLIRContext ( const DialectRegistry & registry,
Threading multithreading = Threading::ENABLED )
explicit

Types. Floating-point Types.

Index Type.

Integer Types.

None Type.

of the above types internally. Unknown Location Attribute.

Bool Attributes.

Unit Attribute.

The empty dictionary attribute.

The empty string attribute.

Definition at line 319 of file MLIRContext.cpp.

References mlir::DialectRegistry::appendTo(), clOptions, ENABLED, mlir::detail::AttributeUniquer::get(), mlir::detail::TypeUniquer::get(), getOrLoadDialect(), and isThreadingGloballyDisabled().

◆ ~MLIRContext()

MLIRContext::~MLIRContext ( )

Definition at line 387 of file MLIRContext.cpp.

Member Function Documentation

◆ allowsUnregisteredDialects()

bool MLIRContext::allowsUnregisteredDialects ( )
nodiscard

Return true if we allow to create operation for unregistered dialects.

Definition at line 615 of file MLIRContext.cpp.

Referenced by doVerifyRoundTrip().

◆ allowUnregisteredDialects()

void MLIRContext::allowUnregisteredDialects ( bool allow = true)

Enables creating operations in unregistered dialects.

This option is heavily discouraged: it is convenient during testing but it is not a good practice to use it in production code. Some system invariants can be broken (like loading a dialect after creating operations) without being caught by assertions or other means.

Definition at line 619 of file MLIRContext.cpp.

Referenced by mlir::lsp::MLIRServer::convertFromBytecode(), doVerifyRoundTrip(), mlir::mlirQueryMain(), mlir::mlirReduceMain(), and mlirTranslateMainImpl().

◆ appendDialectRegistry()

◆ beginTransientScope()

void MLIRContext::beginTransientScope ( )

Begins a transient scope on the context, freezing the current state (all loaded dialects, registered operations, types, attributes, affine expressions, and singletons) as the base state.

Subsequent types, attributes, and expressions allocated will belong to the transient layer.

Preconditions:

  • The context must not already be in a transient scope.
  • Must be called from a single-threaded execution context.
  • Loading dialects, modifying dialect registries, or mutating base storage instances is not supported while in a transient scope.

Definition at line 711 of file MLIRContext.cpp.

References mlir::MLIRContextImpl::affineUniquer, mlir::MLIRContextImpl::attributeUniquer, mlir::detail::DistinctAttributeAllocator::beginTransientScope(), mlir::StorageUniquer::beginTransientScope(), mlir::MLIRContextImpl::dialectReferencingStrAttrs, mlir::MLIRContextImpl::dialectRefStrAttrMutex, mlir::MLIRContextImpl::distinctAttributeAllocator, getImpl(), mlir::MLIRContextImpl::multiThreadedExecutionContext, mlir::MLIRContextImpl::operationInfoMutex, mlir::MLIRContextImpl::transientState, mlir::MLIRContextImpl::typeUniquer, and mlir::MLIRContextImpl::unregisteredOperationsByName.

◆ disableMultithreading()

void MLIRContext::disableMultithreading ( bool disable = true)

Set the flag specifying if multi-threading is disabled by the context.

Return true if multi-threading is enabled by the context.

Enabling multi-threading also enables thread-safe locking. Disabling it also disables thread-safe locking, which can be re-enabled independently with enableThreadSafeLocking(). The command line debugging flag --mlir-disable-threading is overriding this call and making it a no-op!

Set the flag specifying if multi-threading is disabled by the context.

Definition at line 632 of file MLIRContext.cpp.

References isThreadingGloballyDisabled().

Referenced by mlir::PassReproducerOptions::apply(), enableMultithreading(), and performActions().

◆ enableMultithreading()

void mlir::MLIRContext::enableMultithreading ( bool enable = true)
inline

Definition at line 215 of file MLIRContext.h.

References disableMultithreading().

Referenced by performActions(), and setThreadPool().

◆ enableThreadSafeLocking()

void MLIRContext::enableThreadSafeLocking ( )

Enable thread-safe locking for context access, including uniquing types, attributes, affine expressions, and operation names.

This does not create a thread pool or change isMultithreadingEnabled(). For example, clients using their own threads can construct a context with Threading::DISABLED and then call enableThreadSafeLocking().

Disabling multi-threading also disables locking. This method must be called when no other threads are accessing the context. Dialects must still be loaded before accessing the context concurrently. Unlike enableMultithreading(), this is not overridden by the debugging flag –mlir-disable-threading.

Definition at line 670 of file MLIRContext.cpp.

◆ endTransientScope()

void MLIRContext::endTransientScope ( )

Ends the transient scope and resets the context to the base state, pruning all types, attributes, affine expressions, distinct attributes, and unregistered operations created during the transient scope.

Preconditions:

  • The context must be in a transient scope.
  • There must be no remaining IR (operations, blocks, regions, values) referencing the transient types/attributes.
  • Must be called from a single-threaded execution context.

Definition at line 742 of file MLIRContext.cpp.

References mlir::MLIRContextImpl::affineUniquer, mlir::MLIRContextImpl::attributeUniquer, mlir::MLIRContextImpl::dialectReferencingStrAttrs, mlir::MLIRContextImpl::dialectRefStrAttrMutex, mlir::MLIRContextImpl::distinctAttributeAllocator, mlir::detail::DistinctAttributeAllocator::endTransientScope(), mlir::StorageUniquer::endTransientScope(), getImpl(), mlir::MLIRContextImpl::multiThreadedExecutionContext, mlir::MLIRContextImpl::operationInfoMutex, mlir::MLIRContextImpl::transientState, mlir::MLIRContextImpl::typeUniquer, and mlir::MLIRContextImpl::unregisteredOperationsByName.

◆ enterMultiThreadedExecution()

void MLIRContext::enterMultiThreadedExecution ( )

These APIs are tracking whether the context will be used in a multithreading environment: this has no effect other than enabling assertions on misuses of some APIs.

Definition at line 700 of file MLIRContext.cpp.

◆ executeAction() [1/2]

template<typename ActionTy, typename... Args>
void mlir::MLIRContext::executeAction ( function_ref< void()> actionFn,
ArrayRef< IRUnit > irUnits,
Args &&... args )
inline

Dispatch the provided action to the handler if any, or just execute it.

Definition at line 371 of file MLIRContext.h.

References hasActionHandler().

◆ executeAction() [2/2]

void mlir::MLIRContext::executeAction ( function_ref< void()> actionFn,
const tracing::Action & action )
inline

Dispatch the provided action to the handler if any, or just execute it.

Definition at line 361 of file MLIRContext.h.

References hasActionHandler().

Referenced by applyConversion(), mlir::PatternApplicator::matchAndRewrite(), and mlir::walkAndApplyPatterns().

◆ exitMultiThreadedExecution()

void MLIRContext::exitMultiThreadedExecution ( )

Definition at line 705 of file MLIRContext.cpp.

◆ getActionHandler() [1/2]

MLIRContext::HandlerTy & MLIRContext::getActionHandler ( )

Definition at line 404 of file MLIRContext.cpp.

References mlir::MLIRContextImpl::actionHandler, and getImpl().

◆ getActionHandler() [2/2]

const MLIRContext::HandlerTy & MLIRContext::getActionHandler ( ) const

Return a reference to the currently registered action handler.

Its target can be used to gain access to the handler's state, if any.

Definition at line 400 of file MLIRContext.cpp.

References mlir::MLIRContextImpl::actionHandler, and getImpl().

◆ getAffineUniquer()

StorageUniquer & MLIRContext::getAffineUniquer ( )

Returns the storage uniquer used for creating affine constructs.

Definition at line 1317 of file MLIRContext.cpp.

References mlir::OperationName::getImpl().

Referenced by mlir::AffineExpr::ceilDiv(), mlir::AffineExpr::floorDiv(), mlir::AffineExpr::operator%(), and mlir::AffineExpr::operator*().

◆ getAttributeUniquer()

StorageUniquer & MLIRContext::getAttributeUniquer ( )

Returns the storage uniquer used for constructing attribute storage instances.

This should not be used directly.

Definition at line 1256 of file MLIRContext.cpp.

References mlir::OperationName::getImpl().

Referenced by mlir::detail::AttributeUniquer::getWithTypeID(), mlir::detail::AttributeUniquer::getWithTypeID(), mlir::detail::AttributeUniquer::mutate(), and mlir::detail::AttributeUniquer::registerAttribute().

◆ getAvailableDialects()

std::vector< StringRef > MLIRContext::getAvailableDialects ( )

Return information about all available dialects in the registry in this context.

Definition at line 473 of file MLIRContext.cpp.

References result.

Referenced by loadAllAvailableDialects(), and mlir::translateLLVMIRToModule().

◆ getDiagEngine()

DiagnosticEngine & MLIRContext::getDiagEngine ( )

Returns the diagnostic engine for this context.

Definition at line 422 of file MLIRContext.cpp.

References mlir::MLIRContextImpl::diagEngine, and getImpl().

Referenced by emitDiag(), and mlir::detail::ParallelDiagnosticHandlerImpl::ParallelDiagnosticHandlerImpl().

◆ getDialectRegistry()

const DialectRegistry & MLIRContext::getDialectRegistry ( )

Return the dialect registry associated with this context.

Definition at line 457 of file MLIRContext.cpp.

Referenced by doVerifyRoundTrip(), and roundTripModule().

◆ getImpl() [1/2]

◆ getImpl() [2/2]

const MLIRContextImpl & mlir::MLIRContext::getImpl ( ) const
inline

Definition at line 295 of file MLIRContext.h.

◆ getLoadedDialect() [1/2]

template<typename T>
T * mlir::MLIRContext::getLoadedDialect ( )
inline

Get a registered IR dialect for the given derived dialect type.

The derived type must provide a static 'getDialectNamespace' method.

Definition at line 101 of file MLIRContext.h.

References getLoadedDialect().

Referenced by getLoadedDialect(), and getOrLoadDialect().

◆ getLoadedDialect() [2/2]

◆ getLoadedDialects()

std::vector< Dialect * > MLIRContext::getLoadedDialects ( )

Return information about all IR dialects loaded in the context.

Return information about all registered IR dialects.

Definition at line 462 of file MLIRContext.cpp.

References result.

Referenced by mlir::DialectRegistry::applyExtensions(), and mlir::detail::DialectInterfaceCollectionBase::DialectInterfaceCollectionBase().

◆ getNumThreads()

unsigned MLIRContext::getNumThreads ( )

Return the number of threads used by the thread pool in this context.

The number of computed hardware threads can change over the lifetime of a process based on affinity changes, so users should use the number of threads actually in the thread pool for dispatching work. Returns 1 if multithreading is disabled.

Definition at line 682 of file MLIRContext.cpp.

References isMultithreadingEnabled().

◆ getOrLoadDialect() [1/3]

◆ getOrLoadDialect() [2/3]

Dialect * MLIRContext::getOrLoadDialect ( StringRef dialectNamespace,
TypeID dialectID,
function_ref< std::unique_ptr< Dialect >()> ctor )

Get a dialect for the provided namespace and TypeID: abort the program if a dialect exist for this namespace with different TypeID.

If a dialect has not been loaded for this namespace/TypeID yet, use the provided ctor to create one on the fly and load it. Returns a pointer to the dialect owned by the context. The use of this method is in general discouraged in favor of 'getOrLoadDialect<DialectClass>()'.

Returns a pointer to the dialect owned by the context.

Definition at line 501 of file MLIRContext.cpp.

References getImpl(), and mlir::detail::StringAttrStorage::referencedDialect.

◆ getOrLoadDialect() [3/3]

Dialect * MLIRContext::getOrLoadDialect ( StringRef name)

Get (or create) a dialect for the given derived dialect name.

The dialect will be loaded from the registry if no dialect is found. If no dialect is loaded for this name and none is available in the registry, returns nullptr.

Definition at line 488 of file MLIRContext.cpp.

References getLoadedDialect().

◆ getOrLoadDynamicDialect()

DynamicDialect * MLIRContext::getOrLoadDynamicDialect ( StringRef dialectNamespace,
function_ref< void(DynamicDialect *)> ctor )

Get (or create) a dynamic dialect for the given name.

Definition at line 566 of file MLIRContext.cpp.

References getImpl(), and getOrLoadDialect().

Referenced by mlir::DialectRegistry::insertDynamic(), and loadEmptyDialects().

◆ getRegisteredOperations()

ArrayRef< RegisteredOperationName > MLIRContext::getRegisteredOperations ( )

Return a sorted array containing the information about all registered operations.

Return information about all registered operations.

Definition at line 831 of file MLIRContext.cpp.

◆ getRegisteredOperationsByDialect()

ArrayRef< RegisteredOperationName > MLIRContext::getRegisteredOperationsByDialect ( StringRef dialectName)

Return a sorted array containing the information for registered operations filtered by dialect name.

Return information for registered operations by dialect.

Definition at line 837 of file MLIRContext.cpp.

◆ getRegistryHash()

llvm::hash_code MLIRContext::getRegistryHash ( )

Returns a hash of the registry of the context that may be used to give a rough indicator of if the state of the context registry has changed.

The context registry correlates to loaded dialects and their entities (attributes, operations, types, etc.).

Definition at line 605 of file MLIRContext.cpp.

References hash().

◆ getRemarkEngine()

◆ getThreadPool()

llvm::ThreadPoolInterface & MLIRContext::getThreadPool ( )

Return the thread pool used by this context.

This method requires that multithreading be enabled within the context, and should generally not be used directly. Users should instead prefer the threading utilities within Threading.h.

Definition at line 692 of file MLIRContext.cpp.

References isMultithreadingEnabled().

Referenced by mlir::failableParallelForEachWithWorkerId().

◆ getTypeUniquer()

StorageUniquer & MLIRContext::getTypeUniquer ( )

Returns the storage uniquer used for constructing type storage instances.

This should not be used directly.

Definition at line 1169 of file MLIRContext.cpp.

References mlir::OperationName::getImpl().

Referenced by mlir::detail::TypeUniquer::getWithTypeID(), mlir::detail::TypeUniquer::getWithTypeID(), mlir::detail::TypeUniquer::mutate(), and mlir::detail::TypeUniquer::registerType().

◆ hasActionHandler()

bool MLIRContext::hasActionHandler ( )

Return true if a valid ActionHandler is set.

Definition at line 415 of file MLIRContext.cpp.

References mlir::MLIRContextImpl::actionHandler, and getImpl().

Referenced by executeAction(), and executeAction().

◆ isInTransientScope()

bool MLIRContext::isInTransientScope ( ) const

Returns true if the context is currently in a transient scope.

Definition at line 796 of file MLIRContext.cpp.

References getImpl(), and mlir::MLIRContextImpl::transientState.

◆ isMultithreadingEnabled()

bool mlir::MLIRContext::isMultithreadingEnabled ( )
inline

Return true if multi-threading is enabled by the context.

This controls parallel execution within MLIR. Use isThreadSafeLockingEnabled() to query locking for context access.

Definition at line 205 of file MLIRContext.h.

Referenced by mlir::applyPassManagerCLOptions(), mlir::failableParallelForEachWithWorkerId(), getNumThreads(), getThreadPool(), mlir::detail::PassCrashReproducerGenerator::initialize(), performActions(), and setThreadPool().

◆ isOperationRegistered()

bool MLIRContext::isOperationRegistered ( StringRef name)

Return true if this operation name is registered in this context.

Definition at line 858 of file MLIRContext.cpp.

References mlir::RegisteredOperationName::lookup().

◆ isThreadSafeLockingEnabled()

bool mlir::MLIRContext::isThreadSafeLockingEnabled ( )
inline

Return true if thread-safe locking is enabled for context access.

This does not imply that parallel execution within MLIR is enabled.

Definition at line 224 of file MLIRContext.h.

Referenced by mlir::OperationName::OperationName().

◆ loadAllAvailableDialects()

void MLIRContext::loadAllAvailableDialects ( )

Load all dialects available in the registry in this context.

Definition at line 600 of file MLIRContext.cpp.

References getAvailableDialects(), and getOrLoadDialect().

Referenced by roundTripModule(), and mlir::translateLLVMIRToModule().

◆ loadDialect() [1/2]

◆ loadDialect() [2/2]

template<typename Dialect, typename OtherDialect, typename... MoreDialects>
void mlir::MLIRContext::loadDialect ( )
inline

Load a list dialects in the context.

Definition at line 127 of file MLIRContext.h.

References loadDialect().

◆ printOpOnDiagnostic()

void MLIRContext::printOpOnDiagnostic ( bool enable)

Set the flag specifying if we should attach the operation to diagnostics emitted via Operation::emit.

Definition at line 808 of file MLIRContext.cpp.

Referenced by mlirTranslateMainImpl().

◆ printStackTraceOnDiagnostic()

void MLIRContext::printStackTraceOnDiagnostic ( bool enable)

Set the flag specifying if we should attach the current stacktrace when emitting diagnostics.

Definition at line 823 of file MLIRContext.cpp.

◆ registerActionHandler()

void MLIRContext::registerActionHandler ( HandlerTy handler)

Register a handler for handling actions that are dispatched through this context.

A nullptr handler can be set to disable a previously set handler.

Definition at line 396 of file MLIRContext.cpp.

References mlir::MLIRContextImpl::actionHandler, and getImpl().

Referenced by mlir::tracing::InstallDebugHandler::Impl::Impl().

◆ setRemarkEngine()

void MLIRContext::setRemarkEngine ( std::unique_ptr< remark::detail::RemarkEngine > engine)

Set the remark engine for this context.

Definition at line 428 of file MLIRContext.cpp.

References getImpl(), and mlir::MLIRContextImpl::remarkEngine.

◆ setThreadPool()

void MLIRContext::setThreadPool ( llvm::ThreadPoolInterface & pool)

Set a new thread pool to be used in this context.

This method requires that multithreading is disabled for this context prior to the call. This allows to share a thread pool across multiple contexts, as well as decoupling the lifetime of the threads from the contexts. The thread pool must outlive the context. Multi-threading will be enabled as part of this method. The command line debugging flag --mlir-disable-threading will still prevent threading from being enabled and threading won't be enabled after this call in this case.

Definition at line 674 of file MLIRContext.cpp.

References enableMultithreading(), and isMultithreadingEnabled().

◆ shouldPrintOpOnDiagnostic()

bool MLIRContext::shouldPrintOpOnDiagnostic ( )

Return true if we should attach the operation to diagnostics emitted via Operation::emit.

Definition at line 802 of file MLIRContext.cpp.

◆ shouldPrintStackTraceOnDiagnostic()

bool MLIRContext::shouldPrintStackTraceOnDiagnostic ( )

Return true if we should attach the current stacktrace to diagnostics when emitted.

Definition at line 817 of file MLIRContext.cpp.

Referenced by emitDiag().


The documentation for this class was generated from the following files: