Constraints
constraints
¶
ParametrizedAttributeT = TypeVar('ParametrizedAttributeT', bound=ParametrizedAttribute)
module-attribute
¶
ParametrizedAttributeCovT = TypeVar('ParametrizedAttributeCovT', bound=ParametrizedAttribute, covariant=True)
module-attribute
¶
InferenceContext
dataclass
¶
Bases: ABC
Stores the assignments of constraint variables without allowing assignment. Used for inference, at which point variables are read-only.
Source code in xdsl/irdl/constraints.py
attr_variables: AbstractSet[str]
property
¶
range_variables: AbstractSet[str]
property
¶
int_variables: AbstractSet[str]
property
¶
__init__(_variables: dict[str, Attribute] = dict[str, Attribute](), _range_variables: dict[str, tuple[Attribute, ...]] = dict[str, tuple[Attribute, ...]](), _int_variables: dict[str, int] = dict[str, int]()) -> None
¶
get_variable(key: str) -> Attribute | None
¶
get_range_variable(key: str) -> tuple[Attribute, ...] | None
¶
VerificationContext
dataclass
¶
Bases: InferenceContext
Contains the assignment of constraint variables, allowing assignment.
Source code in xdsl/irdl/constraints.py
__init__(_variables: dict[str, Attribute] = dict[str, Attribute](), _range_variables: dict[str, tuple[Attribute, ...]] = dict[str, tuple[Attribute, ...]](), _int_variables: dict[str, int] = dict[str, int]()) -> None
¶
set_attr_variable(key: str, attr: Attribute) -> bool
¶
Tries to assign the attribute 'attr' to key 'key'. If a different attribute is already assigned to this key, then this function throws a VerifyError.
The return value indicates whether this key was set by this call.
Source code in xdsl/irdl/constraints.py
set_range_variable(key: str, attrs: tuple[Attribute, ...]) -> bool
¶
Tries to assign the attributes 'attrs' to key 'key'. If a different attribute range is already assigned to this key, then this function throws a VerifyError.
The return value indicates whether this key was set by this call.
Source code in xdsl/irdl/constraints.py
set_int_variable(key: str, i: int) -> bool
¶
Tries to assign the integer 'i' to key 'key'. If a different integer is already assigned to this key, then this function throws a VerifyError.
The return value indicates whether this key was set by this call.
Source code in xdsl/irdl/constraints.py
ConstraintContext
dataclass
¶
AttrConstraint
dataclass
¶
Bases: ABC, Generic[AttributeCovT]
Constrain an attribute to a certain value.
Source code in xdsl/irdl/constraints.py
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 | |
__init__() -> None
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
abstractmethod
¶
Check if the attribute satisfies the constraint, or raise an exception otherwise.
verifies(attr: Attribute) -> TypeGuard[AttributeCovT]
¶
A helper method to check whether a given attribute matches self.
Source code in xdsl/irdl/constraints.py
variables() -> set[str]
¶
Returns a set of the variables that can be extracted by this constraint.
These variables are always expected to be set after running verify.
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
Check if there is enough information to infer the attribute given the constraint variables that are already set.
Source code in xdsl/irdl/constraints.py
infer(context: InferenceContext) -> AttributeCovT
¶
Infer the attribute given the the values for all variables.
Raises an exception if the attribute cannot be inferred. If can_infer
returns True with the given constraint variables, this method should
not raise an exception.
Source code in xdsl/irdl/constraints.py
get_bases() -> set[type[Attribute]] | None
¶
Get a set of base types that can satisfy this constraint, if there exists a finite collection, or None otherwise.
relax_constraint(other: AttrConstraint[AttributeCovT]) -> AttrConstraint[AttributeCovT] | None
¶
Attempt to relax this constraint by merging it with other,
returning the result if successful.
Source code in xdsl/irdl/constraints.py
__or__(value: AttrConstraint[_AttributeCovT]) -> AttrConstraint[AttributeCovT | _AttributeCovT]
¶
Source code in xdsl/irdl/constraints.py
__and__(value: AttrConstraint) -> AttrConstraint[AttributeCovT]
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint[AttributeCovT]
abstractmethod
¶
A helper function to make type vars used in attribute definitions concrete when creating constraints for new attributes or operations.
Source code in xdsl/irdl/constraints.py
AnyAttr
dataclass
¶
Bases: AttrConstraint
Constraint that is verified by all attributes.
Source code in xdsl/irdl/constraints.py
VarConstraint
dataclass
¶
Bases: AttrConstraint[AttributeCovT]
Constrain an attribute with the given constraint, and constrain all occurences of this constraint (i.e, sharing the same name) to be equal.
Source code in xdsl/irdl/constraints.py
name: str
instance-attribute
¶
The variable name. All uses of that name refer to the same variable.
constraint: AttrConstraint[AttributeCovT]
instance-attribute
¶
The constraint that the variable must satisfy.
__init__(name: str, constraint: AttrConstraint[AttributeCovT]) -> None
¶
get(name: str, constraint: IRDLAttrConstraint[AttributeCovT] = AnyAttr())
staticmethod
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
variables() -> set[str]
¶
infer(context: InferenceContext) -> AttributeCovT
¶
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
get_bases() -> set[type[Attribute]] | None
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> VarConstraint[AttributeCovT]
¶
TypeVarConstraint
dataclass
¶
Bases: AttrConstraint
Stores the TypeVar instance used to define a generic ParametrizedAttribute.
Source code in xdsl/irdl/constraints.py
type_var: TypeVar
instance-attribute
¶
The instance of the TypeVar used in the definition.
base_constraint: AttrConstraint
instance-attribute
¶
Constraint inferred from the base of the TypeVar.
__init__(type_var: TypeVar, base_constraint: AttrConstraint) -> None
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
get_bases() -> set[type[Attribute]] | None
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint
¶
Source code in xdsl/irdl/constraints.py
EqAttrConstraint
dataclass
¶
Bases: AttrConstraint[AttributeCovT], Generic[AttributeCovT]
Constrain an attribute to be equal to another attribute.
Source code in xdsl/irdl/constraints.py
attr: AttributeCovT
instance-attribute
¶
The attribute we want to check equality with.
__init__(attr: AttributeCovT) -> None
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> AttributeCovT
¶
get_bases() -> set[type[Attribute]] | None
¶
relax_constraint(other: AttrConstraint[AttributeCovT]) -> AttrConstraint[AttributeCovT] | None
¶
Source code in xdsl/irdl/constraints.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint[AttributeCovT]
¶
AttrSetConstraint
dataclass
¶
Bases: AttrConstraint[AttributeCovT], Generic[AttributeCovT]
Constrain an attribute to be one of a set of attributes.
Source code in xdsl/irdl/constraints.py
values: frozenset[AttributeCovT]
instance-attribute
¶
__init__(values: frozenset[AttributeCovT]) -> None
¶
__repr__() -> str
¶
get(*values: AttributeInvT) -> AttrConstraint[AttributeInvT]
staticmethod
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
get_bases() -> set[type[Attribute]] | None
¶
relax_constraint(other: AttrConstraint[AttributeCovT]) -> AttrConstraint[AttributeCovT] | None
¶
Source code in xdsl/irdl/constraints.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint[AttributeCovT]
¶
BaseAttr
dataclass
¶
Bases: AttrConstraint[AttributeCovT], Generic[AttributeCovT]
Constrain an attribute to be of a given base type.
Source code in xdsl/irdl/constraints.py
attr: type[AttributeCovT]
instance-attribute
¶
The expected attribute base type.
__init__(attr: type[AttributeCovT]) -> None
¶
__repr__()
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> AttributeCovT
¶
get_bases() -> set[type[Attribute]] | None
¶
relax_constraint(other: AttrConstraint[AttributeCovT]) -> AttrConstraint[AttributeCovT] | None
¶
Source code in xdsl/irdl/constraints.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint[AttributeCovT]
¶
AnyOf
dataclass
¶
Bases: AttrConstraint[AttributeCovT], Generic[AttributeCovT]
Ensure that an attribute satisfies one of the given constraints.
Source code in xdsl/irdl/constraints.py
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 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
attr_constrs: tuple[AttrConstraint[AttributeCovT], ...]
instance-attribute
¶
The tuple of attribute constraints that are checked by this AnyOf constraint.
At most one constraint may be "abstract": an abstract constraint is a BaseAttr
for an abstract base class which can be inherited by other attribute classes.
This abstract attribute type is not runtime-final (i.e., does not have the @irdl_attr_definition decorator).
get(*attr_constrs: IRDLAttrConstraint[AttributeInvT]) -> AttrConstraint[AttributeInvT]
staticmethod
¶
Source code in xdsl/irdl/constraints.py
__init__(attr_constrs: tuple[AttrConstraint[AttributeCovT], ...])
¶
Source code in xdsl/irdl/constraints.py
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
variables() -> set[str]
¶
get_bases() -> set[type[Attribute]] | None
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint[AttributeCovT]
¶
AllOf
dataclass
¶
Bases: AttrConstraint[AttributeCovT]
Ensure that an attribute satisfies all the given constraints.
Source code in xdsl/irdl/constraints.py
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 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | |
attr_constrs: tuple[AttrConstraint[AttributeCovT], ...]
instance-attribute
¶
The list of constraints that are checked.
__init__(attr_constrs: tuple[AttrConstraint[AttributeCovT], ...]) -> None
¶
get(*attr_constrs: IRDLAttrConstraint[AttributeInvT]) -> AttrConstraint[AttributeInvT]
staticmethod
¶
Source code in xdsl/irdl/constraints.py
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
variables() -> set[str]
¶
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> AttributeCovT
¶
get_bases() -> set[type[Attribute]] | None
¶
Source code in xdsl/irdl/constraints.py
__and__(value: AttrConstraint) -> AllOf[AttributeCovT]
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AllOf[AttributeCovT]
¶
ParamAttrConstraint
dataclass
¶
Bases: AttrConstraint[ParametrizedAttributeCovT], Generic[ParametrizedAttributeCovT]
Constrain an attribute to be of a given type, and also constrain its parameters with additional constraints.
Source code in xdsl/irdl/constraints.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 | |
base_attr: type[ParametrizedAttributeCovT]
instance-attribute
¶
The base attribute type.
param_constrs: tuple[AttrConstraint, ...]
instance-attribute
¶
The attribute parameter constraints
__init__(base_attr: type[ParametrizedAttributeCovT], param_constrs: tuple[AttrConstraint, ...]) -> None
¶
get(base_attr: type[ParametrizedAttributeT], *param_constrs: IRDLAttrConstraint | None) -> AttrConstraint[ParametrizedAttributeT]
staticmethod
¶
Source code in xdsl/irdl/constraints.py
__repr__()
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
variables() -> set[str]
¶
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> ParametrizedAttributeCovT
¶
get_bases() -> set[type[Attribute]] | None
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint[ParametrizedAttributeCovT]
¶
Source code in xdsl/irdl/constraints.py
relax_constraint(other: AttrConstraint[ParametrizedAttributeCovT]) -> AttrConstraint[ParametrizedAttributeCovT] | None
¶
Source code in xdsl/irdl/constraints.py
MessageConstraint
dataclass
¶
Bases: AttrConstraint[AttributeCovT]
Attach a message to a constraint, to provide more context when the constraint is not satisfied.
Source code in xdsl/irdl/constraints.py
constr: AttrConstraint[AttributeCovT]
instance-attribute
¶
message: str
instance-attribute
¶
__init__(constr: AttrConstraint[AttributeCovT] | AttributeCovT | type[AttributeCovT], message: str)
¶
Source code in xdsl/irdl/constraints.py
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
variables() -> set[str]
¶
get_bases() -> set[type[Attribute]] | None
¶
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> AttributeCovT
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> MessageConstraint[AttributeCovT]
¶
IntConstraint
dataclass
¶
Bases: ABC
Constrain an integer to certain values.
Source code in xdsl/irdl/constraints.py
__init__() -> None
¶
verify(i: int, constraint_context: VerificationContext) -> None
abstractmethod
¶
Check if the integer satisfies the constraint, or raise an exception otherwise.
variables() -> set[str]
¶
Returns a set of the variables that can be extracted by this constraint.
These variables are always expected to be set after running verify.
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
Check if there is enough information to infer the integer given the constraint variables that are already set.
Source code in xdsl/irdl/constraints.py
infer(context: InferenceContext) -> int
¶
Infer the attribute given the the values for all variables.
Raises an exception if the attribute cannot be inferred. If can_infer
returns True with the given constraint variables, this method should
not raise an exception.
Source code in xdsl/irdl/constraints.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> IntConstraint
abstractmethod
¶
A helper function to make type vars used in attribute definitions concrete when creating constraints for new attributes or operations.
Source code in xdsl/irdl/constraints.py
AnyInt
dataclass
¶
Bases: IntConstraint
Constraint that is verified by all integers.
Source code in xdsl/irdl/constraints.py
verify(i: int, constraint_context: VerificationContext) -> None
¶
EqIntConstraint
dataclass
¶
Bases: IntConstraint
Constrain an integer to a value.
Source code in xdsl/irdl/constraints.py
NotEqualIntConstraint
dataclass
¶
Bases: IntConstraint
Constrain an integer to not be equal to a given value.
Source code in xdsl/irdl/constraints.py
IntSetConstraint
dataclass
¶
Bases: IntConstraint
Constrain an integer to one of a set of integers.
Source code in xdsl/irdl/constraints.py
values: frozenset[int]
instance-attribute
¶
__init__(values: frozenset[int]) -> None
¶
__repr__() -> str
¶
get(*values: int) -> IntConstraint
staticmethod
¶
verify(i: int, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> int
¶
AtLeast
dataclass
¶
Bases: IntConstraint
Constrain an integer to be at least a given value.
Source code in xdsl/irdl/constraints.py
AtMost
dataclass
¶
Bases: IntConstraint
Constrain an integer to be at most a given value.
Source code in xdsl/irdl/constraints.py
IntVarConstraint
dataclass
¶
Bases: IntConstraint
Constrain an integer with the given constraint, and constrain all occurences of this constraint (i.e, sharing the same name) to be equal.
Source code in xdsl/irdl/constraints.py
name: str
instance-attribute
¶
The variable name. All uses of that name refer to the same variable.
constraint: IntConstraint
instance-attribute
¶
The constraint that the variable must satisfy.
__init__(name: str, constraint: IntConstraint) -> None
¶
get(name: str, constraint: int | TypeForm[int] | IntConstraint = AnyInt()) -> IntConstraint
staticmethod
¶
Source code in xdsl/irdl/constraints.py
verify(i: int, constraint_context: VerificationContext) -> None
¶
variables() -> set[str]
¶
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> int
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> IntConstraint
¶
IntTypeVarConstraint
dataclass
¶
Bases: IntConstraint
Stores the TypeVar instance used to define a generic type.
Source code in xdsl/irdl/constraints.py
type_var: TypeVar
instance-attribute
¶
The instance of the TypeVar used in the definition.
base_constraint: IntConstraint
instance-attribute
¶
Constraint inferred from the base of the TypeVar.
__init__(type_var: TypeVar, base_constraint: IntConstraint) -> None
¶
verify(i: int, constraint_context: VerificationContext) -> None
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> IntConstraint
¶
Source code in xdsl/irdl/constraints.py
SizedConstraint
dataclass
¶
Bases: AttrConstraint
Constraint the length of a sized attribute with an int constraint
Source code in xdsl/irdl/constraints.py
len_constraint: IntConstraint
instance-attribute
¶
__init__(len_constraint: IntConstraint) -> None
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
variables() -> set[str]
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint
¶
RangeConstraint
dataclass
¶
Bases: ABC, Generic[AttributeCovT]
Constrain a range of attributes to certain values.
Source code in xdsl/irdl/constraints.py
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 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 | |
__init__() -> None
¶
verify(attrs: Sequence[Attribute], constraint_context: VerificationContext) -> None
abstractmethod
¶
Check if the range satisfies the constraint, or raise an exception otherwise.
verifies(attrs: Sequence[Attribute]) -> TypeGuard[AttributeCovT]
¶
A helper method to check whether a given attribute matches self.
Source code in xdsl/irdl/constraints.py
verify_length(length: int, constraint_context: VerificationContext) -> None
abstractmethod
¶
Check if the length of the range satisfies the constraint, or raise an exception otherwise.
variables() -> set[str]
¶
Returns a set of the variables that can be extracted by this constraint.
These variables are always expected to be set after running verify.
variables_from_length() -> set[str]
¶
Returns a set of the variables that can be extracted from the range length by this constraint.
These variables are always expected to be set after running verify_length.
Source code in xdsl/irdl/constraints.py
can_infer(var_constraint_names: AbstractSet[str], *, length_known: bool) -> bool
¶
Check if there is enough information to infer the attribute given the constraint variables that are already set, and whether the length of the range is known in advance.
Source code in xdsl/irdl/constraints.py
infer(context: InferenceContext, *, length: int | None) -> Sequence[AttributeCovT]
¶
Infer the attribute given the the values for all variables, and possibly the length of the range if known.
Raises an exception if the attribute cannot be inferred. If can_infer
returns True with the given constraint variables, this method should
not raise an exception.
Source code in xdsl/irdl/constraints.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> RangeConstraint[AttributeCovT]
abstractmethod
¶
A helper function to make type vars used in attribute definitions concrete when creating constraints for new attributes or operations.
Source code in xdsl/irdl/constraints.py
of_length(length_constr: int | TypeForm[int] | IntConstraint) -> RangeLengthConstraint[AttributeCovT]
¶
Source code in xdsl/irdl/constraints.py
AnyRange
dataclass
¶
Bases: RangeConstraint
A constraint allowing any range.
Source code in xdsl/irdl/constraints.py
RangeLengthConstraint
dataclass
¶
Bases: RangeConstraint[AttributeCovT]
Constrain an attribute range with the given length.
Source code in xdsl/irdl/constraints.py
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 | |
constraint: RangeConstraint[AttributeCovT]
instance-attribute
¶
The constraint that the variable must satisfy.
length: IntConstraint
instance-attribute
¶
The length that the range must have
__init__(constraint: RangeConstraint[AttributeCovT], length: IntConstraint) -> None
¶
verify(attrs: Sequence[Attribute], constraint_context: VerificationContext) -> None
¶
verify_length(length: int, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/irdl/constraints.py
variables() -> set[str]
¶
variables_from_length() -> set[str]
¶
can_infer(var_constraint_names: AbstractSet[str], *, length_known: bool) -> bool
¶
Source code in xdsl/irdl/constraints.py
infer(context: InferenceContext, *, length: int | None) -> Sequence[AttributeCovT]
¶
Source code in xdsl/irdl/constraints.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> RangeLengthConstraint[AttributeCovT]
¶
Source code in xdsl/irdl/constraints.py
RangeVarConstraint
dataclass
¶
Bases: RangeConstraint[AttributeCovT]
Constrain an attribute range with the given constraint, and constrain all occurences of this constraint (i.e, sharing the same name) to be equal.
Source code in xdsl/irdl/constraints.py
1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 | |
name: str
instance-attribute
¶
The variable name. All uses of that name refer to the same variable.
constraint: RangeConstraint[AttributeCovT]
instance-attribute
¶
The constraint that the variable must satisfy.
__init__(name: str, constraint: RangeConstraint[AttributeCovT]) -> None
¶
get(name: str, constraint: IRDLAttrConstraint[AttributeInvT] | RangeConstraint[AttributeInvT] = AnyRange()) -> RangeConstraint[AttributeInvT]
staticmethod
¶
Source code in xdsl/irdl/constraints.py
verify(attrs: Sequence[Attribute], constraint_context: VerificationContext) -> None
¶
verify_length(length: int, constraint_context: VerificationContext) -> None
¶
variables() -> set[str]
¶
can_infer(var_constraint_names: AbstractSet[str], *, length_known: bool) -> bool
¶
infer(context: InferenceContext, *, length: int | None) -> Sequence[AttributeCovT]
¶
Source code in xdsl/irdl/constraints.py
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> RangeVarConstraint[AttributeCovT]
¶
RangeOf
dataclass
¶
Bases: RangeConstraint[AttributeCovT]
Constrain each element in a range to satisfy a given constraint.
Source code in xdsl/irdl/constraints.py
constr: AttrConstraint[AttributeCovT]
instance-attribute
¶
__init__(constr: IRDLAttrConstraint[AttributeCovT])
¶
verify(attrs: Sequence[Attribute], constraint_context: VerificationContext) -> None
¶
verify_length(length: int, constraint_context: VerificationContext)
¶
Source code in xdsl/irdl/constraints.py
variables() -> set[str]
¶
can_infer(var_constraint_names: AbstractSet[str], *, length_known: bool) -> bool
¶
infer(context: InferenceContext, *, length: int | None) -> Sequence[AttributeCovT]
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> RangeOf[AttributeCovT]
¶
SingleOf
dataclass
¶
Bases: RangeConstraint[AttributeCovT]
Constrain a range to only contain a single element, which should satisfy a given constraint.