qat.experimental.dialect.results.transforms.convert_collections_to_arrays module
Implements the convert_results_collections_to_arrays pass, which lowers
ResultsCollectionType SSA values into
individual ResultsArrayType SSA values
throughout an operation tree.
The pass rewrites CreateOp,
StoreOp, and
ExtractOp that operate on collections,
and applies a generic decomposition for any other operation that carries collection-typed
variadic operands, results, or block arguments.
Entry point: convert_results_collections_to_arrays().
- collection_type_to_array_types(collection)
Returns an ordered mapping of field keys to
ResultsArrayTypefor each field incollection.The keys are ordered by schema field declaration order, which is the canonical ordering used throughout this pass when expanding a collection into individual arrays. Callers that depend on positional correspondence between fields and array values must preserve this order.
Each array type inherits the collection’s size.
- Parameters:
collection¶ (
ResultsCollectionType) – The collection type to decompose.- Return type:
dict[str,ResultsArrayType]- Returns:
An ordered dictionary mapping each field key to its corresponding
ResultsArrayType, in schema field declaration order.
- convert_results_collections_to_arrays(op)
Lowers all
ResultsCollectionTypeSSA values withinopto individualResultsArrayTypeSSA values.The pass walks
op, identifies every nested operation that carries aResultsCollectionTypeoperand, result, or block argument, and rewrites each in dependency order so that no collection-typed values remain in the IR on completion.Operations are rewritten in a fixed-point loop: candidates whose collection-typed operands have not yet been lowered are deferred to the next iteration. The loop terminates when all candidates have been rewritten, or raises if no progress is made.
- Parameters:
op¶ (
Operation) – The root operation whose nested IR is transformed in place.- Raises:
PassFailedException – If any operation cannot be lowered (e.g. it has a non-variadic collection-typed operand or result), or if the fixed-point iteration stalls without making progress.