本文整理汇总了C++中llvm::cl::opt类的典型用法代码示例。如果您正苦于以下问题:C++ opt类的具体用法?C++ opt怎么用?C++ opt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了opt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateArgIfSet
void updateArgIfSet(llvm::cl::opt<T> &argValue, const llvm::Optional<T> &configValue)
{
if (configValue.hasValue() && argValue.getNumOccurrences() == 0)
{
argValue.setValue(configValue.getValue());
}
}
示例2: breakBeforeRunning
// Test the function and pass names we're given against the debug
// options that force us to break prior to a given pass and/or on a
// given function.
static bool breakBeforeRunning(StringRef fnName, StringRef passName) {
if (SILBreakOnFun.empty() && SILBreakOnPass.empty())
return false;
if (SILBreakOnFun.empty() && passName == SILBreakOnPass)
return true;
if (SILBreakOnPass.empty() && fnName == SILBreakOnFun)
return true;
return fnName == SILBreakOnFun && passName == SILBreakOnPass;
}
示例3: breakBeforeRunning
// Test the function and pass names we're given against the debug
// options that force us to break prior to a given pass and/or on a
// given function.
static bool breakBeforeRunning(StringRef fnName, SILFunctionTransform *SFT) {
if (SILBreakOnFun.empty() && SILBreakOnPass.empty())
return false;
if (SILBreakOnFun.empty()
&& (SFT->getName() == SILBreakOnPass || SFT->getTag() == SILBreakOnPass))
return true;
if (SILBreakOnPass.empty() && fnName == SILBreakOnFun)
return true;
return fnName == SILBreakOnFun
&& (SFT->getName() == SILBreakOnPass || SFT->getTag() == SILBreakOnPass);
}
示例4: llvm_manager
// main function
int
main(int argc, char* argv[])
{
llvm::llvm_shutdown_obj llvm_manager(false);
cl::SetVersionPrinter(&PrintVersion);
cl::ParseCommandLineOptions(argc, argv, "", true);
// Handle special exiting options
if (show_license)
{
for (std::size_t i=0; i<sizeof(license_msg)/sizeof(license_msg[0]); i++)
llvm::outs() << license_msg[i] << '\n';
return EXIT_SUCCESS;
}
DiagnosticOptions diag_opts;
diag_opts.ShowOptionNames = 1;
diag_opts.ShowSourceRanges = 1;
TextDiagnosticPrinter diag_printer(llvm::errs(), diag_opts);
IntrusiveRefCntPtr<DiagnosticIDs> diagids(new DiagnosticIDs);
DiagnosticsEngine diags(diagids, &diag_printer, false);
FileSystemOptions opts;
FileManager file_mgr(opts);
SourceManager source_mgr(diags, file_mgr);
diags.setSourceManager(&source_mgr);
diag_printer.setPrefix("ygas");
for (std::vector<std::string>::const_iterator i=unknown_options.begin(),
end=unknown_options.end(); i != end; ++i)
{
diags.Report(diag::warn_unknown_command_line_option) << *i;
}
// Load standard modules
if (!LoadStandardPlugins())
{
diags.Report(diag::fatal_standard_modules);
return EXIT_FAILURE;
}
#ifndef BUILD_STATIC
// Load plugins
for (std::vector<std::string>::const_iterator i=plugin_names.begin(),
end=plugin_names.end(); i != end; ++i)
{
if (!LoadPlugin(*i))
diags.Report(diag::warn_plugin_load) << *i;
}
#endif
// Default to stdin if no filename specified.
if (in_filename.empty())
in_filename = "-";
return do_assemble(source_mgr, diags);
}
示例5: run
void SILPassManager::run() {
const SILOptions &Options = getOptions();
(void) Options;
if (SILPrintAll) {
if (SILPrintOnlyFun.empty() && SILPrintOnlyFuns.empty()) {
llvm::dbgs() << "*** SIL module before transformation ("
<< NumOptimizationIterations << ") ***\n";
Mod->dump(Options.EmitVerboseSIL);
} else {
for (auto &F : *Mod) {
if (!SILPrintOnlyFun.empty() && F.getName().str() == SILPrintOnlyFun) {
llvm::dbgs() << "*** SIL function before transformation ("
<< NumOptimizationIterations << ") ***\n";
F.dump(Options.EmitVerboseSIL);
}
if (!SILPrintOnlyFuns.empty() &&
F.getName().find(SILPrintOnlyFuns, 0) != StringRef::npos) {
llvm::dbgs() << "*** SIL function before transformation ("
<< NumOptimizationIterations << ") ***\n";
F.dump(Options.EmitVerboseSIL);
}
}
}
}
runOneIteration();
}
示例6: main
int main(int argc, char **argv) {
Galois::StatManager M;
LonestarStart(argc, argv, name, desc, url);
if(use_weighted_rmat)
readWeightedRMAT(inputfile.c_str());
else
makeGraph(inputfile.c_str());
#if BORUVKA_DEBUG
EdgeDataType kruskal_wt;
if(verify_via_kruskal){
kruskal_wt= verify(graph);
cout<<"Kruskal MST Result is " << kruskal_wt <<"\n";
}
#endif
cout << "Starting loop body\n";
EdgeDataType mst_wt = runBodyParallel();
cout<<"Boruvka MST Result is " << mst_wt <<"\n";
#if BORUVKA_DEBUG
if(verify_via_kruskal){
assert(kruskal_wt==mst_wt);
}
#endif
#if COMPILE_STATISICS
cout<< " \n==================================================\n";
stat_collector.dump(cout);
cout<< " \n==================================================\n";
#endif
return 0;
}
示例7: main
int main(int argc, char** argv)
{
// Should ParseCommandLineOptions be able to accept a const argv?
llvm::cl::ParseCommandLineOptions(argc, argv, "ploy compiler\n");
const char* file_location = InputFile.c_str();
symbol_table* tbl = sym_tbl = init_symbol_table();
init_symbols(tbl);
pointer ret = parse_file_to_tree(file_location, tbl);
if(!ret)
return 1;
materialize_includes(&ret, tbl);
ploy_do_compile(ret, tbl);
type_map type_define_map;
transform_tree_gen_typedef(ret, tbl, &type_define_map);
transform_tree_gen_typeinfo(ret, tbl, &type_define_map);
compiler* compile = init_compiler(tbl);
compiler_compile_expression(compile, ret, EntryFunc.c_str());
compiler_print_module(compile);
compiler_write_asm_file(compile, OutputFile.c_str());
destroy_compiler(compile);
destroy_symbol_table(tbl);
return 0;
}
示例8: NumDebugFrontendAction
NumDebugFrontendAction() {
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 8
std::error_code EC;
out = new llvm::raw_fd_ostream(output_file.c_str(), EC,
llvm::sys::fs::OpenFlags::F_None);
#else
std::string code;
out = new llvm::raw_fd_ostream(output_file.c_str(), code,
llvm::sys::fs::OpenFlags::F_None);
#endif
}
示例9: printModule
static void printModule(SILModule *Mod, bool EmitVerboseSIL) {
if (SILPrintOnlyFun.empty() && SILPrintOnlyFuns.empty()) {
Mod->dump();
return;
}
for (auto &F : *Mod) {
if (!SILPrintOnlyFun.empty() && F.getName().str() == SILPrintOnlyFun)
F.dump(EmitVerboseSIL);
if (!SILPrintOnlyFuns.empty() &&
F.getName().find(SILPrintOnlyFuns, 0) != StringRef::npos)
F.dump(EmitVerboseSIL);
}
}
示例10: main
int main(int argc, char** argv) {
LonestarStart(argc, argv, name, desc, url);
srand(-1);
MetisGraph metisGraph;
GGraph graph;
metisGraph.setGraph(&graph);
bool directed = true;
if(mtxInput){
readMetisGraph(&metisGraph, filename.c_str());
}else{
readGraph(&metisGraph, filename.c_str(), weighted, directed);
}
partition(&metisGraph, numPartitions);
verify(&metisGraph);
}
示例11: autoDetectFromDirectory
CompilationDatabase *autoDetectCompilations(std::string &ErrorMessage) {
// Auto-detect a compilation database from BuildPath.
if (BuildPath.getNumOccurrences() > 0)
return CompilationDatabase::autoDetectFromDirectory(BuildPath,
ErrorMessage);
// Try to auto-detect a compilation database from the first source.
if (!SourcePaths.empty()) {
if (CompilationDatabase *Compilations =
CompilationDatabase::autoDetectFromSource(SourcePaths[0],
ErrorMessage)) {
// FIXME: just pass SourcePaths[0] once getCompileCommands supports
// non-absolute paths.
SmallString<64> Path(SourcePaths[0]);
llvm::sys::fs::make_absolute(Path);
std::vector<CompileCommand> Commands =
Compilations->getCompileCommands(Path);
// Ignore a detected compilation database that doesn't contain source0
// since it is probably an unrelated compilation database.
if (!Commands.empty())
return Compilations;
}
// Reset ErrorMessage since a fix compilation database will be created if
// it fails to detect one from source.
ErrorMessage = "";
// If no compilation database can be detected from source then we create a
// fixed compilation database with c++11 support.
std::string CommandLine[] = { "-std=c++11" };
return new FixedCompilationDatabase(".", CommandLine);
}
ErrorMessage = "Could not determine sources to transform";
return 0;
}
示例12: main
int main(int argc, char** argv) {
Galois::StatManager statManager;
LonestarStart(argc, argv, name, desc, url);
Galois::StatTimer Tinitial("InitializeTime");
Tinitial.start();
graph.structureFromFile(inputFilename.c_str());
std::cout << "Num nodes: " << graph.size() << "\n";
Tinitial.stop();
//Galois::preAlloc(numThreads);
Galois::Statistic("MeminfoPre", GaloisRuntime::MM::pageAllocInfo());
switch (algo) {
case demo: run<DemoAlgo>(); break;
case asynchronous: run<AsynchronousAlgo>(); break;
default: std::cerr << "Unknown algo: " << algo << "\n";
}
Galois::Statistic("MeminfoPost", GaloisRuntime::MM::pageAllocInfo());
if (!skipVerify && !verify()) {
std::cerr << "verification failed\n";
assert(0 && "verification failed");
abort();
}
return 0;
}
示例13: LLVMTargetMachine
/// HSAILTargetMachine ctor -
///
HSAILTargetMachine::HSAILTargetMachine(const Target &T, StringRef TT,
StringRef CPU, StringRef FS,const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM,CodeGenOpt::Level OL, bool is64bitTarget )
:
LLVMTargetMachine(T, TT, CPU, FS,Options, RM, CM,OL),
Subtarget(TT, CPU, FS, is64bitTarget),
// DLInfo(Subtarget.getDataLayout()),
FrameLowering(TargetFrameLowering::StackGrowsUp,
Subtarget.getStackAlignment(), 0),
// InstrInfo(*this),
// TLInfo(*this),
IntrinsicInfo(this)
{
if (FileType == CGFT_AssemblyFile) {
if (FileType.getNumOccurrences() == 0) {
// LLVM's default is CGFT_AssemblyFile. HSAIL default is binary BRIG,
// thus we need to change output to CGFT_AssemblyFile, unless text
// assembly was explicitly requested by the command line switch.
HSAILFileType = FileType = CGFT_ObjectFile;
}
}
setAsmVerbosityDefault(true);
// disable use of the .loc directive, because only by
// setting this to false does DwarfDebug generate the .debug_line
// section
//
setMCUseLoc(false);
}
示例14: output
int KoonDriver::output() const {
Kompiler kompiler(OutputFilename);
int res = kompiler.kompile(*this->_k.module());
if (res) return res;
std::string object = "/tmp/" + OutputFilename + ".o";
Process("/usr/bin/ld",
"--build-id",
"--eh-frame-hdr",
"--hash-style=gnu",
"-m",
"elf_x86_64",
"-dynamic-linker",
"/lib64/ld-linux-x86-64.so.2",
"../krt/krt0.o",
// "-L/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1",
"-L/usr/lib",
object.c_str(),
// "-lgcc",
// "--as-needed",
// "-lgcc_s",
// "--no-as-needed",
"-lc",
"-o",
OutputFilename.c_str());
Process("/usr/bin/rm", "-f", object.c_str());
return res;
}
示例15: viewCFG
void SILFunction::viewCFG() const {
/// When asserts are disabled, this should be a NoOp.
#ifndef NDEBUG
// If we have a target function, only print that function out.
if (!TargetFunction.empty() && !(getName().str() == TargetFunction))
return;
ViewGraph(const_cast<SILFunction *>(this), "cfg" + getName().str());
#endif
}