kirin.ir.nodes.base.IRNode
classIRNode¶source
kirin.ir.nodes.base.IRNode
Bases: Generic[ParentType], ABC, Printable
Base class for all IR nodes. All IR nodes are hashable and can be compared for equality. The hash of an IR node is the same as the id of the object.
class IRNode!!! note “Pretty Printing” This object is pretty printable via .print() method.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
source | SourceInfo | None | field(default=None, init=False, repr=False) | |
IS_REGION | bool | False | |
IS_BLOCK | bool | False | |
IS_STATEMENT | bool | False |
methodassert_parent¶source
kirin.ir.nodes.base.IRNode.assert_parent
def assert_parent(type_: type[IRNode], parent) -> NoneParameters
| Name | Type | Description |
|---|---|---|
type_ | type[IRNode] | |
parent | — |
propertyparent_node¶source
kirin.ir.nodes.base.IRNode.parent_node
methodis_ancestor¶source
kirin.ir.nodes.base.IRNode.is_ancestor
def is_ancestor(op: IRNode) -> boolCheck if the given node is an ancestor of the current node.
Parameters
| Name | Type | Description |
|---|---|---|
op | IRNode |
Returns
bool
methodget_root¶source
kirin.ir.nodes.base.IRNode.get_root
methodattach¶source
kirin.ir.nodes.base.IRNode.attach
def attach(parent: ParentType) -> NoneAttach the current node to the parent node.
Parameters
| Name | Type | Description |
|---|---|---|
parent | ParentType |
methoddetach¶source
kirin.ir.nodes.base.IRNode.detach
methoddrop_all_references¶source
kirin.ir.nodes.base.IRNode.drop_all_references
methoddelete¶source
kirin.ir.nodes.base.IRNode.delete
def delete(safe: bool = True) -> NoneDelete the current node.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
safe | bool | True | If True, check if the node has any references before deleting. |
methodis_structurally_equal¶source
kirin.ir.nodes.base.IRNode.is_structurally_equal
Signature
def is_structurally_equal(other: 'IRNode', context: dict[IRNode | SSAValue, IRNode | SSAValue] | None = None) -> boolCheck if the current node is structurally equal to the other node.
!!! note
This method is for tweaking the behavior of structural equality.
To check if two nodes are structurally equal, use the is_structurally_equal method.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
other | 'IRNode' | required | The other node to compare. |
context | dict[IRNode | SSAValue, IRNode | SSAValue] | None | None | The context to store the visited nodes. |
Returns
boolTrue if the nodes are structurally equal, False otherwise.
methodwalk¶source
kirin.ir.nodes.base.IRNode.walk
Signature
def walk(*, reverse: bool = False, region_first: bool = False) -> Iterator[Statement]Parameters
| Name | Type | Default | Description |
|---|---|---|---|
reverse | bool | False | |
region_first | bool | False |
Returns
Iterator[Statement]
methodprint_impl¶source
kirin.ir.nodes.base.IRNode.print_impl
methodverify¶source
kirin.ir.nodes.base.IRNode.verify
def verify() -> Nonerun mandatory validation checks. This is not same as verify_type, which may be optional.
sourcemethodverify_type¶source
kirin.ir.nodes.base.IRNode.verify_type