10 #ifndef CONVERSION_SEQTOSV_FIRREGLOWERING_H
11 #define CONVERSION_SEQTOSV_FIRREGLOWERING_H
20 #include "llvm/ADT/SmallPtrSet.h"
37 bool isMuxReachableFrom(seq::FirRegOp regOp,
comb::MuxOp muxOp);
40 void buildReachabilityFrom(Operation *startNode);
42 llvm::DenseMap<Operation *, llvm::SmallDenseSet<Operation *>>
reachableMuxes;
43 llvm::SmallPtrSet<Operation *, 16>
visited;
51 llvm::filter_iterator<Operation::user_iterator,
52 std::function<bool(
const Operation *)>>;
58 : op(op), userIter(op->getUsers().begin(), op->getUsers().end(),
59 opAllowsReachability),
60 userEnd(op->getUsers().end(), op->getUsers().end(),
61 opAllowsReachability) {}
72 bool unvisited =
true;
79 bool disableRegRandomization =
false,
80 bool emitSeparateAlwaysBlocks =
false);
85 unsigned numSubaccessRestored = 0;
99 void initialize(OpBuilder &builder,
RegLowerInfo reg, ArrayRef<Value> rands);
100 void initializeRegisterElements(Location loc, OpBuilder &builder, Value
reg,
101 Value rand,
unsigned &pos);
103 void createTree(OpBuilder &builder, Value
reg, Value term, Value next);
104 std::optional<std::tuple<Value, Value, Value>>
105 tryRestoringSubaccess(OpBuilder &builder, Value
reg, Value term,
108 void addToAlwaysBlock(Block *block, sv::EventControl clockEdge, Value clock,
109 const std::function<
void(OpBuilder &)> &body,
110 sv::ResetType resetStyle = {},
111 sv::EventControl resetEdge = {}, Value reset = {},
112 const std::function<void(OpBuilder &)> &resetBody = {});
114 void addToIfBlock(OpBuilder &builder, Value cond,
115 const std::function<
void()> &trueSide,
116 const std::function<
void()> &falseSide);
119 OpBuilder builder(module.getBody());
120 auto &constant = constantCache[value];
122 constant->setLoc(builder.getFusedLoc({constant->getLoc(), loc}));
131 sv::ResetType, sv::EventControl, Value>;
148 bool needsRandom =
false;
Lower FirRegOp to sv.reg and sv.always.
std::unique_ptr< ReachableMuxes > reachableMuxes
bool needsRegRandomization() const
llvm::SmallDenseMap< std::pair< Value, unsigned >, Value > arrayIndexCache
llvm::SmallDenseMap< IfKeyType, sv::IfOp > ifCache
RegLowerInfo lower(seq::FirRegOp reg)
llvm::SmallDenseMap< APInt, hw::ConstantOp > constantCache
std::pair< Block *, Value > IfKeyType
bool disableRegRandomization
hw::ConstantOp getOrCreateConstant(Location loc, const APInt &value)
std::tuple< Block *, sv::EventControl, Value, sv::ResetType, sv::EventControl, Value > AlwaysKeyType
TypeConverter & typeConverter
bool emitSeparateAlwaysBlocks
llvm::SmallDenseMap< AlwaysKeyType, std::pair< sv::AlwaysOp, sv::IfOp > > alwaysBlocks
llvm::DenseMap< Operation *, llvm::SmallDenseSet< Operation * > > reachableMuxes
llvm::SmallPtrSet< Operation *, 16 > visited
ReachableMuxes(HWModuleOp m)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
def reg(value, clock, reset=None, reset_value=None, name=None, sym_name=None)
llvm::filter_iterator< Operation::user_iterator, std::function< bool(const Operation *)> > ValidUsersIterator
static std::function< bool(const Operation *op)> opAllowsReachability
OpUserInfo(Operation *op)
bool getAndSetUnvisited()
ValidUsersIterator userEnd