Operations
operations
IRDLOperationInvT = TypeVar('IRDLOperationInvT', bound='IRDLOperation')
module-attribute
IRDLOperationCovT = TypeVar('IRDLOperationCovT', bound='IRDLOperation', covariant=True)
module-attribute
IRDLOperationContrT = TypeVar('IRDLOperationContrT', bound='IRDLOperation', contravariant=True)
module-attribute
Operand: TypeAlias = SSAValue
module-attribute
VarOperand = SSAValues[SSAValue[AttributeCovT]]
module-attribute
OptOperand: TypeAlias = SSAValue | None
module-attribute
VarOpResult = SSAValues[OpResult[AttributeCovT]]
module-attribute
OptOpResult: TypeAlias = OpResult[AttributeInvT] | None
module-attribute
VarRegion: TypeAlias = tuple[Region, ...]
module-attribute
OptRegion: TypeAlias = Region | None
module-attribute
Successor: TypeAlias = Block
module-attribute
OptSuccessor: TypeAlias = Block | None
module-attribute
VarSuccessor: TypeAlias = list[Block]
module-attribute
AttrOrPropInvT = TypeVar('AttrOrPropInvT', bound=AttrOrPropDef)
module-attribute
IRDLOperation
dataclass
Bases: Operation
Source code in xdsl/irdl/operations.py
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 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 | |
assembly_format: str | None = None
class-attribute
custom_directives: tuple[type[CustomDirective], ...] = ()
class-attribute
__init__(*, operands: Sequence[SSAValue | Operation | Sequence[SSAValue | Operation] | None] | None = None, result_types: Sequence[Attribute | Sequence[Attribute] | None] | None = None, properties: Mapping[str, Attribute | None] | None = None, attributes: Mapping[str, Attribute | None] | None = None, successors: Sequence[Block | Sequence[Block] | None] | None = None, regions: Sequence[Region | None | Sequence[Operation] | Sequence[Block] | Sequence[Region | Sequence[Operation] | Sequence[Block]]] | None = None)
Source code in xdsl/irdl/operations.py
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 124 125 126 127 128 129 130 131 132 133 | |
__post_init__()
Source code in xdsl/irdl/operations.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
build(*, operands: Sequence[SSAValue | Operation | Sequence[SSAValue | Operation] | None] | None = None, result_types: Sequence[Attribute | Sequence[Attribute] | None] | None = None, attributes: Mapping[str, Attribute | None] | None = None, properties: Mapping[str, Attribute | None] | None = None, successors: Sequence[Block | Sequence[Block] | None] | None = None, regions: Sequence[Region | None | Sequence[Operation] | Sequence[Block] | Sequence[Region | Sequence[Operation] | Sequence[Block]]] | None = None) -> Self
classmethod
Create a new operation using builders.
Source code in xdsl/irdl/operations.py
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 | |
get_irdl_definition() -> OpDef
classmethod
Get the IRDL operation definition.
Source code in xdsl/irdl/operations.py
193 194 195 196 | |
__eq__(other: object) -> bool
Source code in xdsl/irdl/operations.py
198 199 | |
__hash__() -> int
Source code in xdsl/irdl/operations.py
201 202 | |
IRDLOption
dataclass
Bases: ABC
Additional option used in IRDL.
Source code in xdsl/irdl/operations.py
205 206 207 | |
__init__() -> None
AttrSizedSegments
dataclass
Bases: IRDLOption, ABC
Expect an attribute on the operation that contains the segment sizes of the
operand, result, region, or successor lists.
For instance, the list [a, b, c, d] with segment sizes [1, 3] will result
in the [a], [b, c, d] lists.
The attribute must be a dense array of i32, its lenght must be equal to the
number of segments (e.g. the number of operand definitions), and its sum must
be equal to the number of elements in the list (e.g. the number of operands).
Source code in xdsl/irdl/operations.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
attribute_name: str
class-attribute
as_property: bool = False
class-attribute
instance-attribute
Name of the attribute containing the segment sizes.
__init__(as_property: bool = False) -> None
container(op: Operation) -> dict[str, Attribute]
Source code in xdsl/irdl/operations.py
226 227 228 229 230 | |
AttrSizedOperandSegments
dataclass
Bases: AttrSizedSegments
Expect an attribute on the operation that contains the sizes of the operand
definitions.
See AttrSizedSegments for more information.
Source code in xdsl/irdl/operations.py
233 234 235 236 237 238 239 240 241 242 | |
attribute_name = 'operandSegmentSizes'
class-attribute
instance-attribute
Name of the attribute containing the variadic operand sizes.
__init__(as_property: bool = False) -> None
AttrSizedResultSegments
dataclass
Bases: AttrSizedSegments
Expect an attribute on the operation that contains the sizes of the result
definitions.
See AttrSizedSegments for more information.
Source code in xdsl/irdl/operations.py
245 246 247 248 249 250 251 252 253 254 | |
attribute_name = 'resultSegmentSizes'
class-attribute
instance-attribute
Name of the attribute containing the variadic result sizes.
__init__(as_property: bool = False) -> None
AttrSizedRegionSegments
dataclass
Bases: AttrSizedSegments
Expect an attribute on the operation that contains the sizes of the region
definitions.
See AttrSizedSegments for more information.
Source code in xdsl/irdl/operations.py
257 258 259 260 261 262 263 264 265 266 | |
attribute_name = 'regionSegmentSizes'
class-attribute
instance-attribute
Name of the attribute containing the variadic region sizes.
__init__(as_property: bool = False) -> None
AttrSizedSuccessorSegments
dataclass
Bases: AttrSizedSegments
Expect an attribute on the operation that contains the sizes of the successor
definitions.
See AttrSizedSegments for more information.
Source code in xdsl/irdl/operations.py
269 270 271 272 273 274 275 276 277 278 | |
attribute_name = 'successorSegmentSizes'
class-attribute
instance-attribute
Name of the attribute containing the variadic successor sizes.
__init__(as_property: bool = False) -> None
SameVariadicSize
dataclass
Bases: IRDLOption
All variadic definitions should have the same size.
Source code in xdsl/irdl/operations.py
281 282 283 284 | |
SameVariadicResultSize
dataclass
Bases: SameVariadicSize
All variadic results should have the same size.
Source code in xdsl/irdl/operations.py
287 288 289 290 | |
SameVariadicOperandSize
dataclass
Bases: SameVariadicSize
All variadic operands should have the same size.
Source code in xdsl/irdl/operations.py
293 294 295 296 | |
SameVariadicRegionSize
dataclass
Bases: SameVariadicSize
All variadic regions should have the same size.
Source code in xdsl/irdl/operations.py
299 300 301 302 | |
SameVariadicSuccessorSize
dataclass
Bases: SameVariadicSize
All variadic successors should have the same size.
Source code in xdsl/irdl/operations.py
305 306 307 308 | |
ParsePropInAttrDict
dataclass
Bases: IRDLOption
Allows properties to be omitted from the assembly format, causing them to be parsed as part of the attribute dictionary. This should only be used to ensure MLIR compatibility, it is otherwise bad design to use it.
Source code in xdsl/irdl/operations.py
311 312 313 314 315 316 317 318 | |
__init__() -> None
OperandOrResultDef
dataclass
Bases: ABC
An operand or a result definition. Should not be used directly.
Source code in xdsl/irdl/operations.py
321 322 323 | |
__init__() -> None
VariadicDef
dataclass
Bases: OperandOrResultDef
A variadic operand or result definition. Should not be used directly.
Source code in xdsl/irdl/operations.py
326 327 328 | |
__init__() -> None
OptionalDef
dataclass
Bases: VariadicDef
An optional operand or result definition. Should not be used directly.
Source code in xdsl/irdl/operations.py
331 332 333 | |
__init__() -> None
OperandDef
dataclass
Bases: OperandOrResultDef
An IRDL operand definition.
Source code in xdsl/irdl/operations.py
336 337 338 339 340 341 342 343 344 | |
constr: RangeConstraint = single_range_constr_coercion(attr)
instance-attribute
The operand constraint.
__init__(attr: Attribute | type[Attribute] | AttrConstraint)
Source code in xdsl/irdl/operations.py
343 344 | |
VarOperandDef
dataclass
Bases: OperandDef, VariadicDef
An IRDL variadic operand definition.
Source code in xdsl/irdl/operations.py
350 351 352 353 354 355 356 357 358 | |
constr = range_constr_coercion(attr)
instance-attribute
__init__(attr: Attribute | type[Attribute] | AttrConstraint | RangeConstraint)
Source code in xdsl/irdl/operations.py
354 355 356 357 358 | |
OptOperandDef
dataclass
Bases: VarOperandDef, OptionalDef
An IRDL optional operand definition.
Source code in xdsl/irdl/operations.py
364 365 366 | |
__init__() -> None
ResultDef
dataclass
Bases: OperandOrResultDef
An IRDL result definition.
Source code in xdsl/irdl/operations.py
372 373 374 375 376 377 378 379 380 381 382 383 | |
constr: RangeConstraint = single_range_constr_coercion(attr)
instance-attribute
The result constraint.
__init__(attr: Attribute | type[Attribute] | AttrConstraint | RangeConstraint)
Source code in xdsl/irdl/operations.py
379 380 381 382 383 | |
VarResultDef
dataclass
Bases: ResultDef, VariadicDef
An IRDL variadic result definition.
Source code in xdsl/irdl/operations.py
386 387 388 389 390 391 392 393 | |
constr = range_constr_coercion(attr)
instance-attribute
__init__(attr: Attribute | type[Attribute] | AttrConstraint | RangeConstraint)
Source code in xdsl/irdl/operations.py
390 391 392 393 | |
OptResultDef
dataclass
Bases: VarResultDef, OptionalDef
An IRDL optional result definition.
Source code in xdsl/irdl/operations.py
399 400 401 | |
__init__() -> None
RegionDef
dataclass
An IRDL region definition.
Source code in xdsl/irdl/operations.py
407 408 409 410 411 412 413 | |
entry_args: RangeConstraint = field(default_factory=(lambda: RangeOf(AnyAttr())))
class-attribute
instance-attribute
__init__(entry_args: RangeConstraint = (lambda: RangeOf(AnyAttr()))()) -> None
VarRegionDef
dataclass
Bases: RegionDef, VariadicDef
An IRDL variadic region definition.
Source code in xdsl/irdl/operations.py
416 417 418 | |
__init__(entry_args: RangeConstraint = (lambda: RangeOf(AnyAttr()))()) -> None
OptRegionDef
dataclass
Bases: RegionDef, OptionalDef
An IRDL optional region definition.
Source code in xdsl/irdl/operations.py
421 422 423 | |
__init__(entry_args: RangeConstraint = (lambda: RangeOf(AnyAttr()))()) -> None
SingleBlockRegionDef
dataclass
Bases: RegionDef
An IRDL region definition that expects exactly one block.
Source code in xdsl/irdl/operations.py
430 431 432 | |
__init__(entry_args: RangeConstraint = (lambda: RangeOf(AnyAttr()))()) -> None
VarSingleBlockRegionDef
dataclass
Bases: RegionDef, VariadicDef
An IRDL variadic region definition that expects exactly one block.
Source code in xdsl/irdl/operations.py
435 436 | |
OptSingleBlockRegionDef
dataclass
Bases: RegionDef, OptionalDef
An IRDL optional region definition that expects exactly one block.
Source code in xdsl/irdl/operations.py
439 440 | |
AttrOrPropDef
dataclass
An IRDL attribute or property definition.
Source code in xdsl/irdl/operations.py
443 444 445 446 447 448 | |
constr: AttrConstraint
instance-attribute
default_value: Attribute | None = None
class-attribute
instance-attribute
__init__(constr: AttrConstraint, default_value: Attribute | None = None) -> None
AttributeDef
dataclass
Bases: AttrOrPropDef
An IRDL attribute definition.
Source code in xdsl/irdl/operations.py
451 452 453 | |
__init__(constr: AttrConstraint, default_value: Attribute | None = None) -> None
OptAttributeDef
dataclass
Bases: AttributeDef, OptionalDef
An IRDL attribute definition for an optional attribute.
Source code in xdsl/irdl/operations.py
456 457 458 | |
__init__(constr: AttrConstraint, default_value: Attribute | None = None) -> None
PropertyDef
dataclass
Bases: AttrOrPropDef
An IRDL property definition.
Source code in xdsl/irdl/operations.py
461 462 463 | |
__init__(constr: AttrConstraint, default_value: Attribute | None = None) -> None
OptPropertyDef
dataclass
Bases: PropertyDef, OptionalDef
An IRDL property definition for an optional property.
Source code in xdsl/irdl/operations.py
466 467 468 | |
__init__(constr: AttrConstraint, default_value: Attribute | None = None) -> None
SuccessorDef
An IRDL successor definition.
Source code in xdsl/irdl/operations.py
471 472 | |
VarSuccessorDef
dataclass
Bases: SuccessorDef, VariadicDef
An IRDL variadic successor definition.
Source code in xdsl/irdl/operations.py
475 476 | |
OptSuccessorDef
dataclass
Bases: SuccessorDef, OptionalDef
An IRDL optional successor definition.
Source code in xdsl/irdl/operations.py
479 480 | |
OpDef
dataclass
The internal IRDL definition of an operation.
Source code in xdsl/irdl/operations.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 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 1226 1227 1228 | |
name: str = field(kw_only=False)
class-attribute
instance-attribute
operands: list[tuple[str, OperandDef]] = field(default_factory=(list[tuple[str, OperandDef]]))
class-attribute
instance-attribute
results: list[tuple[str, ResultDef]] = field(default_factory=(list[tuple[str, ResultDef]]))
class-attribute
instance-attribute
properties: dict[str, PropertyDef] = field(default_factory=(dict[str, PropertyDef]))
class-attribute
instance-attribute
attributes: dict[str, AttributeDef] = field(default_factory=(dict[str, AttributeDef]))
class-attribute
instance-attribute
regions: list[tuple[str, RegionDef]] = field(default_factory=(list[tuple[str, RegionDef]]))
class-attribute
instance-attribute
successors: list[tuple[str, SuccessorDef]] = field(default_factory=(list[tuple[str, SuccessorDef]]))
class-attribute
instance-attribute
options: list[IRDLOption] = field(default_factory=(list[IRDLOption]))
class-attribute
instance-attribute
traits: OpTraits = field(default_factory=(lambda: traits_def()))
class-attribute
instance-attribute
accessor_names: dict[str, tuple[str, Literal['attribute', 'property']]] = field(default_factory=(dict[str, tuple[str, Literal['attribute', 'property']]]))
class-attribute
instance-attribute
Mapping from the accessor name to the attribute or property name. In some cases, the attribute name is not a valid Python identifier, or is already used by the operation, so we need to use a different name.
assembly_format: str | None = field(default=None)
class-attribute
instance-attribute
custom_directives: dict[str, type[CustomDirective]] = field(default_factory=(lambda: {}))
class-attribute
instance-attribute
__init__(*, name: str, operands: list[tuple[str, OperandDef]] = list[tuple[str, OperandDef]](), results: list[tuple[str, ResultDef]] = list[tuple[str, ResultDef]](), properties: dict[str, PropertyDef] = dict[str, PropertyDef](), attributes: dict[str, AttributeDef] = dict[str, AttributeDef](), regions: list[tuple[str, RegionDef]] = list[tuple[str, RegionDef]](), successors: list[tuple[str, SuccessorDef]] = list[tuple[str, SuccessorDef]](), options: list[IRDLOption] = list[IRDLOption](), traits: OpTraits = (lambda: traits_def())(), accessor_names: dict[str, tuple[str, Literal['attribute', 'property']]] = dict[str, tuple[str, Literal['attribute', 'property']]](), assembly_format: str | None = None, custom_directives: dict[str, type[CustomDirective]] = (lambda: {})()) -> None
from_pyrdl(pyrdl_def: type[IRDLOperationInvT]) -> OpDef
staticmethod
Decorator used on classes to define a new operation definition.
Source code in xdsl/irdl/operations.py
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 | |
verify(op: Operation)
Given an IRDL definition, verify that an operation satisfies its invariants.
Source code in xdsl/irdl/operations.py
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 1226 1227 1228 | |
VarIRConstruct
Bases: Enum
An enum representing the part of an IR that may be variadic. This contains operands, results, and regions.
Source code in xdsl/irdl/operations.py
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | |
OPERAND = 1
class-attribute
instance-attribute
RESULT = 2
class-attribute
instance-attribute
REGION = 3
class-attribute
instance-attribute
SUCCESSOR = 4
class-attribute
instance-attribute
BaseAccessor
dataclass
Bases: ABC
Base class for accessor objects for retrieving operands, results, regions, and successors.
Source code in xdsl/irdl/operations.py
1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 | |
construct: VarIRConstruct
instance-attribute
The construct type we are accessing.
idx: int
instance-attribute
Index of this accessor. i.e. the number of accessors of this construct type appearing before this one.
__init__(construct: VarIRConstruct, idx: int) -> None
index(args: Sequence[_Construct]) -> _Construct | Sequence[_Construct] | None
abstractmethod
Index the sequence of all operands/results/etc., returning the correct elements/slice.
Source code in xdsl/irdl/operations.py
1798 1799 1800 1801 1802 1803 | |
__get__(obj: Operation, objtype=None) -> Any
Source code in xdsl/irdl/operations.py
1805 1806 1807 | |
BeforeVariadicSingleAccessor
dataclass
Bases: BaseAccessor
Access a non-variadic construct which appears before any variadic arguments.
Source code in xdsl/irdl/operations.py
1810 1811 1812 1813 1814 1815 1816 1817 | |
__init__(construct: VarIRConstruct, idx: int) -> None
index(args: Sequence[_Construct]) -> _Construct
Source code in xdsl/irdl/operations.py
1816 1817 | |
AfterVariadicSingleAccessor
dataclass
Bases: BaseAccessor
Access a non-variadic construct which appears after any variadic arguments.
Source code in xdsl/irdl/operations.py
1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 | |
num_defs: int
instance-attribute
Number of accessors for this construct type.
__init__(construct: VarIRConstruct, idx: int, num_defs: int) -> None
index(args: Sequence[_Construct]) -> _Construct
Source code in xdsl/irdl/operations.py
1829 1830 | |
SameOptionalAccessor
dataclass
Bases: BaseAccessor
Access an optional construct when all variadic arguments have the same size. This occurs when the appropriate same-size option is set or there is a single variadic.
In this case either all variadics contain 1 element or no elements.
Source code in xdsl/irdl/operations.py
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 | |
num_defs: int
instance-attribute
Number of accessors for this construct type.
__init__(construct: VarIRConstruct, idx: int, num_defs: int) -> None
index(args: Sequence[_Construct]) -> _Construct | None
Source code in xdsl/irdl/operations.py
1846 1847 1848 1849 | |
UniqueVariadicAccessor
dataclass
Bases: BaseAccessor
Access a variadic construct in the case where it is the only variadic.
Source code in xdsl/irdl/operations.py
1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 | |
num_defs: int
instance-attribute
Number of accessors for this construct type.
__init__(construct: VarIRConstruct, idx: int, num_defs: int) -> None
index(args: Sequence[_Construct]) -> Sequence[_Construct]
Source code in xdsl/irdl/operations.py
1861 1862 | |
SameVariadicBaseAccessor
dataclass
Bases: BaseAccessor, ABC
Source code in xdsl/irdl/operations.py
1865 1866 1867 1868 1869 1870 1871 1872 | |
num_defs: int
instance-attribute
Number of accessors for this construct type.
num_variadics: int
instance-attribute
Number of variadic accessors for this construct type.
variadics_encountered: int
instance-attribute
Number of variadic accessors for this construct type which appear before this one.
__init__(construct: VarIRConstruct, idx: int, num_defs: int, num_variadics: int, variadics_encountered: int) -> None
SameVariadicAccessor
dataclass
Bases: SameVariadicBaseAccessor
Access a variadic construct in the case where all variadics have the same size.
The size of the variadic is calculated by subtracting the number of non-variadic arguments from the total number of arguments, and dividing the result by the number of variadic arguments.
Source code in xdsl/irdl/operations.py
1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 | |
__init__(construct: VarIRConstruct, idx: int, num_defs: int, num_variadics: int, variadics_encountered: int) -> None
index(args: Sequence[_Construct]) -> Sequence[_Construct]
Source code in xdsl/irdl/operations.py
1885 1886 1887 1888 1889 | |
SameVariadicSingleAccessor
dataclass
Bases: SameVariadicBaseAccessor
Access a non-variadic construct in the case where all variadics have the same size.
Source code in xdsl/irdl/operations.py
1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 | |
__init__(construct: VarIRConstruct, idx: int, num_defs: int, num_variadics: int, variadics_encountered: int) -> None
index(args: Sequence[_Construct]) -> _Construct
Source code in xdsl/irdl/operations.py
1898 1899 1900 1901 | |
BaseAttrAccessor
dataclass
Bases: ABC
Base class for accessors in the case where there is a "segment size" attribute.
Source code in xdsl/irdl/operations.py
1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 | |
construct: VarIRConstruct
instance-attribute
The construct type we are accessing.
idx: int
instance-attribute
Index of this accessor. i.e. the number of accessors of this construct type appearing before this one.
option: AttrSizedSegments
instance-attribute
The option used to declare variadic sizes are obtained from an attribute.
__init__(construct: VarIRConstruct, idx: int, option: AttrSizedSegments) -> None
index(values: tuple[int, ...], args: Sequence[Any]) -> Any
abstractmethod
Index the sequence of all operands/results/etc., returning the correct elements/slice.
The values argument contains the integer values of the "segment size" attribute.
Source code in xdsl/irdl/operations.py
1922 1923 1924 1925 1926 1927 1928 | |
__get__(obj: Operation, objtype=None)
Source code in xdsl/irdl/operations.py
1930 1931 1932 1933 | |
SingleAttrAccessor
dataclass
Bases: BaseAttrAccessor
Access a non-variadic construct when there is a "segment size" attribute.
Source code in xdsl/irdl/operations.py
1936 1937 1938 1939 1940 1941 1942 1943 | |
__init__(construct: VarIRConstruct, idx: int, option: AttrSizedSegments) -> None
index(values: tuple[int, ...], args: Sequence[Any]) -> Any
Source code in xdsl/irdl/operations.py
1942 1943 | |
VariadicAttrAccessor
dataclass
Bases: BaseAttrAccessor
Access a variadic construct when there is a "segment size" attribute.
Source code in xdsl/irdl/operations.py
1946 1947 1948 1949 1950 1951 1952 1953 1954 | |
__init__(construct: VarIRConstruct, idx: int, option: AttrSizedSegments) -> None
index(values: tuple[int, ...], args: Sequence[Any]) -> Any
Source code in xdsl/irdl/operations.py
1952 1953 1954 | |
OptionalAttrAccessor
dataclass
Bases: BaseAttrAccessor
Access an optional construct when there is a "segment size" attribute.
Source code in xdsl/irdl/operations.py
1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 | |
__init__(construct: VarIRConstruct, idx: int, option: AttrSizedSegments) -> None
index(values: tuple[int, ...], args: Sequence[Any]) -> Any
Source code in xdsl/irdl/operations.py
1963 1964 1965 1966 | |
OptionalAttributeAccessor
dataclass
Accessor for an optional operation attribute.
Source code in xdsl/irdl/operations.py
2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 | |
attribute_name: str
instance-attribute
default_value: Attribute | None
instance-attribute
__init__(attribute_name: str, default_value: Attribute | None) -> None
__get__(obj: IRDLOperation, objtype=None)
Source code in xdsl/irdl/operations.py
2060 2061 | |
__set__(obj: IRDLOperation, value)
Source code in xdsl/irdl/operations.py
2063 2064 2065 2066 2067 | |
AttributeAccessor
dataclass
Accessor for an operation attribute.
Source code in xdsl/irdl/operations.py
2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 | |
attribute_name: str
instance-attribute
__init__(attribute_name: str) -> None
__get__(obj: IRDLOperation, objtype=None)
Source code in xdsl/irdl/operations.py
2076 2077 | |
__set__(obj: IRDLOperation, value)
Source code in xdsl/irdl/operations.py
2079 2080 | |
OptionalPropertyAccessor
dataclass
Accessor for an optional operation property.
Source code in xdsl/irdl/operations.py
2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 | |
property_name: str
instance-attribute
default_value: Attribute | None
instance-attribute
__init__(property_name: str, default_value: Attribute | None) -> None
__get__(obj: IRDLOperation, objtype=None)
Source code in xdsl/irdl/operations.py
2090 2091 | |
__set__(obj: IRDLOperation, value)
Source code in xdsl/irdl/operations.py
2093 2094 2095 2096 2097 | |
PropertyAccessor
dataclass
Accessor for an operation property.
Source code in xdsl/irdl/operations.py
2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 | |
property_name: str
instance-attribute
__init__(property_name: str) -> None
__get__(obj: IRDLOperation, objtype=None)
Source code in xdsl/irdl/operations.py
2106 2107 | |
__set__(obj: IRDLOperation, value)
Source code in xdsl/irdl/operations.py
2109 2110 | |
result_def(constraint: IRDLAttrConstraint[AttributeInvT] = Attribute, *, default: None = None, resolver: None = None, init: Literal[False] = False) -> OpResult[AttributeInvT]
Defines a result of an operation.
Source code in xdsl/irdl/operations.py
577 578 579 580 581 582 583 584 585 586 587 | |
var_result_def(constraint: RangeConstraint[AttributeInvT] | IRDLAttrConstraint[AttributeInvT] = Attribute, *, default: None = None, resolver: None = None, init: Literal[False] = False) -> VarOpResult[AttributeInvT]
Defines a variadic result of an operation.
Source code in xdsl/irdl/operations.py
590 591 592 593 594 595 596 597 598 599 600 601 602 | |
opt_result_def(constraint: RangeConstraint[AttributeInvT] | IRDLAttrConstraint[AttributeInvT] = Attribute, *, default: None = None, resolver: None = None, init: Literal[False] = False) -> OptOpResult[AttributeInvT]
Defines an optional result of an operation.
Source code in xdsl/irdl/operations.py
605 606 607 608 609 610 611 612 613 614 615 616 617 | |
prop_def(constraint: IRDLAttrConstraint[AttributeInvT] = Attribute, default_value: Attribute | None = None, *, prop_name: str | None = None, default: None = None, resolver: None = None, init: Literal[False] = False) -> AttributeInvT
Defines a property of an operation.
Source code in xdsl/irdl/operations.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
opt_prop_def(constraint: IRDLAttrConstraint[AttributeInvT] = Attribute, default_value: Attribute | None = None, *, prop_name: str | None = None, default: None = None, resolver: None = None, init: Literal[False] = False) -> AttributeInvT | None
opt_prop_def(
constraint: IRDLAttrConstraint[AttributeInvT],
default_value: Attribute,
*,
prop_name: str | None = None,
default: None = None,
resolver: None = None,
init: Literal[False] = False,
) -> AttributeInvT
opt_prop_def(
constraint: IRDLAttrConstraint[
AttributeInvT
] = Attribute,
default_value: Attribute | None = None,
*,
prop_name: str | None = None,
default: None = None,
resolver: None = None,
init: Literal[False] = False,
) -> AttributeInvT | None
Defines an optional property of an operation.
Source code in xdsl/irdl/operations.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
attr_def(constraint: IRDLAttrConstraint[AttributeInvT] = Attribute, default_value: Attribute | None = None, *, attr_name: str | None = None, default: None = None, resolver: None = None, init: Literal[False] = False) -> AttributeInvT
Defines an attribute of an operation.
Source code in xdsl/irdl/operations.py
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | |
opt_attr_def(constraint: IRDLAttrConstraint[AttributeInvT] = Attribute, default_value: Attribute | None = None, *, attr_name: str | None = None, default: None = None, resolver: None = None, init: Literal[False] = False) -> AttributeInvT | None
opt_attr_def(
constraint: IRDLAttrConstraint[AttributeInvT],
default_value: Attribute,
*,
attr_name: str | None = None,
default: None = None,
resolver: None = None,
init: Literal[False] = False,
) -> AttributeInvT
opt_attr_def(
constraint: IRDLAttrConstraint[
AttributeInvT
] = Attribute,
default_value: Attribute | None = None,
*,
attr_name: str | None = None,
default: None = None,
resolver: None = None,
init: Literal[False] = False,
) -> AttributeInvT | None
Defines an optional attribute of an operation.
Source code in xdsl/irdl/operations.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | |
operand_def(constraint: IRDLAttrConstraint = Attribute, *, default: None = None, resolver: None = None, init: Literal[False] = False) -> Operand
Defines an operand of an operation.
Source code in xdsl/irdl/operations.py
736 737 738 739 740 741 742 743 744 745 746 | |
var_operand_def(constraint: RangeConstraint | IRDLAttrConstraint = Attribute, *, default: None = None, resolver: None = None, init: Literal[False] = False) -> VarOperand
Defines a variadic operand of an operation.
Source code in xdsl/irdl/operations.py
749 750 751 752 753 754 755 756 757 758 759 | |
opt_operand_def(constraint: RangeConstraint | IRDLAttrConstraint = Attribute, *, default: None = None, resolver: None = None, init: Literal[False] = False) -> OptOperand
Defines an optional operand of an operation.
Source code in xdsl/irdl/operations.py
762 763 764 765 766 767 768 769 770 771 772 | |
region_def(single_block: Literal['single_block'] | None = None, *, entry_args: RangeConstraint | IRDLAttrConstraint = RangeOf(AnyAttr()), default: None = None, resolver: None = None, init: Literal[False] = False) -> Region
Defines a region of an operation.
Source code in xdsl/irdl/operations.py
775 776 777 778 779 780 781 782 783 784 785 786 787 | |
var_region_def(single_block: Literal['single_block'] | None = None, *, entry_args: RangeConstraint | IRDLAttrConstraint = RangeOf(AnyAttr()), default: None = None, resolver: None = None, init: Literal[False] = False) -> VarRegion
Defines a variadic region of an operation.
Source code in xdsl/irdl/operations.py
790 791 792 793 794 795 796 797 798 799 800 801 802 | |
opt_region_def(single_block: Literal['single_block'] | None = None, *, entry_args: RangeConstraint | IRDLAttrConstraint = RangeOf(AnyAttr()), default: None = None, resolver: None = None, init: Literal[False] = False) -> OptRegion
Defines an optional region of an operation.
Source code in xdsl/irdl/operations.py
805 806 807 808 809 810 811 812 813 814 815 816 817 | |
successor_def(*, default: None = None, resolver: None = None, init: Literal[False] = False) -> Successor
Defines a successor of an operation.
Source code in xdsl/irdl/operations.py
820 821 822 823 824 825 826 827 828 829 | |
var_successor_def(*, default: None = None, resolver: None = None, init: Literal[False] = False) -> VarSuccessor
Defines a variadic successor of an operation.
Source code in xdsl/irdl/operations.py
832 833 834 835 836 837 838 839 840 841 | |
opt_successor_def(*, default: None = None, resolver: None = None, init: Literal[False] = False) -> OptSuccessor
Defines an optional successor of an operation.
Source code in xdsl/irdl/operations.py
844 845 846 847 848 849 850 851 852 853 | |
traits_def(*traits: OpTrait)
Defines the traits of an operation.
Note that traits_def from parent superclasses get included automatically.
Source code in xdsl/irdl/operations.py
859 860 861 862 863 864 | |
lazy_traits_def(future_traits: Callable[[], tuple[OpTrait, ...]])
Defines the traits of an operation, in the case where any trait uses an operation that is not yet declared.
Source code in xdsl/irdl/operations.py
867 868 869 870 871 872 | |
get_construct_name(construct: VarIRConstruct) -> str
Get the type name, this is used mostly for error messages.
Source code in xdsl/irdl/operations.py
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 | |
get_plural_name(number: int, name: str) -> str
Print a number followed by a name, possibly making the name plural.
Source code in xdsl/irdl/operations.py
1256 1257 1258 1259 1260 | |
get_construct_defs(op_def: OpDef, construct: VarIRConstruct) -> list[tuple[str, OperandDef]] | list[tuple[str, ResultDef]] | list[tuple[str, RegionDef]] | list[tuple[str, SuccessorDef]]
Get the definitions of this type in an operation definition.
Source code in xdsl/irdl/operations.py
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | |
get_op_constructs(op: Operation, construct: VarIRConstruct) -> Sequence[SSAValue] | Sequence[OpResult] | Sequence[Region] | Sequence[Successor]
Get the list of arguments of the type in an operation. For example, if the argument type is an operand, get the list of operands.
Source code in xdsl/irdl/operations.py
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 | |
get_attr_size_option(construct: VarIRConstruct) -> type[AttrSizedSegments]
Get the AttrSized option for this type.
Source code in xdsl/irdl/operations.py
1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 | |
get_same_variadic_size_option(construct: VarIRConstruct) -> type[SameVariadicOperandSize | SameVariadicResultSize | SameVariadicRegionSize | SameVariadicSuccessorSize]
Get the AttrSized option for this type.
Source code in xdsl/irdl/operations.py
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 | |
get_multiple_variadic_options(construct: VarIRConstruct) -> list[type[IRDLOption]]
Source code in xdsl/irdl/operations.py
1341 1342 1343 1344 | |
verify_variadic_attr_size(op: Operation, op_def: OpDef, construct: VarIRConstruct, option: AttrSizedSegments)
Verify the number of 'construct' is valid, obtaining sizes from an attribute.
Source code in xdsl/irdl/operations.py
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 | |
verify_variadic_same_size(length: int, op_def: OpDef, construct: VarIRConstruct, construct_name: str)
Verify the number of 'construct' is valid, assuming all variadics have the same size.
Source code in xdsl/irdl/operations.py
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 | |
verify_variadic_size(op: Operation, op_def: OpDef, construct: VarIRConstruct)
Verify the number of 'construct' is valid, given the number and type of variadic definitions.
Source code in xdsl/irdl/operations.py
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 | |
irdl_op_verify_regions(op: Operation, op_def: OpDef, constraint_context: ConstraintContext)
Source code in xdsl/irdl/operations.py
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 | |
irdl_op_verify_arg_list(op: Operation, op_def: OpDef, construct: Literal[VarIRConstruct.OPERAND, VarIRConstruct.RESULT], constraint_context: ConstraintContext) -> None
Verify the argument list of an operation.
Source code in xdsl/irdl/operations.py
1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 | |
irdl_build_arg_list(construct: VarIRConstruct, args: Sequence[_T | Sequence[_T] | None], arg_defs: Sequence[tuple[str, Any]], error_prefix: str = '') -> tuple[list[_T], list[int]]
irdl_build_arg_list(
construct: Literal[VarIRConstruct.OPERAND],
args: Sequence[SSAValue | Sequence[SSAValue] | None],
arg_defs: Sequence[tuple[str, OperandDef]],
error_prefix: str,
) -> tuple[list[SSAValue], list[int]]
irdl_build_arg_list(
construct: Literal[VarIRConstruct.RESULT],
args: Sequence[Attribute | Sequence[Attribute] | None],
arg_defs: Sequence[tuple[str, ResultDef]],
error_prefix: str,
) -> tuple[list[Attribute], list[int]]
irdl_build_arg_list(
construct: Literal[VarIRConstruct.REGION],
args: Sequence[Region | Sequence[Region] | None],
arg_defs: Sequence[tuple[str, RegionDef]],
error_prefix: str,
) -> tuple[list[Region], list[int]]
irdl_build_arg_list(
construct: Literal[VarIRConstruct.SUCCESSOR],
args: Sequence[Successor | Sequence[Successor] | None],
arg_defs: Sequence[tuple[str, SuccessorDef]],
error_prefix: str,
) -> tuple[list[Successor], list[int]]
Build a list of arguments (operands, results, regions)
Source code in xdsl/irdl/operations.py
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 | |
irdl_build_operations_arg(operand: _OperandArg | Sequence[_OperandArg] | None) -> SSAValue | list[SSAValue]
Source code in xdsl/irdl/operations.py
1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 | |
irdl_build_region_arg(r: _RegionArg) -> Region
Source code in xdsl/irdl/operations.py
1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 | |
irdl_build_regions_arg(r: _RegionArg | Sequence[_RegionArg] | None) -> Region | list[Region]
Source code in xdsl/irdl/operations.py
1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 | |
irdl_op_init(self: IRDLOperation, op_def: OpDef, *, operands: Sequence[SSAValue | Operation | Sequence[SSAValue | Operation] | None], result_types: Sequence[Attribute | Sequence[Attribute] | None], properties: Mapping[str, Attribute | None], attributes: Mapping[str, Attribute | None], successors: Sequence[Successor | Sequence[Successor] | None], regions: Sequence[Region | Sequence[Operation] | Sequence[Block] | Sequence[Region | Sequence[Operation] | Sequence[Block]] | None])
Builder for an irdl operation.
Source code in xdsl/irdl/operations.py
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 | |
irdl_op_arg_definition(new_attrs: dict[str, Any], construct: VarIRConstruct, op_def: OpDef) -> None
Source code in xdsl/irdl/operations.py
1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 | |
get_accessors_from_op_def(op_def: OpDef, custom_verify: Any | None) -> dict[str, Any]
Get python accessors from an operation definition.
Source code in xdsl/irdl/operations.py
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 | |
irdl_op_definition(cls: type[IRDLOperationInvT]) -> type[IRDLOperationInvT]
Decorator used on classes to define a new operation definition.
Source code in xdsl/irdl/operations.py
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 | |