Declarative assembly format
declarative_assembly_format
¶
This file contains the data structures necessary for the parsing and printing of the MLIR declarative assembly format defined at https://mlir.llvm.org/docs/DefiningDialects/Operations/#declarative-assembly-format .
CustomDirectiveInvT = TypeVar('CustomDirectiveInvT', bound=CustomDirective)
module-attribute
¶
ParsingState
dataclass
¶
State carried during the parsing of an operation using the declarative assembly format. It contains the elements that have already been parsed.
Source code in xdsl/irdl/declarative_assembly_format.py
op_type: type[IRDLOperation] = op_type
instance-attribute
¶
operands: list[Sequence[UnresolvedOperand] | None] = [None] * len(op_def.operands)
instance-attribute
¶
operand_types: list[Sequence[Attribute] | None] = [None] * len(op_def.operands)
instance-attribute
¶
result_types: list[Sequence[Attribute] | None] = [None] * len(op_def.results)
instance-attribute
¶
regions: list[Sequence[Region] | None] = [None] * len(op_def.regions)
instance-attribute
¶
successors: list[Sequence[Successor] | None] = [None] * len(op_def.successors)
instance-attribute
¶
attributes: dict[str, Attribute] = {}
instance-attribute
¶
properties: dict[str, Attribute] = {}
instance-attribute
¶
context: VerificationContext = VerificationContext()
instance-attribute
¶
__init__(op_type: type[IRDLOperation])
¶
Source code in xdsl/irdl/declarative_assembly_format.py
PrintingState
dataclass
¶
State carried during the printing of an operation using the declarative assembly format. It contains information on the last token, to know if a space should be emitted.
Source code in xdsl/irdl/declarative_assembly_format.py
last_was_punctuation: bool = field(default=False)
class-attribute
instance-attribute
¶
Was the last element parsed a punctuation.
should_emit_space: bool = field(default=True)
class-attribute
instance-attribute
¶
Should the printer emit a space before the next element. Depending on the directive, the space might not be printed (for instance for some punctuations).
__init__(last_was_punctuation: bool = False, should_emit_space: bool = True) -> None
¶
print_whitespace(printer: Printer)
¶
Handles whitespace printing for the majority of format directives.
Source code in xdsl/irdl/declarative_assembly_format.py
FormatProgram
dataclass
¶
The toplevel data structure of a declarative assembly format program. It is used to parse and print an operation.
Source code in xdsl/irdl/declarative_assembly_format.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
stmts: tuple[FormatDirective, ...]
instance-attribute
¶
The statements composing the program. They are executed in order.
__init__(stmts: tuple[FormatDirective, ...]) -> None
¶
from_str(input: str, op_def: OpDef) -> FormatProgram
staticmethod
¶
Create the assembly format data program from its string representation. This might raise a ParseError exception if the string is invalid.
Source code in xdsl/irdl/declarative_assembly_format.py
parse(parser: Parser, op_type: type[IRDLOperationInvT]) -> IRDLOperationInvT
¶
Parse the operation with this format. The given operation type is expected to be the operation type represented by the operation definition passed to the FormatParser that created this FormatProgram.
Source code in xdsl/irdl/declarative_assembly_format.py
resolve_constraint_variables(state: ParsingState, op_def: OpDef)
¶
Runs verification on the parsed parts of the operation, adding the resolved value
of each constraint variable to the ConstraintContext state.context.
Source code in xdsl/irdl/declarative_assembly_format.py
resolve_operand_types(state: ParsingState, op_def: OpDef) -> Sequence[Sequence[Attribute]]
¶
Use the inferred type resolutions to fill missing operand types from other parsed types.
Source code in xdsl/irdl/declarative_assembly_format.py
resolve_result_types(state: ParsingState, op_def: OpDef) -> Sequence[Sequence[Attribute]]
¶
Use the inferred type resolutions to fill missing result types from other parsed types.
Source code in xdsl/irdl/declarative_assembly_format.py
print(printer: Printer, op: IRDLOperation) -> None
¶
Print the operation with this format. The given operation is expected to be defined using the operation definition passed to the FormatParser that created this FormatProgram.
Source code in xdsl/irdl/declarative_assembly_format.py
Directive
dataclass
¶
Bases: ABC
An assembly format directive
Source code in xdsl/irdl/declarative_assembly_format.py
__init__() -> None
¶
is_present(op: IRDLOperation) -> bool
¶
is_anchorable() -> bool
¶
is_variadic_like() -> bool
¶
Variadic-like format directives parse a comma separated list, and cannot be
followed by , directive.
is_optional_like() -> bool
¶
Directives that successfully parse the empty string. The first element in an optional group must be optional-like.
FormatDirective
dataclass
¶
Bases: Directive, ABC
A format directive for operation format.
Source code in xdsl/irdl/declarative_assembly_format.py
parse(parser: Parser, state: ParsingState) -> None
abstractmethod
¶
parse_optional(parser: Parser, state: ParsingState) -> None
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
abstractmethod
¶
set_empty(state: ParsingState)
¶
Set the appropriate field of the parsing state to be empty. Used when a variable appears in an optional group which is not parsed.
CustomDirective
dataclass
¶
Bases: FormatDirective, ABC
A user defined assembly format directive.
A custom directive can have multiple parameters, whose types should be
declared in the parameters field.
Source code in xdsl/irdl/declarative_assembly_format.py
parameters: dict[str, type[FormatDirective]]
class-attribute
¶
TypeableDirective
dataclass
¶
Bases: Directive, ABC
Directives which can be used to set or get types.
Source code in xdsl/irdl/declarative_assembly_format.py
TypeDirective
dataclass
¶
Bases: FormatDirective
A directive which parses the type of a typeable directive, with format: type-directive ::= type(typeable-directive)
Source code in xdsl/irdl/declarative_assembly_format.py
inner: TypeableDirective
instance-attribute
¶
__init__(inner: TypeableDirective) -> None
¶
set(state: ParsingState, types: Sequence[Attribute])
¶
parse(parser: Parser, state: ParsingState)
¶
get(op: IRDLOperation) -> Sequence[Attribute]
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
is_present(op: IRDLOperation) -> bool
¶
is_anchorable() -> bool
¶
is_variadic_like() -> bool
¶
is_optional_like() -> bool
¶
VariableDirective
dataclass
¶
Bases: Directive, ABC
A variable directive, with the following format: variable-directive ::= dollar-ident The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
VariadicVariable
dataclass
¶
Bases: VariableDirective, ABC
Source code in xdsl/irdl/declarative_assembly_format.py
OptionalVariable
dataclass
¶
Bases: VariableDirective, ABC
Source code in xdsl/irdl/declarative_assembly_format.py
AttrDictDirective
dataclass
¶
Bases: FormatDirective
An attribute dictionary directive, with the following format:
attr-dict-directive ::= attr-dict
attr-dict-with-format-directive ::= attributes attr-dict
The directive (with and without the keyword) will always print a space before, and
will not request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
with_keyword: bool
instance-attribute
¶
If this is set, the format starts with the attributes keyword.
reserved_attr_names: set[str]
instance-attribute
¶
The set of attributes that should not be printed. These attributes are printed in other places in the format, and thus would be printed twice otherwise.
expected_properties: set[str]
instance-attribute
¶
Properties that should be printed and parsed as part of this attr-dict. This is used to keep compatibility with MLIR which allows that.
__init__(with_keyword: bool, reserved_attr_names: set[str], expected_properties: set[str]) -> None
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
OperandDirective
dataclass
¶
Bases: FormatDirective, TypeableDirective, ABC
Base class for operand directives to aid typechecking.
Source code in xdsl/irdl/declarative_assembly_format.py
OperandVariable
dataclass
¶
Bases: VariableDirective, OperandDirective
An operand variable, with the following format: operand-directive ::= dollar-ident The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
__init__(name: str, index: int) -> None
¶
set(state: ParsingState, operand: UnresolvedOperand)
¶
set_types(state: ParsingState, types: Sequence[Attribute])
¶
parse(parser: Parser, state: ParsingState)
¶
parse_types(parser: Parser, state: ParsingState)
¶
parse_single_type(parser: Parser, state: ParsingState) -> None
¶
get(op: IRDLOperation) -> SSAValue
¶
get_types(op: IRDLOperation) -> Sequence[Attribute]
¶
VariadicOperandVariable
dataclass
¶
Bases: VariadicVariable, OperandDirective
A variadic operand variable, with the following format:
operand-directive ::= ( percent-ident ( , percent-id )* )?
The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
__init__(name: str, index: int) -> None
¶
set(state: ParsingState, operands: Sequence[UnresolvedOperand])
¶
set_types(state: ParsingState, types: Sequence[Attribute])
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
parse_types(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
parse_single_type(parser: Parser, state: ParsingState) -> None
¶
get(op: IRDLOperation) -> VarOperand
¶
get_types(op: IRDLOperation) -> Sequence[Attribute]
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
OptionalOperandVariable
dataclass
¶
Bases: OptionalVariable, OperandDirective
An optional operand variable, with the following format: operand-directive ::= ( percent-ident )? The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
set(state: ParsingState, operand: UnresolvedOperand | None)
¶
set_types(state: ParsingState, types: Sequence[Attribute])
¶
parse(parser: Parser, state: ParsingState)
¶
parse_types(parser: Parser, state: ParsingState)
¶
parse_single_type(parser: Parser, state: ParsingState) -> None
¶
get(op: IRDLOperation) -> SSAValue | None
¶
get_types(op: IRDLOperation) -> Sequence[Attribute]
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
OperandsOrResultDirective
dataclass
¶
Bases: TypeableDirective, ABC
Base class for the 'operands' and 'results' directives.
Source code in xdsl/irdl/declarative_assembly_format.py
OperandsDirective
dataclass
¶
Bases: OperandsOrResultDirective, FormatDirective
An operands directive, with the following format: operands-directive ::= operands Prints each operand of the operation, inserting a comma between each.
Source code in xdsl/irdl/declarative_assembly_format.py
set_types(state: ParsingState, types: Sequence[Attribute]) -> None
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
parse_types(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
parse_single_type(parser: Parser, state: ParsingState) -> None
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
get_types(op: IRDLOperation) -> Sequence[Attribute]
¶
set_empty(state: ParsingState)
¶
ResultVariable
dataclass
¶
Bases: VariableDirective, TypeableDirective
An result variable, with the following format: result-directive ::= dollar-ident This directive can not be used for parsing and printing directly, as result parsing is not handled by the custom operation parser.
Source code in xdsl/irdl/declarative_assembly_format.py
VariadicResultVariable
dataclass
¶
Bases: VariadicVariable, TypeableDirective
A variadic result variable, with the following format:
result-directive ::= percent-ident (( , percent-id )* )?
This directive can not be used for parsing and printing directly, as result
parsing is not handled by the custom operation parser.
Source code in xdsl/irdl/declarative_assembly_format.py
OptionalResultVariable
dataclass
¶
Bases: OptionalVariable, TypeableDirective
An optional result variable, with the following format: result-directive ::= ( percent-ident )? This directive can not be used for parsing and printing directly, as result parsing is not handled by the custom operation parser.
Source code in xdsl/irdl/declarative_assembly_format.py
ResultsDirective
dataclass
¶
Bases: OperandsOrResultDirective
A results directive, with the following format: results-directive ::= results A typeable directive which processes the result types of the operation.
Source code in xdsl/irdl/declarative_assembly_format.py
set_types(state: ParsingState, types: Sequence[Attribute]) -> None
¶
parse_types(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
parse_single_type(parser: Parser, state: ParsingState) -> None
¶
get_types(op: IRDLOperation) -> Sequence[Attribute]
¶
FunctionalTypeDirective
dataclass
¶
Bases: FormatDirective
A directive which parses a functional type, with format:
functional-type-directive ::= functional-type(typeable-directive, typeable-directive)
A functional type is either of the form
( type-list ) -> ( type-list )
or
( type-list ) -> type
where type-list is a comma separated list of types (or the empty string to signify the empty list).
The second format is preferred for printing when possible.
Source code in xdsl/irdl/declarative_assembly_format.py
operand_typeable_directive: TypeableDirective
instance-attribute
¶
result_typeable_directive: TypeableDirective
instance-attribute
¶
__init__(operand_typeable_directive: TypeableDirective, result_typeable_directive: TypeableDirective) -> None
¶
parse_optional(parser: Parser, state: ParsingState) -> None
¶
Parse a functional type if an opening parenthesis is present, otherwise leave the parser and state unchanged. Once it is present, require the complete signature.
This supports direct Python API use. The directive is not yet optional-like and cannot be the first element of a declarative optional group.
Source code in xdsl/irdl/declarative_assembly_format.py
parse(parser: Parser, state: ParsingState)
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
RegionDirective
dataclass
¶
Bases: FormatDirective, ABC
Baseclass to help keep typechecking simple.
Source code in xdsl/irdl/declarative_assembly_format.py
RegionVariable
dataclass
¶
Bases: RegionDirective, VariableDirective
A region variable, with the following format: region-directive ::= dollar-ident The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
__init__(name: str, index: int) -> None
¶
set(state: ParsingState, region: Region)
¶
parse(parser: Parser, state: ParsingState)
¶
parse_optional(parser: Parser, state: ParsingState)
¶
get(op: IRDLOperation) -> Region
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
is_anchorable() -> bool
¶
set_empty(state: ParsingState)
¶
is_present(op: IRDLOperation) -> bool
¶
VariadicRegionVariable
dataclass
¶
Bases: RegionDirective, VariadicVariable
A variadic region variable, with the following format: region-directive ::= dollar-ident
The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
__init__(name: str, index: int) -> None
¶
set(state: ParsingState, region: Sequence[Region])
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
parse_optional(parser: Parser, state: ParsingState)
¶
get(op: IRDLOperation) -> Sequence[Region]
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
OptionalRegionVariable
dataclass
¶
Bases: RegionDirective, OptionalVariable
An optional region variable, with the following format: region-directive ::= dollar-ident The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
SuccessorDirective
dataclass
¶
Bases: FormatDirective, ABC
Base class for type checking. A variadic successor directive cannot follow another variadic successor directive.
Source code in xdsl/irdl/declarative_assembly_format.py
SuccessorVariable
dataclass
¶
Bases: VariableDirective, SuccessorDirective
A successor variable, with the following format: successor-directive ::= dollar-ident The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
VariadicSuccessorVariable
dataclass
¶
Bases: VariadicVariable, SuccessorDirective
A variadic successor variable, with the following format: successor-directive ::= dollar-ident The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
set(state: ParsingState, successors: Sequence[Successor])
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
get(op: IRDLOperation) -> Sequence[Successor]
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
OptionalSuccessorVariable
dataclass
¶
Bases: OptionalVariable, SuccessorDirective
An optional successor variable, with the following format: successor-directive ::= dollar-ident The directive will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
AttributeVariable
dataclass
¶
Bases: FormatDirective
An attribute variable, with the following format: attribute-variable ::= dollar-ident The directive will request a space to be printed right after.
Source code in xdsl/irdl/declarative_assembly_format.py
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 | |
name: str
instance-attribute
¶
The attribute name as it should be in the attribute or property dictionary.
is_property: bool
instance-attribute
¶
Should this attribute be put in the attribute or property dictionary.
is_optional: bool
instance-attribute
¶
Is this attribute optional in the operation definition.
default_value: Attribute | None
instance-attribute
¶
__init__(name: str, is_property: bool, is_optional: bool, default_value: Attribute | None) -> None
¶
set(state: ParsingState, attr: Attribute)
¶
parse_attr(parser: Parser) -> Attribute | None
¶
parse(parser: Parser, state: ParsingState)
¶
get(op: IRDLOperation) -> Attribute | None
¶
print_attr(printer: Printer, attr: Attribute) -> None
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
is_present(op: IRDLOperation) -> bool
¶
is_anchorable() -> bool
¶
UniqueBaseAttributeVariable
dataclass
¶
Bases: AttributeVariable
Source code in xdsl/irdl/declarative_assembly_format.py
unique_base: type[Attribute]
instance-attribute
¶
The known base class of the Attribute, if any.
__init__(name: str, is_property: bool, is_optional: bool, default_value: Attribute | None, unique_base: type[Attribute]) -> None
¶
parse_attr(parser: Parser) -> Attribute | None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
print_attr(printer: Printer, attr: Attribute) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
TypedAttributeVariable
dataclass
¶
Bases: UniqueBaseAttributeVariable
Source code in xdsl/irdl/declarative_assembly_format.py
DenseArrayAttributeVariable
dataclass
¶
Bases: AttributeVariable
Source code in xdsl/irdl/declarative_assembly_format.py
elt_type: IntegerType | AnyFloat
instance-attribute
¶
__init__(name: str, is_property: bool, is_optional: bool, default_value: Attribute | None, elt_type: IntegerType | AnyFloat) -> None
¶
parse_attr(parser: Parser) -> Attribute | None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
print_attr(printer: Printer, attr: Attribute) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
SymbolNameAttributeVariable
dataclass
¶
Bases: AttributeVariable
Source code in xdsl/irdl/declarative_assembly_format.py
parse_attr(parser: Parser) -> Attribute | None
¶
OptionalUnitAttrVariable
¶
Bases: AttributeVariable
An optional UnitAttr variable that holds no value and derives its meaning from its existence. Holds a parse and print method to reflect this.
operand-directive ::= (unit_attr unit_attr^)?
Also see: https://mlir.llvm.org/docs/DefiningDialects/Operations/#unit-attributes
Source code in xdsl/irdl/declarative_assembly_format.py
WhitespaceDirective
dataclass
¶
Bases: FormatDirective
A whitespace directive, with the following format:
whitespace-directive ::= `
| ` | ``
This directive is only applied during printing, and has no effect during
parsing.
The directive will not request any space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
PunctuationDirective
dataclass
¶
Bases: FormatDirective
A punctuation directive, with the following format:
punctuation-directive ::= punctuation
The directive will request a space to be printed right after, unless the punctuation
is <, (, {, or [.
It will also print a space before if a space is requested, and that the punctuation
is neither >, ), }, ], or , if the last element was a punctuation, and
additionally neither <, (, }, ], if the last element was not a punctuation.
Source code in xdsl/irdl/declarative_assembly_format.py
punctuation: PunctuationSpelling
instance-attribute
¶
The punctuation that should be printed/parsed.
__init__(punctuation: PunctuationSpelling) -> None
¶
parse(parser: Parser, state: ParsingState)
¶
parse_optional(parser: Parser, state: ParsingState) -> None
¶
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
KeywordDirective
dataclass
¶
Bases: FormatDirective
A keyword directive, with the following format: keyword-directive ::= bare-ident The directive expects a specific identifier, and will request a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
OptionalGroupDirective
dataclass
¶
Bases: FormatDirective
Source code in xdsl/irdl/declarative_assembly_format.py
anchor: Directive
instance-attribute
¶
then_whitespace: tuple[WhitespaceDirective, ...]
instance-attribute
¶
then_first: FormatDirective
instance-attribute
¶
then_elements: tuple[FormatDirective, ...]
instance-attribute
¶
else_elements: tuple[FormatDirective, ...]
instance-attribute
¶
__init__(anchor: Directive, then_whitespace: tuple[WhitespaceDirective, ...], then_first: FormatDirective, then_elements: tuple[FormatDirective, ...], else_elements: tuple[FormatDirective, ...]) -> None
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/irdl/declarative_assembly_format.py
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/irdl/declarative_assembly_format.py
set_empty(state: ParsingState) -> None
¶
AttrParsingState
dataclass
¶
AttrFormatDirective
dataclass
¶
Bases: ABC
Base class for attribute/type format directives.
Separate from FormatDirective because operation formats parse full ops (operands, results, regions, etc.) using Parser and ParsingState, while attribute/type formats only fill parameter slots of a ParametrizedAttribute using AttrParser and AttrParsingState.
Source code in xdsl/irdl/declarative_assembly_format.py
AttrWhitespaceDirective
dataclass
¶
Bases: AttrFormatDirective
A whitespace directive for attribute/type assembly format.
Mirrors the op-side WhitespaceDirective: only applied during printing, with no effect during parsing.
Source code in xdsl/irdl/declarative_assembly_format.py
AttrKeywordDirective
dataclass
¶
Bases: AttrFormatDirective
A keyword directive for attribute/type assembly format.
Mirrors the op-side KeywordDirective: expects a specific identifier and requests a space to be printed after.
Source code in xdsl/irdl/declarative_assembly_format.py
AttrFormatProgram
dataclass
¶
The toplevel data structure of a declarative assembly format program for attributes/types.
Source code in xdsl/irdl/declarative_assembly_format.py
stmts: tuple[AttrFormatDirective, ...]
instance-attribute
¶
The statements composing the program. They are executed in order.
__init__(stmts: tuple[AttrFormatDirective, ...]) -> None
¶
from_str(format_str: str, attr_def: ParamAttrDef) -> AttrFormatProgram
staticmethod
¶
Source code in xdsl/irdl/declarative_assembly_format.py
parse(parser: AttrParser, attr_def: ParamAttrDef) -> list[Attribute]
¶
Run each directive in order, returning the parsed parameter values.
IRDL constraint verification runs when the attribute is constructed, not during this parse step.
Source code in xdsl/irdl/declarative_assembly_format.py
print(printer: Printer, attr: ParametrizedAttribute) -> None
¶
irdl_custom_directive(cls: type[CustomDirectiveInvT]) -> type[CustomDirectiveInvT]
¶
Decorator used on custom directives to define the parameters class variable.