Move TableGen's parser and entry point into a library

This is the first step towards splitting LLVM and Clang's tblgen executables.

llvm-svn: 140951
This commit is contained in:
Peter Collingbourne 2011-10-01 16:41:13 +00:00
parent 20dde1e8fb
commit 84c287e33c
77 changed files with 369 additions and 241 deletions

View File

@ -195,6 +195,7 @@ endif()
# Put this before tblgen. Else we have a circular dependence. # Put this before tblgen. Else we have a circular dependence.
add_subdirectory(lib/Support) add_subdirectory(lib/Support)
add_subdirectory(lib/TableGen)
set(LLVM_TABLEGEN "tblgen" CACHE set(LLVM_TABLEGEN "tblgen" CACHE
STRING "Native TableGen executable. Saves building one when cross-compiling.") STRING "Native TableGen executable. Saves building one when cross-compiling.")

View File

@ -10,7 +10,7 @@
LEVEL := . LEVEL := .
# Top-Level LLVM Build Stages: # Top-Level LLVM Build Stages:
# 1. Build lib/Support, which is used by utils (tblgen). # 1. Build lib/Support and lib/TableGen, which are used by utils (tblgen).
# 2. Build utils, which is used by VMCore. # 2. Build utils, which is used by VMCore.
# 3. Build VMCore, which builds the Intrinsics.inc file used by libs. # 3. Build VMCore, which builds the Intrinsics.inc file used by libs.
# 4. Build libs, which are needed by llvm-config. # 4. Build libs, which are needed by llvm-config.
@ -27,10 +27,10 @@ LEVEL := .
ifneq ($(findstring llvmCore, $(RC_ProjectName)),llvmCore) # Normal build (not "Apple-style"). ifneq ($(findstring llvmCore, $(RC_ProjectName)),llvmCore) # Normal build (not "Apple-style").
ifeq ($(BUILD_DIRS_ONLY),1) ifeq ($(BUILD_DIRS_ONLY),1)
DIRS := lib/Support utils DIRS := lib/Support lib/TableGen utils
OPTIONAL_DIRS := OPTIONAL_DIRS :=
else else
DIRS := lib/Support utils lib/VMCore lib tools/llvm-shlib \ DIRS := lib/Support lib/TableGen utils lib/VMCore lib tools/llvm-shlib \
tools/llvm-config tools runtime docs unittests tools/llvm-config tools runtime docs unittests
OPTIONAL_DIRS := projects bindings OPTIONAL_DIRS := projects bindings
endif endif

View File

@ -1,4 +1,4 @@
//===- Error.h - tblgen error handling helper routines ----------*- C++ -*-===// //===- llvm/TableGen/Error.h - tblgen error handling helpers ----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -12,8 +12,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef ERROR_H #ifndef LLVM_TABLEGEN_ERROR_H
#define ERROR_H #define LLVM_TABLEGEN_ERROR_H
#include "llvm/Support/SourceMgr.h" #include "llvm/Support/SourceMgr.h"

View File

@ -0,0 +1,26 @@
//===- llvm/TableGen/Main.h - tblgen entry point ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the common entry point for tblgen tools.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TABLEGEN_MAIN_H
#define LLVM_TABLEGEN_MAIN_H
namespace llvm {
class TableGenAction;
/// Run the table generator, performing the specified Action on parsed records.
int TableGenMain(char *argv0, TableGenAction &Action);
}
#endif

View File

@ -1,5 +1,4 @@
//===- llvm/TableGen/Record.h - Classes for Table Records -------*- C++ -*-===//
//===- Record.h - Classes to represent Table Records ------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -13,8 +12,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef RECORD_H #ifndef LLVM_TABLEGEN_RECORD_H
#define RECORD_H #define LLVM_TABLEGEN_RECORD_H
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/FoldingSet.h"

View File

@ -0,0 +1,34 @@
//===- llvm/TableGen/TableGenAction.h - defines TableGenAction --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the TableGenAction base class to be derived from by
// tblgen tools.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TABLEGEN_TABLEGENACTION_H
#define LLVM_TABLEGEN_TABLEGENACTION_H
namespace llvm {
class raw_ostream;
class RecordKeeper;
class TableGenAction {
public:
virtual ~TableGenAction() {}
/// Perform the action using Records, and write output to OS.
/// @returns true on error, false otherwise
virtual bool operator()(raw_ostream &OS, RecordKeeper &Records) = 0;
};
}
#endif

View File

@ -1,4 +1,4 @@
//===- TableGenBackend.h - Base class for TableGen Backends -----*- C++ -*-===// //===- llvm/TableGen/TableGenBackend.h - Backend base class -----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -12,8 +12,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef TABLEGENBACKEND_H #ifndef LLVM_TABLEGEN_TABLEGENBACKEND_H
#define TABLEGENBACKEND_H #define LLVM_TABLEGEN_TABLEGENBACKEND_H
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <string> #include <string>

