[Mlir-commits] [mlir] [MLIR] Convert DialectReductionPatternInterface using ODS (PR #180640)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Feb 15 10:12:28 PST 2026
================
@@ -126,6 +131,27 @@ static void emitInterfaceMethodsDef(const DialectInterface &interface,
}
}
+static void emitConstructor(const DialectInterface &interface,
+ raw_ostream &os) {
+
+ raw_indented_ostream ios(os);
+
+ // We consider a constructor protected if interface has at least one pure
+ // virtual method
+ auto hasProtectedConstructor =
+ llvm::any_of(interface.getMethods(), [](const InterfaceMethod &method) {
+ return method.isPureVirtual();
+ });
+
+ ios.indent(0);
+ if (hasProtectedConstructor)
+ ios << "protected:\n";
----------------
aidint wrote:
This is the last thing that we emit into the class. Constructor is at end of the emission. I did this to avoid an extra `if(hasProtectedConstructor)` at start of the class. I believe it respects public-first order, it only puts the constructor at end of the class definition (whether it's public or protected). One other approach would be doing the same at start of the class and then emit `public: <constructor>` or `protected: <constructor> public:`.
https://github.com/llvm/llvm-project/pull/180640
More information about the Mlir-commits
mailing list