Beaver.MLIR.Dialect.CF (beaver v0.4.8)

Copy Markdown

This module defines functions for Ops in CF dialect.

Summary

Functions

Return op name cf.assert as a bitstring.

cf.assert - Assert operation with message attribute

Return op name cf.br as a bitstring.

cf.br - Branch operation

Return op name cf.cond_br as a bitstring.

Create cf.cond_br op. Passing atom will lead to defer the creation of this terminator.

Return op name cf.switch as a bitstring.

cf.switch - Switch operation

Functions

assert()

Return op name cf.assert as a bitstring.

assert(ssa)

cf.assert - Assert operation with message attribute

Attributes

  • msg - Single, StrAttr, string attribute

Operands

  • arg - Single, I1, 1-bit signless integer

Description

Assert operation at runtime with single boolean operand and an error message attribute. If the argument is true this operation has no effect. Otherwise, the program execution will abort. The provided error message may be used by a runtime to propagate the error to the user.

Example:

cf.assert %b, "Expected ... to be true"

br()

Return op name cf.br as a bitstring.

br(ssa)

cf.br - Branch operation

Operands

  • destOperands - Variadic, AnyType, variadic of any non-token type

Description

The cf.br operation represents a direct branch operation to a given block. The operands of this operation are forwarded to the successor block, and the number and type of the operands must match the arguments of the target block.

Example:

^bb2:
  %2 = call @someFn()
  cf.br ^bb3(%2 : tensor<*xf32>)
^bb3(%3: tensor<*xf32>):

cond_br()

Return op name cf.cond_br as a bitstring.

cond_br(ssa)

Create cf.cond_br op. Passing atom will lead to defer the creation of this terminator.

switch()

Return op name cf.switch as a bitstring.

switch(ssa)

cf.switch - Switch operation

Attributes

  • case_values - Optional, AnyIntElementsAttr, integer elements attribute
  • case_operand_segments - Single, DenseI32ArrayAttr, i32 dense array attribute

Operands

  • flag - Single, AnyInteger, integer
  • defaultOperands - Variadic, AnyType, variadic of any non-token type
  • caseOperands - Variadic, AnyType, variadic of any non-token type

Description

The cf.switch terminator operation represents a switch on a signless integer value. If the flag matches one of the specified cases, then the corresponding destination is jumped to. If the flag does not match any of the cases, the default destination is jumped to. The count and types of operands must align with the arguments in the corresponding target blocks.

Example:

cf.switch %flag : i32, [
  default: ^bb1(%a : i32),
  42: ^bb1(%b : i32),
  43: ^bb3(%c : i32)
]