4. Syntax#
Tile IR is constructed as an MLIR dialect and is normally distributed in the stable binary format described in Binary Format. For inspection, testing, and compiler development, the dialect also provides a human-readable MLIR syntax. This textual form is unstable: it may change without the compatibility guarantees of the bytecode format and is not a distribution format for Tile IR programs.
This chapter introduces the top-level textual structure. The generated Operations and Type System chapters define the complete syntax and constraints for individual operations and types.
4.1. Module#
A program is one cuda_tile.module operation. Its body contains zero or more module-level items: globals and kernel entry points. Experimental or internal language versions may also permit device functions.
cuda_tile.module @module_name {
// Module-level items.
}
Names beginning with @ are symbols. A symbol must be unique within its containing
symbol table.
4.2. Global Variables#
A cuda_tile.global declares a statically initialized allocation in global
memory. The initial value and its tile type are written together; the optional
visibility, constant, and alignment modifiers precede the value.
global @coefficients <f32: [1.0, 2.0, 3.0, 4.0]> : tile<4xf32>
global private constant @flag alignment = 4 <i32: [1]> : tile<1xi32>
See cuda_tile.global for the authoritative grammar and semantics.
4.3. Kernel Entry Points#
A cuda_tile.entry defines a kernel. Kernel arguments are named SSA values
(names beginning with %), and every argument has a rank-0 tile type. Entries do not
return values.
entry @kernel(%base: tile<ptr<f32>>, %count: tile<i32>) {
// Operations in SSA form.
return
}
An operation may consume SSA values, attributes, or symbols and may produce zero or more new SSA values. Each operation’s generated reference entry gives its exact assembly form, operand and result constraints, and examples.
4.4. Types#
The principal value types are tiles, views, and tokens. A tile contains an element type and an optional shape; omitting dimensions produces a rank-0 tile. Pointers are element types and therefore appear inside tiles.
tile<f32> // rank-0 floating-point tile
tile<16x32xi32> // rank-2 integer tile
tile<ptr<f16>> // rank-0 tile containing a typed pointer
tensor_view<?x64xf16, strides=[?, 1]>
token
The supported element types, view parameters, type equivalence rules, and restrictions are specified in Type System.