Beaver.Slang behaviour (beaver v0.4.8)

Copy Markdown

Defines extensible MLIR dialects in Elixir and compiles their schemas to IRDL.

Slang supports named type and attribute parameters, named operation operands, results, attributes and regions, reusable constraints, any_of, all_of and base constraints, and optional or variadic operands and results. Built-in dynamic operation traits can be attached when the dialect is loaded.

Schema construction and runtime interface attachment are separate: __slang_dialect__/1 builds the inspectable IRDL module, while load/2 verifies and registers that module before attaching traits. See the Slang guide for a complete dialect and the supported syntax.

Summary

Functions

This macro is invoked when the module is used. It sets up the module by registering attributes and importing macros from Beaver.Slang.

Generates an irdl.all_of constraint.

This macro generates the AST for the irdl.any op.

This macro generates the AST for the any_of attribute in the dialect.

Generates an irdl.base constraint from a base name or a Slang type/attribute.

Defines a reusable named constraint.

This macro defines a attribute in the dialect.

Defines a reusable named constraint.

This macro defines an operation in the dialect. It generates the AST for the creator function for the operation.

This macro defines a type in the dialect.

This macro generates the AST for irdl.is op, usually used to create a constraint on type

This function loads the MLIR dialect into the MLIR context. It invokes the internal function of the provided module to create the dialect's IRDL module and performs additional MLIR transformations and verification.

Marks an operand or result constraint as optional.

Marks an operand or result constraint as a required singleton.

Marks an operand or result constraint as variadic.

Functions

__using__(opts)

(macro)

This macro is invoked when the module is used. It sets up the module by registering attributes and importing macros from Beaver.Slang.

all_of(types)

(macro)

Generates an irdl.all_of constraint.

any()

(macro)

This macro generates the AST for the irdl.any op.

any_of(types)

(macro)

This macro generates the AST for the any_of attribute in the dialect.

base(base)

(macro)

Generates an irdl.base constraint from a base name or a Slang type/attribute.

Base names use upstream IRDL spelling such as "!builtin.integer" or "#builtin.string".

defalias(call, block)

(macro)

Defines a reusable named constraint.

defalias is retained as a concise spelling of defconstraint.

defattr(call, opts \\ [])

(macro)

This macro defines a attribute in the dialect.

defconstraint(call, block)

(macro)

Defines a reusable named constraint.

Reference it from another declaration with ^name.

defop(call, block \\ nil)

(macro)

This macro defines an operation in the dialect. It generates the AST for the creator function for the operation.

deftype(call, opts \\ [])

(macro)

This macro defines a type in the dialect.

is(type)

(macro)

This macro generates the AST for irdl.is op, usually used to create a constraint on type

load(ctx, mod)

This function loads the MLIR dialect into the MLIR context. It invokes the internal function of the provided module to create the dialect's IRDL module and performs additional MLIR transformations and verification.

optional(constraint)

(macro)

Marks an operand or result constraint as optional.

single(constraint)

(macro)

Marks an operand or result constraint as a required singleton.

variadic(constraint)

(macro)

Marks an operand or result constraint as variadic.