Skip to content

Conversation

@maerhart
Copy link
Member

@maerhart maerhart commented Dec 2, 2025

No description provided.

@maerhart maerhart added Reducer Related to `circt-reduce` RTG Involving the `rtg` dialect labels Dec 2, 2025
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +20 to +37
/// Replace virtual registers with a constant register.
struct VirtualRegisterConstantifier : public OpReduction<VirtualRegisterOp> {
LogicalResult rewrite(VirtualRegisterOp op) override {
if (op.getAllowedRegs().getAllowedRegs().empty())
return failure();

OpBuilder builder(op);
auto constReg = ConstantOp::create(builder, op.getLoc(),
op.getAllowedRegs().getAllowedRegs()[0]);
op.getResult().replaceAllUsesWith(constReg);
op.erase();
return success();
}

std::string getName() const override {
return "rtg-virtual-register-constantifier";
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go into an anonymous namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reducer Related to `circt-reduce` RTG Involving the `rtg` dialect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants