tvm_tirx.sym.ConstraintContext#
- class tvm_tirx.sym.ConstraintContext(parent=None, parent_local_prefix=0)#
Bases:
ObjectTracks the constraints relevant to each point in a traversal.
Holds variable bindings, value ranges, and predicates collected during traversal. Callbacks can inspect these constraints when processing the current expression or statement.
- Parameters:
parent (ConstraintContext or None, optional) – Parent context, or
Noneto construct an empty root.parent_local_prefix (int, optional) – Number of parent-local entries to capture, between zero and the parent’s
local_size(), inclusive. Defaults to zero and must be zero for a root.
- append(constraint)#
Append a local premise without changing any existing prefix.
- Parameters:
constraint (Constraint) – Premise to append. Existing premises must not be modified through aliases, including changes to the meaning of their referenced IR.
- local_size()#
Return the local entry count, excluding captured ancestors.
- snapshot()#
Capture the constraints currently visible in this context.
Later additions to this context do not affect the returned context, which can be extended independently. Constraint objects and expressions remain shared.
- Returns:
ConstraintContext – A context containing the captured constraints.