[PATCH] D74438: [mlir] Allow adding extra class declarations to interfaces.
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 16 00:03:32 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG857b655d7aac: [mlir] Allow adding extra class declarations to interfaces. (authored by riverriddle at google.com <riverriddle at google.com>, committed by rriddle).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74438/new/
https://reviews.llvm.org/D74438
Files:
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/TableGen/OpInterfaces.h
mlir/lib/TableGen/OpInterfaces.cpp
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
Index: mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
===================================================================
--- mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
+++ mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
@@ -205,6 +205,11 @@
emitMethodNameAndArgs(method, os, /*addOperationArg=*/false);
os << ";\n";
}
+
+ // Emit any extra declarations.
+ if (Optional<StringRef> extraDecls = interface.getExtraClassDeclaration())
+ os << *extraDecls << "\n";
+
os << "};\n";
}
Index: mlir/lib/TableGen/OpInterfaces.cpp
===================================================================
--- mlir/lib/TableGen/OpInterfaces.cpp
+++ mlir/lib/TableGen/OpInterfaces.cpp
@@ -86,6 +86,12 @@
return value.empty() ? llvm::Optional<StringRef>() : value;
}
+// Return the interfaces extra class declaration code.
+llvm::Optional<StringRef> OpInterface::getExtraClassDeclaration() const {
+ auto value = def->getValueAsString("extraClassDeclaration");
+ return value.empty() ? llvm::Optional<StringRef>() : value;
+}
+
// Return the body for this method if it has one.
llvm::Optional<StringRef> OpInterface::getVerify() const {
auto value = def->getValueAsString("verify");
Index: mlir/include/mlir/TableGen/OpInterfaces.h
===================================================================
--- mlir/include/mlir/TableGen/OpInterfaces.h
+++ mlir/include/mlir/TableGen/OpInterfaces.h
@@ -86,6 +86,9 @@
// Return the description of this method if it has one.
llvm::Optional<StringRef> getDescription() const;
+ // Return the interfaces extra class declaration code.
+ llvm::Optional<StringRef> getExtraClassDeclaration() const;
+
// Return the verify method body if it has one.
llvm::Optional<StringRef> getVerify() const;
Index: mlir/include/mlir/IR/OpBase.td
===================================================================
--- mlir/include/mlir/IR/OpBase.td
+++ mlir/include/mlir/IR/OpBase.td
@@ -1503,6 +1503,10 @@
// The list of methods defined by this interface.
list<InterfaceMethod> methods = [];
+
+ // An optional code block containing extra declarations to place in the
+ // interface declaration.
+ code extraClassDeclaration = "";
}
// Whether to declare the op interface methods in the op's header. This class
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74438.244858.patch
Type: text/x-patch
Size: 2276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200216/79434f91/attachment.bin>
More information about the llvm-commits
mailing list