[llvm-commits] [llvm] r165165 - in /llvm/trunk: include/llvm/TableGen/Main.h lib/TableGen/Main.cpp
Sean Silva
silvas at purdue.edu
Wed Oct 3 14:29:18 PDT 2012
Author: silvas
Date: Wed Oct 3 16:29:18 2012
New Revision: 165165
URL: http://llvm.org/viewvc/llvm-project?rev=165165&view=rev
Log:
tblgen: Put new TableGenMain API in place.
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.
Modified:
llvm/trunk/include/llvm/TableGen/Main.h
llvm/trunk/lib/TableGen/Main.cpp
Modified: llvm/trunk/include/llvm/TableGen/Main.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Main.h?rev=165165&r1=165164&r2=165165&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Main.h (original)
+++ llvm/trunk/include/llvm/TableGen/Main.h Wed Oct 3 16:29:18 2012
@@ -21,6 +21,14 @@
/// 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
Modified: llvm/trunk/lib/TableGen/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Main.cpp?rev=165165&r1=165164&r2=165165&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Main.cpp (original)
+++ llvm/trunk/lib/TableGen/Main.cpp Wed Oct 3 16:29:18 2012
@@ -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 @@
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;
More information about the llvm-commits
mailing list