diff options
Diffstat (limited to 'mlir/tools/mlir-tblgen/OpInterfacesGen.cpp')
-rw-r--r-- | mlir/tools/mlir-tblgen/OpInterfacesGen.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp index 3cc1636..730b5b2 100644 --- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp +++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp @@ -42,10 +42,10 @@ static raw_ostream &emitCPPType(StringRef type, raw_ostream &os) { /// Emit the method name and argument list for the given method. If 'addThisArg' /// is true, then an argument is added to the beginning of the argument list for /// the concrete value. -static void emitMethodNameAndArgs(const InterfaceMethod &method, +static void emitMethodNameAndArgs(const InterfaceMethod &method, StringRef name, raw_ostream &os, StringRef valueType, bool addThisArg, bool addConst) { - os << method.getName() << '('; + os << name << '('; if (addThisArg) { if (addConst) os << "const "; @@ -183,11 +183,13 @@ static void emitInterfaceDefMethods(StringRef interfaceQualName, emitInterfaceMethodDoc(method, os); emitCPPType(method.getReturnType(), os); os << interfaceQualName << "::"; - emitMethodNameAndArgs(method, os, valueType, /*addThisArg=*/false, + emitMethodNameAndArgs(method, method.getName(), os, valueType, + /*addThisArg=*/false, /*addConst=*/!isOpInterface); // Forward to the method on the concrete operation type. - os << " {\n return " << implValue << "->" << method.getName() << '('; + os << " {\n return " << implValue << "->" << method.getUniqueName() + << '('; if (!method.isStatic()) { os << implValue << ", "; os << (isOpInterface ? "getOperation()" : "*this"); @@ -239,7 +241,7 @@ void InterfaceGenerator::emitConceptDecl(const Interface &interface) { for (auto &method : interface.getMethods()) { os << " "; emitCPPType(method.getReturnType(), os); - os << "(*" << method.getName() << ")("; + os << "(*" << method.getUniqueName() << ")("; if (!method.isStatic()) { os << "const Concept *impl, "; emitCPPType(valueType, os) << (method.arg_empty() ? "" : ", "); @@ -289,13 +291,13 @@ void InterfaceGenerator::emitModelDecl(const Interface &interface) { os << " " << modelClass << "() : Concept{"; llvm::interleaveComma( interface.getMethods(), os, - [&](const InterfaceMethod &method) { os << method.getName(); }); + [&](const InterfaceMethod &method) { os << method.getUniqueName(); }); os << "} {}\n\n"; // Insert each of the virtual method overrides. for (auto &method : interface.getMethods()) { emitCPPType(method.getReturnType(), os << " static inline "); - emitMethodNameAndArgs(method, os, valueType, + emitMethodNameAndArgs(method, method.getUniqueName(), os, valueType, /*addThisArg=*/!method.isStatic(), /*addConst=*/false); os << ";\n"; @@ -319,7 +321,7 @@ void InterfaceGenerator::emitModelDecl(const Interface &interface) { if (method.isStatic()) os << "static "; emitCPPType(method.getReturnType(), os); - os << method.getName() << "("; + os << method.getUniqueName() << "("; if (!method.isStatic()) { emitCPPType(valueType, os); os << "tablegen_opaque_val"; @@ -350,7 +352,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) { emitCPPType(method.getReturnType(), os); os << "detail::" << interface.getName() << "InterfaceTraits::Model<" << valueTemplate << ">::"; - emitMethodNameAndArgs(method, os, valueType, + emitMethodNameAndArgs(method, method.getUniqueName(), os, valueType, /*addThisArg=*/!method.isStatic(), /*addConst=*/false); os << " {\n "; @@ -384,7 +386,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) { emitCPPType(method.getReturnType(), os); os << "detail::" << interface.getName() << "InterfaceTraits::FallbackModel<" << valueTemplate << ">::"; - emitMethodNameAndArgs(method, os, valueType, + emitMethodNameAndArgs(method, method.getUniqueName(), os, valueType, /*addThisArg=*/!method.isStatic(), /*addConst=*/false); os << " {\n "; @@ -396,7 +398,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) { os << "return static_cast<const " << valueTemplate << " *>(impl)->"; // Add the arguments to the call. - os << method.getName() << '('; + os << method.getUniqueName() << '('; if (!method.isStatic()) os << "tablegen_opaque_val" << (method.arg_empty() ? "" : ", "); llvm::interleaveComma( @@ -416,7 +418,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) { << "InterfaceTraits::ExternalModel<ConcreteModel, " << valueTemplate << ">::"; - os << method.getName() << "("; + os << method.getUniqueName() << "("; if (!method.isStatic()) { emitCPPType(valueType, os); os << "tablegen_opaque_val"; @@ -477,7 +479,8 @@ void InterfaceGenerator::emitInterfaceTraitDecl(const Interface &interface) { emitInterfaceMethodDoc(method, os, " "); os << " " << (method.isStatic() ? "static " : ""); emitCPPType(method.getReturnType(), os); - emitMethodNameAndArgs(method, os, valueType, /*addThisArg=*/false, + emitMethodNameAndArgs(method, method.getName(), os, valueType, + /*addThisArg=*/false, /*addConst=*/!isOpInterface && !method.isStatic()); os << " {\n " << tblgen::tgfmt(defaultImpl->trim(), &traitMethodFmt) << "\n }\n"; @@ -514,7 +517,8 @@ static void emitInterfaceDeclMethods(const Interface &interface, for (auto &method : interface.getMethods()) { emitInterfaceMethodDoc(method, os, " "); emitCPPType(method.getReturnType(), os << " "); - emitMethodNameAndArgs(method, os, valueType, /*addThisArg=*/false, + emitMethodNameAndArgs(method, method.getName(), os, valueType, + /*addThisArg=*/false, /*addConst=*/!isOpInterface); os << ";\n"; } @@ -536,11 +540,8 @@ void InterfaceGenerator::forwardDeclareInterface(const Interface &interface) { // Emit a forward declaration of the interface class so that it becomes usable // in the signature of its methods. - std::string comments = tblgen::emitSummaryAndDescComments( - "", interface.getDescription().value_or("")); - if (!comments.empty()) { - os << comments << "\n"; - } + tblgen::emitSummaryAndDescComments(os, "", + interface.getDescription().value_or("")); StringRef interfaceName = interface.getName(); os << "class " << interfaceName << ";\n"; @@ -560,11 +561,8 @@ void InterfaceGenerator::emitInterfaceDecl(const Interface &interface) { // Emit a forward declaration of the interface class so that it becomes usable // in the signature of its methods. - std::string comments = tblgen::emitSummaryAndDescComments( - "", interface.getDescription().value_or("")); - if (!comments.empty()) { - os << comments << "\n"; - } + tblgen::emitSummaryAndDescComments(os, "", + interface.getDescription().value_or("")); // Emit the traits struct containing the concept and model declarations. os << "namespace detail {\n" |