39#include <system_error>
71 "long-string-literals",
72 cl::desc(
"when emitting large string tables, prefer string literals over "
73 "comma-separated char literals. This can be a readability and "
74 "compile-time performance win, but upsets some compilers"),
78 "no-warn-on-unused-template-args",
79 cl::desc(
"Disable unused template argument warnings."));
84 errs() << ProgName <<
": " <<
Msg;
96 SMCoords(
const SourceMgr &Mgr, SMLoc Loc) {
113 if (This.Buf ==
Last.Buf && This.Line ==
Last.Line) {
152 return reportError(argv0,
"the option -d must be used together with -o\n");
158 EC.message() +
"\n");
173 std::set<std::string> Dependencies;
174 for (
unsigned I = 2,
E =
SrcMgr.getNumBuffers();
I <=
E; ++
I)
175 Dependencies.insert(
SrcMgr.getMemoryBuffer(
I)->getBufferIdentifier().str());
176 for (
const std::string &Dep : Dependencies)
177 DepOut.
os() <<
' ' << Dep;
190 if (std::move(ExistingOrErr.get())->getBuffer() == Content)
200 EC.message() +
"\n");
201 OutFile.
os() << Content;
211 if (std::error_code EC = FileOrErr.
getError())
213 "': " + EC.message() +
"\n");
216 SrcMgr.AddNewSourceBuffer(std::move(*FileOrErr),
SMLoc());
225 std::string OutString;
245 Timer.startPhaseTiming();
263 Timer.startBackendTimer(
"Backend overall");
270 status = MainFn ? MainFn(OutFiles, Records) : 1;
271 Timer.stopBackendTimer();
299 Timer.stopPhaseTiming();
311 int Res = MainFn(OS, Records);
312 OutFiles = {std::move(S), {}};
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Provides ErrorOr<T> smart pointer.
static cl::opt< bool > NoWarnOnUnusedTemplateArgs("no-warn-on-unused-template-args", cl::desc("Disable unused template argument warnings."))
static cl::list< std::string > IncludeDirs("I", cl::desc("Directory of include files"), cl::value_desc("directory"), cl::Prefix)
static cl::opt< bool > WriteIfChanged("write-if-changed", cl::desc("Only write output if it changed"))
static cl::opt< std::string > DependFilename("d", cl::desc("Dependency filename"), cl::value_desc("filename"), cl::init(""))
static cl::opt< std::string > OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::init("-"))
static cl::opt< bool > TimePhases("time-phases", cl::desc("Time phases of parser and backend"))
static int createDependencyFile(const char *argv0)
Create a dependency file for -d option.
static int preprocessInput(TGLexer &Lex, raw_ostream &OS)
Create preprocessed output for -E option.
static cl::opt< std::string > InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"))
static int WriteOutput(const char *argv0, StringRef Filename, StringRef Content)
static cl::list< std::string > MacroNames("D", cl::desc("Name of the macro to be defined"), cl::value_desc("macro name"), cl::Prefix)
static cl::opt< bool > Preprocess("E", cl::desc("Write preprocessed output"))
static int reportError(const char *ProgName, Twine Msg)
static constexpr StringLiteral Filename
Defines the virtual file system interface vfs::FileSystem.
Represents either an error or a value T.
std::error_code getError() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Represents a location in source code.
constexpr const char * getPointer() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
LLVM_ABI std::pair< unsigned, unsigned > getLineAndColumn(SMLoc Loc, unsigned BufferID=0) const
Find the line and column number for the specified location in the specified file.
LLVM_ABI unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
Represent a constant reference to a string, i.e.
TGLexer - TableGen Lexer class.
SMRange getLocRange() const
tgtok::TokKind getCode() const
bool ParseFile()
ParseFile - Main entrypoint for parsing a tblgen file.
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
LLVM_ABI void stopTimer()
Stop the timer.
LLVM_ABI void startTimer()
Start the timer running.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
A raw_ostream that writes to an std::string.
LLVM_ABI bool ApplyCallback(const RecordKeeper &Records, TableGenOutputFiles &OutFiles, StringRef FilenamePrefix)
Apply callback for any command line option registered above.
initializer< Ty > init(const Ty &Val)
@ OF_Text
The file should be opened in text mode on platforms like z/OS that make this distinction.
@ OF_ForceUTF8
The file should be tagged as UTF-8 rather than the default IBM-1047 encoding.
LLVM_ABI StringRef stem(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get stem.
LLVM_ABI void replace_extension(SmallVectorImpl< char > &path, const Twine &extension, Style style=Style::native)
Replace the file extension of path with extension.
LLVM_ABI IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI unsigned ErrorsPrinted
function_ref< bool(TableGenOutputFiles &OutFiles, const RecordKeeper &Records)> MultiFileTableGenMainFn
Perform the action using Records, and store output in OutFiles.
function_ref< bool(raw_ostream &OS, const RecordKeeper &Records)> TableGenMainFn
Returns true on error, false otherwise.
LLVM_ABI cl::opt< bool > EmitLongStrLiterals
Controls emitting large character arrays as strings or character arrays.
LLVM_ABI SourceMgr SrcMgr
LLVM_ABI int TableGenMain(const char *argv0, TableGenMainFn MainFn=nullptr)
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ End
Run the machine verifier once, at the end of the pipeline.
std::map< StringRef, std::string > AdditionalFiles