Move helper code to peepopt.cc, check offset

This commit is contained in:
Alain Dargelas 2024-12-19 14:08:37 -08:00
parent b63ef81cb7
commit b525a0280a
3 changed files with 13 additions and 8 deletions

View File

@ -28,6 +28,9 @@ bool did_something;
// scratchpad configurations for pmgen // scratchpad configurations for pmgen
int shiftadd_max_ratio; int shiftadd_max_ratio;
// Helper function, removes LSB 0s
SigSpec remove_bottom_padding(SigSpec sig);
#include "passes/pmgen/peepopt_pm.h" #include "passes/pmgen/peepopt_pm.h"
struct PeepoptPass : public Pass { struct PeepoptPass : public Pass {
@ -117,4 +120,13 @@ struct PeepoptPass : public Pass {
} }
} PeepoptPass; } PeepoptPass;
SigSpec remove_bottom_padding(SigSpec sig)
{
int i = 0;
for (; i < sig.size() - 1 && sig[i] == State::S0; i++) {
}
return sig.extract(i, sig.size() - i);
}
PRIVATE_NAMESPACE_END PRIVATE_NAMESPACE_END

View File

@ -60,7 +60,7 @@ code
reject; reject;
if (b_const.size() > 64) if (b_const.size() > 64)
reject; reject;
if (c_const.size() > 64) if (c_const.size() + offset > 64)
reject; reject;
// Check for potential mult overflow // Check for potential mult overflow

View File

@ -429,13 +429,6 @@ with open(outfile, "w") as f:
print(" }", file=f) print(" }", file=f)
print("", file=f) print("", file=f)
print(" SigSpec remove_bottom_padding(SigSpec sig) {", file=f)
print(" int i = 0;", file=f)
print(" for (; i < sig.size() - 1 && sig[i] == State::S0; i++) {} ", file=f)
print(" return sig.extract(i, sig.size() - i);", file=f)
print(" }", file=f)
print("", file=f)
print(" void blacklist(Cell *cell) {", file=f) print(" void blacklist(Cell *cell) {", file=f)
print(" if (cell != nullptr && blacklist_cells.insert(cell).second) {", file=f) print(" if (cell != nullptr && blacklist_cells.insert(cell).second) {", file=f)
print(" auto ptr = rollback_cache.find(cell);", file=f) print(" auto ptr = rollback_cache.find(cell);", file=f)