View File

@ -1,4 +1,4 @@
# `Support' library is added on the top-level CMakeLists.txt # `Support' and `TableGen' libraries are added on the top-level CMakeLists.txt
add_subdirectory(VMCore) add_subdirectory(VMCore)
add_subdirectory(CodeGen) add_subdirectory(CodeGen)

View File

@ -0,0 +1,16 @@
## FIXME: This only requires RTTI because tblgen uses it. Fix that.
set(LLVM_REQUIRES_RTTI 1)
set(LLVM_REQUIRES_EH 1)
add_llvm_library(LLVMTableGen
Error.cpp
Main.cpp
Record.cpp
TableGenBackend.cpp
TGLexer.cpp
TGParser.cpp
)
add_llvm_library_dependencies(LLVMTableGen
LLVMSupport
)

View File

@ -12,7 +12,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"

124
llvm/lib/TableGen/Main.cpp Normal file
View File

@ -0,0 +1,124 @@
//===- Main.cpp - Top-Level TableGen implementation -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// TableGen is a tool which can be used to build up a description of something,
// then invoke one or more "tablegen backends" to emit information about the
// description in some predefined format. In practice, this is used by the LLVM
// code generators to automate generation of a code generator through a
// high-level description of the target.
//
//===----------------------------------------------------------------------===//
#include "TGParser.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/system_error.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenAction.h"
#include <algorithm>
#include <cstdio>
using namespace llvm;
namespace {
cl::opt<std::string>
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
cl::init("-"));
cl::opt<std::string>
DependFilename("d", cl::desc("Dependency filename"), cl::value_desc("filename"),
cl::init(""));
cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
cl::list<std::string>
IncludeDirs("I", cl::desc("Directory of include files"),
cl::value_desc("directory"), cl::Prefix);
}
namespace llvm {
int TableGenMain(char *argv0, TableGenAction &Action) {
RecordKeeper Records;
try {
// Parse the input file.
OwningPtr<MemoryBuffer> File;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) {
errs() << "Could not open input file '" << InputFilename << "': "
<< ec.message() <<"\n";
return 1;
}
MemoryBuffer *F = File.take();
// Tell SrcMgr about this buffer, which is what TGParser will pick up.
SrcMgr.AddNewSourceBuffer(F, SMLoc());
// Record the location of the include directory so that the lexer can find
// it later.
SrcMgr.setIncludeDirs(IncludeDirs);
TGParser Parser(SrcMgr, Records);
if (Parser.ParseFile())
return 1;
std::string Error;
tool_output_file Out(OutputFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv0 << ": error opening " << OutputFilename
<< ":" << Error << "\n";
return 1;
}
if (!DependFilename.empty()) {
if (OutputFilename == "-") {
errs() << argv0 << ": the option -d must be used together with -o\n";
return 1;
}
tool_output_file DepOut(DependFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv0 << ": error opening " << DependFilename
<< ":" << Error << "\n";
return 1;
}
DepOut.os() << OutputFilename << ":";
const std::vector<std::string> &Dependencies = Parser.getDependencies();
for (std::vector<std::string>::const_iterator I = Dependencies.begin(),
E = Dependencies.end();
I != E; ++I) {
DepOut.os() << " " << (*I);
}
DepOut.os() << "\n";
DepOut.keep();
}
if (Action(Out.os(), Records))
return 1;
// Declare success.
Out.keep();
return 0;
} catch (const TGError &Error) {
PrintError(Error);
} catch (const std::string &Error) {
PrintError(Error);
} catch (const char *Error) {
PrintError(Error);
} catch (...) {
errs() << argv0 << ": Unknown unexpected exception occurred.\n";
}
return 1;
}
}

View File

@ -0,0 +1,18 @@
##===- lib/TableGen/Makefile -------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
LEVEL = ../..
LIBRARYNAME = LLVMTableGen
BUILD_ARCHIVE = 1
## FIXME: This only requires RTTI because tblgen uses it. Fix that.
REQUIRES_RTTI = 1
REQUIRES_EH = 1
include $(LEVEL)/Makefile.common

View File

@ -11,8 +11,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "TGLexer.h" #include "TGLexer.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "llvm/Support/SourceMgr.h" #include "llvm/Support/SourceMgr.h"
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include "llvm/Config/config.h" #include "llvm/Config/config.h"

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "TGParser.h" #include "TGParser.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>

View File

@ -15,7 +15,7 @@
#define TGPARSER_H #define TGPARSER_H
#include "TGLexer.h" #include "TGLexer.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/Support/SourceMgr.h" #include "llvm/Support/SourceMgr.h"
#include <map> #include <map>

View File

