Varith transformations
varith_transformations
¶
ARITH_TO_VARITH_TYPE_MAP: dict[type[arith.SignlessIntegerBinaryOperation | arith.FloatingPointLikeBinaryOperation], type[varith.VarithOp]] = {arith.AddiOp: varith.VarithAddOp, arith.AddfOp: varith.VarithAddOp, arith.MuliOp: varith.VarithMulOp, arith.MulfOp: varith.VarithMulOp}
module-attribute
¶
ARITH_TYPES: dict[tuple[Literal['float', 'int'], Literal['add', 'mul']], type[arith.SignlessIntegerBinaryOperation | arith.FloatingPointLikeBinaryOperation]] = {('int', 'add'): arith.AddiOp, ('int', 'mul'): arith.MuliOp, ('float', 'add'): arith.AddfOp, ('float', 'mul'): arith.MulfOp}
module-attribute
¶
ArithToVarithPattern
¶
Bases: RewritePattern
Merges two arith operations into a varith operation.
Source code in xdsl/transforms/varith_transformations.py
match_and_rewrite(op: arith.AddiOp | arith.AddfOp | arith.MuliOp | arith.MulfOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/varith_transformations.py
VarithToArithPattern
¶
Bases: RewritePattern
Splits a varith operation into a sequence of arith operations.
Source code in xdsl/transforms/varith_transformations.py
match_and_rewrite(op: varith.VarithOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/varith_transformations.py
MergeVarithOpsPattern
¶
Bases: RewritePattern
Looks at every operand to a varith op, and merges them into it if possible.
e.g. a varith.add(arith.addi(1,2), varith.add(3, 4, 5), 6) becomes a varith.add(1,2,3,4,5,6)
Source code in xdsl/transforms/varith_transformations.py
match_and_rewrite(op: varith.VarithOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/varith_transformations.py
FuseRepeatedAddArgsPattern
dataclass
¶
Bases: RewritePattern
Prefer operand * count(operand) over repeated addition of operand.
The minimum count to trigger this rewrite can be specified in min_reps.
Source code in xdsl/transforms/varith_transformations.py
min_reps: int
instance-attribute
¶
Minimum repetitions of operand to trigger fusion.
__init__(min_reps: int) -> None
¶
match_and_rewrite(op: varith.VarithAddOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/varith_transformations.py
fuse(arg: SSAValue, count: int, t: builtin.IntegerType | builtin.IndexType | builtin.AnyFloat)
staticmethod
¶
Source code in xdsl/transforms/varith_transformations.py
ConvertArithToVarithPass
dataclass
¶
Bases: ModulePass
Convert chains of arith.{add|mul}{i,f} operations into a single long variadic add or mul operation.
Used for simplifying arithmetic operations for rewrites that need to either change the order or completely "cut an equation in half".
Source code in xdsl/transforms/varith_transformations.py
ConvertVarithToArithPass
dataclass
¶
Bases: ModulePass
Convert a single long variadic add or mul operation into a chain of arith.{add|mul}{i,f} operations. Reverses ConvertArithToVarithPass.
Source code in xdsl/transforms/varith_transformations.py
name = 'convert-varith-to-arith'
class-attribute
instance-attribute
¶
VarithFuseRepeatedOperandsPass
dataclass
¶
Bases: ModulePass
Fuses several occurrences of the same operand into one.
Source code in xdsl/transforms/varith_transformations.py
is_integer_like_type(t: Attribute) -> bool
¶
Returns true if t is an integer/container of integers/container of container of integers ...