Predicate
predicate
¶
This file implements some of the core data structures used in the pdl-to-pdl-interp conversion.
POSITION_COSTS = {OperationPosition: 1, OperandPosition: 2, OperandGroupPosition: 3, AttributePosition: 4, ConstraintPosition: 5, ResultPosition: 6, ResultGroupPosition: 7, TypePosition: 8, AttributeLiteralPosition: 9, TypeLiteralPosition: 10, UsersPosition: 11, ForEachPosition: 12}
module-attribute
¶
Different position types are ranked by priority. A lower cost means a higher priority. This is used to decide which position to branch on first when evaluating predicates.
QUESTION_COSTS = {IsNotNullQuestion: 1, OperationNameQuestion: 2, OperandCountAtLeastQuestion: 3, OperandCountQuestion: 4, ResultCountAtLeastQuestion: 5, ResultCountQuestion: 6, EqualToQuestion: 7, AttributeConstraintQuestion: 8, TypeConstraintQuestion: 9, ConstraintQuestion: 10}
module-attribute
¶
Different question types are ranked by priority. A lower cost means a higher priority. This is used to decide which question to branch on first when evaluating predicates.
Position
dataclass
¶
Bases: ABC
The position class encodes a location in a pattern. Each pattern has a root position. From there, other positions can be reached representing operands, results, and more.
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
OperationPosition
dataclass
¶
Bases: Position
Represents an operation in the IR
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
depth: int
instance-attribute
¶
__init__(parent: Optional[Position] = None, *, depth: int) -> None
¶
is_root() -> bool
¶
is_operand_defining_op() -> bool
¶
__repr__()
¶
get_operand(operand_num: int) -> OperandPosition
¶
get_operand_group(group_num: int, is_variadic: bool) -> OperandGroupPosition
¶
get_all_operands() -> OperandGroupPosition
¶
get_result(result_num: int) -> ResultPosition
¶
get_result_group(group_num: int | None, is_variadic: bool) -> ResultGroupPosition
¶
get_all_results() -> ResultGroupPosition
¶
get_attribute(attr_name: str) -> AttributePosition
¶
ValuePosition
dataclass
¶
Bases: Position
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
OperandPosition
dataclass
¶
Bases: ValuePosition
Represents an operand of an operation
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
OperandGroupPosition
dataclass
¶
Bases: Position
Represents a group of operands
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
ResultPosition
dataclass
¶
Bases: ValuePosition
Represents a result of an operation
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
AttributePosition
dataclass
¶
TypePosition
dataclass
¶
UsersPosition
dataclass
¶
ForEachPosition
dataclass
¶
ResultGroupPosition
dataclass
¶
Bases: Position
Represents a group of results
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
AttributeLiteralPosition
dataclass
¶
Bases: Position
Represents a literal attribute value
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
TypeLiteralPosition
dataclass
¶
Bases: Position
Represents a literal type value
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
ConstraintPosition
dataclass
¶
Bases: Position
Represents a result from a constraint
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
constraint: ConstraintQuestion
instance-attribute
¶
result_index: int
instance-attribute
¶
__init__(parent: Optional[Position] = None, *, constraint: ConstraintQuestion, result_index: int) -> None
¶
get_constraint(constraint_question: ConstraintQuestion, result_index: int) -> ConstraintPosition
staticmethod
¶
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
Question
dataclass
¶
Answer
dataclass
¶
Predicate
dataclass
¶
Base predicate class
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
q: Question
instance-attribute
¶
a: Answer
instance-attribute
¶
__init__(q: Question, a: Answer) -> None
¶
get_is_not_null() -> Predicate
staticmethod
¶
get_operation_name(name: str) -> Predicate
staticmethod
¶
get_operand_count(count: int) -> Predicate
staticmethod
¶
get_result_count(count: int) -> Predicate
staticmethod
¶
get_equal_to(other_position: Position) -> Predicate
staticmethod
¶
get_operand_count_at_least(count: int) -> Predicate
staticmethod
¶
Get predicate for minimum operand count (variadic case)
get_result_count_at_least(count: int) -> Predicate
staticmethod
¶
Get predicate for minimum result count (variadic case)
get_attribute_constraint(attr_value: Attribute) -> Predicate
staticmethod
¶
Get predicate for attribute value constraint
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
get_type_constraint(type_value: TypeAttribute | ArrayAttr[TypeAttribute]) -> Predicate
staticmethod
¶
Get predicate for type value constraint
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
get_constraint(name: str, arg_positions: tuple[Position, ...], result_types: tuple[pdl.AnyPDLType | pdl.RangeType[pdl.AnyPDLType], ...], is_negated: bool = False) -> Predicate
staticmethod
¶
Get predicate for a native constraint
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
IsNotNullQuestion
dataclass
¶
OperationNameQuestion
dataclass
¶
OperandCountQuestion
dataclass
¶
ResultCountQuestion
dataclass
¶
EqualToQuestion
dataclass
¶
OperandCountAtLeastQuestion
dataclass
¶
ResultCountAtLeastQuestion
dataclass
¶
AttributeConstraintQuestion
dataclass
¶
TypeConstraintQuestion
dataclass
¶
ConstraintQuestion
dataclass
¶
Bases: Question
Represents a native constraint check
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
name: str
instance-attribute
¶
arg_positions: tuple[Position, ...]
instance-attribute
¶
result_types: tuple[pdl.AnyPDLType | pdl.RangeType[pdl.AnyPDLType], ...]
instance-attribute
¶
is_negated: bool
instance-attribute
¶
__init__(name: str, arg_positions: tuple[Position, ...], result_types: tuple[pdl.AnyPDLType | pdl.RangeType[pdl.AnyPDLType], ...], is_negated: bool) -> None
¶
TrueAnswer
dataclass
¶
FalseAnswer
dataclass
¶
UnsignedAnswer
dataclass
¶
StringAnswer
dataclass
¶
AttributeAnswer
dataclass
¶
TypeAnswer
dataclass
¶
Bases: Answer
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
PositionalPredicate
dataclass
¶
Bases: Predicate
A predicate applied to a specific position
Source code in xdsl/transforms/convert_pdl_to_pdl_interp/predicate.py
get_position_cost(position: Position) -> int
¶
Get cost for a position type, with fallback for unknown types.
get_question_cost(question: Question) -> int
¶
Get cost for a question type, with fallback for unknown types.