Format
format
FuncOpLikeParseResult: TypeAlias = tuple[str, Sequence[Attribute], Sequence[Attribute], Region, DictionaryAttr | None, ArrayAttr[DictionaryAttr] | None, ArrayAttr[DictionaryAttr] | None]
module-attribute
FuncOpLikeParseResultWithVariadic: TypeAlias = tuple[str, Sequence[Attribute], Sequence[Attribute], Region, DictionaryAttr | None, ArrayAttr[DictionaryAttr] | None, ArrayAttr[DictionaryAttr] | None, bool]
module-attribute
AbstractYieldOperation
Bases: IRDLOperation, Generic[AttributeInvT]
A base class for yielding operations to inherit, provides the standard custom syntax
and a definition of the arguments variadic operand.
Source code in xdsl/dialects/utils/format.py
27 28 29 30 31 32 33 34 35 36 37 38 | |
arguments = var_operand_def(AttributeInvT)
class-attribute
instance-attribute
assembly_format = 'attr-dict ($arguments^ `:` type($arguments))?'
class-attribute
instance-attribute
__init__(*operands: SSAValue | Operation)
Source code in xdsl/dialects/utils/format.py
37 38 | |
print_for_op_like(printer: Printer, lower_bound: IntegerAttr | SSAValue, upper_bound: IntegerAttr | SSAValue, step: IntegerAttr | SSAValue, iter_args: Sequence[SSAValue], body: Region, default_indvar_type: type[TypeAttribute] | None = None, bound_words: Sequence[str] = ['to'])
Prints the loop bounds, step, iteration arguments, and body.
Users can provide a default induction variable type and specific human-readable words for bounds (default: "to").
Note that providing a default induction variable type is required to suggest that
all loop control variable types (induction, bounds and step) have the same type,
hence moving the induction variable type printing to the end of the for expression.
The induction variable type printing is ommited when it matches the expected default
type (default_indvar_type).
The lower_bound, upper_bound, and step may be dynamic SSAValues or static
IntegerAttrs.
When static, the typed integer literal is printed (value and type), not an SSA
value reference.
Source code in xdsl/dialects/utils/format.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
parse_for_op_like(parser: Parser, default_indvar_type: TypeAttribute | None = None, bound_words: Sequence[str] = ['to'], *, allow_static_upper_bound: bool = False, allow_static_step: bool = False) -> tuple[SSAValue, IntegerAttr | SSAValue, IntegerAttr | SSAValue, Sequence[SSAValue], Region]
parse_for_op_like(
parser: Parser,
default_indvar_type: TypeAttribute | None = ...,
bound_words: Sequence[str] = ...,
*,
allow_static_upper_bound: Literal[False] = ...,
allow_static_step: Literal[False] = ...,
) -> tuple[
SSAValue, SSAValue, SSAValue, Sequence[SSAValue], Region
]
parse_for_op_like(
parser: Parser,
default_indvar_type: TypeAttribute | None = ...,
bound_words: Sequence[str] = ...,
*,
allow_static_upper_bound: Literal[False] = ...,
allow_static_step: Literal[True],
) -> tuple[
SSAValue,
SSAValue,
IntegerAttr | SSAValue,
Sequence[SSAValue],
Region,
]
parse_for_op_like(
parser: Parser,
default_indvar_type: TypeAttribute | None = ...,
bound_words: Sequence[str] = ...,
*,
allow_static_upper_bound: Literal[True],
allow_static_step: Literal[False] = ...,
) -> tuple[
SSAValue,
IntegerAttr | SSAValue,
SSAValue,
Sequence[SSAValue],
Region,
]
parse_for_op_like(
parser: Parser,
default_indvar_type: TypeAttribute | None = ...,
bound_words: Sequence[str] = ...,
*,
allow_static_upper_bound: Literal[True],
allow_static_step: Literal[True],
) -> tuple[
SSAValue,
IntegerAttr | SSAValue,
IntegerAttr | SSAValue,
Sequence[SSAValue],
Region,
]
Returns the loop bounds, step, iteration arguments, and body.
Users can provide a default induction variable type and specific human-readable words for bounds (default: "to"). Note that providing a default induction variable type is required to suggest that all loop control variable types (induction, bounds and step) have the same type, hence the induction variable type is potentially expected at the end of the for expression.
When allow_static_upper_bound=True, the upper bound may be either a static typed
integer literal or a dynamic SSA value.
When allow_static_step=True, the step may be either a static typed integer literal
or a dynamic SSA value.
The default (False) only allows dynamic SSA values.
Source code in xdsl/dialects/utils/format.py
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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
print_func_op_like(printer: Printer, sym_name: StringAttr, function_type: FunctionType, body: Region, attributes: dict[str, Attribute], *, arg_attrs: ArrayAttr[DictionaryAttr] | None = None, res_attrs: ArrayAttr[DictionaryAttr] | None = None, reserved_attr_names: Sequence[str], is_variadic: bool = False, print_empty_outputs: bool = True)
Source code in xdsl/dialects/utils/format.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
parse_func_op_like(parser: Parser, *, reserved_attr_names: Sequence[str], allow_variadic: bool = False) -> FuncOpLikeParseResult | FuncOpLikeParseResultWithVariadic
parse_func_op_like(
parser: Parser,
*,
reserved_attr_names: Sequence[str],
allow_variadic: Literal[False] = False,
) -> FuncOpLikeParseResult
parse_func_op_like(
parser: Parser,
*,
reserved_attr_names: Sequence[str],
allow_variadic: Literal[True],
) -> FuncOpLikeParseResultWithVariadic
Returns the function name, argument types, return types, body, extra args, arg_attrs and res_attrs. If allow_variadic=True, also returns is_variadic as the 8th element.
Source code in xdsl/dialects/utils/format.py
453 454 455 456 457 458 459 460 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 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
print_func_argument(printer: Printer, arg: BlockArgument, attrs: DictionaryAttr | None)
Keep function-argument syntax compatible with MLIR parser expectations:
%arg : type {attrs} loc(...) (location after attrs).
Source code in xdsl/dialects/utils/format.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
print_func_output(printer: Printer, out_type: Attribute, attrs: DictionaryAttr | None)
Source code in xdsl/dialects/utils/format.py
587 588 589 590 591 592 | |
print_assignment(printer: Printer, arg: BlockArgument, val: SSAValue)
Source code in xdsl/dialects/utils/format.py
595 596 597 598 | |
parse_assignment(parser: Parser) -> tuple[Parser.UnresolvedArgument, UnresolvedOperand]
Source code in xdsl/dialects/utils/format.py
601 602 603 604 605 606 607 | |