Class StructuralVisitorWithConstraintContextObj#

Inheritance Relationships#

Base Type#

Derived Type#

Class Documentation#

class StructuralVisitorWithConstraintContextObj : public tvm::ffi::StructuralVisitorObj#

Visits values using their structural visit behavior while maintaining the constraint context relevant to each callback.

Subclassed by tvm::tirx::ObjectVisitorWithConstraintContext

Public Types

using VisitorObjType = StructuralVisitorWithConstraintContextObj#
using StateTupleType = std::tuple<const sym::ConstraintContext&>#

Public Functions

inline StructuralVisitorWithConstraintContextObj()#

Construct a visitor using constraint-aware default descent.

inline void AppendConstraint(const sym::Constraint &constraint)#

Add a fact to the current scope, creating its child context on the first append.

Parameters:

constraint – Binding, range, or predicate valid in the current scope.

template<typename F>
inline decltype(f()) WithConstraintScope(F &&f)#

Run an Expected-returning callback in a constraint scope. Use AppendConstraint to add facts. Scopes without facts keep the incoming context. Success and visit interrupts restore the incoming position. Terminal errors propagate without restoration; discard the traversal context after failure.

inline ffi::Expected<ffi::Optional<ffi::VisitInterrupt>> DefaultVisitExpected(ffi::AnyView value) noexcept#

Descend with the sparse specialized hook, or the ordinary fallback. Call this from a Visit callback to descend its matched node exactly once. Calling it from that node’s registered hook re-enters the same hook.

  • Bind and Assert add facts for later statements in the same sequence.

  • If, While, and lazy if_then_else add scalar boolean guards inside branches/bodies.

  • For and thread launch add ranges in their bodies; Let adds a binding in its body.

  • Binding values and loop bounds are visited before their facts are added.

  • Predicates retain their expressions (including likely). Only tirx.assume_always sets assume_always=true, guaranteeing truth throughout the containing scope, including mutations.

  • Branch predicates, binding values, range bounds, and explicit assume_always predicates are collected without effect filtering. Ordinary assertions require a pure condition. Only known positive loop steps yield ranges.

  • Binding values retain their original reads; eager Select adds no branch guards.

  • Call and RegionStmt use tirx::op_attr hooks with the complete containing node. Unregistered Ops use ordinary Call descent or isolated RegionStmt body scopes.

Semantic hooks assume well-formed IR. No analyzer is created. These expressions do not snapshot mutable reads: consumers need stable captured values or lifetime guarantees, invalidation, or skipped inference. An unchanged context does not imply unchanged memory. Do not use one visitor for overlapping traversals.

Public Members

sym::ConstraintContext constraints#

Active effective premises. Consumers must not append during traversal. Retain this handle and constraints->LocalSize() for a stable position, or use constraints->ToArray() for an independent sequence of handles. The context itself remains live.

Public Static Functions

static inline int32_t _GetOrAllocRuntimeTypeIndex()#
static inline int32_t RuntimeTypeIndex() noexcept#

Protected Functions

inline explicit StructuralVisitorWithConstraintContextObj(const ffi::StructuralVisitorVTable *vtable)#
inline StateTupleType StateTuple() const noexcept#