23struct VirtualRegisterConstantifier :
public OpReduction<VirtualRegisterOp> {
24 LogicalResult rewrite(VirtualRegisterOp op)
override {
25 if (op.getAllowedRegs().getAllowedRegs().empty())
28 OpBuilder builder(op);
29 auto constReg = ConstantOp::create(builder, op.getLoc(),
30 op.getAllowedRegs().getAllowedRegs()[0]);
31 op.getResult().replaceAllUsesWith(constReg);
36 std::string
getName()
const override {
37 return "rtg-virtual-register-constantifier";
54 patterns.add<VirtualRegisterConstantifier, 2>();
58 mlir::DialectRegistry ®istry) {
59 registry.addExtension(+[](MLIRContext *ctx, RTGDialect *dialect) {
false return failure()
Parse an optional keyword or string and set instance into 'result'.
StringAttr getName(ArrayAttr names, size_t idx)
Return the name at the specified index of the ArrayAttr or null if it cannot be determined.
void registerReducePatternDialectInterface(mlir::DialectRegistry ®istry)
Register the RTG Reduction pattern dialect interface to the given registry.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
A reduction pattern for a specific operation.
A dialect interface to provide reduction patterns to a reducer tool.
void populateReducePatterns(circt::ReducePatternSet &patterns) const override