Base
IRNode dataclass
IRNode()
Bases: Generic[ParentType], ABC, Printable
flowchart TD
kirin.ir.nodes.base.IRNode[IRNode]
kirin.print.printable.Printable[Printable]
kirin.print.printable.Printable --> kirin.ir.nodes.base.IRNode
click kirin.ir.nodes.base.IRNode href "" "kirin.ir.nodes.base.IRNode"
click kirin.print.printable.Printable href "" "kirin.print.printable.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.
Pretty Printing
This object is pretty printable via .print() method.
parent_node abstractmethod property writable
parent_node: ParentType | None
Parent node of the current node.
attach
attach(parent: ParentType) -> None
Attach the current node to the parent node.
Source code in src/kirin/ir/nodes/base.py
65 66 67 68 69 70 71 72 73 | |
delete abstractmethod
delete(safe: bool = True) -> None
Delete the current node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
safe | bool | If True, check if the node has any references before deleting. | True |
Source code in src/kirin/ir/nodes/base.py
85 86 87 88 89 90 91 92 | |
detach abstractmethod
detach() -> None
Detach the current node from the parent node.
Source code in src/kirin/ir/nodes/base.py
75 76 77 78 | |
drop_all_references abstractmethod
drop_all_references() -> None
Drop all references to other nodes.
Source code in src/kirin/ir/nodes/base.py
80 81 82 83 | |
get_root
get_root() -> IRNode
Get the root node of the current node.
Source code in src/kirin/ir/nodes/base.py
59 60 61 62 63 | |
is_ancestor
is_ancestor(op: IRNode) -> bool
Check if the given node is an ancestor of the current node.
Source code in src/kirin/ir/nodes/base.py
51 52 53 54 55 56 57 | |
is_structurally_equal abstractmethod
is_structurally_equal(
other: Self,
context: (
dict[IRNode | SSAValue, IRNode | SSAValue] | None
) = None,
) -> bool
Check 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 | Description | Default |
|---|---|---|---|
other | Self | The other node to compare. | required |
context | dict[IRNode | SSAValue, IRNode | SSAValue] | None | The context to store the visited nodes. | None |
Returns:
| Type | Description |
|---|---|
bool | True if the nodes are structurally equal, False otherwise. |
Source code in src/kirin/ir/nodes/base.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
verify abstractmethod
verify() -> None
run mandatory validation checks. This is not same as verify_type, which may be optional.
Source code in src/kirin/ir/nodes/base.py
129 130 131 132 | |
verify_type abstractmethod
verify_type() -> None
verify the type of the node.
Source code in src/kirin/ir/nodes/base.py
134 135 136 137 | |