19 Custom Assembly Syntax
Custom assembly syntax is a dialect’s readable presentation of an operation. It is layered over generic MLIR syntax, not a separate IR. A good custom form makes common code easy to scan while preserving enough information to parse and verify the operation unambiguously.
19.1 Declarative Or Handwritten
ODS can describe many syntax forms declaratively: operands, types, attributes, keywords, optional groups, regions, and punctuation. Complex grammars use handwritten parser and printer methods. Prefer declarative formats when they express the operation clearly; they keep syntax close to the operation declaration and reduce parser/printer drift.
19.2 Syntax Must Not Hide Semantics
Eliding a result type is reasonable only when it can be inferred unambiguously. Eliding an attribute is reasonable only when it is a stable default. Do not invent a clever concise syntax that obscures memory space, layout, flags, or region contracts a reader needs to understand correctness.
Always keep generic syntax usable. It is the escape hatch for unknown dialects, debugging, and tools that need an unambiguous representation.