tblgen: Put new TableGenMain API in place.
authorSean Silva <silvas@purdue.edu>
Wed, 3 Oct 2012 21:29:18 +0000 (21:29 +0000)
committerSean Silva <silvas@purdue.edu>
Wed, 3 Oct 2012 21:29:18 +0000 (21:29 +0000)
In order to avoid rev-lock with Clang when moving to the new API, also
preserve the current API temporarily and insert a shim to implement the
new API in terms of the old.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165165 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/TableGen/Main.h
lib/TableGen/Main.cpp

index deaef4a9908a5d24536bee979712856ae439f079..663779f176ca072dca28de0ab536f149efce48c5 100644 (file)
@@ -21,6 +21,14 @@ class TableGenAction;
 /// Run the table generator, performing the specified Action on parsed records.
 int TableGenMain(char *argv0, TableGenAction &Action);
 
+class RecordKeeper;
+class raw_ostream;
+typedef bool TableGenMainFn(raw_ostream &OS, RecordKeeper &Records);
+
+/// Perform the action using Records, and write output to OS.
+/// \returns true on error, false otherwise
+int TableGenMain(char *argv0, TableGenMainFn *MainFn);
+
 }
 
 #endif
index 7aeef563b859b088f25150b9d686b992412678dc..83bc66f46080b012dbc79bc42d43a3bec03fda39 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/system_error.h"
 #include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Main.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenAction.h"
 #include <algorithm>
@@ -47,8 +48,26 @@ namespace {
               cl::value_desc("directory"), cl::Prefix);
 }
 
+namespace {
+// XXX: this is a crutch for transitioning to the new TableGenMain API
+// (with a TableGenMainFn* instead of a pointless class).
+class StubTransitionalTableGenAction : public TableGenAction {
+  TableGenMainFn *MainFn;
+public:
+  StubTransitionalTableGenAction(TableGenMainFn *M) : MainFn(M) {}
+  bool operator()(raw_ostream &OS, RecordKeeper &Records) {
+    return MainFn(OS, Records);
+  }
+};
+}
+
 namespace llvm {
 
+int TableGenMain(char *argv0, TableGenMainFn *MainFn) {
+  StubTransitionalTableGenAction Action(MainFn);
+  return TableGenMain(argv0, Action);
+}
+
 int TableGenMain(char *argv0, TableGenAction &Action) {
   RecordKeeper Records;