17#include "mlir/Pass/Pass.h"
21#define GEN_PASS_DEF_LOWERSIZEOF
22#include "circt/Dialect/FIRRTL/Passes.h.inc"
27using namespace firrtl;
31 :
public circt::firrtl::impl::LowerSizeOfBase<LowerSizeOfPass> {
34 void runOnOperation()
override {
35 SmallVector<SizeOfIntrinsicOp> sizeofOps;
36 getOperation().walk([&](SizeOfIntrinsicOp op) { sizeofOps.push_back(op); });
38 if (sizeofOps.empty()) {
39 markAllAnalysesPreserved();
43 for (SizeOfIntrinsicOp op : sizeofOps) {
47 "failed to elaborate sizeof intrinsic: unable to determine "
49 .attachNote(op.getInput().getLoc())
50 <<
"operand of type " << op.getInput().getType()
51 <<
" defined here has unknown width";
52 return signalPassFailure();
55 OpBuilder builder(op);
56 auto constant = ConstantOp::create(builder, op.getLoc(), op.getType(),
58 op.getResult().replaceAllUsesWith(constant);
std::optional< int64_t > getBitWidth(FIRRTLBaseType type, bool ignoreFlip=false)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.