Liveness
liveness
¶
We store the register that a value will be stored in at runtime on the value's type. When the value is unallocated, it is considered to be in one of an unbounded set of registers, meaning each register only ever holds one value. If it is allocated, then at no point should two values with the same allocated register type be "live" at the same point in the IR. The infrastructure in this class helps detect when this occurs, used for verification and legalization.
LivenessContext
dataclass
¶
Bases: ABC
Reverse-liveness walk over register-allocatable IR.
On entry to update_liveness, alive holds the values live after the operation
(its results already removed), on exit it must hold those live before it.
Use copy to fork alive for a nested region walk while sharing other state.
Source code in xdsl/backend/liveness.py
_ = KW_ONLY
class-attribute
instance-attribute
¶
alive: set[SSAValue]
instance-attribute
¶
__init__(alive: set[SSAValue]) -> None
¶
copy(alive: set[SSAValue]) -> Self
¶
handle_live_inout(op: Operation, value: SSAValue, *, duplicate_inout: bool = False) -> SSAValue
abstractmethod
¶
op is about to clobber value, which is still live, or value is used by
more than one in/out operand when duplicate_inout is True.
Subclasses must override this to either raise an error or insert a copy to avoid
the clobber.
Source code in xdsl/backend/liveness.py
process_region(region: Region) -> None
¶
Source code in xdsl/backend/liveness.py
process_block(block: Block) -> None
¶
process_op(op: Operation) -> None
¶
Source code in xdsl/backend/liveness.py
VerifyLivenessContext
dataclass
¶
Bases: LivenessContext
Helper to verify that registers can be allocated in the input, raising a
VerifyException if not.
Source code in xdsl/backend/liveness.py
__init__(alive: set[SSAValue]) -> None
¶
handle_live_inout(op: Operation, value: SSAValue, *, duplicate_inout: bool = False) -> SSAValue
¶
Handles live inout by raising a VerifyException, with distinct messages for
the case of duplicate inout or use after using as inout operand.