Milo compiles through MLIR with its own dialect, milo. The compiler parses and type-checks Milo, then emits milo dialect IR. milo-opt runs Milo's passes on it (drop elaboration, bounds-check versioning, lowering of structured control flow) and lowers it to LLVM, which produces the binary.
This page is the dialect reference, generated from mlir/Milo.td by mlir-tblgen. The design and milestones are in docs/mlir-backend.md.
Unstable (v0)
Ops and types still change between commits.
'milo' Dialect
Milo's own MLIR dialect: ownership, checks and Vec memory as IR
Milo compiles through MLIR, and this is its dialect. The Milo compiler type-checks the source and emits milo dialect IR (src/emit-mlir.ts); milo-opt, a C++ tool built on upstream MLIR, runs Milo's passes on it and lowers it to the LLVM dialect.
The dialect exists to keep facts that are lost in LLVM IR:
- Ownership: a slot owns a value with drop glue, and the
milo-elaborate-dropspass decides from the IR where each value is dropped. - Checks: a bounds check or a checked arithmetic op is a panic point ordered against element writes, so
milo-version-bounds-checkscan version a loop instead of hoisting the check out of it. - Vec memory: a Vec's header (ptr, len, cap) and its elements are separate memory, so an element store never invalidates a loaded length or data pointer.
Types: ints carry their signedness in the type (si32, ui8), never in an attribute; bool is i1; !milo.ref is a second-class reference (a place that is never stored), !milo.ptr a raw pointer.
Control flow stays structured (milo.if, milo.while, milo.loop, milo.for, milo.match, milo.scope) until milo-lower-structured-cf lowers it to cf branches; break, continue and return may exit any number of them.
The op verifiers define valid milo IR. A complete program also needs the module the Milo compiler emits around it (runtime, globals, the main wrapper), so the dialect is not yet a standalone target for other frontends.
[TOC]
Operations
milo.add (::milo::AddOp)
Integer or float addition
Syntax:
operation ::= `milo.add` $lhs `,` $rhs (`wrapping` $wrapping^)? attr-dict `:` type($result)lhs + rhs. On an int it panics on overflow (in the signedness of the type) unless wrapping, Milo's @wrapping or --no-overflow-checks, which gives two's complement. The panic names the op's location. Floats never trap and never carry wrapping.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
rhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float |
milo.addr (::milo::AddrOp)
The address of a place as a raw pointer
Syntax:
operation ::= `milo.addr` $place attr-dict `:` type($place)x.addrOf() on a place (unsafe): its address as a raw pointer, which may outlive the borrow; what it may then touch is the unsafe code's promise.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
place | the address of a place: a local slot, a field, an element or a Vec by reference: the address of its header |
Results:
| Result | Description |
|---|---|
result | a raw pointer, untyped |
milo.and (::milo::AndOp)
Bitwise and, or logical and on bool
Syntax:
operation ::= `milo.and` $lhs `,` $rhs attr-dict `:` type($result)lhs & rhs on ints, or both bools (the non-short-circuit form; && is a milo.if). Never traps.
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 1-bit signless integer |
rhs | signed integer or unsigned integer or 1-bit signless integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 1-bit signless integer |
milo.array.elem_ref (::milo::ArrayElemRefOp)
Unchecked element place of an array
Syntax:
operation ::= `milo.array.elem_ref` $array `[` $index `]` attr-dict `:` type($array) `->` type($ref)The place of element index of an array place, unchecked.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
array | the address of a place: a local slot, a field, an element |
index | 64-bit signless integer |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.array.index (::milo::ArrayIndexOp)
Checked element place of an array
Syntax:
operation ::= `milo.array.index` $array `[` $index `]` attr-dict `:` type($array) `->` type($ref)a[i] on the place of a fixed-size array: the element's place after legacy's bounds check against the size (genBoundsCheckedPtr; the panic names the op's location). milo-expand-index lowers it to bounds_check and array.elem_ref.
Operands:
| Operand | Description |
|---|---|
array | the address of a place: a local slot, a field, an element |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.arraytail.array (::milo::ArrayTailArrayOp)
The array place of an arraytail slot
Syntax:
operation ::= `milo.arraytail.array` $ref attr-dict `:` type($ref) `->` type($array)The array an arraytail slot holds, as a place: the array is built there, then milo.arraytail.start sets the cursor.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
array | the address of a place: a local slot, a field, an element |
milo.arraytail.start (::milo::ArrayTailStartOp)
Set an arraytail's cursor to its first element
Syntax:
operation ::= `milo.arraytail.start` $ref attr-dict `:` type($ref)The cursor of the arraytail in ref set to 0, after its array was built in place. The emitter follows it with milo.filled.
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.arraytail.take (::milo::ArrayTailTakeOp)
Move the next element out of an arraytail
Syntax:
operation ::= `milo.arraytail.take` $ref `[` $index `]` attr-dict `:` type($ref) `->` type($result)Element index moved out of the arraytail in ref, the cursor set past it. Unchecked, as milo.vectail.take: the loop keeps index below N and in order.
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.arraytail.take_place (::milo::ArrayTailTakePlaceOp)
The place of the next element of an arraytail
Syntax:
operation ::= `milo.arraytail.take_place` $ref `[` $index `]` attr-dict `:` type($ref) `->` type($result)milo.arraytail.take for a place-only element: its place, which the caller copies out of (milo.copy), with the cursor set past it.
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
result | the address of a place: a local slot, a field, an element |
milo.bits (::milo::BitsOp)
A bit intrinsic of an integer
Syntax:
operation ::= `milo.bits` $kind `,` $value (`,` $amount^)? attr-dict `:` type($value) (`,` type($amount)^)? `->` type($result)ctpop, ctlz, cttz count bits of value (defined for 0: the width) and give an si64; bitreverse gives the value's type; fshl / fshr rotate value by amount (taken mod the width), the value's type.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
kind | ::mlir::StringAttr | string attribute |
Operands:
| Operand | Description |
|---|---|
value | signed integer or unsigned integer |
amount | signed integer or unsigned integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer |
milo.bounds_check (::milo::BoundsCheckOp)
Panic unless 0 <= index < len
Syntax:
operation ::= `milo.bounds_check` $index `,` $len attr-dict `:` type($index) `,` type($len)Panics unless 0 <= index < len (one unsigned compare). Reading VecElems pins it after every earlier element store: a task that recovers from the panic observes exactly the writes made before the failing index. The panic names the op's location.
Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Read on ::milo::VecElemsResource, MemoryEffects::Write on ::milo::PanicResource}
Operands:
| Operand | Description |
|---|---|
index | 64-bit signless integer or 64-bit signed integer |
len | 64-bit signless integer or 64-bit signed integer |
milo.break (::milo::BreakOp)
Leave the innermost loop
Syntax:
operation ::= `milo.break` attr-dictLeaves the innermost enclosing milo.while, milo.loop, milo.for or milo.for_in, from any depth of nested regions inside its body (not from a while's cond region). A terminator that is not a region branch: it jumps over the regions between it and its loop.
Traits: Terminator
milo.call_ptr (::milo::CallPtrOp)
A call through a raw code pointer
Syntax:
operation ::= `milo.call_ptr` $callee `(` $args `)` attr-dict `:` functional-type($args, $result)A C function pointer called (extern (..) => R values), a closure's code pointer called with its env (_callClosureVoid), or an interface method from its itable: an indirect call, arguments and result as the dialect's types lower. It may do anything a call does.
Operands:
| Operand | Description |
|---|---|
callee | a raw pointer, untyped |
args | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.cast (::milo::CastOp)
Convert a scalar to another scalar type
Syntax:
operation ::= `milo.cast` $operand attr-dict `:` type($operand) `to` type($result)x as T between scalars. Never traps. Int to int sign- or zero-extends by the source's signedness (bool zero-extends), or truncates. Float to int saturates (NaN is 0). A pointer converts only to or from an integer type.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
operand | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped |
milo.ccall (::milo::CCallOp)
A call of a C function that is variadic
Syntax:
operation ::= `milo.ccall` $callee `(` $args `)` `fixed` $fixed attr-dict `:` functional-type($args, $result)printf(fmt, ...), open(path, flags, ...): the first fixed arguments are the declared ones, the rest go through C's ... as they are (no promotion, as legacy codegen passes them). The callee is declared variadic here.
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
callee | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
fixed | ::mlir::IntegerAttr | 64-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
args | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.check_unaliased (::milo::CheckUnaliasedOp)
Panic if two by-ref arguments are the same place
Syntax:
operation ::= `milo.check_unaliased` $lhs `,` $rhs attr-dict `:` type($lhs) `,` type($rhs)Before a call with two by-ref arguments of which one is &mut: panics if they are the same place. The checker rejects the aliasing it can prove; this is the runtime half, and what makes noalias on a &mut param sound.
Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Write on ::milo::PanicResource}
Operands:
| Operand | Description |
|---|---|
lhs | the address of a place: a local slot, a field, an element or a Vec by reference: the address of its header |
rhs | the address of a place: a local slot, a field, an element or a Vec by reference: the address of its header |
milo.closure (::milo::ClosureOp)
A by-reference closure value
Syntax:
operation ::= `milo.closure` $fn (`(` $captures^ `:` type($captures) `)`)? (`heap` $heap^)? (`static` $staticEnv^)? attr-dict `:` type($result)A by-reference closure literal: fn is its body, a func.func taking (!milo.ptr env, params...), and the env (an entry-block slot of this frame: null drop header, then the captures' addresses in order) lends it every capture in place. The checker keeps such a closure from outliving the frame; no captures means a null env. Not Pure: the body may write any capture whenever the value is called.
heap: the env is malloc'd instead, its drop header free (legacy genClosure's heapEnv, a scoped task's literal: the creating frame returns before the scope joins the task, and the task's reap calls the header). It owns the block and no capture.
static: the env is a module-level global (<fn>_env) instead of a slot: a closure built by a global's initializer, whose frame is gone before the global is called (legacy genClosure's staticEnv). Its captures are globals, already static.
Interfaces: SymbolUserOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
fn | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
heap | ::mlir::UnitAttr | unit attribute |
staticEnv | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
captures | variadic of the address of a place: a local slot, a field, an element or a Vec by reference: the address of its header |
Results:
| Result | Description |
|---|---|
result | a fn value: fn pointer and env |
milo.closure.call (::milo::ClosureCallOp)
Call a fn value
Syntax:
operation ::= `milo.closure.call` $callee `(` $args `)` attr-dict `:` type($callee) (`,` type($args)^)? (`->` type($result)^)?f(args) through a fn value: its fn pointer called with its env first. Unknown code, so no traits.
Interfaces: ArgAndResultAttrsOpInterface, CallOpInterface
Operands:
| Operand | Description |
|---|---|
callee | a fn value: fn pointer and env |
args | variadic of any non-token type |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.cmp (::milo::CmpOp)
Compare two scalars or pointers
Syntax:
operation ::= `milo.cmp` $predicate `,` $lhs `,` $rhs attr-dict `:` type($lhs)Signedness comes from the operand type (bool compares as signed i1, as legacy codegen does). On floats every comparison is ordered except ne, which holds when either side is NaN, so x != x is true for NaN.
Traits: AlwaysSpeculatableImplTrait, SameTypeOperands
Interfaces: ConditionallySpeculatable, InferIntRangeInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
predicate | ::milo::CmpPredicateAttr | comparison |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped |
rhs | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped |
Results:
| Result | Description |
|---|---|
result | 1-bit signless integer |
milo.condition (::milo::ConditionOp)
End the cond region of milo.while
Syntax:
operation ::= `milo.condition` $condition attr-dictEnds the cond region of milo.while: when condition is true the body runs, else the loop exits.
Traits: AlwaysSpeculatableImplTrait, HasParent<WhileOp>, Terminator
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), RegionBranchTerminatorOpInterface
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
condition | 1-bit signless integer |
milo.const (::milo::ConstOp)
An int, float or bool literal
Syntax:
operation ::= `milo.const` $value attr-dictA scalar constant; the attribute's type is the result type (an int carries its signedness, a bool is i1). The dialect's constant materializer makes these for folds.
Traits: AlwaysSpeculatableImplTrait, ConstantLike
Interfaces: ConditionallySpeculatable, InferIntRangeInterface, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
value | ::mlir::TypedAttr | TypedAttr instance |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer |
milo.continue (::milo::ContinueOp)
Restart the innermost loop
Syntax:
operation ::= `milo.continue` attr-dictStarts the next iteration of the innermost enclosing milo.while, milo.loop, milo.for or milo.for_in (the step of a milo.for, the cond of a milo.while), from any depth of nested regions inside its body.
Traits: Terminator
milo.contract_check (::milo::ContractCheckOp)
Panic unless a contract clause holds
Syntax:
operation ::= `milo.contract_check` $cond $kind attr-dictA requires, ensures or invariant clause checked at run time (a contract-checking build): unless cond holds, the program reports the clause kind and the op's location and aborts (legacy emitContractCheck, through the out-of-line __milo_contract_fail).
Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Write on ::milo::PanicResource}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
kind | ::mlir::StringAttr | string attribute |
Operands:
| Operand | Description |
|---|---|
cond | 1-bit signless integer |
milo.copy (::milo::CopyOp)
Copy a struct, enum or array between places
Syntax:
operation ::= `milo.copy` $src `,` $dst attr-dict `:` type($src) `,` type($dst) `of` $elemA T copied from one place to another, as legacy's llvm.memcpy: how a 128+ byte aggregate moves between places without becoming an SSA value (SROA splits a whole aggregate load per element). Either side is a slot (!milo.ref<T>) or a raw pointer to a T. It moves no ownership by itself: an owned source that gives its value up is emptied right after with an unused milo.move, an owned destination is marked milo.filled. The same place on both sides (swap(v[i], v[j]) once CSE merges the two element references) copies nothing.
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
elem | ::mlir::TypeAttr | any type attribute |
Operands:
| Operand | Description |
|---|---|
src | the address of a place: a local slot, a field, an element or a raw pointer, untyped |
dst | the address of a place: a local slot, a field, an element or a raw pointer, untyped |
milo.dbg.var (::milo::DbgVarOp)
Names a slot as a source variable for the debugger (-g only)
Syntax:
operation ::= `milo.dbg.var` $ref `:` type($ref) attr-dictmilo.dbg.var %slot {name = "sum"}: the slot holds the source variable name. Emitted only under -g, so a build without it has none. It writes the slot's resource so no pass drops or reorders it, and it is a user mem2reg cannot promote, which keeps the variable in memory for the debugger. convert-milo-to-llvm keeps the op, with a pointer operand and the DI type of the pointee in di_type; milo-lower-debug-vars (after the function has its DISubprogram) turns it into llvm.intr.dbg.declare.
arg: the 1-based parameter number. fields: struct name to its field names, and enum name to its variant names, for the structs and enums the pointee holds (the dialect's types carry neither).
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
arg | ::mlir::IntegerAttr | 32-bit signless integer attribute |
fields | ::mlir::DictionaryAttr | dictionary of named attribute values |
di_type | ::mlir::Attribute | any attribute |
Operands:
| Operand | Description |
|---|---|
ref | any non-token type |
milo.div (::milo::DivOp)
Integer or float division
Syntax:
operation ::= `milo.div` $lhs `,` $rhs (`wrapping` $wrapping^)? attr-dict `:` type($result)lhs / rhs. An integer divisor of zero always panics, wrapping or not; signed MIN / -1 panics unless wrapping, which yields MIN. Signed division truncates toward zero. Floats follow IEEE and never trap.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
rhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float |
milo.drop (::milo::DropOp)
Run the drop glue of the value in a place
Syntax:
operation ::= `milo.drop` $ref (`if` $flag^)? attr-dict `:` type($ref)The value in the slot dies: its drop glue runs (legacy's, codegen mlirDropHelper). On an owned slot this is "if it holds one" until milo-elaborate-drops decides: it erases the drop where the slot is empty on every path, keeps it where it is full on every path, and gives it the slot's drop flag (if %flag) where that differs by path. A field of an owned slot that a milo.move takes a value out of is tracked the same way, and a drop of a place with such a field under it becomes drops of its fields, the last first. On any other place (a &mut param, a field) it always holds one.
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
flag | 1-bit signless integer |
milo.enum.field_ref (::milo::EnumFieldRefOp)
The place of one payload field of an enum place
Syntax:
operation ::= `milo.enum.field_ref` $ref `[` $tag `,` $index `]` attr-dict `:` type($ref) `->` type($result)The place of field index of the payload of variant tag, inside the enum at ref: what a &mut match subject binds, so an assignment to the binding writes the payload. Meaningful only while the enum has that tag (inside the arm that matched it).
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
tag | ::mlir::IntegerAttr | 32-bit signless integer attribute |
index | ::mlir::IntegerAttr | 64-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
result | the address of a place: a local slot, a field, an element |
milo.enum.new (::milo::EnumNewOp)
An enum value of one variant
Syntax:
operation ::= `milo.enum.new` $tag ( `(` $fields^ `:` type($fields) `)` )? attr-dict `->` type($result)E.V(args): the variant with tag tag, its payload fields from the operands.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
tag | ::mlir::IntegerAttr | 32-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
fields | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
Results:
| Result | Description |
|---|---|
result | a tagged enum by value, with its layout |
milo.enum.payload (::milo::EnumPayloadOp)
One payload field of an enum value
Syntax:
operation ::= `milo.enum.payload` $value `[` $tag `,` $index `]` attr-dict `:` type($value) `->` type($result)Field index of the payload of variant tag. Meaningful only when the value has that tag: milo-lower-structured-cf makes these at the entry of the arm that matched it.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
tag | ::mlir::IntegerAttr | 32-bit signless integer attribute |
index | ::mlir::IntegerAttr | 64-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
value | a tagged enum by value, with its layout |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.enum.set_tag (::milo::EnumSetTagOp)
Write the tag of an enum place
Syntax:
operation ::= `milo.enum.set_tag` $ref `,` $tag attr-dict `:` type($ref)The tag of the enum at ref written in place: with the payload stored through enum.field_ref, how a 128+ byte enum literal is built where it lives.
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
tag | ::mlir::IntegerAttr | 32-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.enum.tag (::milo::EnumTagOp)
The tag of an enum value
Syntax:
operation ::= `milo.enum.tag` $value attr-dict `:` type($value)The tag of an enum value (x is V compares it; milo.match switches on it).
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
value | a tagged enum by value, with its layout |
Results:
| Result | Description |
|---|---|
tag | 32-bit signed integer |
milo.enum.tag_at (::milo::EnumTagAtOp)
The tag of an enum place, read in place
Syntax:
operation ::= `milo.enum.tag_at` $ref attr-dict `:` type($ref)The tag of the enum at ref, read in place: how a 128+ byte enum, never an SSA value, is matched (a switch on this, payload bindings through enum.field_ref).
Interfaces: InferTypeOpInterface
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
tag | 32-bit signed integer |
milo.env.capture (::milo::EnvCaptureOp)
The place of one capture, inside a closure body
Syntax:
operation ::= `milo.env.capture` $env `[` $index `]` attr-dict `:` type($place)Inside a closure body: the place of capture index, read out of the env, which must be the function's first argument.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
index | ::mlir::IntegerAttr | 64-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
env | a raw pointer, untyped |
Results:
| Result | Description |
|---|---|
place | the address of a place: a local slot, a field, an element or a Vec by reference: the address of its header |
milo.field_ref (::milo::FieldRefOp)
The place of one field of a struct place
Syntax:
operation ::= `milo.field_ref` $ref `[` $index `]` attr-dict `:` type($ref) `->` type($result)The place of field index inside the struct at ref: still second-class, it only feeds loads, stores and by-ref arguments.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
index | ::mlir::IntegerAttr | 64-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
result | the address of a place: a local slot, a field, an element |
milo.filled (::milo::FilledOp)
Mark an owned slot full after an in-place fill
Syntax:
operation ::= `milo.filled` $ref attr-dict `:` type($ref)The owned slot ref now holds a value that was written into it in place (field by field, or by an sret call through its address) rather than by milo.store: for drop elaboration it is a store. A 128+ byte aggregate is filled this way, never loaded whole.
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.fn.addr (::milo::FnAddrOp)
The code address of a named function
Syntax:
operation ::= `milo.fn.addr` $fn attr-dictf as *u8 for a named function: the symbol's own address (not a closure trampoline), as legacy codegen casts it. A C function pointer handed to C wants exactly this.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
fn | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
Results:
| Result | Description |
|---|---|
result | a raw pointer, untyped |
milo.fn.cast (::milo::FnCastOp)
Retype a fn value between owning and plain
Syntax:
operation ::= `milo.fn.cast` $value attr-dict `:` type($value) `->` type($result)A fn value retyped between owning and plain, with the same signature and bits. Plain to owning: a named fn's trampoline or a frame closure handed to a move param; the owning drop glue skips a null env and a null header, so dropping it frees nothing. Owning to plain: a move closure stored into a plain fn field, where nobody drops it (legacy leaks its env the same way).
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
value | a fn value: fn pointer and env |
Results:
| Result | Description |
|---|---|
result | a fn value: fn pointer and env |
milo.for (::milo::ForOp)
A counted loop over a half-open int range
Syntax:
operation ::= `milo.for` $start `to` $end `:` type($start) $bodyRegion attr-dictfor i in start..end { body }: both bounds evaluated once, before the loop; the body's entry block argument is i, immutable inside the body. < follows the signedness of the type and the step is a plain (wrapping) +1, as legacy codegen emits it: i < end already bounds i, so the step cannot overflow.
Traits: RecursiveMemoryEffects
Interfaces: LoopLikeOpInterface, RegionBranchOpInterface
Operands:
| Operand | Description |
|---|---|
start | signed integer or unsigned integer |
end | signed integer or unsigned integer |
milo.for_in (::milo::ForInOp)
for x in c over a Vec, a slice, a string or a fixed array (top layer)
Syntax:
operation ::= `milo.for_in` $iterable `:` type($iterable) $bodyRegion attr-dictfor x in c: the body's entry block takes the index and the element, (%i: si64, %x: X). The iterable and X:
!milo.vec<E>(a Vec or slice place): X isE(the element by value) or!milo.ref<E>(the element's place);!milo.string(a string value): X isui8, a byte;!milo.ref<!milo.array<E, N>>(an array place): X is!milo.ref<E>.
The body ends as a milo.while body does: in milo.yield (next element), or a jump (break and continue target this loop, return), or milo.unreachable after a milo.scope that jumps.
milo.for_in %v : !milo.vec<si32> {
^bb0(%i: si64, %x: si32):
milo.yield
}milo-desugar lowers it (rule E-FOR-IN): the length is read once, then a milo.while over an entry-block index slot (Vec, slice, string), or a milo.for from 0 to N (array).
Traits: RecursiveMemoryEffects
Operands:
| Operand | Description |
|---|---|
iterable | a Vec by reference: the address of its header or Milo's string value or the address of a place: a local slot, a field, an element |
milo.global (::milo::GlobalOp)
The place of a module global
Syntax:
operation ::= `milo.global` $name (`thread_local` $tls^)? attr-dict `:` type($ref)The place of module global name (a let/var at module level), defined by the legacy module. Not an owned slot: what it holds outlives every function, so no scope drops it; a store over it drops the old value (milo-scope-drops), as through a &mut param. thread_local: a thread_local global, one per OS thread. Its address is taken as legacy takes it (a plain use of the symbol), so it is as constant within a function here as it is there.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
tls | ::mlir::UnitAttr | unit attribute |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.global.addr (::milo::GlobalAddrOp)
The address of a module global the dialect does not describe
Syntax:
operation ::= `milo.global.addr` $name attr-dictA global the rest of the module defines (an interface's itable itable.T.I, the process globals), by symbol: declared here, defined there.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
Results:
| Result | Description |
|---|---|
result | a raw pointer, untyped |
milo.global.def (::milo::GlobalDefOp)
The definition of a module global, with its static initializer
Syntax:
operation ::= `milo.global.def` $sym_name (`thread_local` $tls^)? `:` $type (`=` $init^)? attr-dictModule global sym_name of type, internal to the module (thread_local: one per OS thread), whose bytes milo.global and milo.global.addr name. init is the value it starts as, laid out by type: an integer or float attribute for a scalar (an integer is resized to the field's width, a float rounded to its precision), an array attribute for a struct (one entry per field, in order) or an array (one entry per element, or a single entry for all of them), unit for zero. Absent: all zero. A global whose initializer needs code is zero here and filled at run time.
Interfaces: Symbol
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
type | ::mlir::TypeAttr | any type attribute |
init | ::mlir::Attribute | any attribute |
tls | ::mlir::UnitAttr | unit attribute |
milo.global.init (::milo::GlobalInitOp)
Fill a lazy global before its first read
Syntax:
operation ::= `milo.global.init` $name attr-dictLazy global name is filled before the next statement reads it: a call of legacy's guarded entry (__milo.lazy.<name>, src/lazy-globals.ts), which runs the initializer the first time. It runs arbitrary code, so it declares no effects (any memory).
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
milo.heap.free (::milo::HeapFreeOp)
Free a box without dropping its payload
Syntax:
operation ::= `milo.heap.free` $heap attr-dict `:` type($heap)The box freed and its payload not dropped: what is left after the payload moved out (let x = *h), as legacy's genHeapMoveOut frees it.
Operands:
| Operand | Description |
|---|---|
heap | an owned box holding one value |
milo.heap.new (::milo::HeapNewOp)
Box a value on the heap
Syntax:
operation ::= `milo.heap.new` $value attr-dict `:` type($value) `->` type($result)Heap.new(v): a box of T's size from malloc, value moved into it. It allocates, so two are never one (not Pure).
Operands:
| Operand | Description |
|---|---|
value | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
Results:
| Result | Description |
|---|---|
result | an owned box holding one value |
milo.heap.place (::milo::HeapPlaceOp)
The place of the value in a box
Syntax:
operation ::= `milo.heap.place` $heap attr-dict `:` type($heap) `->` type($ref)*h: the place of the T in the box, the box's pointer itself.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
heap | an owned box holding one value |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.if (::milo::IfOp)
If/else, as a statement or an expression
Syntax:
operation ::= `milo.if` $condition (`->` type($results)^)? $thenRegion (`else` $elseRegion^)? attr-dictif cond { } else { }. With results it is an expression (&&, ||): both regions then yield values of the result types. A region may instead end in return, break, continue or unreachable.
Traits: NoRegionArguments, RecursiveMemoryEffects
Interfaces: RegionBranchOpInterface
Operands:
| Operand | Description |
|---|---|
condition | 1-bit signless integer |
Results:
| Result | Description |
|---|---|
results | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.index (::milo::IndexOp)
Checked element read through a Vec reference
Syntax:
operation ::= `milo.index` $vec `[` $index `]` attr-dict `:` type($vec) `->` type($result)Source-level Vec access through a &Vec<T> / &mut Vec<T> (or slice) param, as the language writes it: v[i], v[i] = x, v.len(). The index is Milo's i64 (narrower ints are cast to it first, by their own signedness). milo-expand-index lowers these to vec.len, bounds_check and vec.load/store above, which the loop passes understand.
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer |
milo.index.ref (::milo::IndexRefOp)
Checked element place through a Vec reference
Syntax:
operation ::= `milo.index.ref` $vec `[` $index `]` attr-dict `:` type($vec) `->` type($ref)v[i] as a place, for an element that is not a scalar: its address after legacy's bounds check (the panic names the op's location), lent to a &T argument, read or written field by field, or stored over. Read as a value it is a load, or for an owning element legacy's deep copy of the place. milo-expand-index lowers it to len, bounds_check and vec.elem_ref.
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.index.store (::milo::IndexStoreOp)
Checked element write through a Vec reference
Syntax:
operation ::= `milo.index.store` $value `,` $vec `[` $index `]` attr-dict `:` type($value) `,` type($vec)v[i] = x on a &mut Vec<T> param of scalar T: panics unless 0 <= i < len (the panic names the op's location), then writes element i. milo-expand-index lowers it to vec.len, bounds_check and vec.store.
Operands:
| Operand | Description |
|---|---|
value | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer |
vec | a Vec by reference: the address of its header |
index | 64-bit signed integer |
milo.interp (::milo::InterpOp)
An interpolated string: a fresh string from its parts' text (top layer)
$"...": each part's text appended in order to a fresh, owned string. A part is a scalar (siN, uiN, f32, f64, i1, !milo.ptr: decimal, shortest round-trip digits, true/false, an address), a !milo.string value (its bytes), or a place (!milo.ref<T> or !milo.vec<E>) followed by via @glue, the display glue that appends its text: func.func @glue(<place type>, !milo.ref<!milo.string>). site is the "file:line" a failed allocation's overflow panic names. No parts, [], is the empty string.
%s = milo.interp "main.milo:3" [%n : si32, %t : !milo.string, %p : !milo.ref<!milo.struct<"P", si32>> via @"P$display"]milo-desugar lowers it (rule E-INTERP) to appends into an entry-block slot: the runtime's rtStringPush* per scalar, milo.string.append per string, a call of the glue per place.
Interfaces: InferTypeOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
glue | ::mlir::ArrayAttr | array attribute |
site | ::mlir::StringAttr | string attribute |
Operands:
| Operand | Description |
|---|---|
parts | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or Milo's string value or the address of a place: a local slot, a field, an element or a Vec by reference: the address of its header |
Results:
| Result | Description |
|---|---|
result | Milo's string value |
milo.itable (::milo::ItableOp)
An interface's method table for one concrete type
Syntax:
operation ::= `milo.itable` $sym_name $methods (`drop` $drop^)? attr-dictModule-level constant sym_name: one pointer per method of the interface, in interface order, then a destructor slot, which is the drop function or null when the concrete type has none. The slot comes last so every method index stays valid; dispatch indexes the table and never reads its struct type. milo.global.addr reaches it by symbol. A method or drop symbol nothing in the module defines is declared at lowering and resolves against the rest of the module after the textual splice.
Interfaces: Symbol
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
sym_name | ::mlir::StringAttr | string attribute |
methods | ::mlir::ArrayAttr | array attribute |
drop | ::mlir::FlatSymbolRefAttr | flat symbol reference attribute |
milo.len (::milo::LenOp)
Len of a Vec reference, as Milo's si64
Syntax:
operation ::= `milo.len` $vec attr-dict `:` type($vec)v.len() on a &Vec<T> param: the header's len as si64. milo-expand-index lowers it to vec.len. Reads only header memory.
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Read on ::milo::VecHeaderResource}
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
Results:
| Result | Description |
|---|---|
len | 64-bit signed integer |
milo.load (::milo::LoadOp)
Read the value in a place
Syntax:
operation ::= `milo.load` $ref attr-dict `:` type($ref)The value in ref, read in place. On an owned slot it is a view: it takes no ownership, and the slot keeps the value (and its drop). Drop elaboration requires an owned slot to be full on every path to a load.
Interfaces: InferTypeOpInterface
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.loop (::milo::LoopOp)
An infinite loop
Syntax:
operation ::= `milo.loop` $bodyRegion attr-dictwhile true { body }: only break or return leaves it. The body ends in yield or continue (the next iteration) or a jump.
Traits: NoRegionArguments, RecursiveMemoryEffects
Interfaces: LoopLikeOpInterface, RegionBranchOpInterface
milo.map.len (::milo::MapLenOp)
Len of a HashMap value
Syntax:
operation ::= `milo.map.len` $value attr-dict `:` type($value)m.len() of a HashMap value (a view is enough): the header's len field.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
value | a HashMap value |
Results:
| Result | Description |
|---|---|
len | 64-bit signed integer |
milo.match (::milo::MatchOp)
A switch on an enum tag or an int or bool
Syntax:
operation ::= `milo.match` $subject `:` type($subject) (`->` type($results)^)? $cases (`default` $hasDefault^)? $arms attr-dictmatch subject { arms }, one region per arm. On an enum, cases holds each arm's tag and the arm's entry block takes that variant's payload fields as arguments (what the pattern binds); on an int or bool, cases are the literal values and arms take none. With default the last region is the _ arm; without one, a value matching no case is unreachable (the checker proved the match exhaustive). With results it is an expression: each arm yields them or ends in a jump.
Traits: RecursiveMemoryEffects
Interfaces: RegionBranchOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
cases | ::mlir::DenseI64ArrayAttr | i64 dense array attribute |
hasDefault | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
subject | a tagged enum by value, with its layout or signed integer or unsigned integer or 1-bit signless integer |
Results:
| Result | Description |
|---|---|
results | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.move (::milo::MoveOp)
Move the value out of an owned slot
Syntax:
operation ::= `milo.move` $ref attr-dict `:` type($ref)The value in an owned slot, moved out: the result owns it and the slot holds nothing after it, so drop elaboration erases or flags the slot's later drops. On a field of an owned slot (a partial move) only that field is emptied.
Interfaces: InferTypeOpInterface
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.mul (::milo::MulOp)
Integer or float multiplication
Syntax:
operation ::= `milo.mul` $lhs `,` $rhs (`wrapping` $wrapping^)? attr-dict `:` type($result)lhs * rhs. On an int it panics on overflow (in the signedness of the type) unless wrapping, which gives two's complement. The panic names the op's location. Floats never trap and never carry wrapping.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
rhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float |
milo.neg (::milo::NegOp)
Unary minus
Syntax:
operation ::= `milo.neg` $operand (`wrapping` $wrapping^)? attr-dict `:` type($result)Unary -: panics on overflow (signed MIN, any nonzero unsigned) unless wrapping.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
operand | signed integer or unsigned integer or 32-bit float or 64-bit float |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float |
milo.not (::milo::NotOp)
Logical not on bool, bitwise not on an int
Syntax:
operation ::= `milo.not` $operand attr-dict `:` type($result)! on bool, ~ on an int.
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
operand | signed integer or unsigned integer or 1-bit signless integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 1-bit signless integer |
milo.or (::milo::OrOp)
Bitwise or, or logical or on bool
Syntax:
operation ::= `milo.or` $lhs `,` $rhs attr-dict `:` type($result)lhs | rhs on ints, or either bool (the non-short-circuit form; || is a milo.if). Never traps.
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 1-bit signless integer |
rhs | signed integer or unsigned integer or 1-bit signless integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 1-bit signless integer |
milo.overflows (::milo::OverflowsOp)
Whether integer arithmetic would overflow
Syntax:
operation ::= `milo.overflows` $kind `,` $lhs `,` $rhs attr-dict `:` type($lhs)True when lhs <kind> rhs has no result in the type (in its signedness): add, sub and mul past the range; div and rem by zero, or signed MIN by -1. Never traps. x.checkedAdd(y) is None when this holds, else Some of the wrapping op.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
kind | ::mlir::StringAttr | string attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer |
rhs | signed integer or unsigned integer |
Results:
| Result | Description |
|---|---|
result | 1-bit signless integer |
milo.panic_if (::milo::PanicIfOp)
Panic with a message when a condition holds
Syntax:
operation ::= `milo.panic_if` $bad `,` $message (`(` $values^ `)`)? attr-dictWhen bad holds, prints message to stderr as a printf format and aborts through the panic hook. message is the whole text, site included, as the emitter builds it; its only conversions are %lld, one per value, at most three. Every other % is written %%.
milo.panic_if %neg, "milo: negative length at a.milo:3:9: %lld\n"(%n)Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Write on ::milo::PanicResource}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
message | ::mlir::StringAttr | string attribute |
Operands:
| Operand | Description |
|---|---|
bad | 1-bit signless integer |
values | variadic of 64-bit signed integer |
milo.ptr.elem (::milo::PtrElemOp)
The address of element i of a raw pointer
Syntax:
operation ::= `milo.ptr.elem` $ptr `[` $index `]` `:` $elem attr-dictp[i] on a *T as a place: the address of element i (unchecked, as in C). The element is then read and written with ptr.load/ptr.store, whose unknown memory may be a Vec's header or elements: std's Vec methods write their header this way, so a place reached through a pointer is never a milo.ref (whose Slot resource excludes both).
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
elem | ::mlir::TypeAttr | any type attribute |
Operands:
| Operand | Description |
|---|---|
ptr | a raw pointer, untyped |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
result | a raw pointer, untyped |
milo.ptr.field (::milo::PtrFieldOp)
The address of a field through a raw pointer
Syntax:
operation ::= `milo.ptr.field` $ptr `[` $index `]` `:` $record attr-dictThe address of field index of the struct at ptr.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
index | ::mlir::IntegerAttr | 64-bit signless integer attribute |
record | ::mlir::TypeAttr | any type attribute |
Operands:
| Operand | Description |
|---|---|
ptr | a raw pointer, untyped |
Results:
| Result | Description |
|---|---|
result | a raw pointer, untyped |
milo.ptr.lend (::milo::PtrLendOp)
The place at a raw pointer, lent to a call
Syntax:
operation ::= `milo.ptr.lend` $ptr attr-dict `->` type($place)f(&mut (*p).items): the place behind a raw pointer passed as a by-ref argument, a !milo.ref or, for a Vec, its header (!milo.vec), at the same address. Only a call takes it: a place reached through a pointer is never read or written here through a ref (see ptr.elem), so the frame's Slot accesses still never alias it.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ptr | a raw pointer, untyped |
Results:
| Result | Description |
|---|---|
place | the address of a place: a local slot, a field, an element or a Vec by reference: the address of its header |
milo.ptr.load (::milo::PtrLoadOp)
Read a value through a raw pointer
Syntax:
operation ::= `milo.ptr.load` $ptr attr-dict `:` type($result)Reads a value of the result type from ptr (unsafe code). The pointer is untyped, so the type read is the result type. Any memory may be read: a raw pointer may point into a Vec's header or elements, a slot or the heap.
Operands:
| Operand | Description |
|---|---|
ptr | a raw pointer, untyped |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.ptr.store (::milo::PtrStoreOp)
Write a value through a raw pointer
Syntax:
operation ::= `milo.ptr.store` $value `,` $ptr attr-dict `:` type($value)Writes value to ptr (unsafe code). Any memory may be written, Vec headers included: std's Vec methods grow a Vec this way. Moves no ownership: the stored value belongs to whatever the pointer points at.
Operands:
| Operand | Description |
|---|---|
value | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
ptr | a raw pointer, untyped |
milo.rem (::milo::RemOp)
Integer or float remainder
Syntax:
operation ::= `milo.rem` $lhs `,` $rhs (`wrapping` $wrapping^)? attr-dict `:` type($result)lhs % rhs. An integer divisor of zero always panics, wrapping or not; signed MIN % -1 panics unless wrapping, which yields 0. The result has the sign of lhs. Floats follow IEEE (fmod) and never trap.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
rhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float |
milo.replay.enter (::milo::ReplayEnterOp)
Enter a record/replay engine function
Syntax:
operation ::= `milo.replay.enter` attr-dictEntry to and exit from a record/replay engine function (std/replay; HIRFunction replayEngine): while the recorder's heap switch is on, the engine's own allocations go to libc's malloc rather than the recorded fixed-address heap, so their nesting depth is counted in replay$rrDepth. Enter at the top of the body, exit before every return.
milo.replay.exit (::milo::ReplayExitOp)
Leave a record/replay engine function
Syntax:
operation ::= `milo.replay.exit` attr-dictThe exit half of milo.replay.enter: decrements replay$rrDepth before every return of a record/replay engine function.
milo.return (::milo::ReturnOp)
Return from the function
Syntax:
operation ::= `milo.return` ($value^ `:` type($value))? attr-dictreturn, from any depth of nested regions, with the function's result when it has one. A terminator that is not a region branch: it leaves every region around it.
Traits: Terminator
Operands:
| Operand | Description |
|---|---|
value | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.saturating (::milo::SaturatingOp)
Integer add, sub or mul clamped to the type's range
Syntax:
operation ::= `milo.saturating` $kind `,` $lhs `,` $rhs attr-dict `:` type($result)x.saturatingAdd(y): the result, or the type's MIN or MAX in the direction the true result lies. Never traps.
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
kind | ::mlir::StringAttr | string attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer |
rhs | signed integer or unsigned integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer |
milo.scope (::milo::ScopeOp)
A lexical scope that owns slots
Syntax:
operation ::= `milo.scope` ($slots^ `:` type($slots))? (`->` type($results)^)? $body attr-dictA lexical scope that owns the slots it lists: whatever they still hold dies when control leaves it, by falling off its end or by a break, continue or return out of it (milo-scope-drops puts the drops there). With results it yields them, like milo.if.
Traits: NoRegionArguments, RecursiveMemoryEffects
Interfaces: RegionBranchOpInterface
Operands:
| Operand | Description |
|---|---|
slots | variadic of the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
results | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.shl (::milo::ShlOp)
Shift left
Syntax:
operation ::= `milo.shl` $lhs `,` $rhs (`wrapping` $wrapping^)? attr-dict `:` type($result)lhs << rhs. An amount >= the bit width, or negative, panics unless wrapping, which masks the amount to the width.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer |
rhs | signed integer or unsigned integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer |
milo.shr (::milo::ShrOp)
Shift right
Syntax:
operation ::= `milo.shr` $lhs `,` $rhs (`wrapping` $wrapping^)? attr-dict `:` type($result)lhs >> rhs: arithmetic on a signed int, logical on an unsigned one. An amount >= the bit width, or negative, panics unless wrapping, which masks the amount to the width.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer |
rhs | signed integer or unsigned integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer |
milo.store (::milo::StoreOp)
Write a value into a place
Syntax:
operation ::= `milo.store` $value `,` $ref (`init` $init^)? attr-dict `:` type($ref)init: the place holds no value yet (a lazy global's first fill, HIR Assign isInit), so nothing is dropped before the store even when the type has drop glue.
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
init | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
value | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
ref | the address of a place: a local slot, a field, an element |
milo.string.append (::milo::StringAppendOp)
Append to the string in a place
Syntax:
operation ::= `milo.string.append` $dst `,` $value attr-dict `:` type($dst)The bytes of value appended to the string at dst, in place: legacy's pushStr (amortized growth; a shared buffer is made unique first). milo-append-in-place makes these out of s = s + x.
Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::SideEffects::DefaultResource, MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}
Operands:
| Operand | Description |
|---|---|
dst | the address of a place: a local slot, a field, an element |
value | Milo's string value |
milo.string.byte (::milo::StringByteOp)
Checked byte read of a string
Syntax:
operation ::= `milo.string.byte` $value `[` $index `]` attr-dicts[i]: byte i of the string, after legacy's bounds check (__milo_bounds_fail with the op's location, the same panic as a Vec index).
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::SideEffects::DefaultResource, MemoryEffects::Write on ::milo::PanicResource}
Operands:
| Operand | Description |
|---|---|
value | Milo's string value |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
byte | 8-bit unsigned integer |
milo.string.concat (::milo::StringConcatOp)
Concatenate two strings into a new one
Syntax:
operation ::= `milo.string.concat` $lhs `,` $rhs attr-dicta + b on strings: a new owned string, made by the runtime's concatenation (milo.string.concat, std/rt.milo, the operands through slots). Allocates, so two are never merged: each result is an owner of its own.
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Read on ::mlir::SideEffects::DefaultResource, MemoryEffects::Allocate on ::mlir::SideEffects::DefaultResource}
Operands:
| Operand | Description |
|---|---|
lhs | Milo's string value |
rhs | Milo's string value |
Results:
| Result | Description |
|---|---|
result | Milo's string value |
milo.string.data (::milo::StringDataOp)
The data pointer of a string
Syntax:
operation ::= `milo.string.data` $value attr-dictA string's data pointer (its bytes, no NUL promised): s as *u8 and the bytes a for b in s walks, as legacy reads field 0 of %String. The ODS types are its verifier.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
value | Milo's string value |
Results:
| Result | Description |
|---|---|
result | a raw pointer, untyped |
milo.string.len (::milo::StringLenOp)
Len of a string value, in bytes
Syntax:
operation ::= `milo.string.len` $value attr-dicts.len() of a string value (a view is enough).
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
value | Milo's string value |
Results:
| Result | Description |
|---|---|
len | 64-bit signed integer |
milo.string.lit (::milo::StringLitOp)
A string literal
Syntax:
operation ::= `milo.string.lit` $value attr-dictA string literal: the bytes as a private constant, len, cap 0.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
value | ::mlir::StringAttr | string attribute |
Results:
| Result | Description |
|---|---|
result | Milo's string value |
milo.string.share (::milo::StringShareOp)
A new owner of the string in a place
Syntax:
operation ::= `milo.string.share` $ref attr-dict `:` type($ref)A new owner of the string at ref (Milo's implicit copy of a string, HIR StringClone): legacy's share, one more count on a heap buffer. It writes that count, so two shares of one place are two owners: CSE must not fold them.
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
result | Milo's string value |
milo.struct.get (::milo::StructGetOp)
One field of a struct value
Syntax:
operation ::= `milo.struct.get` $value `[` $index `]` attr-dict `:` type($value) `->` type($result)Field index of a struct value.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
index | ::mlir::IntegerAttr | 64-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
value | a struct by value, identified by name |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.struct.new (::milo::StructNewOp)
A struct value from its fields
Syntax:
operation ::= `milo.struct.new` ($fields^ `:` type($fields))? attr-dict `->` type($result)S { a: x, b: y }: the fields in declaration order (the emitter evaluates them in source order first).
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
fields | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
Results:
| Result | Description |
|---|---|
result | a struct by value, identified by name |
milo.sub (::milo::SubOp)
Integer or float subtraction
Syntax:
operation ::= `milo.sub` $lhs `,` $rhs (`wrapping` $wrapping^)? attr-dict `:` type($result)lhs - rhs. On an int it panics on overflow (in the signedness of the type) unless wrapping, which gives two's complement. The panic names the op's location. Floats never trap and never carry wrapping.
Traits: SameOperandsAndResultType
Interfaces: InferTypeOpInterface, MemoryEffectOpInterface
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
wrapping | ::mlir::UnitAttr | unit attribute |
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
rhs | signed integer or unsigned integer or 32-bit float or 64-bit float |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float |
milo.try (::milo::TryOp)
e? on an owned Option or Result (top layer)
Syntax:
operation ::= `milo.try` $subject `:` type($subject) (`->` type($result)^)? `ok` $ok `err` $err $errRegion attr-dicte?: the subject is an owned enum value; ok and err are the tags of its two variants, each with at most one field. On ok the op yields the ok payload (no result when the ok variant has none); on err the region runs, its entry block taking the err payload (no argument when the err variant has none). The region always leaves: it ends in milo.return, or in milo.unreachable after a milo.scope whose body returns.
%x = milo.try %r : !milo.enum<"Res", size = 8, align = 4, [0: (si32 at 4), 1: (si32 at 4)]> -> si32 ok 0 err 1 {
^bb0(%e: si32):
milo.return %e : si32
}milo-desugar lowers it to a two-arm milo.match (rules E-PROPAGATE, E-MATCH).
Traits: RecursiveMemoryEffects
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
ok | ::mlir::IntegerAttr | 32-bit signless integer attribute |
err | ::mlir::IntegerAttr | 32-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
subject | a tagged enum by value, with its layout |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.unreachable (::milo::UnreachableOp)
A point control cannot reach
Syntax:
operation ::= `milo.unreachable` attr-dictControl cannot get here (past a while true with no break); traps if it does.
Traits: Terminator
milo.var (::milo::VarOp)
A mutable local slot
Syntax:
operation ::= `milo.var` $name (`owned` $owned^)? (`structural` $structural^)? attr-dict `:` type($ref)var name: a mutable local. Must sit in the function's entry block, so the frame is fixed: a slot allocated inside a loop would grow the stack every iteration.
owned: the slot holds a value with drop glue (a string, a Vec) that it owns. Such a slot is listed by the milo.scope that owns it; from there on the IR says only where the value is stored (milo.store), moved out (milo.move) and read in place (milo.load, a view that never owns), and milo-scope-drops / milo-elaborate-drops decide where it dies.
structural: an owned slot holding a structural clone (legacy emitDeepCloneFromPtr of a Vec element matched by value), which shares any resource handle with the original: its drop is legacy's structural one (milo.sdrop.<key>), which runs no user Drop.
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
name | ::mlir::StringAttr | string attribute |
owned | ::mlir::UnitAttr | unit attribute |
structural | ::mlir::UnitAttr | unit attribute |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.vec.data (::milo::VecDataOp)
The data pointer of the Vec at a header address
Syntax:
operation ::= `milo.vec.data` $vec attr-dict `:` type($vec)v.ptr(): the Vec's data pointer, read out of its header.
Interfaces: InferTypeOpInterface
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
Results:
| Result | Description |
|---|---|
result | a raw pointer, untyped |
milo.vec.elem_ref (::milo::VecElemRefOp)
Unchecked element place
Syntax:
operation ::= `milo.vec.elem_ref` $vec `[` $index `]` attr-dict `:` type($vec) `->` type($ref)The place of element index, unchecked (the bounds_check is before it): reads only the header's data pointer.
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
index | 64-bit signless integer |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.vec.len (::milo::VecLenOp)
Len of the Vec at a header address
Syntax:
operation ::= `milo.vec.len` $vec attr-dict `:` type($vec)The len field of the Vec header vec points at. Reads only header memory, so element stores in a loop do not stop it from being hoisted (milo-hoist-vec-reads).
Interfaces: InferTypeOpInterface
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
Results:
| Result | Description |
|---|---|
len | 64-bit signless integer |
milo.vec.load (::milo::VecLoadOp)
Unchecked element read
Syntax:
operation ::= `milo.vec.load` $vec `[` $index `]` attr-dict `:` type($vec) `->` type($result)Element index of the Vec at vec, unchecked: the frontend emits a bounds_check before it. Reads header and element memory only, never a slot.
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
index | 64-bit signless integer |
Results:
| Result | Description |
|---|---|
result | any non-token type |
milo.vec.new (::milo::VecNewOp)
An empty Vec value
Syntax:
operation ::= `milo.vec.new` attr-dict `:` type($result)Vec.new(): no buffer, len 0, cap 0.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Results:
| Result | Description |
|---|---|
result | a Vec value, the header itself |
milo.vec.place (::milo::VecPlaceOp)
The header address of the Vec in a slot
Syntax:
operation ::= `milo.vec.place` $ref attr-dict `:` type($ref) `->` type($vec)The header of the Vec in a slot, for indexing and len: the same address. A Vec of owning closures may be lent as one of plain closures (the same bits), as a generic std body instantiated with the plain T sees it.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
vec | a Vec by reference: the address of its header |
milo.vec.slot (::milo::VecSlotOp)
The slot of the Vec behind a header place
Syntax:
operation ::= `milo.vec.slot` $vec attr-dict `:` type($vec) `->` type($ref)The inverse of milo.vec.place: a &mut Vec param or field is lent as its header, and what writes the whole Vec (replace(v, w), swap) wants its slot: the same address.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
vec | a Vec by reference: the address of its header |
Results:
| Result | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
milo.vec.store (::milo::VecStoreOp)
Unchecked element write
Syntax:
operation ::= `milo.vec.store` $value `,` $vec `[` $index `]` attr-dict `:` type($value) `,` type($vec)Writes value to element index of the Vec at vec, unchecked: the frontend emits a bounds_check before it. Reads the header (for the data pointer) and writes only element memory, so a cached len or data pointer stays valid across it.
Operands:
| Operand | Description |
|---|---|
value | any non-token type |
vec | a Vec by reference: the address of its header |
index | 64-bit signless integer |
milo.vectail.init (::milo::VecTailInitOp)
Move a Vec into a vectail slot
Syntax:
operation ::= `milo.vectail.init` $vec `,` $ref attr-dict `:` type($vec) `,` type($ref)The Vec vec moved into the owned slot ref with its cursor at 0. A fill in place: the emitter follows it with milo.filled.
Operands:
| Operand | Description |
|---|---|
vec | a Vec value, the header itself |
ref | the address of a place: a local slot, a field, an element |
milo.vectail.take (::milo::VecTailTakeOp)
Move the next element out of a vectail
Syntax:
operation ::= `milo.vectail.take` $ref `[` $index `]` attr-dict `:` type($ref) `->` type($result)Element index moved out of the vectail in ref, and the cursor set past it: from here on the element is the result's, not the Vec's. Unchecked: the loop condition keeps index below len, and the elements come in order, so the cursor only moves forward.
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.vectail.take_place (::milo::VecTailTakePlaceOp)
The place of the next element of a vectail
Syntax:
operation ::= `milo.vectail.take_place` $ref `[` $index `]` attr-dict `:` type($ref) `->` type($result)vectail.take for a place-only element (128+ bytes, or holding an array): the element's place, which the caller copies out of (milo.copy), with the cursor set past it.
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
index | 64-bit signed integer |
Results:
| Result | Description |
|---|---|
result | the address of a place: a local slot, a field, an element |
milo.vectail.vec (::milo::VecTailVecOp)
The header address of the Vec in a vectail slot
Syntax:
operation ::= `milo.vectail.vec` $ref attr-dict `:` type($ref) `->` type($vec)The header of the Vec in a vectail slot, for its data pointer and len: the same address.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ref | the address of a place: a local slot, a field, an element |
Results:
| Result | Description |
|---|---|
vec | a Vec by reference: the address of its header |
milo.while (::milo::WhileOp)
A while loop
Syntax:
operation ::= `milo.while` $condRegion `do` $bodyRegion attr-dictwhile cond { body }: the cond region ends in milo.condition, the body in a yield (next iteration) or a jump.
Traits: NoRegionArguments, RecursiveMemoryEffects
Interfaces: LoopLikeOpInterface, RegionBranchOpInterface
milo.xor (::milo::XorOp)
Bitwise exclusive or
Syntax:
operation ::= `milo.xor` $lhs `,` $rhs attr-dict `:` type($result)lhs ^ rhs on ints or bools. Never traps.
Traits: AlwaysSpeculatableImplTrait, SameOperandsAndResultType
Interfaces: ConditionallySpeculatable, InferTypeOpInterface, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
lhs | signed integer or unsigned integer or 1-bit signless integer |
rhs | signed integer or unsigned integer or 1-bit signless integer |
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 1-bit signless integer |
milo.yield (::milo::YieldOp)
End a region normally
Syntax:
operation ::= `milo.yield` ($values^ `:` type($values))? attr-dictEnds a region of milo.if, milo.match or milo.scope with that op's results, or a loop body with no values (the next iteration: for milo.for the step, for milo.while the cond region again).
Traits: AlwaysSpeculatableImplTrait, HasParent<IfOp, WhileOp, LoopOp, ForOp, ForInOp, MatchOp, ScopeOp>, Terminator
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface), RegionBranchTerminatorOpInterface
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
values | variadic of signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
milo.zero (::milo::ZeroOp)
The all-zero value of a type
Syntax:
operation ::= `milo.zero` attr-dict `:` type($result)zeroed<T>(): every byte of a T zero, legacy's zeroinitializer. For a string or a Vec that is the empty one (null data, cap 0), whose drop does nothing.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Results:
| Result | Description |
|---|---|
result | signed integer or unsigned integer or 32-bit float or 64-bit float or 1-bit signless integer or a raw pointer, untyped or a struct by value, identified by name or a tagged enum by value, with its layout or a fixed-size array, held only in places or Milo's string value or a Vec value, the header itself or a HashMap value or an owned box holding one value or an owned box of an interface value or a borrowed interface value or a fn value: fn pointer and env |
Types
ArrayTailType
A fixed array being consumed from the front
Syntax:
!milo.arraytail<
::mlir::Type # arrayType
>What is left of a fixed array a consuming for x in [a, b] takes apart from the front: legacy's { [N x T], i64 cursor } (genConsumedIterable). As !milo.vectail: the drop glue drops the elements from the cursor on, so a break or a return out of the loop drops exactly what no iteration took. Lives only in an owned slot, never as an SSA value.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| arrayType | ::mlir::Type |
ArrayType
A fixed-size array, held only in places
Syntax:
!milo.array<
::mlir::Type, # elementType
int64_t # size
>A fixed-size array [T; N], legacy's [N x T]. Held only in places, as a 128+ byte aggregate is, whatever its size: an SSA value exists only at the ABI (a by-value param or argument), so a large buffer is never split per element. Its elements own nothing.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| elementType | ::mlir::Type | |
| size | int64_t |
DynRefType
A borrowed interface value
Syntax:
!milo.dynref<
::llvm::StringRef # iface
>A &I: legacy's literal { ptr data, ptr itable }, borrowing both (a param, a &T or &mut T coerced to &I). It owns nothing; a method call through it is legacy's dispatch in a helper, as for !milo.dyn.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| iface | ::llvm::StringRef |
DynType
An owned box of an interface value
Syntax:
!milo.dyn<
::llvm::StringRef # iface
>A Heap<I> of an interface: legacy's { ptr data, ptr itable }, owned (its drop glue, legacy's milo.drop.dyn.<I>, runs the concrete type's drop through the itable and frees the box). Opaque: a method call through it is legacy's dispatch in a helper.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| iface | ::llvm::StringRef |
EnumType
A tagged enum by value, with its layout
A tagged enum by value, with the layout legacy codegen computed (EnumLayout), spelled out so nothing here recomputes it: size bytes stored as [size/align x i(8*align)] (or { i32 } when size is 0, a fieldless enum), the i32 tag in bytes 0..4, and each variant's fields at the byte offsets after at: !milo.enum<"Shape", size = 24, align = 8, [0: (f64 at 8), 1: (f64 at 8, f64 at 16), 2: ()]> A niche-packed enum (EnumLayout.niche: two variants, one fieldless, one with a single field) has no tag word. It is stored as its payload alone, { P }, and the fieldless variant is the value after niche in the payload's leading integer: !milo.enum<"Option_R", niche = 2147483647 : i32, [0: (si32 at 0), 1: ()]>
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| name | ::llvm::StringRef |
FnType
A fn value: fn pointer and env
A fn value (T) => R: legacy's { ptr fn, ptr env }. The fn takes the env first, then the params of signature (a &T param is a !milo.ref, a &Vec<T> a !milo.vec). A plain one's env is null or a frame's (milo.closure), never owned, so the value is Copy and has no drop glue. An owning one (move (T) => R, !milo.fn<owning (T) -> R>) holds a heap env whose first word is its drop glue: it is an owned value, dropped through legacy's glue for owning closures (milo.drop.ownfn).
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| signature | ::mlir::FunctionType | |
| owning | bool |
HeapType
An owned box holding one value
Syntax:
!milo.heap<
::mlir::Type # valueType
>A Heap<T>: legacy's malloc'd pointer to one T, owned (its drop glue, legacy's milo.drop.heap.<t>, drops the T and frees the box). *h is the place milo.heap.place gives. Through it a type can hold itself (enum Expr { Add(Heap<Expr>, ...) }).
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| valueType | ::mlir::Type |
MapType
A HashMap value
Syntax:
!milo.map<
::mlir::Type, # keyType
::mlir::Type # valueType
>A HashMap<K, V> value: %HashMap = { ptr data, i64 len, i64 cap, i64 seed, i64 tombs } (src/layout.ts HASHMAP_FIELDS). Its methods are Milo code in std/hashmap that reads it through a raw pointer, so no op here looks inside; K and V only name its drop glue (legacy's, milo.drop.map.<k>.<v>).
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| keyType | ::mlir::Type | |
| valueType | ::mlir::Type |
PtrType
A raw pointer, untyped
Syntax: !milo.ptr
A raw pointer *T (unsafe code only). Untyped, like LLVM's: *T can be reinterpreted, so the pointee type rides on each access (milo.ptr.load/store), not on the pointer. Unlike a !milo.ref it is a first-class value: stored, returned, compared, cast.
RefType
The address of a place: a local slot, a field, an element
Syntax:
!milo.ref<
::mlir::Type # pointee
>The address of a place holding a pointee: a mutable local (milo.var), a field, an element, a global or a by-ref param (Mojo's !lit.ref, ClangIR's !cir.ptr). Second-class, as Milo's references are: it never escapes a call, is never stored and never returned (milo-verify checks this). Its memory is the Slot resource, disjoint from Vec headers and elements; a place reached through a raw pointer is a !milo.ptr.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| pointee | ::mlir::Type |
StringType
Milo's string value
Syntax: !milo.string
Milo's string value: %String = { ptr data, i64 len, i64 cap }, the same bytes the runtime helpers (std/rt.milo) read. A literal has cap 0: its buffer is static, so its drop glue does nothing. Strings and Vecs are owned values: see milo.var owned.
StructType
A struct by value, identified by name
A struct by value, named as src/layout.ts names its LLVM type (%Point), with its fields' types in declaration order: !milo.struct<"Point", si64, f64>. It lowers to the identified LLVM struct of that name, and the layout is LLVM's natural one, which is src/layout.ts's. A type with its own impl Drop says so after its name, !milo.struct<"Noisy" drop, si64> (enums the same way): it has drop glue whatever its fields are, and the glue runs the user's drop first (legacy's, through milo.drop.<key>). Structs and enums are identified by name, as LLVM's identified structs are: the body is set once, after the type exists, so a type can hold itself through a Vec (a JSON value, a tree). Inside its own body it is spelled by name alone, !milo.enum<"Json">, which is the same type. A second body for a name must equal the first (the parser checks).
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| name | ::llvm::StringRef |
VecTailType
A Vec being consumed from the front
Syntax:
!milo.vectail<
::mlir::Type # elementType
>What is left of a Vec a consuming for x in makeVec() takes apart from the front: legacy's { %Vec, i64 cursor } (genConsumedIterable). The elements before the cursor were moved out; the drop glue drops those from the cursor on, then frees the buffer, so a break or a return out of the loop frees exactly what no iteration took. Lives only in an owned slot (milo.vectail.init), never as an SSA value.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| elementType | ::mlir::Type |
VecType
A Vec by reference: the address of its header
Syntax:
!milo.vec<
::mlir::Type # elementType
>A Vec<T> passed by reference: the address of its {ptr, len, cap} header (a &Vec<T> or &mut Vec<T> param, or milo.vec.place of a slot). Borrowed: it owns nothing, and nothing drops through it. The indexing and len ops take it.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| elementType | ::mlir::Type |
VecValType
A Vec value, the header itself
Syntax:
!milo.vecval<
::mlir::Type # elementType
>A Vec<T> value: legacy's %Vec = { ptr data, i64 len, i64 cap }. Its place, the address of that header, is !milo.vec<T> (milo.vec.place), which the indexing ops take.
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| elementType | ::mlir::Type |
Enums
CmpPredicate
Comparison
Cases:
| Symbol | Value | String |
|---|---|---|
| eq | 0 | eq |
| ne | 1 | ne |
| lt | 2 | lt |
| le | 3 | le |
| gt | 4 | gt |
| ge | 5 | ge |