Dynamic index list
dynamic_index_list
¶
This file contains utility functions to manipulate lists of integers and SSAValues, that are encoded as a dense list of integers attributes and a variadic operand.
For instance, the [1, 2, %3, 4, %5] list is represented as:
- static_values = [1, 2, MARKER, 4, MARKER]
- dynamic_values = [%3, %5]
where MARKER is a special value that indicates that the value at that position is dynamic.
DynamicIndexList
dataclass
¶
Bases: CustomDirective
Custom directive for parsing dynamic index list. These contain a mix of indices and (untyped) ssa values.
Source code in xdsl/dialects/utils/dynamic_index_list.py
dynamic_position: VariadicOperandVariable
instance-attribute
¶
static_position: AttributeVariable
instance-attribute
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/dialects/utils/dynamic_index_list.py
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/dialects/utils/dynamic_index_list.py
set_empty(state: ParsingState)
¶
is_present(op: IRDLOperation) -> bool
¶
Source code in xdsl/dialects/utils/dynamic_index_list.py
ScalableDynamicIndexList
dataclass
¶
Bases: CustomDirective
Custom directive for parsing a dynamic index list where each element may
additionally be marked as scalable by wrapping it in square brackets,
e.g. [4, [8], %v].
Port of upstream custom<DynamicIndexList> with scalable flags.
Source code in xdsl/dialects/utils/dynamic_index_list.py
dynamic_values: VariadicOperandVariable
instance-attribute
¶
static_values: AttributeVariable
instance-attribute
¶
scalable_flags: AttributeVariable
instance-attribute
¶
parse(parser: Parser, state: ParsingState)
¶
Source code in xdsl/dialects/utils/dynamic_index_list.py
print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None
¶
Source code in xdsl/dialects/utils/dynamic_index_list.py
verify_dynamic_index_list(static_values: Sequence[int], dynamic_values: Sequence[SSAValue], dynamic_index: int, end_message: str = '') -> None
¶
Verify that the static list contains only integers and that the dynamic list
contains only SSAValues. The static list should be of the same length as the
dynamic list, with the dynamic values replaced by dynamic_index.
Source code in xdsl/dialects/utils/dynamic_index_list.py
get_dynamic_index_list(static_values: Sequence[int], dynamic_values: Sequence[SSAValue], dynamic_index: int) -> list[SSAValue | int]
¶
Get a mixed list of SSAValues and integers from the static and dynamic
lists. The static list contains integers, where the ones marked with
dynamic_index are to be replaced with the SSAValues from the dynamic list.
For instance, given the static list [1, 2, MARKER, 4, MARKER] and the
dynamic list [%3, %5], the result will be [1, 2, %3, 4, %5].
Source code in xdsl/dialects/utils/dynamic_index_list.py
split_dynamic_index_list(values: Sequence[SSAValue | int], dynamic_index: int) -> tuple[list[int], list[SSAValue]]
¶
Split a mixed list of SSAValues and integers into static and dynamic lists.
The static list contains integers, where the ones marked with dynamic_index
are to be replaced with the SSAValues from the dynamic list.
For instance, given the list [1, 2, %3, 4, %5], the result will be:
- static: [1, 2, MARKER, 4, MARKER]
- dynamic: [%3, %5]
Source code in xdsl/dialects/utils/dynamic_index_list.py
print_dynamic_index_list(printer: Printer, dynamic_index: int, values: Sequence[SSAValue], integers: Iterable[int], value_types: Sequence[Attribute] = (), *, delimiter: Parser.Delimiter = Parser.Delimiter.SQUARE)
¶
Prints a list with either
1) the static integer value in integers is ShapedType.DYNAMIC or
2) the next value otherwise.
If value_types is non-empty, it is expected to contain as many elements as values
indicating their types. This allows idiomatic printing of mixed value and
integer attributes in a list. E.g.
[%arg0 : index, 7, 42, %arg42 : i32].
The dynamic_index parameter specifies the sentinel value to use to print an ssa
value instead of a constant.
Source code in xdsl/dialects/utils/dynamic_index_list.py
parse_dynamic_index_with_type(parser: Parser) -> int | SSAValue
¶
Parses an element in an index list, either an index or an ssa value with a type:
e.g. 42 or %val : i32.
Source code in xdsl/dialects/utils/dynamic_index_list.py
parse_dynamic_index_without_type(parser: Parser) -> int | UnresolvedOperand
¶
Parses an element in an index list, either an index or an ssa value without a type:
e.g. 42 or %val.
Source code in xdsl/dialects/utils/dynamic_index_list.py
parse_dynamic_index_list_with_types(parser: Parser, dynamic_index: int, *, delimiter: Parser.Delimiter = Parser.Delimiter.SQUARE) -> tuple[Sequence[SSAValue], Sequence[int]]
¶
Parses an in index list, composed of a mix of indices and ssa values with types:
e.g. [1, 2, 3, %val : i32, 5].
The dynamic_index parameter specifies the sentinel value to use to print an ssa
value instead of a constant.
Source code in xdsl/dialects/utils/dynamic_index_list.py
parse_dynamic_index_list_without_types(parser: Parser, dynamic_index: int, *, delimiter: Parser.Delimiter = Parser.Delimiter.SQUARE) -> tuple[Sequence[UnresolvedOperand], Sequence[int]]
¶
Parses an in index list, composed of a mix of indices and ssa values without types:
e.g. [1, 2, 3, %val, 5].
The dynamic_index parameter specifies the sentinel value to use to print an ssa
value instead of a constant.