1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! `#[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.
//!
//! ```ignore
//! #[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 = "..."`):
//!
//! ```text
//! #[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`).
use TokenStream;
use ;