35#include <system_error>
67 "no-warn-on-unused-template-args",
68 cl::desc(
"Disable unused template argument warnings."));
71 errs() << ProgName <<
": " << Msg;
82 return reportError(argv0,
"the option -d must be used together with -o\n");
91 DepOut.
os() <<
' ' << Dep;
99 std::function<TableGenMainFn> MainFn) {
103 Records.startPhaseTiming();
107 Records.startTimer(
"Parse, build records");
110 if (std::error_code EC = FileOrErr.
getError())
112 "': " + EC.message() +
"\n");
130 Records.startBackendTimer(
"Backend overall");
131 std::string OutString;
136 ActionFn(Records, Out);
138 status = MainFn(Out, Records);
141 Records.stopBackendTimer();
154 Records.startTimer(
"Write output");
155 bool WriteFile =
true;
160 if (
auto ExistingOrErr =
162 if (std::move(ExistingOrErr.get())->getBuffer() == OutString)
170 EC.message() +
"\n");
171 OutFile.
os() << OutString;
177 Records.stopPhaseTiming();
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 int createDependencyFile(const TGParser &Parser, const char *argv0)
Create a dependency file for -d option.
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 cl::opt< std::string > InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"))
static cl::list< std::string > MacroNames("D", cl::desc("Name of the macro to be defined"), cl::value_desc("macro name"), cl::Prefix)
static int reportError(const char *ProgName, Twine Msg)
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.
void setIncludeDirs(const std::vector< std::string > &Dirs)
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
const TGLexer::DependenciesSetTy & getDependencies() const
bool ParseFile()
ParseFile - Main entrypoint for parsing a tblgen file.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A raw_ostream that writes to an std::string.
ManagedStatic< cl::opt< FnT >, OptCreatorT > Action
void(*)(RecordKeeper &Records, raw_ostream &OS) FnT
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.
This is an optimization pass for GlobalISel generic memory operations.
int TableGenMain(const char *argv0, std::function< TableGenMainFn > MainFn=nullptr)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.