Skip to content

Commit 25b4a76

Browse files
Adapt tests to new changes
1 parent a98cfd3 commit 25b4a76

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

mlir/test/mlir-tblgen/op-interface.td

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ def ExtraShardDeclsInterface : OpInterface<"ExtraShardDeclsInterface"> {
3131
// DECL-NEXT: return (*this).someOtherMethod();
3232
// DECL-NEXT: }
3333

34-
// DECL: struct ExtraShardDeclsInterfaceTrait
35-
// DECL: bool sharedMethodDeclaration() {
36-
// DECL-NEXT: return (*static_cast<ConcreteOp *>(this)).someOtherMethod();
37-
// DECL-NEXT: }
38-
3934
def TestInheritanceMultiBaseInterface : OpInterface<"TestInheritanceMultiBaseInterface"> {
4035
let methods = [
4136
InterfaceMethod<
@@ -71,7 +66,7 @@ def TestInheritanceMiddleBaseInterface
7166
def TestInheritanceZDerivedInterface
7267
: OpInterface<"TestInheritanceZDerivedInterface", [TestInheritanceMiddleBaseInterface]>;
7368

74-
// DECL: class TestInheritanceZDerivedInterface
69+
// DECL: struct TestInheritanceZDerivedInterfaceInterfaceTraits
7570
// DECL: struct Concept {
7671
// DECL: const TestInheritanceMultiBaseInterface::Concept *implTestInheritanceMultiBaseInterface = nullptr;
7772
// DECL-NOT: const TestInheritanceMultiBaseInterface::Concept
@@ -173,10 +168,16 @@ def DeclareMethodsWithDefaultOp : Op<TestDialect, "declare_methods_op",
173168
// DECL: /// some function comment
174169
// DECL: int foo(int input);
175170

176-
// DECL-LABEL: struct TestOpInterfaceVerifyTrait
171+
// Trait declarations / definitions come after interface definitions.
172+
// DECL: struct ExtraShardDeclsInterfaceTrait : public
173+
// DECL: bool sharedMethodDeclaration() {
174+
// DECL-NEXT: return (*static_cast<ConcreteOp *>(this)).someOtherMethod();
175+
// DECL-NEXT: }
176+
177+
// DECL-LABEL: struct TestOpInterfaceVerifyTrait : public
177178
// DECL: verifyTrait
178179

179-
// DECL-LABEL: struct TestOpInterfaceVerifyRegionTrait
180+
// DECL-LABEL: struct TestOpInterfaceVerifyRegionTrait : public
180181
// DECL: verifyRegionTrait
181182

182183
// Method implementations come last, after all class definitions.

mlir/tools/mlir-tblgen/OpInterfacesGen.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,14 @@ void InterfaceGenerator::forwardDeclareInterface(const Interface &interface) {
534534
for (StringRef ns : namespaces)
535535
os << "namespace " << ns << " {\n";
536536

537+
// Emit a forward declaration of the interface class so that it becomes usable
538+
// in the signature of its methods.
539+
std::string comments = tblgen::emitSummaryAndDescComments(
540+
"", interface.getDescription().value_or(""));
541+
if (!comments.empty()) {
542+
os << comments << "\n";
543+
}
544+
537545
StringRef interfaceName = interface.getName();
538546
os << "class " << interfaceName << ";\n";
539547

@@ -642,10 +650,10 @@ bool InterfaceGenerator::emitInterfaceDecls() {
642650
forwardDeclareInterface(Interface(def));
643651
for (const Record *def : sortedDefs)
644652
emitInterfaceDecl(Interface(def));
645-
for (const Record *def : sortedDefs)
646-
emitModelMethodsDef(Interface(def));
647653
for (const Record *def : sortedDefs)
648654
emitInterfaceTraitDecl(Interface(def));
655+
for (const Record *def : sortedDefs)
656+
emitModelMethodsDef(Interface(def));
649657

650658
return false;
651659
}

0 commit comments

Comments
 (0)