Allow separation of declarations and definitions in <Target>ISelDAGToDAG.inc
This patch adds the ability to include the member function declarations
in the instruction selector class separately from the member bodies.
Defining GET_DAGISEL_DECL macro to any value will only include the member
declarations. To include bodies, define GET_DAGISEL_BODY macro to be the
selector class name. Example:
class FooDAGToDAGISel : public SelectionDAGISel {
// Pull in declarations only.
#define GET_DAGISEL_DECL
#include "FooISelDAGToDAG.inc"
};
// Include the function bodies (with names qualified with the provided
// class name).
#define GET_DAGISEL_BODY FooDAGToDAGISel
#include "FooISelDAGToDAG.inc"
When neither of the two macros are defined, the function bodies are emitted
inline (in the same way as before this patch).
Differential Revision: https://reviews.llvm.org/D39596
llvm-svn: 317903
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index 4740f16..9592ab7 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -127,6 +127,16 @@
<< "// *** instruction selector class. These functions are really "
<< "methods.\n\n";
+ OS << "// If GET_DAGISEL_DECL is #defined with any value, only function\n"
+ "// declarations will be included when this file is included.\n"
+ "// If GET_DAGISEL_BODY is #defined, its value should be the name of\n"
+ "// the instruction selector class. Function bodies will be emitted\n"
+ "// and each function's name will be qualified with the name of the\n"
+ "// class.\n"
+ "//\n"
+ "// When neither of the GET_DAGISEL* macros is defined, the functions\n"
+ "// are emitted inline.\n\n";
+
DEBUG(errs() << "\n\nALL PATTERNS TO MATCH:\n\n";
for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(),
E = CGP.ptm_end(); I != E; ++I) {