The current OpBuilder has a set of virtual functions required by the fact that the PatternRewriter inherits from it for convenience. The PatternRewriter is required to know about IR mutations for correctness. This revision changes the relationship to be explicit by having users register a listener with the builder instead of using inheritance/vtables. This still requires that users properly transfer the listener when creating new builders, but has several benefits:
- More than one builder can be created during pattern rewrites(assuming that the listener is properly forwarded)
- OpBuilder no longer requires a vtable, and thus does not incur the cost when a listener isn't present.