3. Syntax#

Tile IR is intended to be constructed using the Tile IR MLIR dialect and stored as bytecode. For human understanding we provide a human-readable syntax based on the MLIR dialect with certain printing and parsing simplifications to standardize it for reading and comprehension. This representation is not intended to be used for writing Tile IR programs but is rather a tool for users to understand the Tile IR IR. To that end we make no stability guarantees on the format of this syntax.

With that said we will do our best effort to ensure that the human-readable syntax is stable for the duration of the Tile IR project but we reserve the right to make changes, or introduce small changes due to upstream MLIR evolution.

3.1. Module#

A Tile IR program consists of a Tile IR module which contains a series of items.

cuda_tile.module @symbol_name {
    <items>*
}

3.2. Items#

An item is a kernel definition or a global variable definition.

symbol_name := `@` identifier
ssa_name := `%` identifier

module ::= `cuda_tile.module` @symbol_name {
    <items>*
}

<items> ::= <kernel_definition> | <global_variable_definition>

<global_variable_definition> ::= `global` <symbol_name> `:` <type> `=` <value>

function_signature ::= <function_parameter>*

function_parameter ::= <ssa_name> `:` <type>

<kernel_definition> ::= `func` @kernel_name `(` <function_signature> `)` `->` <function_type> {
    <kernel_body>
}

3.3. Globals#

A global variable definition is a variable that is defined outside of a kernel.

global_variable_definition ::= `global` <symbol_name> `:` <type> `=` <value>

3.4. Kernels#

A kernel definition is a function that is defined inside a Tile IR module.

A kernel definition’s body is a sequence of operations.

kernel_body ::= <operation>*

operation ::= (ssa_name `,`?)* `=` <operation_name> <ssa_name>* attribute=attribute_value : type ...

3.5. Types#

A type in Tile IR is a fixed pre-defined set of types.

element_type ::= `f32` | `f64` | `i8` | `i16` | `i32` | `i64` | `b8` | `b16` | `b32` | `b64`

type ::= `tile` `<` shape `x` element_type `>`

shape ::= `[` integer_literal (`x` integer_literal)* `]`