# `Beaver.MLIR.RewriterBase`

This module defines functions working with MLIR RewriterBase.

# `insertion_position`

```elixir
@type insertion_position() ::
  :current
  | :clear
  | {:before, Beaver.MLIR.Operation.t()}
  | {:after, Beaver.MLIR.Operation.t()}
  | {:after_value, Beaver.MLIR.Value.t()}
  | {:start, Beaver.MLIR.Block.t()}
  | {:end, Beaver.MLIR.Block.t()}
```

# `t`

```elixir
@type t() :: %Beaver.MLIR.RewriterBase{ref: term()}
```

# `block`

# `cancel_op_modification`

# `clear_insertion_point`

# `clone`

# `clone_region_before`

# `clone_with_mapping`

# `clone_without_regions`

# `context`

# `create_block_before`

# `erase_block`

# `erase_op`

# `finalize_op_modification`

# `inline_block_before`

# `inline_region_before`

# `insert`

# `insertion_block`

# `make`

# `merge_blocks`

# `move_block_before`

# `move_op_after`

# `move_op_before`

# `operation_after_insertion`

# `replace`

Syntactic sugar for `replace_all_uses_with/3` and `replace_all_op_uses_with_operation/3`.

# `replace_all_op_uses_with_operation`

# `replace_all_op_uses_with_value_range`

# `replace_all_uses_except`

# `replace_all_uses_with`

# `replace_all_value_range_uses_with`

# `replace_op`

```elixir
@spec replace_op(
  t(),
  Beaver.MLIR.Operation.t(),
  Beaver.MLIR.Operation.t() | Beaver.MLIR.Value.t() | [Beaver.MLIR.Value.t()]
) :: :ok
```

Replaces an operation and erases it through MLIR's rewriter infrastructure.

A replacement can be another operation, one value, or a list of values. The
result counts and types must match before MLIR is called.

# `replace_op_uses_within_block`

# `replace_op_with_operation`

# `replace_op_with_values`

# `restore_insertion_point`

# `save_insertion_point`

# `set_insertion_point_after`

# `set_insertion_point_after_value`

# `set_insertion_point_before`

# `set_insertion_point_to_end`

# `set_insertion_point_to_start`

# `start_op_modification`

# `with_insertion_point`

```elixir
@spec with_insertion_point(t(), (-&gt; result)) :: result when result: var
```

Runs `fun` and restores the current insertion point afterward.

Restoration happens on normal return, throw, exit, and exception.

# `with_insertion_point`

```elixir
@spec with_insertion_point(t(), insertion_position(), (-&gt; result)) :: result
when result: var
```

Temporarily moves the insertion point while running `fun`.

Supported positions are `:clear`, `{:before, operation}`,
`{:after, operation}`, `{:after_value, value}`, `{:start, block}`, and
`{:end, block}`. The previous insertion point is always restored.

