Expand description
#[mlir::op] and #[mlir::dialect]. Neither writes conversion code: op spells each
field’s MLIR role in its serde name (decoded by mlirformat::Field) and forwards the
conversions to the runtime; dialect turns an enum of ops into a registrable op table.
ⓘ
#[mlir::op("arith.maxsi", format = "$lhs `,` $rhs attr-dict `:` type($result)", results(result))]
pub struct ArithMax<'a> {
#[slot(result)] pub lhs: Value<'a>, // operand; its type is type variable `result`
#[slot(result)] pub rhs: Value<'a>,
#[dtype] pub result: Type<'a>, // type variable (result #0 by `results(...)`)
}Field markers (a Vec field is variadic; MLIR names are the lowerCamelCase field names
unless name = "..."):
#[slot(T)] operand(s) typed by type variable T
#[dtype] #[dtype(i1)] #[dtype(i1 = x)] #[dtype(of = attr)] #[dtype(eq = x)] #[dtype(is = index)] #[dtype(el = x)]
type variable; how custom form infers it when unspelled
#[attr] #[attr(int = "i32")] #[attr(dialect = "arith.overflow", default = "<none>")]
property (`bool`: unit attribute; enum: case value typed
`int`, default i64); a dialect attribute is
spelled without its prefix, its default is omitted
#[region] #[successor]attrs (discardable attributes) and loc fields are added. Options: format = "...",
results(a, b), custom (no Op impl: print / parse written by hand), generic (no custom
form: always printed generic).
#[mlir::dialect("ns", params = f)]: f structures !ns.x<...> / #ns.x<...> bodies
(Dialect::parse_params).