Attributes
attributes
TypeAttributeInvT = TypeVar('TypeAttributeInvT', bound=(type[Attribute]))
module-attribute
IRDLAttrConstraint: TypeAlias = AttrConstraint[AttributeInvT] | AttributeInvT | type[AttributeInvT] | type[ConstraintConvertible[AttributeInvT]] | ConstraintConvertible[AttributeInvT] | TypeForm[AttributeInvT]
module-attribute
Attribute constraints represented using the IRDL python frontend. Attribute constraints
can either be:
- An instance of AttrConstraint representing a constraint on an attribute.
- An instance of Attribute representing an equality constraint on an attribute.
- A type representing a specific attribute class.
- A TypeForm that can represent both unions and generic attributes.
- An instance or subclass of ConstraintConvertible.
GenericData
dataclass
Bases: Data[_DataElement], ABC
A Data with type parameters.
Source code in xdsl/irdl/attributes.py
79 80 81 82 83 84 85 86 87 88 89 90 | |
constr() -> AttrConstraint
abstractmethod
staticmethod
Returns a constraint for this subclass. Generic arguments are constrained via TypeVarConstraints.
Source code in xdsl/irdl/attributes.py
84 85 86 87 88 89 90 | |
ParamDef
Bases: NamedTuple
Contains information about a parameter,
effectively acting as a resolved _ParameterDef
Source code in xdsl/irdl/attributes.py
171 172 173 174 175 176 177 178 | |
constr: AttrConstraint
instance-attribute
converter: Callable[[Any], Attribute] | None = None
class-attribute
instance-attribute
ParamAttrDef
dataclass
The IRDL definition of a parametrized attribute.
Source code in xdsl/irdl/attributes.py
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 279 280 281 282 283 284 | |
name: str
instance-attribute
parameters: list[tuple[str, ParamDef]]
instance-attribute
__init__(name: str, parameters: list[tuple[str, ParamDef]]) -> None
from_pyrdl(pyrdl_def: type[ParametrizedAttribute]) -> ParamAttrDef
staticmethod
Source code in xdsl/irdl/attributes.py
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 | |
verify(attr: ParametrizedAttribute)
Verify that attr satisfies the invariants.
Source code in xdsl/irdl/attributes.py
279 280 281 282 283 284 | |
ConstraintConvertible
Bases: Generic[AttributeCovT]
Abstract superclass for values that have corresponding Attribute constraints.
Source code in xdsl/irdl/attributes.py
371 372 373 374 375 376 377 378 379 380 381 382 383 | |
base_constr() -> AttrConstraint[AttributeCovT]
abstractmethod
staticmethod
The constraint for this class.
Source code in xdsl/irdl/attributes.py
376 377 378 379 | |
constr() -> AttrConstraint[AttributeCovT]
abstractmethod
The constraint for this instance.
Source code in xdsl/irdl/attributes.py
381 382 383 | |
param_def(constraint: AttrConstraint[AttributeInvT] | None = None, *, converter: Callable[[Any], AttributeInvT] | None = None, init: Literal[True] = True) -> AttributeInvT
Defines a parameter of a ParametrizedAttribute.
Source code in xdsl/irdl/attributes.py
118 119 120 121 122 123 124 125 | |
check_attr_name(cls: type)
Check that the attribute class has a correct name.
Source code in xdsl/irdl/attributes.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
get_accessors_from_param_attr_def(attr_def: ParamAttrDef) -> dict[str, Any]
Source code in xdsl/irdl/attributes.py
290 291 292 293 294 295 | |
irdl_param_attr_definition(cls: _PAttrTT) -> _PAttrTT
Decorator used on classes to define a new attribute definition.
Source code in xdsl/irdl/attributes.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
irdl_attr_definition(cls: TypeAttributeInvT | None = None, *, init: bool = True) -> TypeAttributeInvT | Callable[[TypeAttributeInvT], TypeAttributeInvT]
irdl_attr_definition(
cls: TypeAttributeInvT, *, init: bool = True
) -> TypeAttributeInvT
irdl_attr_definition(
*, init: bool = True
) -> Callable[[TypeAttributeInvT], TypeAttributeInvT]
Source code in xdsl/irdl/attributes.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
irdl_list_to_attr_constraint(pyrdl_constraints: Sequence[IRDLAttrConstraint], *, allow_type_var: bool = False) -> AttrConstraint
Convert a list of PyRDL type annotations to an AttrConstraint.
Each list element correspond to a constraint to satisfy.
If there is a ConstraintVar annotation, we add the entire constraint to
the constraint variable.
Source code in xdsl/irdl/attributes.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
irdl_to_attr_constraint(irdl: IRDLAttrConstraint[AttributeInvT], *, allow_type_var: bool = False) -> AttrConstraint[AttributeInvT]
Source code in xdsl/irdl/attributes.py
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 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
base(irdl: type[AttributeInvT]) -> AttrConstraint[AttributeInvT]
Converts an attribute type into the equivalent constraint, detecting generic parameters if present.
Source code in xdsl/irdl/attributes.py
590 591 592 593 594 595 | |
eq(irdl: AttributeInvT) -> AttrConstraint[AttributeInvT]
Converts an attribute instance into the equivalent constraint.
Source code in xdsl/irdl/attributes.py
598 599 600 601 602 | |
get_optional_int_constraint(arg: Any) -> IntConstraint | None
If the input is an int or an int type, return the corresponding constraint, otherwise return None.
Source code in xdsl/irdl/attributes.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | |
get_int_constraint(arg: int | TypeForm[int]) -> IntConstraint
If the input is an int or an int type, return the corresponding constraint,
otherwise raise PyRDLTypeError.
Source code in xdsl/irdl/attributes.py
647 648 649 650 651 652 653 654 655 | |
range_constr_coercion(attr: AttributeCovT | type[AttributeCovT] | AttrConstraint[AttributeCovT] | RangeConstraint[AttributeCovT]) -> RangeConstraint[AttributeCovT]
Source code in xdsl/irdl/attributes.py
658 659 660 661 662 663 664 665 666 667 668 | |
single_range_constr_coercion(attr: AttributeCovT | type[AttributeCovT] | AttrConstraint[AttributeCovT]) -> RangeConstraint[AttributeCovT]
Source code in xdsl/irdl/attributes.py
671 672 673 674 | |
get_constraint(arg: IRDLAttrConstraint | int | TypeForm[int], *, allow_type_var: bool = False) -> AttrConstraint | IntConstraint
get_constraint(
arg: int | TypeForm[int],
*,
allow_type_var: bool = False,
) -> IntConstraint
get_constraint(
arg: IRDLAttrConstraint, *, allow_type_var: bool = False
) -> AttrConstraint
get_constraint(
arg: IRDLAttrConstraint | int | TypeForm[int],
*,
allow_type_var: bool = False,
) -> AttrConstraint | IntConstraint
Converts the input expression, constraint, or type to the corresponding constraint.
Source code in xdsl/irdl/attributes.py
701 702 703 704 705 706 707 708 709 710 711 712 | |