Bases: ModulePass
Converts all riscv_scf.for loops to riscv_snitch.frep_outer loops, if the loops pass
the riscv_snitch.frep_outer verification criteria:
- The induction variable is not used
- Step is 1
- All operations in the loop all operate on float registers
- All operations are pure or one of
a) riscv_snitch.read
b) riscv_snitch.write
c) builtin.unrealized_conversion_cast
Source code in xdsl/transforms/convert_riscv_scf_for_to_frep.py
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 | class ConvertRiscvScfForToFrepPass(ModulePass):
"""
Converts all riscv_scf.for loops to riscv_snitch.frep_outer loops, if the loops pass
the riscv_snitch.frep_outer verification criteria:
1. The induction variable is not used
2. Step is 1
3. All operations in the loop all operate on float registers
4. All operations are pure or one of
a) riscv_snitch.read
b) riscv_snitch.write
c) builtin.unrealized_conversion_cast
"""
name = "convert-riscv-scf-for-to-frep"
def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
PatternRewriteWalker(
GreedyRewritePatternApplier(
[
ScfYieldLowering(),
ScfForLowering(),
]
),
apply_recursively=False,
).rewrite_module(op)
|
Source code in xdsl/transforms/convert_riscv_scf_for_to_frep.py
104
105
106
107
108
109
110
111
112
113 | def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
PatternRewriteWalker(
GreedyRewritePatternApplier(
[
ScfYieldLowering(),
ScfForLowering(),
]
),
apply_recursively=False,
).rewrite_module(op)
|