LLVM: lib/TableGen/Main.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

34#include

35#include

36#include <system_error>

37#include

38using namespace llvm;

39

43

46 cl::desc("Dependency filename"),

49

52

56

60

63

66

68 "no-warn-on-unused-template-args",

69 cl::desc("Disable unused template argument warnings."));

70

72 errs() << ProgName << ": " << Msg;

74 return 1;

75}

76

77

78

79

80

83 return reportError(argv0, "the option -d must be used together with -o\n");

84

85 std::error_code EC;

87 if (EC)

89 EC.message() + "\n");

92 DepOut.os() << ' ' << Dep;

93 }

94 DepOut.os() << "\n";

95 DepOut.keep();

96 return 0;

97}

98

100 std::function MainFn) {

103

105 Timer.startPhaseTiming();

106

107

108

112 if (std::error_code EC = FileOrErr.getError())

114 "': " + EC.message() + "\n");

115

117

118

120

121

122

124

126

128 return 1;

130

131

132 Timer.startBackendTimer("Backend overall");

133 std::string OutString;

135 unsigned status = 0;

136

137

139 status = MainFn ? MainFn(Out, Records) : 1;

140 Timer.stopBackendTimer();

141 if (status)

142 return 1;

143

144

145

146

147

150 return Ret;

151 }

152

154 bool WriteFile = true;

156

157

158

159 if (auto ExistingOrErr =

161 if (std::move(ExistingOrErr.get())->getBuffer() == OutString)

162 WriteFile = false;

163 }

164 if (WriteFile) {

165 std::error_code EC;

167 if (EC)

169 EC.message() + "\n");

170 OutFile.os() << OutString;

172 OutFile.keep();

173 }

174

176 Timer.stopPhaseTiming();

177

180 return 0;

181}

Provides ErrorOr 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(""), 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.

This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...

void stopTimer()

Stop the timer.

void startTimer()

Start the timer running.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

A raw_ostream that writes to an std::string.

bool ApplyCallback(const RecordKeeper &Records, raw_ostream &OS)

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.

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.