[Mlir-commits] [mlir] 3ae43a5 - [ods] Enable getting forward decls allow

Jacques Pienaar llvmlistbot at llvm.org
Tue Jul 14 06:52:49 PDT 2020


Author: Jacques Pienaar
Date: 2020-07-14T06:52:32-07:00
New Revision: 3ae43a580eeacede5b9be715d2539e87030fe1ca

URL: https://github.com/llvm/llvm-project/commit/3ae43a580eeacede5b9be715d2539e87030fe1ca
DIFF: https://github.com/llvm/llvm-project/commit/3ae43a580eeacede5b9be715d2539e87030fe1ca.diff

LOG: [ods] Enable getting forward decls allow

Summary: Currently forward decls are included with all the op classes. But there are cases (say when splitting up headers) where one wants the forward decls but not all the classes. Add an option to enable this. This does not change any current behavior (some further refactoring is probably due here).

Differential Revision: https://reviews.llvm.org/D83727

Added: 
    

Modified: 
    mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 5e009e602524..faeb21265142 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2129,15 +2129,19 @@ void OpOperandAdaptorEmitter::emitDef(const Operator &op, raw_ostream &os) {
 // Emits the opcode enum and op classes.
 static void emitOpClasses(const std::vector<Record *> &defs, raw_ostream &os,
                           bool emitDecl) {
-  IfDefScope scope("GET_OP_CLASSES", os);
   // First emit forward declaration for each class, this allows them to refer
   // to each others in traits for example.
   if (emitDecl) {
+    os << "#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES)\n";
+    os << "#undef GET_OP_FWD_DEFINES\n";
     for (auto *def : defs) {
       Operator op(*def);
       os << "class " << op.getCppClassName() << ";\n";
     }
+    os << "#endif\n\n";
   }
+
+  IfDefScope scope("GET_OP_CLASSES", os);
   for (auto *def : defs) {
     Operator op(*def);
     if (emitDecl) {


        


More information about the Mlir-commits mailing list