@ -11,8 +11,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
using namespace llvm; using namespace llvm;
void TableGenBackend::EmitSourceFileHeader(const std::string &Desc, void TableGenBackend::EmitSourceFileHeader(const std::string &Desc,

View File

@ -18,10 +18,10 @@
#include "ARMDecoderEmitter.h" #include "ARMDecoderEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Record.h"
#include <vector> #include <vector>
#include <map> #include <map>

View File

@ -15,9 +15,8 @@
#ifndef ARMDECODEREMITTER_H #ifndef ARMDECODEREMITTER_H
#define ARMDECODEREMITTER_H #define ARMDECODEREMITTER_H
#include "TableGenBackend.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -98,8 +98,6 @@
#include "AsmMatcherEmitter.h" #include "AsmMatcherEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Error.h"
#include "Record.h"
#include "StringMatcher.h" #include "StringMatcher.h"
#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/PointerUnion.h"
@ -109,6 +107,8 @@
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include <map> #include <map>
#include <set> #include <set>
using namespace llvm; using namespace llvm;

View File

@ -15,7 +15,7 @@
#ifndef ASMMATCHER_EMITTER_H #ifndef ASMMATCHER_EMITTER_H
#define ASMMATCHER_EMITTER_H #define ASMMATCHER_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include <cassert> #include <cassert>
namespace llvm { namespace llvm {

View File

@ -14,13 +14,13 @@
#include "AsmWriterEmitter.h" #include "AsmWriterEmitter.h"
#include "AsmWriterInst.h" #include "AsmWriterInst.h"
#include "Error.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h"
#include "StringToOffsetTable.h" #include "StringToOffsetTable.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include <algorithm> #include <algorithm>
using namespace llvm; using namespace llvm;

View File

@ -15,7 +15,7 @@
#ifndef ASMWRITER_EMITTER_H #ifndef ASMWRITER_EMITTER_H
#define ASMWRITER_EMITTER_H #define ASMWRITER_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include <map> #include <map>
#include <vector> #include <vector>
#include <cassert> #include <cassert>

View File

@ -13,8 +13,8 @@
#include "AsmWriterInst.h" #include "AsmWriterInst.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/TableGen/Record.h"
using namespace llvm; using namespace llvm;

View File

@ -25,7 +25,6 @@ add_llvm_utility(tblgen
DAGISelMatcher.cpp DAGISelMatcher.cpp
DisassemblerEmitter.cpp DisassemblerEmitter.cpp
EDEmitter.cpp EDEmitter.cpp
Error.cpp
FastISelEmitter.cpp FastISelEmitter.cpp
FixedLenDecoderEmitter.cpp FixedLenDecoderEmitter.cpp
InstrEnumEmitter.cpp InstrEnumEmitter.cpp
@ -34,21 +33,16 @@ add_llvm_utility(tblgen
NeonEmitter.cpp NeonEmitter.cpp
OptParserEmitter.cpp OptParserEmitter.cpp
PseudoLoweringEmitter.cpp PseudoLoweringEmitter.cpp
Record.cpp
RegisterInfoEmitter.cpp RegisterInfoEmitter.cpp
SetTheory.cpp SetTheory.cpp
StringMatcher.cpp StringMatcher.cpp
SubtargetEmitter.cpp SubtargetEmitter.cpp
TGLexer.cpp
TGParser.cpp
TGValueTypes.cpp TGValueTypes.cpp
TableGen.cpp TableGen.cpp
TableGenBackend.cpp
X86DisassemblerTables.cpp X86DisassemblerTables.cpp
X86RecognizableInstr.cpp X86RecognizableInstr.cpp
) )
target_link_libraries(tblgen LLVMSupport LLVMTableGen)
target_link_libraries(tblgen LLVMSupport)
if( MINGW ) if( MINGW )
target_link_libraries(tblgen imagehlp psapi) target_link_libraries(tblgen imagehlp psapi)
if(CMAKE_SIZEOF_VOID_P MATCHES "8") if(CMAKE_SIZEOF_VOID_P MATCHES "8")

View File

@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "CallingConvEmitter.h" #include "CallingConvEmitter.h"
#include "Record.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "llvm/TableGen/Record.h"
using namespace llvm; using namespace llvm;
void CallingConvEmitter::run(raw_ostream &O) { void CallingConvEmitter::run(raw_ostream &O) {

View File

@ -15,7 +15,7 @@
#ifndef CALLINGCONV_EMITTER_H #ifndef CALLINGCONV_EMITTER_H
#define CALLINGCONV_EMITTER_H #define CALLINGCONV_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include <cassert> #include <cassert>
namespace llvm { namespace llvm {

View File

@ -14,8 +14,8 @@
#ifndef CLANGAST_EMITTER_H #ifndef CLANGAST_EMITTER_H
#define CLANGAST_EMITTER_H #define CLANGAST_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include <string> #include <string>
#include <cctype> #include <cctype>
#include <map> #include <map>

View File

@ -12,8 +12,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "ClangAttrEmitter.h" #include "ClangAttrEmitter.h"
#include "Record.h"
#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/StringSwitch.h"
#include "llvm/TableGen/Record.h"
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>

View File

@ -14,7 +14,7 @@
#ifndef CLANGATTR_EMITTER_H #ifndef CLANGATTR_EMITTER_H
#define CLANGATTR_EMITTER_H #define CLANGATTR_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "ClangDiagnosticsEmitter.h" #include "ClangDiagnosticsEmitter.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/DenseSet.h"

View File

@ -14,7 +14,7 @@
#ifndef CLANGDIAGS_EMITTER_H #ifndef CLANGDIAGS_EMITTER_H
#define CLANGDIAGS_EMITTER_H #define CLANGDIAGS_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "ClangSACheckersEmitter.h" #include "ClangSACheckersEmitter.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/DenseSet.h"
#include <map> #include <map>
#include <string> #include <string>

View File

@ -14,7 +14,7 @@
#ifndef CLANGSACHECKERS_EMITTER_H #ifndef CLANGSACHECKERS_EMITTER_H
#define CLANGSACHECKERS_EMITTER_H #define CLANGSACHECKERS_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -15,7 +15,7 @@
#include "CodeEmitterGen.h" #include "CodeEmitterGen.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"

View File

@ -14,7 +14,7 @@
#ifndef CODEMITTERGEN_H #ifndef CODEMITTERGEN_H
#define CODEMITTERGEN_H #define CODEMITTERGEN_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include <vector> #include <vector>
#include <string> #include <string>

View File

@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"

View File

@ -13,8 +13,8 @@
#include "CodeGenInstruction.h" #include "CodeGenInstruction.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"

View File

@ -14,7 +14,7 @@
#include "CodeGenRegisters.h" #include "CodeGenRegisters.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"

View File

@ -15,8 +15,8 @@
#ifndef CODEGEN_REGISTERS_H #ifndef CODEGEN_REGISTERS_H
#define CODEGEN_REGISTERS_H #define CODEGEN_REGISTERS_H
#include "Record.h"
#include "SetTheory.h" #include "SetTheory.h"
#include "llvm/TableGen/Record.h"
#include "llvm/CodeGen/ValueTypes.h" #include "llvm/CodeGen/ValueTypes.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"

View File

@ -16,7 +16,7 @@
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "CodeGenIntrinsics.h" #include "CodeGenIntrinsics.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"

View File

@ -19,7 +19,7 @@
#include "CodeGenRegisters.h" #include "CodeGenRegisters.h"
#include "CodeGenInstruction.h" #include "CodeGenInstruction.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <algorithm> #include <algorithm>

View File

@ -13,7 +13,7 @@
#include "DAGISelEmitter.h" #include "DAGISelEmitter.h"
#include "DAGISelMatcher.h" #include "DAGISelMatcher.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
using namespace llvm; using namespace llvm;

View File

@ -14,7 +14,7 @@
#ifndef DAGISEL_EMITTER_H #ifndef DAGISEL_EMITTER_H
#define DAGISEL_EMITTER_H #define DAGISEL_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
namespace llvm { namespace llvm {

View File

@ -10,7 +10,7 @@
#include "DAGISelMatcher.h" #include "DAGISelMatcher.h"
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
using namespace llvm; using namespace llvm;

View File

@ -13,7 +13,7 @@
#include "DAGISelMatcher.h" #include "DAGISelMatcher.h"
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"

View File

@ -10,7 +10,7 @@
#include "DAGISelMatcher.h" #include "DAGISelMatcher.h"
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
#include "CodeGenRegisters.h" #include "CodeGenRegisters.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"

View File

@ -9,12 +9,12 @@
#include "DisassemblerEmitter.h" #include "DisassemblerEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Error.h"
#include "Record.h"
#include "X86DisassemblerTables.h" #include "X86DisassemblerTables.h"
#include "X86RecognizableInstr.h" #include "X86RecognizableInstr.h"
#include "ARMDecoderEmitter.h" #include "ARMDecoderEmitter.h"
#include "FixedLenDecoderEmitter.h" #include "FixedLenDecoderEmitter.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
using namespace llvm; using namespace llvm;
using namespace llvm::X86Disassembler; using namespace llvm::X86Disassembler;

View File

@ -10,7 +10,7 @@
#ifndef DISASSEMBLEREMITTER_H #ifndef DISASSEMBLEREMITTER_H
#define DISASSEMBLEREMITTER_H #define DISASSEMBLEREMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -17,8 +17,8 @@
#include "AsmWriterInst.h" #include "AsmWriterInst.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h"
#include "llvm/TableGen/Record.h"
#include "llvm/MC/EDInstInfo.h" #include "llvm/MC/EDInstInfo.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"

View File

@ -16,7 +16,7 @@
#ifndef SEMANTIC_INFO_EMITTER_H #ifndef SEMANTIC_INFO_EMITTER_H
#define SEMANTIC_INFO_EMITTER_H #define SEMANTIC_INFO_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -18,8 +18,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "FastISelEmitter.h" #include "FastISelEmitter.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/VectorExtras.h" #include "llvm/ADT/VectorExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"

View File

@ -14,8 +14,8 @@
#ifndef FASTISEL_EMITTER_H #ifndef FASTISEL_EMITTER_H
#define FASTISEL_EMITTER_H #define FASTISEL_EMITTER_H
#include "TableGenBackend.h"
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
#include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -16,7 +16,7 @@
#include "FixedLenDecoderEmitter.h" #include "FixedLenDecoderEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"

View File

@ -16,8 +16,8 @@
#define FixedLenDECODEREMITTER_H #define FixedLenDECODEREMITTER_H
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "TableGenBackend.h"
#include "llvm/TableGen/TableGenBackend.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
namespace llvm { namespace llvm {

View File

@ -14,7 +14,7 @@
#include "InstrEnumEmitter.h" #include "InstrEnumEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include <cstdio> #include <cstdio>
using namespace llvm; using namespace llvm;

View File

@ -15,7 +15,7 @@
#ifndef INSTRENUM_EMITTER_H #ifndef INSTRENUM_EMITTER_H
#define INSTRENUM_EMITTER_H #define INSTRENUM_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {

View File

@ -14,7 +14,7 @@
#include "InstrInfoEmitter.h" #include "InstrInfoEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include <algorithm> #include <algorithm>
using namespace llvm; using namespace llvm;

View File

@ -15,8 +15,8 @@
#ifndef INSTRINFO_EMITTER_H #ifndef INSTRINFO_EMITTER_H
#define INSTRINFO_EMITTER_H #define INSTRINFO_EMITTER_H
#include "TableGenBackend.h"
#include "CodeGenDAGPatterns.h" #include "CodeGenDAGPatterns.h"
#include "llvm/TableGen/TableGenBackend.h"
#include <vector> #include <vector>
#include <map> #include <map>

View File

@ -13,8 +13,8 @@
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "IntrinsicEmitter.h" #include "IntrinsicEmitter.h"
#include "Record.h"
#include "StringMatcher.h" #include "StringMatcher.h"
#include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include <algorithm> #include <algorithm>
using namespace llvm; using namespace llvm;

View File

@ -15,7 +15,7 @@
#define INTRINSIC_EMITTER_H #define INTRINSIC_EMITTER_H
#include "CodeGenIntrinsics.h" #include "CodeGenIntrinsics.h"
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {
class IntrinsicEmitter : public TableGenBackend { class IntrinsicEmitter : public TableGenBackend {

View File

@ -9,7 +9,7 @@
LEVEL = ../.. LEVEL = ../..
TOOLNAME = tblgen TOOLNAME = tblgen
USEDLIBS = LLVMSupport.a USEDLIBS = LLVMTableGen.a LLVMSupport.a
REQUIRES_EH := 1 REQUIRES_EH := 1
REQUIRES_RTTI := 1 REQUIRES_RTTI := 1

View File

@ -24,7 +24,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "NeonEmitter.h" #include "NeonEmitter.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"

View File

@ -16,8 +16,8 @@
#ifndef NEON_EMITTER_H #ifndef NEON_EMITTER_H
#define NEON_EMITTER_H #define NEON_EMITTER_H
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "OptParserEmitter.h" #include "OptParserEmitter.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
using namespace llvm; using namespace llvm;

View File

@ -10,7 +10,7 @@
#ifndef UTILS_TABLEGEN_OPTPARSEREMITTER_H #ifndef UTILS_TABLEGEN_OPTPARSEREMITTER_H
#define UTILS_TABLEGEN_OPTPARSEREMITTER_H #define UTILS_TABLEGEN_OPTPARSEREMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
namespace llvm { namespace llvm {
/// OptParserEmitter - This tablegen backend takes an input .td file /// OptParserEmitter - This tablegen backend takes an input .td file

View File

@ -8,10 +8,10 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "pseudo-lowering" #define DEBUG_TYPE "pseudo-lowering"
#include "Error.h"
#include "CodeGenInstruction.h" #include "CodeGenInstruction.h"
#include "PseudoLoweringEmitter.h" #include "PseudoLoweringEmitter.h"
#include "Record.h" #include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/ADT/IndexedMap.h" #include "llvm/ADT/IndexedMap.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"

View File

@ -12,7 +12,7 @@
#include "CodeGenInstruction.h" #include "CodeGenInstruction.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include "llvm/ADT/IndexedMap.h" #include "llvm/ADT/IndexedMap.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"

View File

@ -16,7 +16,7 @@
#include "RegisterInfoEmitter.h" #include "RegisterInfoEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "CodeGenRegisters.h" #include "CodeGenRegisters.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"

View File

@ -16,7 +16,7 @@
#ifndef REGISTER_INFO_EMITTER_H #ifndef REGISTER_INFO_EMITTER_H
#define REGISTER_INFO_EMITTER_H #define REGISTER_INFO_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include <vector> #include <vector>
namespace llvm { namespace llvm {

View File

@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "SetTheory.h" #include "SetTheory.h"
#include "Error.h" #include "llvm/TableGen/Error.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"
using namespace llvm; using namespace llvm;

View File

@ -13,7 +13,7 @@
#include "SubtargetEmitter.h" #include "SubtargetEmitter.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h" #include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include <algorithm> #include <algorithm>

View File

@ -14,7 +14,7 @@
#ifndef SUBTARGET_EMITTER_H #ifndef SUBTARGET_EMITTER_H
#define SUBTARGET_EMITTER_H #define SUBTARGET_EMITTER_H
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include "llvm/MC/MCInstrItineraries.h" #include "llvm/MC/MCInstrItineraries.h"
#include <vector> #include <vector>
#include <map> #include <map>

View File

@ -1,4 +1,4 @@
//===- TableGen.cpp - Top-Level TableGen implementation -------------------===// //===- TableGen.cpp - Top-Level TableGen implementation for LLVM ----------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -7,11 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// TableGen is a tool which can be used to build up a description of something, // This file contains the main function for LLVM's TableGen.
// then invoke one or more "tablegen backends" to emit information about the
// description in some predefined format. In practice, this is used by the LLVM
// code generators to automate generation of a code generator through a
// high-level description of the target.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -26,28 +22,25 @@
#include "DAGISelEmitter.h" #include "DAGISelEmitter.h"
#include "DisassemblerEmitter.h" #include "DisassemblerEmitter.h"
#include "EDEmitter.h" #include "EDEmitter.h"
#include "Error.h"
#include "FastISelEmitter.h" #include "FastISelEmitter.h"
#include "InstrInfoEmitter.h" #include "InstrInfoEmitter.h"
#include "IntrinsicEmitter.h" #include "IntrinsicEmitter.h"
#include "NeonEmitter.h" #include "NeonEmitter.h"
#include "OptParserEmitter.h" #include "OptParserEmitter.h"
#include "PseudoLoweringEmitter.h" #include "PseudoLoweringEmitter.h"
#include "Record.h"
#include "RegisterInfoEmitter.h" #include "RegisterInfoEmitter.h"
#include "ARMDecoderEmitter.h" #include "ARMDecoderEmitter.h"
#include "SubtargetEmitter.h" #include "SubtargetEmitter.h"
#include "SetTheory.h" #include "SetTheory.h"
#include "TGParser.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/Signals.h" #include "llvm/Support/Signals.h"
#include "llvm/Support/system_error.h" #include "llvm/TableGen/Error.h"
#include <algorithm> #include "llvm/TableGen/Main.h"
#include <cstdio> #include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenAction.h"
using namespace llvm; using namespace llvm;
enum ActionType { enum ActionType {
@ -172,197 +165,125 @@ namespace {
Class("class", cl::desc("Print Enum list for this class"), Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name")); cl::value_desc("class name"));
cl::opt<std::string>
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"),
cl::init("-"));
cl::opt<std::string>
DependFilename("d", cl::desc("Dependency filename"), cl::value_desc("filename"),
cl::init(""));
cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
cl::list<std::string>
IncludeDirs("I", cl::desc("Directory of include files"),
cl::value_desc("directory"), cl::Prefix);
cl::opt<std::string> cl::opt<std::string>
ClangComponent("clang-component", ClangComponent("clang-component",
cl::desc("Only use warnings from specified component"), cl::desc("Only use warnings from specified component"),
cl::value_desc("component"), cl::Hidden); cl::value_desc("component"), cl::Hidden);
} }
class LLVMTableGenAction : public TableGenAction {
int main(int argc, char **argv) { public:
RecordKeeper Records; bool operator()(raw_ostream &OS, RecordKeeper &Records) {
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
try {
// Parse the input file.
OwningPtr<MemoryBuffer> File;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) {
errs() << "Could not open input file '" << InputFilename << "': "
<< ec.message() <<"\n";
return 1;
}
MemoryBuffer *F = File.take();
// Tell SrcMgr about this buffer, which is what TGParser will pick up.
SrcMgr.AddNewSourceBuffer(F, SMLoc());
// Record the location of the include directory so that the lexer can find
// it later.
SrcMgr.setIncludeDirs(IncludeDirs);
TGParser Parser(SrcMgr, Records);
if (Parser.ParseFile())
return 1;
std::string Error;
tool_output_file Out(OutputFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv[0] << ": error opening " << OutputFilename
<< ":" << Error << "\n";
return 1;
}
if (!DependFilename.empty()) {
if (OutputFilename == "-") {
errs() << argv[0] << ": the option -d must be used together with -o\n";
return 1;
}
tool_output_file DepOut(DependFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv[0] << ": error opening " << DependFilename
<< ":" << Error << "\n";
return 1;
}
DepOut.os() << OutputFilename << ":";
const std::vector<std::string> &Dependencies = Parser.getDependencies();
for (std::vector<std::string>::const_iterator I = Dependencies.begin(),
E = Dependencies.end();
I != E; ++I) {
DepOut.os() << " " << (*I);
}
DepOut.os() << "\n";
DepOut.keep();
}
switch (Action) { switch (Action) {
case PrintRecords: case PrintRecords:
Out.os() << Records; // No argument, dump all contents OS << Records; // No argument, dump all contents
break; break;
case GenEmitter: case GenEmitter:
CodeEmitterGen(Records).run(Out.os()); CodeEmitterGen(Records).run(OS);
break; break;
case GenRegisterInfo: case GenRegisterInfo:
RegisterInfoEmitter(Records).run(Out.os()); RegisterInfoEmitter(Records).run(OS);
break; break;
case GenInstrInfo: case GenInstrInfo:
InstrInfoEmitter(Records).run(Out.os()); InstrInfoEmitter(Records).run(OS);
break; break;
case GenCallingConv: case GenCallingConv:
CallingConvEmitter(Records).run(Out.os()); CallingConvEmitter(Records).run(OS);
break; break;
case GenAsmWriter: case GenAsmWriter:
AsmWriterEmitter(Records).run(Out.os()); AsmWriterEmitter(Records).run(OS);
break; break;
case GenARMDecoder: case GenARMDecoder:
ARMDecoderEmitter(Records).run(Out.os()); ARMDecoderEmitter(Records).run(OS);
break; break;
case GenAsmMatcher: case GenAsmMatcher:
AsmMatcherEmitter(Records).run(Out.os()); AsmMatcherEmitter(Records).run(OS);
break; break;
case GenClangAttrClasses: case GenClangAttrClasses:
ClangAttrClassEmitter(Records).run(Out.os()); ClangAttrClassEmitter(Records).run(OS);
break; break;
case GenClangAttrImpl: case GenClangAttrImpl:
ClangAttrImplEmitter(Records).run(Out.os()); ClangAttrImplEmitter(Records).run(OS);
break; break;
case GenClangAttrList: case GenClangAttrList:
ClangAttrListEmitter(Records).run(Out.os()); ClangAttrListEmitter(Records).run(OS);
break; break;
case GenClangAttrPCHRead: case GenClangAttrPCHRead:
ClangAttrPCHReadEmitter(Records).run(Out.os()); ClangAttrPCHReadEmitter(Records).run(OS);
break; break;
case GenClangAttrPCHWrite: case GenClangAttrPCHWrite:
ClangAttrPCHWriteEmitter(Records).run(Out.os()); ClangAttrPCHWriteEmitter(Records).run(OS);
break; break;
case GenClangAttrSpellingList: case GenClangAttrSpellingList:
ClangAttrSpellingListEmitter(Records).run(Out.os()); ClangAttrSpellingListEmitter(Records).run(OS);
break; break;
case GenClangAttrLateParsedList: case GenClangAttrLateParsedList:
ClangAttrLateParsedListEmitter(Records).run(Out.os()); ClangAttrLateParsedListEmitter(Records).run(OS);
break; break;
case GenClangDiagsDefs: case GenClangDiagsDefs:
ClangDiagsDefsEmitter(Records, ClangComponent).run(Out.os()); ClangDiagsDefsEmitter(Records, ClangComponent).run(OS);
break; break;
case GenClangDiagGroups: case GenClangDiagGroups:
ClangDiagGroupsEmitter(Records).run(Out.os()); ClangDiagGroupsEmitter(Records).run(OS);
break; break;
case GenClangDiagsIndexName: case GenClangDiagsIndexName:
ClangDiagsIndexNameEmitter(Records).run(Out.os()); ClangDiagsIndexNameEmitter(Records).run(OS);
break; break;
case GenClangDeclNodes: case GenClangDeclNodes:
ClangASTNodesEmitter(Records, "Decl", "Decl").run(Out.os()); ClangASTNodesEmitter(Records, "Decl", "Decl").run(OS);
ClangDeclContextEmitter(Records).run(Out.os()); ClangDeclContextEmitter(Records).run(OS);
break; break;
case GenClangStmtNodes: case GenClangStmtNodes:
ClangASTNodesEmitter(Records, "Stmt", "").run(Out.os()); ClangASTNodesEmitter(Records, "Stmt", "").run(OS);
break; break;
case GenClangSACheckers: case GenClangSACheckers:
ClangSACheckersEmitter(Records).run(Out.os()); ClangSACheckersEmitter(Records).run(OS);
break; break;
case GenDisassembler: case GenDisassembler:
DisassemblerEmitter(Records).run(Out.os()); DisassemblerEmitter(Records).run(OS);
break; break;
case GenPseudoLowering: case GenPseudoLowering:
PseudoLoweringEmitter(Records).run(Out.os()); PseudoLoweringEmitter(Records).run(OS);
break; break;
case GenOptParserDefs: case GenOptParserDefs:
OptParserEmitter(Records, true).run(Out.os()); OptParserEmitter(Records, true).run(OS);
break; break;
case GenOptParserImpl: case GenOptParserImpl:
OptParserEmitter(Records, false).run(Out.os()); OptParserEmitter(Records, false).run(OS);
break; break;
case GenDAGISel: case GenDAGISel:
DAGISelEmitter(Records).run(Out.os()); DAGISelEmitter(Records).run(OS);
break; break;
case GenFastISel: case GenFastISel:
FastISelEmitter(Records).run(Out.os()); FastISelEmitter(Records).run(OS);
break; break;
case GenSubtarget: case GenSubtarget:
SubtargetEmitter(Records).run(Out.os()); SubtargetEmitter(Records).run(OS);
break; break;
case GenIntrinsic: case GenIntrinsic:
IntrinsicEmitter(Records).run(Out.os()); IntrinsicEmitter(Records).run(OS);
break; break;
case GenTgtIntrinsic: case GenTgtIntrinsic:
IntrinsicEmitter(Records, true).run(Out.os()); IntrinsicEmitter(Records, true).run(OS);
break; break;
case GenEDInfo: case GenEDInfo:
EDEmitter(Records).run(Out.os()); EDEmitter(Records).run(OS);
break; break;
case GenArmNeon: case GenArmNeon:
NeonEmitter(Records).run(Out.os()); NeonEmitter(Records).run(OS);
break; break;
case GenArmNeonSema: case GenArmNeonSema:
NeonEmitter(Records).runHeader(Out.os()); NeonEmitter(Records).runHeader(OS);
break; break;
case GenArmNeonTest: case GenArmNeonTest:
NeonEmitter(Records).runTests(Out.os()); NeonEmitter(Records).runTests(OS);
break; break;
case PrintEnums: case PrintEnums:
{ {
std::vector<Record*> Recs = Records.getAllDerivedDefinitions(Class); std::vector<Record*> Recs = Records.getAllDerivedDefinitions(Class);
for (unsigned i = 0, e = Recs.size(); i != e; ++i) for (unsigned i = 0, e = Recs.size(); i != e; ++i)
Out.os() << Recs[i]->getName() << ", "; OS << Recs[i]->getName() << ", ";
Out.os() << "\n"; OS << "\n";
break; break;
} }
case PrintSets: case PrintSets:
@ -371,33 +292,29 @@ int main(int argc, char **argv) {
Sets.addFieldExpander("Set", "Elements"); Sets.addFieldExpander("Set", "Elements");
std::vector<Record*> Recs = Records.getAllDerivedDefinitions("Set"); std::vector<Record*> Recs = Records.getAllDerivedDefinitions("Set");
for (unsigned i = 0, e = Recs.size(); i != e; ++i) { for (unsigned i = 0, e = Recs.size(); i != e; ++i) {
Out.os() << Recs[i]->getName() << " = ["; OS << Recs[i]->getName() << " = [";
const std::vector<Record*> *Elts = Sets.expand(Recs[i]); const std::vector<Record*> *Elts = Sets.expand(Recs[i]);
assert(Elts && "Couldn't expand Set instance"); assert(Elts && "Couldn't expand Set instance");
for (unsigned ei = 0, ee = Elts->size(); ei != ee; ++ei) for (unsigned ei = 0, ee = Elts->size(); ei != ee; ++ei)
Out.os() << ' ' << (*Elts)[ei]->getName(); OS << ' ' << (*Elts)[ei]->getName();
Out.os() << " ]\n"; OS << " ]\n";
} }
break; break;
} }
default: default:
assert(1 && "Invalid Action"); assert(1 && "Invalid Action");
return 1; return true;
} }
// Declare success. return false;
Out.keep();
return 0;
} catch (const TGError &Error) {
PrintError(Error);
} catch (const std::string &Error) {
PrintError(Error);
} catch (const char *Error) {
PrintError(Error);
} catch (...) {
errs() << argv[0] << ": Unknown unexpected exception occurred.\n";
} }
};
return 1; int main(int argc, char **argv) {
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
LLVMTableGenAction Action;
return TableGenMain(argv[0], Action);
} }

View File

@ -17,7 +17,7 @@
#include "X86DisassemblerShared.h" #include "X86DisassemblerShared.h"
#include "X86DisassemblerTables.h" #include "X86DisassemblerTables.h"
#include "TableGenBackend.h" #include "llvm/TableGen/TableGenBackend.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"

View File

@ -20,8 +20,8 @@
#include "X86DisassemblerTables.h" #include "X86DisassemblerTables.h"
#include "CodeGenTarget.h" #include "CodeGenTarget.h"
#include "Record.h"
#include "llvm/TableGen/Record.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"