Index
ir
¶
OpTraitInvT = TypeVar('OpTraitInvT', bound=OpTrait)
module-attribute
¶
OpT = TypeVar('OpT', bound='Operation')
module-attribute
¶
DialectInterfaceT = TypeVar('DialectInterfaceT', bound=DialectInterface)
module-attribute
¶
A = TypeVar('A', bound='Attribute')
module-attribute
¶
DataElement = TypeVar('DataElement', covariant=True, bound=Hashable)
module-attribute
¶
AttributeCovT = TypeVar('AttributeCovT', bound=Attribute, covariant=True, default=Attribute)
module-attribute
¶
AttributeInvT = TypeVar('AttributeInvT', bound=Attribute, default=Attribute)
module-attribute
¶
SSAValueCovT = TypeVar('SSAValueCovT', bound=SSAValue[Attribute], default=SSAValue[Attribute])
module-attribute
¶
OperationInvT = TypeVar('OperationInvT', bound=Operation)
module-attribute
¶
IRNode: TypeAlias = Operation | Region | Block
module-attribute
¶
DialectInterface
¶
Bases: ABC
A base class for dialects' interfaces. They usually define functionality which is dialect specific to some transformation.
For example DialectInlinerInterface defines which dialect operations can be inlined and how. Dialects will implement this interface and the inlining transformation will query them through the base interface.
The design logic tries to follow MLIR's dialect interfaces closely https://mlir.llvm.org/docs/Interfaces/#dialect-interfaces
Source code in xdsl/dialect_interfaces/__init__.py
IsTerminator
dataclass
¶
Bases: OpTrait
This trait provides verification and functionality for operations that are known to be terminators.
See external documentation.
Source code in xdsl/traits.py
verify(op: Operation) -> None
¶
Check that the operation satisfies the IsTerminator trait requirements.
Source code in xdsl/traits.py
NoTerminator
dataclass
¶
Bases: OpTrait
Allow an operation to have single block regions with no terminator.
See external documentation.
Source code in xdsl/traits.py
OpTrait
dataclass
¶
A trait attached to an operation definition. Traits can be used to define operation invariants, additional semantic information, or to group operations that have similar properties. Note that traits are the merge of traits and interfaces in MLIR.
Source code in xdsl/traits.py
VerifyException
¶
Bases: DiagnosticException
Dialect
dataclass
¶
Contains the operations and attributes of a specific dialect
Source code in xdsl/ir/core.py
operations: Iterator[type[Operation]]
property
¶
attributes: Iterator[type[Attribute]]
property
¶
name: str
property
¶
split_name(name: str) -> tuple[str, str]
staticmethod
¶
get_interface(interface: type[DialectInterfaceT]) -> DialectInterfaceT | None
¶
Return a class that implements the 'interface' if it exists.
has_interface(interface: type[DialectInterfaceT]) -> bool
¶
__init__(_name: str, _operations: list[type[Operation]] = list[type['Operation']](), _attributes: list[type[Attribute]] = list[type['Attribute']](), _interfaces: list[DialectInterface] = list[DialectInterface]()) -> None
¶
Attribute
dataclass
¶
Bases: ABC
A compile-time value. Attributes are used to represent SSA variable types, and can be attached on operations to give extra information.
Source code in xdsl/ir/core.py
name: str = field(init=False, repr=False)
class-attribute
¶
The attribute name should be a static field in the attribute classes.
__post_init__()
¶
verify() -> None
¶
Check that the attribute parameters satisfy the expected invariants. Raise a VerifyException otherwise.
__str__() -> str
¶
__init__() -> None
¶
BuiltinAttribute
dataclass
¶
Bases: Attribute, ABC
This class is used to mark builtin attributes.
Unlike other attributes in MLIR, parsing of Builtin attributes
is handled directly by the parser.
Printing of these attributes is handled by the print_builtin function, which must
be implemented by all Builtin attributes.
Attributes outside of the builtin dialect should not inherit from BuiltinAttribute.
Source code in xdsl/ir/core.py
print_builtin(printer: Printer) -> None
abstractmethod
¶
Prints the attribute using the supplied printer.
BuiltinAttributes need not follow the same rules as other attributes, for example
they do not need to be prefixed by ! or # and do not need to print their name.
Source code in xdsl/ir/core.py
__init__() -> None
¶
TypeAttribute
dataclass
¶
Bases: Attribute
This class should only be inherited by classes inheriting Attribute.
This class is only used for printing attributes in the MLIR format,
inheriting this class prefix the attribute by ! instead of #.
Source code in xdsl/ir/core.py
OpaqueSyntaxAttribute
dataclass
¶
Bases: Attribute
This class should only be inherited by classes inheriting Attribute. This class is only used for printing attributes in the opaque form.
See external documentation.
Source code in xdsl/ir/core.py
SpacedOpaqueSyntaxAttribute
dataclass
¶
Bases: OpaqueSyntaxAttribute
This class should only be inherited by classes inheriting Attribute. This class is only used for printing attributes in the opaque form.
See external documentation.
Source code in xdsl/ir/core.py
Data
dataclass
¶
Bases: Attribute, ABC, Generic[DataElement]
An attribute represented by a Python structure.
Source code in xdsl/ir/core.py
data: DataElement
instance-attribute
¶
new(params: Any) -> Self
classmethod
¶
Create a new Data given its parameter.
The params argument should be of the same type as the Data generic
argument.
This function should be preferred over __init__ when instantiating
attributes in a generic way (i.e., without knowing their concrete type
statically).
Source code in xdsl/ir/core.py
get(attr: DataElement | Self) -> Self
classmethod
¶
Creates an element of this class from DataElement,
or returns the input when it is already an instance of this class.
This function is useful for __init__ methods, for example when a we
would like to accept either a StringAttr or a str.
Source code in xdsl/ir/core.py
parse_parameter(parser: AttrParser) -> DataElement
abstractmethod
classmethod
¶
print_parameter(printer: Printer) -> None
abstractmethod
¶
__init__(data: DataElement) -> None
¶
ParametrizedAttribute
dataclass
¶
Bases: Attribute
An attribute parametrized by other attributes.
Source code in xdsl/ir/core.py
parameters: tuple[Attribute, ...]
property
¶
__init__(*parameters: Any)
¶
Source code in xdsl/ir/core.py
new(params: Sequence[Attribute]) -> Self
classmethod
¶
Create a new ParametrizedAttribute given its parameters.
This function should be preferred over __init__ when instantiating
attributes in a generic way (i.e., without knowing their concrete type
statically).
Source code in xdsl/ir/core.py
parse_parameters(parser: AttrParser) -> Sequence[Attribute]
classmethod
¶
print_parameters(printer: Printer) -> None
¶
TypedAttribute
dataclass
¶
Bases: ParametrizedAttribute, ABC
An attribute with a type.
Source code in xdsl/ir/core.py
Use
dataclass
¶
The use of a SSA value.
Source code in xdsl/ir/core.py
operation: Operation
property
¶
The operation using the value.
index: int
property
¶
The index of the operand using the value in the operation.
__repr__() -> str
¶
__hash__() -> int
¶
__eq__(other: object) -> bool
¶
__init__(_operation: Operation, _index: int, _prev_use: Use | None = None, _next_use: Use | None = None) -> None
¶
IRUses
dataclass
¶
Bases: Iterable[Use]
Multi-pass iterable of the uses of an IR value (SSAValue or Block).
Source code in xdsl/ir/core.py
IRWithUses
dataclass
¶
Bases: ABC
IRNode which stores a list of its uses.
Source code in xdsl/ir/core.py
first_use: Use | None = field(init=False, default=None, repr=False)
class-attribute
instance-attribute
¶
The first use of the value in the use list.
uses: IRUses
property
¶
Returns an iterable of all uses of the value.
add_use(use: Use)
¶
Add a new use of the value.
Source code in xdsl/ir/core.py
remove_use(use: Use)
¶
Remove a use of the value.
Source code in xdsl/ir/core.py
has_one_use() -> bool
¶
Returns true if the value has exactly one use.
has_more_than_one_use() -> bool
¶
Returns true if the value has more than one use.
get_unique_use() -> Use | None
¶
Returns the single use of the value, or None if there are no uses or more than one use.
Source code in xdsl/ir/core.py
get_user_of_unique_use() -> Operation | None
¶
Returns the user of the single use of the value. If there are no uses or more than one use, returns None.
Source code in xdsl/ir/core.py
__init__() -> None
¶
IRWithName
dataclass
¶
Bases: ABC
Source code in xdsl/ir/core.py
name_hint: str | None
property
writable
¶
is_valid_name(name: str | None)
classmethod
¶
Returns True if name is None or a valid name for an identifier.
extract_valid_name(name: str | None) -> str | None
classmethod
¶
If the name is valid, extracts the name before an optional _\d+ suffix.
Raises ValueError otherwise.
Source code in xdsl/ir/core.py
__init__() -> None
¶
SSAValue
dataclass
¶
Bases: IRWithUses, IRWithName, ABC, Generic[AttributeCovT]
A reference to an SSA variable. An SSA variable is either an operation result, or a basic block argument.
Source code in xdsl/ir/core.py
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 617 618 619 620 621 622 623 624 625 626 627 628 | |
type: AttributeCovT
property
¶
owner: Operation | Block
abstractmethod
property
¶
An SSA variable is either an operation result, or a basic block argument. This property returns the Operation or Block that currently defines a specific value.
get(arg: SSAValue | Operation, *, type: TypeForm[AttributeInvT] = Attribute) -> SSAValue[AttributeInvT]
staticmethod
¶
Get a new SSAValue from either a SSAValue, or an operation with a single result. Checks that the resulting SSAValue is of the supplied type, if provided.
Source code in xdsl/ir/core.py
replace_all_uses_with(value: SSAValue) -> None
¶
Replace the value by another value in all its uses.
Source code in xdsl/ir/core.py
replace_uses_with_if(value: SSAValue, predicate: Callable[[Use], bool])
¶
Replace the value by another value in all its uses that pass the given test function.
Source code in xdsl/ir/core.py
erase(safe_erase: bool = True) -> None
¶
Erase the value. If safe_erase is True, then check that no operations use the value anymore. If safe_erase is False, then replace its uses by an ErasedSSAValue.
Source code in xdsl/ir/core.py
__hash__()
¶
__eq__(other: object) -> bool
¶
__init__(_type: AttributeCovT) -> None
¶
OpResult
dataclass
¶
Bases: SSAValue[AttributeCovT], Generic[AttributeCovT]
A reference to an SSA variable defined by an operation result.
Source code in xdsl/ir/core.py
BlockArgument
dataclass
¶
Bases: SSAValue[AttributeCovT], Generic[AttributeCovT]
A reference to an SSA variable defined by a basic block argument.
Source code in xdsl/ir/core.py
block: Block
instance-attribute
¶
The block defining the variable.
index: int
instance-attribute
¶
The index of the variable in the block arguments.
location: LocationAttr = field(default_factory=_unknown_loc)
class-attribute
instance-attribute
¶
Source location attached to this block argument.
owner: Block
property
¶
__repr__() -> str
¶
__init__(_type: AttributeCovT, block: Block, index: int, location: LocationAttr = _unknown_loc()) -> None
¶
ErasedSSAValue
dataclass
¶
Bases: SSAValue
An erased SSA variable. This is used during transformations when a SSA variable is destroyed but still used.
Source code in xdsl/ir/core.py
SSAValues
¶
Bases: tuple[SSAValueCovT, ...], Generic[SSAValueCovT]
A helper data structure for a sequence of SSAValues.
Source code in xdsl/ir/core.py
OpOperands
dataclass
¶
Bases: Sequence[SSAValue]
A view of the operand list of an operation. Any modification to the view is reflected on the operation.
Source code in xdsl/ir/core.py
__getitem__(idx: int | slice) -> SSAValue | Sequence[SSAValue]
¶
__setitem__(idx: int, operand: SSAValue) -> None
¶
Source code in xdsl/ir/core.py
__iter__() -> Iterator[SSAValue]
¶
__len__() -> int
¶
__eq__(other: object)
¶
__hash__()
¶
__init__(_op: Operation) -> None
¶
OpTraits
¶
Bases: Iterable[OpTrait]
An operation's traits. Some operations have mutually recursive traits, such as one is always the parent operation of the other. For this case, the operation's traits can be declared lazily and resolved only at the first use.
Source code in xdsl/ir/core.py
gen_traits: Callable[[], tuple[OpTrait, ...]] = gen_traits
instance-attribute
¶
Factory method that lazily populates the traits on first use.
traits: frozenset[OpTrait]
property
¶
Returns a copy of this instance's traits.
__init__(gen_traits: Callable[[], tuple[OpTrait, ...]]) -> None
¶
add_trait(trait: OpTrait)
¶
__iter__() -> Iterator[OpTrait]
¶
Operation
dataclass
¶
Bases: _IRNode
A generic operation. Operation definitions inherit this class.
Source code in xdsl/ir/core.py
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 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 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 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 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 1367 1368 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 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 | |
name: str
class-attribute
¶
The operation name. Should be a static member of the class
results: SSAValues[OpResult] = SSAValues(OpResult(result_type, self, idx) for idx, result_type in enumerate(result_types))
class-attribute
instance-attribute
¶
The results created by the operation.
properties: dict[str, Attribute] = dict(properties)
class-attribute
instance-attribute
¶
The properties attached to the operation. Properties are inherent to the definition of an operation's semantics, and thus cannot be discarded by transformations.
attributes: dict[str, Attribute] = dict(attributes)
class-attribute
instance-attribute
¶
The attributes attached to the operation.
location: LocationAttr = _unknown_loc() if location is None else location
class-attribute
instance-attribute
¶
The source location attached to this operation.
regions: tuple[Region, ...] = ()
class-attribute
instance-attribute
¶
Regions arguments of the operation.
parent: Block | None = field(default=None)
class-attribute
instance-attribute
¶
The block containing this operation.
traits: OpTraits
class-attribute
¶
Traits attached to an operation definition. This is a static field, and is made empty by default by PyRDL if not set by the operation definition.
parent_node: IRNode | None
property
¶
result_types: Sequence[Attribute]
property
¶
operand_types: Sequence[Attribute]
property
¶
next_op: Operation | None
property
¶
Next operation in block containing this operation.
prev_op: Operation | None
property
¶
Previous operation in block containing this operation.
operands: OpOperands = operands
instance-attribute
property
writable
¶
successors: OpSuccessors = list(successors)
instance-attribute
property
writable
¶
successor_uses: Sequence[Use]
property
¶
parent_op() -> Operation | None
¶
parent_region() -> Region | None
¶
parent_block() -> Block | None
¶
__post_init__()
¶
__init__(*, operands: Sequence[SSAValue] = (), result_types: Sequence[Attribute] = (), properties: Mapping[str, Attribute] = {}, attributes: Mapping[str, Attribute] = {}, location: LocationAttr | None = None, successors: Sequence[Block] = (), regions: Sequence[Region] = ()) -> None
¶
Source code in xdsl/ir/core.py
create(*, operands: Sequence[SSAValue] = (), result_types: Sequence[Attribute] = (), properties: Mapping[str, Attribute] = {}, attributes: Mapping[str, Attribute] = {}, location: LocationAttr | None = None, successors: Sequence[Block] = (), regions: Sequence[Region] = ()) -> Self
classmethod
¶
Source code in xdsl/ir/core.py
add_region(region: Region) -> None
¶
Add an unattached region to the operation.
Source code in xdsl/ir/core.py
get_region_index(region: Region) -> int
¶
Get the region position in the operation.
Source code in xdsl/ir/core.py
detach_region(region: int | Region) -> Region
¶
Detach a region from the operation. Returns the detached region.
Source code in xdsl/ir/core.py
drop_all_references() -> None
¶
Drop all references to other operations. This function is called prior to deleting an operation.
Source code in xdsl/ir/core.py
walk(*, reverse: bool = False, region_first: bool = False) -> Iterator[Operation]
¶
Iterate all operations contained in the operation (including this one). If region_first is set, then the operation regions are iterated before the operation. If reverse is set, then the region, block, and operation lists are iterated in reverse order.
Source code in xdsl/ir/core.py
walk_blocks(*, reverse: bool = False) -> Iterator[Block]
¶
Iterate over all the blocks nested in the region. Iterate in reverse order if reverse is True.
Source code in xdsl/ir/core.py
get_attr_or_prop(name: str) -> Attribute | None
¶
Get a named attribute or property. It first look into the property dictionary, then into the attribute dictionary.
Source code in xdsl/ir/core.py
is_before_in_block(other_op: Operation) -> bool
¶
Return true if the current operation is located strictly before other_op. False otherwise.
Source code in xdsl/ir/core.py
verify(verify_nested_ops: bool = True) -> None
¶
Source code in xdsl/ir/core.py
parse(parser: Parser) -> Self
classmethod
¶
print(printer: Printer)
¶
clone_without_regions(value_mapper: dict[SSAValue, SSAValue] | None = None, block_mapper: dict[Block, Block] | None = None, *, clone_name_hints: bool = True, clone_operands: bool = True) -> Self
¶
Clone an operation, with empty regions instead.
Source code in xdsl/ir/core.py
clone(value_mapper: dict[SSAValue, SSAValue] | None = None, block_mapper: dict[Block, Block] | None = None, *, clone_name_hints: bool = True, clone_operands: bool = True) -> Self
¶
Clone an operation with all its regions and operations in them.
Source code in xdsl/ir/core.py
has_trait(trait: type[OpTrait] | OpTrait, *, value_if_unregistered: bool = True) -> bool
classmethod
¶
Check if the operation implements a trait with the given parameters. If the operation is not registered, return value_if_unregisteed instead.
Source code in xdsl/ir/core.py
get_trait(trait: type[OpTraitInvT] | OpTraitInvT) -> OpTraitInvT | None
classmethod
¶
Return a trait with the given type and parameters, if it exists.
Source code in xdsl/ir/core.py
get_traits_of_type(trait_type: type[OpTraitInvT]) -> list[OpTraitInvT]
classmethod
¶
Get all the traits of the given type satisfied by this operation.
erase(safe_erase: bool = True, drop_references: bool = True) -> None
¶
Erase the operation, and remove all its references to other operations. If safe_erase is specified, check that the operation results are not used.
Source code in xdsl/ir/core.py
detach()
¶
is_structurally_equivalent(other: IRNode, context: dict[IRNode | SSAValue, IRNode | SSAValue] | None = None) -> bool
¶
Check if two operations are structurally equivalent. The context is a mapping of IR nodes to IR nodes that are already known to be equivalent. This enables checking whether the use dependencies and successors are equivalent.
Source code in xdsl/ir/core.py
emit_error(message: str, underlying_error: Exception) -> NoReturn
¶
Emit an error with the given message.
Source code in xdsl/ir/core.py
dialect_name() -> str
classmethod
¶
__repr__() -> str
¶
Source code in xdsl/ir/core.py
__str__() -> str
¶
__format__(format_spec: str) -> str
¶
Source code in xdsl/ir/core.py
BlockOps
dataclass
¶
Bases: Reversible[Operation], Iterable[Operation]
Multi-pass iterable of the operations in a block. Follows the next_op for each operation.
Source code in xdsl/ir/core.py
block: Block
instance-attribute
¶
first: Operation | None
property
¶
First operation in the block, None if block is empty.
last: Operation | None
property
¶
Last operation in the block, None if block is empty.
__iter__()
¶
__len__()
¶
__bool__() -> bool
¶
__reversed__()
¶
__init__(block: Block) -> None
¶
Block
dataclass
¶
Bases: _IRNode, IRWithUses, IRWithName
A sequence of operations
Source code in xdsl/ir/core.py
1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 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 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 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 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 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 | |
parent: Region | None = field(default=None, repr=False)
class-attribute
instance-attribute
¶
Parent region containing the block.
arg_types: Sequence[Attribute]
property
¶
parent_node: IRNode | None
property
¶
ops: BlockOps
property
¶
Returns a multi-pass Iterable of this block's operations.
next_block: Block | None
property
¶
The next block in the parent region
prev_block: Block | None
property
¶
The previous block in the parent region
args: tuple[BlockArgument, ...]
property
¶
Returns the block arguments.
is_empty: bool
property
¶
Returns True if there are no operations in this block.
first_op: Operation | None
property
¶
The first operation in this block.
last_op: Operation | None
property
¶
The last operation in this block.
is_default_block_name(name: str) -> bool
staticmethod
¶
Check if a name matches the default block naming pattern (bb followed by digits).
__init__(ops: Iterable[Operation] = (), *, arg_types: Iterable[Attribute] = ())
¶
Source code in xdsl/ir/core.py
predecessors() -> tuple[Block, ...]
¶
parent_op() -> Operation | None
¶
parent_region() -> Region | None
¶
parent_block() -> Block | None
¶
__repr__() -> str
¶
insert_arg(arg_type: Attribute, index: int, location: LocationAttr | None = None) -> BlockArgument
¶
Insert a new argument with a given type to the arguments list at a specific index. Returns the new argument.
Source code in xdsl/ir/core.py
erase_arg(arg: BlockArgument, safe_erase: bool = True) -> None
¶
Erase a block argument. If safe_erase is True, check that the block argument is not used. If safe_erase is False, replace the block argument uses with an ErasedSSAVAlue.
Source code in xdsl/ir/core.py
insert_op_after(new_op: Operation, existing_op: Operation) -> None
¶
Inserts new_op into this block, after existing_op.
new_op should not be attached to a block.
Source code in xdsl/ir/core.py
insert_op_before(new_op: Operation, existing_op: Operation) -> None
¶
Inserts new_op into this block, before existing_op.
new_op should not be attached to a block.
Source code in xdsl/ir/core.py
add_op(operation: Operation) -> None
¶
Add an operation at the end of the block. The operation should not be attached to another block already.
Source code in xdsl/ir/core.py
add_ops(ops: Iterable[Operation]) -> None
¶
Add operations at the end of the block. The operations should not be attached to another block.
insert_ops_before(ops: Sequence[Operation], existing_op: Operation) -> None
¶
insert_ops_after(ops: Sequence[Operation], existing_op: Operation) -> None
¶
split_before(b_first: Operation, *, arg_types: Iterable[Attribute] = ()) -> Block
¶
Split the block into two blocks before the specified operation.
Note that all operations before the one given stay as part of the original basic
block, and the rest of the operations in the original block are moved to the new
block, including the old terminator.
The original block is left without a terminator.
The newly formed block is inserted into the parent region immediately after self
and returned.
Source code in xdsl/ir/core.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 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 | |
get_operation_index(op: Operation) -> int
¶
Get the operation position in a block.
Source code in xdsl/ir/core.py
detach_op(op: Operation) -> Operation
¶
Detach an operation from the block. Returns the detached operation.
Source code in xdsl/ir/core.py
erase_op(op: Operation, safe_erase: bool = True) -> None
¶
Erase an operation from the block. If safe_erase is True, check that the operation has no uses.
walk(*, reverse: bool = False, region_first: bool = False) -> Iterable[Operation]
¶
Iterate over all operations contained in the block. If region_first is set, then the operation regions are iterated before the operation. If reverse is set, then the region, block, and operation lists are iterated in reverse order.
Source code in xdsl/ir/core.py
walk_blocks(*, reverse: bool = False) -> Iterator[Block]
¶
Iterate over all the blocks nested within this block, including self, in the order in which they are printed in the IR. Iterate in reverse order if reverse is True.
Source code in xdsl/ir/core.py
verify() -> None
¶
Source code in xdsl/ir/core.py
drop_all_references() -> None
¶
Drop all references to other operations. This function is called prior to deleting a block.
Source code in xdsl/ir/core.py
find_ancestor_op_in_block(op: Operation) -> Operation | None
¶
Traverse up the operation hierarchy starting from op to find the ancestor operation that resides in the block.
Returns None if no ancestor is found.
Source code in xdsl/ir/core.py
erase(safe_erase: bool = True) -> None
¶
Erase the block, and remove all its references to other operations. If safe_erase is specified, check that no operation results are used outside the block.
Source code in xdsl/ir/core.py
is_structurally_equivalent(other: IRNode, context: dict[IRNode | SSAValue, IRNode | SSAValue] | None = None) -> bool
¶
Check if two blocks are structurally equivalent. The context is a mapping of IR nodes to IR nodes that are already known to be equivalent. This enables checking whether the use dependencies and successors are equivalent.
Source code in xdsl/ir/core.py
OpSuccessors
dataclass
¶
Bases: Sequence[Block]
A view of the successor list of an operation. Any modification to the view is reflected on the operation.
Source code in xdsl/ir/core.py
__getitem__(idx: int | slice) -> Block | Sequence[Block]
¶
__setitem__(idx: int, successor: Block) -> None
¶
Source code in xdsl/ir/core.py
__iter__() -> Iterator[Block]
¶
__len__() -> int
¶
__eq__(other: object)
¶
__hash__()
¶
__init__(_op: Operation) -> None
¶
RegionBlocks
dataclass
¶
Bases: Sequence[Block], Reversible[Block]
Multi-pass iterable of the blocks in a region.
Source code in xdsl/ir/core.py
first: Block | None
property
¶
First block in the region, None if region is empty.
last: Block | None
property
¶
Last block in the region, None if region is empty.
__iter__()
¶
__getitem__(idx: int | slice) -> Block | Sequence[Block]
¶
Source code in xdsl/ir/core.py
__len__()
¶
__bool__() -> bool
¶
__reversed__()
¶
__init__(_region: Region) -> None
¶
Region
dataclass
¶
Bases: _IRNode
A region contains a CFG of blocks. Regions are contained in operations.
Source code in xdsl/ir/core.py
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 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 | |
parent: Operation | None = field(default=None, repr=False)
class-attribute
instance-attribute
¶
Operation containing the region.
parent_node: IRNode | None
property
¶
blocks: RegionBlocks
property
¶
A multi-pass iterable of blocks.
first_block: Block | None
property
¶
First block in this region. This is the entry block if present.
last_block: Block | None
property
¶
Last block in this region.
ops: BlockOps
property
¶
Get the operations of a single-block region. Returns an exception if the region is not single-block.
op: Operation
property
¶
Get the operation of a single-operation single-block region. Returns an exception if the region is not single-operation single-block.
block: Block
property
¶
Get the block of a single-block region. Returns an exception if the region is not single-block.
DEFAULT
¶
A marker to be used as a default parameter to functions when a default single-block region should be constructed.
__init__(blocks: Block | Iterable[Block] = ())
¶
parent_block() -> Block | None
¶
parent_op() -> Operation | None
¶
parent_region() -> Region | None
¶
find_ancestor_block_in_region(block: Block) -> Block | None
¶
Returns 'block' if 'block' lies in this region, or otherwise finds the ancestor of 'block' that lies in this region.
Returns None if no ancestor block that lies in this region is found.
Source code in xdsl/ir/core.py
__repr__() -> str
¶
add_block(block: Block | Iterable[Block]) -> None
¶
Insert one or multiple blocks at the end of the region. The blocks should not be attached to another region.
Source code in xdsl/ir/core.py
insert_block_before(block: Block | Iterable[Block], target: Block) -> None
¶
Insert one or multiple blocks before a given block in the region. The blocks should not be attached to another region.
Source code in xdsl/ir/core.py
insert_block_after(block: Block | Iterable[Block], target: Block) -> None
¶
Insert one or multiple blocks after a given block in the region. The blocks should not be attached to another region.
Source code in xdsl/ir/core.py
insert_block(blocks: Block | Iterable[Block], index: int) -> None
¶
Insert one or multiple blocks at a given index in the region. The blocks should not be attached to another region.
Source code in xdsl/ir/core.py
get_block_index(block: Block) -> int
¶
Get the block position in a region.
Source code in xdsl/ir/core.py
detach_block(block: int | Block) -> Block
¶
Detach a block from the region. Returns the detached block.
Source code in xdsl/ir/core.py
erase_block(block: int | Block, safe_erase: bool = True) -> None
¶
Erase a block from the region. If safe_erase is True, check that the block has no uses.
Source code in xdsl/ir/core.py
clone() -> Region
¶
clone_into(dest: Region, insert_index: int | None = None, value_mapper: dict[SSAValue, SSAValue] | None = None, block_mapper: dict[Block, Block] | None = None, *, clone_name_hints: bool = True, clone_operands: bool = True)
¶
Clone all block of this region into dest to position insert_index
Source code in xdsl/ir/core.py
walk(*, reverse: bool = False, region_first: bool = False) -> Iterator[Operation]
¶
Call a function on all operations contained in the region. If region_first is set, then the operation regions are iterated before the operation. If reverse is set, then the region, block, and operation lists are iterated in reverse order.
Source code in xdsl/ir/core.py
verify() -> None
¶
drop_all_references() -> None
¶
Drop all references to other operations. This function is called prior to deleting a region.
erase() -> None
¶
Erase the region, and remove all its references to other operations.
move_blocks(region: Region) -> None
¶
Move the blocks of this region to another region. Leave no blocks in this region.
Source code in xdsl/ir/core.py
move_blocks_before(target: Block) -> None
¶
Move the blocks of this region to another region, before the target block. Leave no blocks in this region.
Source code in xdsl/ir/core.py
is_structurally_equivalent(other: IRNode, context: dict[IRNode | SSAValue, IRNode | SSAValue] | None = None) -> bool
¶
Check if two regions are structurally equivalent. The context is a mapping of IR nodes to IR nodes that are already known to be equivalent. This enables checking whether the use dependencies and successors are equivalent.