MLIR: lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp File Reference (original) (raw)
Go to the source code of this file.
Namespaces |
---|
Macros | |
---|---|
#define | GEN_PASS_DEF_ASYNCTOASYNCRUNTIMEPASS |
#define | GEN_PASS_DEF_ASYNCFUNCTOASYNCRUNTIMEPASS |
#define | DEBUG_TYPE "async-to-async-runtime" |
Functions | |
---|---|
static CoroMachinery | setupCoroMachinery (func::FuncOp func) |
Utility to partially update the regular function CFG to the coroutine CFG compatible with LLVM coroutines switched-resume lowering using async.runtime. More... | |
static Block * | setupSetErrorBlock (CoroMachinery &coro) |
static std::pair< func::FuncOp, CoroMachinery > | outlineExecuteOp (SymbolTable &symbolTable, ExecuteOp execute) |
Outline the body region attached to the async.execute op into a standalone function. More... | |
Variables | |
---|---|
static constexpr const char | kAsyncFnPrefix [] = "async_execute_fn" |
◆ DEBUG_TYPE
#define DEBUG_TYPE "async-to-async-runtime"
◆ GEN_PASS_DEF_ASYNCFUNCTOASYNCRUNTIMEPASS
#define GEN_PASS_DEF_ASYNCFUNCTOASYNCRUNTIMEPASS
◆ GEN_PASS_DEF_ASYNCTOASYNCRUNTIMEPASS
#define GEN_PASS_DEF_ASYNCTOASYNCRUNTIMEPASS
◆ FuncCoroMapPtr
◆ outlineExecuteOp()
static std::pair<func::FuncOp, CoroMachinery> outlineExecuteOp ( SymbolTable & symbolTable, ExecuteOp execute ) | static |
---|
Outline the body region attached to the async.execute
op into a standalone function.
Note that this is not reversible transformation.
Definition at line 297 of file AsyncToAsyncRuntime.cpp.
References mlir::ImplicitLocOpBuilder::atBlockBegin(), mlir::async::cloneConstantsIntoTheRegion(), mlir::ImplicitLocOpBuilder::create(), mlir::get(), mlir::Value::getType(), mlir::getUsedValuesDefinedAbove(), mlir::SymbolTable::insert(), kAsyncFnPrefix, mlir::IRMapping::map(), mlir::SymbolTable::Private, mlir::SymbolTable::setSymbolVisibility(), and setupCoroMachinery().
◆ setupCoroMachinery()
static CoroMachinery setupCoroMachinery ( func::FuncOp func) | static |
---|
Utility to partially update the regular function CFG to the coroutine CFG compatible with LLVM coroutines switched-resume lowering using async.runtime.
* and async.coro.*
operations. Adds a new entry block that branches into preexisting entry block. Also inserts trailing blocks.
The result types of the passed func
start with an optional async.token
and be continued with some number of async.value
s.
See LLVM coroutines documentation: https://llvm.org/docs/Coroutines.html
entry
block sets up the coroutine.set_error
block sets completion token and async values state to error.cleanup
block cleans up the coroutine state.- `suspend block after the @llvm.coro.end() defines what value will be returned to the initial caller of a coroutine. Everything before the @llvm.coro.end() will be executed at every suspension point.
Coroutine structure (only the important bits):
func @some_fn() -> (!async.token, !async.value) { ^entry(): token = : !async.token // create async runtime token value = : !async.value // create async value id = async.coro.getId // create a coroutine id hdl = async.coro.begin id // create a coroutine handle cf.br ^preexisting_entry_block
/* preexisting blocks modified to branch to the cleanup block */
^set_error: // this block created lazily only if needed (see code below) async.runtime.set_error token : !async.token async.runtime.set_error value : !async.value cf.br ^cleanup
^cleanup: async.coro.free hdl // delete the coroutine state cf.br ^suspend
^suspend: async.coro.end hdl // marks the end of a coroutine return token, value : !async.token, !async.value }
Definition at line 172 of file AsyncToAsyncRuntime.cpp.
References mlir::ImplicitLocOpBuilder::atBlockBegin(), mlir::Block::front(), mlir::get(), mlir::Block::getOperations(), and mlir::Block::splitBlock().
Referenced by outlineExecuteOp().
◆ setupSetErrorBlock()
static Block* setupSetErrorBlock ( CoroMachinery & coro) | static |
---|
◆ kAsyncFnPrefix
constexpr const char kAsyncFnPrefix[] = "async_execute_fn" | staticconstexpr |
---|