本文整理汇总了C++中cl::opt::compare方法的典型用法代码示例。如果您正苦于以下问题:C++ opt::compare方法的具体用法?C++ opt::compare怎么用?C++ opt::compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::opt
的用法示例。
在下文中一共展示了opt::compare方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char* argv[] ) {
cl::ParseCommandLineOptions(argc, argv);
// We need exception handling in LLVM compiled code.
// Pending question returns control to interpreter via throwing exceptions.
llvm::JITExceptionHandling = true;
CouchRunService *server =
new CouchRunService( S_CouchURL, S_CouchDB, S_CouchDoc );
if( 0 == S_Message.compare( "restart" ) ) {
server->restart();
}
else if( 0 == S_Message.compare( "status" ) ) {
int state = server->status();
std::cout << "Status: " << state << std::endl;
}
else if( 0 == S_Message.compare( "next" ) ) {
server->next();
}
else if( 0 == S_Message.compare( "suggest" ) ) {
if( 1 != S_Argv.size() ) {
std::cerr << "Usage: nkb-couchserver suggest <hypo>\n";
return 1;
}
server->suggest( std::string( S_Argv[0] ) );
}
else if( 0 == S_Message.compare( "volunteer" ) ) {
if( 2 != S_Argv.size() ) {
std::cerr << "Usage: nkb-couchserver volunteer <sign> <value>\n";
return 1;
}
std::string sign( S_Argv[0] );
std::string val( S_Argv[1] );
char c = val[0];
if( 0 == val.compare( "true" ) ) {
server->volunteer( sign, 1 );
}
else if( 0 == val.compare( "false" ) ) {
server->volunteer( sign, 0 );
}
else if( isalpha( c ) ) {
server->volunteer( sign, val );
}
else {
double d = atof( val.c_str() );
server->volunteer( sign, d );
}
}
else {
}
delete server;
return 0;
}
示例2: main
int main(int argc, char **argv) {
InitLLVM X(argc, argv);
// Initialize targets and assembly parsers.
InitializeAllTargetInfos();
InitializeAllTargetMCs();
InitializeAllAsmParsers();
// Enable printing of available targets when flag --version is specified.
cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
cl::HideUnrelatedOptions({&ToolOptions, &ViewOptions});
// Parse flags and initialize target options.
cl::ParseCommandLineOptions(argc, argv,
"llvm machine code performance analyzer.\n");
// Get the target from the triple. If a triple is not specified, then select
// the default triple for the host. If the triple doesn't correspond to any
// registered target, then exit with an error message.
const char *ProgName = argv[0];
const Target *TheTarget = getTarget(ProgName);
if (!TheTarget)
return 1;
// GetTarget() may replaced TripleName with a default triple.
// For safety, reconstruct the Triple object.
Triple TheTriple(TripleName);
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
MemoryBuffer::getFileOrSTDIN(InputFilename);
if (std::error_code EC = BufferPtr.getError()) {
WithColor::error() << InputFilename << ": " << EC.message() << '\n';
return 1;
}
// Apply overrides to llvm-mca specific options.
processViewOptions();
SourceMgr SrcMgr;
// Tell SrcMgr about this buffer, which is what the parser will pick up.
SrcMgr.AddNewSourceBuffer(std::move(*BufferPtr), SMLoc());
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
assert(MRI && "Unable to create target register info!");
std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TripleName));
assert(MAI && "Unable to create target asm info!");
MCObjectFileInfo MOFI;
MCContext Ctx(MAI.get(), MRI.get(), &MOFI, &SrcMgr);
MOFI.InitMCObjectFileInfo(TheTriple, /* PIC= */ false, Ctx);
std::unique_ptr<buffer_ostream> BOS;
std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
std::unique_ptr<MCInstrAnalysis> MCIA(
TheTarget->createMCInstrAnalysis(MCII.get()));
if (!MCPU.compare("native"))
MCPU = llvm::sys::getHostCPUName();
std::unique_ptr<MCSubtargetInfo> STI(
TheTarget->createMCSubtargetInfo(TripleName, MCPU, /* FeaturesStr */ ""));
if (!STI->isCPUStringValid(MCPU))
return 1;
if (!PrintInstructionTables && !STI->getSchedModel().isOutOfOrder()) {
WithColor::error() << "please specify an out-of-order cpu. '" << MCPU
<< "' is an in-order cpu.\n";
return 1;
}
if (!STI->getSchedModel().hasInstrSchedModel()) {
WithColor::error()
<< "unable to find instruction-level scheduling information for"
<< " target triple '" << TheTriple.normalize() << "' and cpu '" << MCPU
<< "'.\n";
if (STI->getSchedModel().InstrItineraries)
WithColor::note()
<< "cpu '" << MCPU << "' provides itineraries. However, "
<< "instruction itineraries are currently unsupported.\n";
return 1;
}
// Parse the input and create CodeRegions that llvm-mca can analyze.
mca::AsmCodeRegionGenerator CRG(*TheTarget, SrcMgr, Ctx, *MAI, *STI, *MCII);
Expected<const mca::CodeRegions &> RegionsOrErr = CRG.parseCodeRegions();
if (!RegionsOrErr) {
if (auto Err =
handleErrors(RegionsOrErr.takeError(), [](const StringError &E) {
WithColor::error() << E.getMessage() << '\n';
})) {
// Default case.
WithColor::error() << toString(std::move(Err)) << '\n';
}
return 1;
//.........这里部分代码省略.........
示例3: main
int main(int argc, char *argv[]) {
//command line arguments
cl::SetVersionPrinter(printVersion);
cl::ParseCommandLineOptions(argc, argv, "binary recursive descent");
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
llvm::InitializeAllDisassemblers();
llvm::Triple *triple;
//make an LLVM target that is appropriate
const Target *x86Target = NULL;
for(TargetRegistry::iterator it = TargetRegistry::begin(),
e = TargetRegistry::end();
it != e;
++it)
{
const Target &t = *it;
if(string(t.getName()) == SystemArch) {
x86Target = &t;
break;
}
}
if(!SystemArch.compare("x86-64")){
triple = new Triple(DEFAULT_TRIPLE_X64);
} else {
triple = new Triple(DEFAULT_TRIPLE);
}
ExternalFunctionMap funcs(triple->getTriple());
try {
if(FuncMap.size()) {
for(unsigned i = 0; i < FuncMap.size(); ++i) {
funcs.parseMap(FuncMap[i]);
}
}
} catch (LErr &l){
cerr << "Exception while parsing external map:\n"
<< l.what() << std::endl;
return -2;
}
if(InputFilename == "") {
errs() << "Invalid arguments.\nUse :'" << argv[0] << " -help' for help\n";
return -1;
}
if(PriorKnowledge == "") {
outs() << "Disassembly not guided by outside facts.\nUse :'" << argv[0] << "-p <protobuff>' to feed information to guide the disassembly\n";
}
//open the binary input file
ExecutableContainer *exc = NULL;
try {
exc = ExecutableContainer::open(InputFilename, x86Target, PriorKnowledge);
} catch (LErr &l) {
errs() << "Could not open: " << InputFilename << ", reason: " << l.what() << "\n";
return -1;
} catch (...) {
errs() << "Could not open: " << InputFilename << "\n";
return -1;
}
//sanity
if(EntrySymbol.size() == 0 && EntryPoint.size() == 0) {
::uint64_t file_ep;
// maybe this file format specifies an entry point?
if(false == exc->getEntryPoint(file_ep)) {
//We don't know which entry point to use!
llvm::errs() << "Could not identify an entry point for: [" << InputFilename << "].\n";
llvm::errs() << "You must manually specify at least one entry point. Use either -entry-symbol or -e.\n";
return -1;
}
}
if(exc->is_open()) {
//convert to native CFG
NativeModulePtr m;
try{
m = makeNativeModule(exc, funcs);
} catch(LErr &l) {
outs() << "Failure to make module: " << l.what() << "\n";
return -1;
}
if(m) {
//write out to protobuf
string outS = dumpProtoBuf(m);
if(outS.size() > 0) {
filesystem::path p;
if (OutputFilename == "") {
//write out to file, but, make the file name
//.........这里部分代码省略.........
示例4: main
int main(int argc, char **argv) {
InitLLVM X(argc, argv);
// Initialize targets and assembly parsers.
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
// Enable printing of available targets when flag --version is specified.
cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
cl::HideUnrelatedOptions({&ToolOptions, &ViewOptions});
// Parse flags and initialize target options.
cl::ParseCommandLineOptions(argc, argv,
"llvm machine code performance analyzer.\n");
MCTargetOptions MCOptions;
MCOptions.PreserveAsmComments = false;
// Get the target from the triple. If a triple is not specified, then select
// the default triple for the host. If the triple doesn't correspond to any
// registered target, then exit with an error message.
const char *ProgName = argv[0];
const Target *TheTarget = getTarget(ProgName);
if (!TheTarget)
return 1;
// GetTarget() may replaced TripleName with a default triple.
// For safety, reconstruct the Triple object.
Triple TheTriple(TripleName);
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
MemoryBuffer::getFileOrSTDIN(InputFilename);
if (std::error_code EC = BufferPtr.getError()) {
WithColor::error() << InputFilename << ": " << EC.message() << '\n';
return 1;
}
// Apply overrides to llvm-mca specific options.
processViewOptions();
SourceMgr SrcMgr;
// Tell SrcMgr about this buffer, which is what the parser will pick up.
SrcMgr.AddNewSourceBuffer(std::move(*BufferPtr), SMLoc());
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
assert(MRI && "Unable to create target register info!");
std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TripleName));
assert(MAI && "Unable to create target asm info!");
MCObjectFileInfo MOFI;
MCContext Ctx(MAI.get(), MRI.get(), &MOFI, &SrcMgr);
MOFI.InitMCObjectFileInfo(TheTriple, /* PIC= */ false, Ctx);
std::unique_ptr<buffer_ostream> BOS;
mca::CodeRegions Regions(SrcMgr);
MCStreamerWrapper Str(Ctx, Regions);
std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
std::unique_ptr<MCInstrAnalysis> MCIA(
TheTarget->createMCInstrAnalysis(MCII.get()));
if (!MCPU.compare("native"))
MCPU = llvm::sys::getHostCPUName();
std::unique_ptr<MCSubtargetInfo> STI(
TheTarget->createMCSubtargetInfo(TripleName, MCPU, /* FeaturesStr */ ""));
if (!STI->isCPUStringValid(MCPU))
return 1;
if (!PrintInstructionTables && !STI->getSchedModel().isOutOfOrder()) {
WithColor::error() << "please specify an out-of-order cpu. '" << MCPU
<< "' is an in-order cpu.\n";
return 1;
}
if (!STI->getSchedModel().hasInstrSchedModel()) {
WithColor::error()
<< "unable to find instruction-level scheduling information for"
<< " target triple '" << TheTriple.normalize() << "' and cpu '" << MCPU
<< "'.\n";
if (STI->getSchedModel().InstrItineraries)
WithColor::note()
<< "cpu '" << MCPU << "' provides itineraries. However, "
<< "instruction itineraries are currently unsupported.\n";
return 1;
}
std::unique_ptr<MCAsmParser> P(createMCAsmParser(SrcMgr, Ctx, Str, *MAI));
MCAsmLexer &Lexer = P->getLexer();
MCACommentConsumer CC(Regions);
Lexer.setCommentConsumer(&CC);
if (AssembleInput(ProgName, *P, TheTarget, *STI, *MCII, MCOptions))
//.........这里部分代码省略.........