Beaver.MLIR.Value (beaver v0.4.8)

Copy Markdown

This module handles MLIR values, which represent SSA (Static Single Assignment) values in the IR.

Values can be either block arguments or operation results. That's why this module provides functions to check if a value is an argument or a result (argument?/1, result?/1), or to get the owner of a result (owner/1).

Conditional use replacement runs its native traversal on an MLIR worker thread and dispatches each use to the calling BEAM process through Kinda.CallbackRuntime.

Summary

Functions

Return the defining op of this value if this value is a result

Return the defining op of this value. Raises if this value is not a result

Replaces uses of value for which predicate returns true.

Returns true if the value is a result of an operation.

Return the type of this value

Types

t()

@type t() :: %Beaver.MLIR.Value{ref: term()}

Functions

argument?(value)

make(value)

owner(value)

Return the defining op of this value if this value is a result

owner!(value)

Return the defining op of this value. Raises if this value is not a result

replace_uses_with_if(value1, value2, predicate)

@spec replace_uses_with_if(t(), t(), (Beaver.MLIR.OpOperand.t() -> boolean())) :: :ok

Replaces uses of value for which predicate returns true.

The predicate receives an Beaver.MLIR.OpOperand and executes in the calling BEAM process. Native traversal runs outside the scheduler and waits through Kinda's resource-backed callback runtime. The source and replacement values must belong to the same multithreaded MLIR context.

Predicate exceptions are re-raised with their original stacktrace after the native traversal stops. This operation is not transactional: replacements accepted before an exception remain applied.

result?(value)

Returns true if the value is a result of an operation.

type(value)

Return the type of this value