mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-20 14:29:27 +00:00
Convert command line option processing code over to use the syntax supported
by the CommandLine 2.0 library git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
21735d739b
commit
50e3f88d38
@ -79,15 +79,13 @@ class PassPrinter; // Do not implement
|
|||||||
|
|
||||||
template <class PassName>
|
template <class PassName>
|
||||||
class PassPrinter<Pass, PassName> : public Pass {
|
class PassPrinter<Pass, PassName> : public Pass {
|
||||||
const string Message;
|
|
||||||
const AnalysisID ID;
|
const AnalysisID ID;
|
||||||
public:
|
public:
|
||||||
PassPrinter(const string &M, AnalysisID id) : Message(M), ID(id) {}
|
PassPrinter(AnalysisID id) : ID(id) {}
|
||||||
|
|
||||||
const char *getPassName() const { return "IP Pass Printer"; }
|
const char *getPassName() const { return "IP Pass Printer"; }
|
||||||
|
|
||||||
virtual bool run(Module &M) {
|
virtual bool run(Module &M) {
|
||||||
std::cout << Message << "\n";
|
|
||||||
printPass(getAnalysis<PassName>(ID), std::cout, M);
|
printPass(getAnalysis<PassName>(ID), std::cout, M);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,15 +97,14 @@ public:
|
|||||||
|
|
||||||
template <class PassName>
|
template <class PassName>
|
||||||
class PassPrinter<FunctionPass, PassName> : public FunctionPass {
|
class PassPrinter<FunctionPass, PassName> : public FunctionPass {
|
||||||
const string Message;
|
|
||||||
const AnalysisID ID;
|
const AnalysisID ID;
|
||||||
public:
|
public:
|
||||||
PassPrinter(const string &M, AnalysisID id) : Message(M), ID(id) {}
|
PassPrinter(AnalysisID id) : ID(id) {}
|
||||||
|
|
||||||
const char *getPassName() const { return "Function Pass Printer"; }
|
const char *getPassName() const { return "Function Pass Printer"; }
|
||||||
|
|
||||||
virtual bool runOnFunction(Function &F) {
|
virtual bool runOnFunction(Function &F) {
|
||||||
std::cout << Message << " on function '" << F.getName() << "'\n";
|
std::cout << "Running on function '" << F.getName() << "'\n";
|
||||||
printPass(getAnalysis<PassName>(ID), std::cout, F);
|
printPass(getAnalysis<PassName>(ID), std::cout, F);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -121,19 +118,19 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
template <class PassType, class PassName, AnalysisID &ID>
|
template <class PassType, class PassName, AnalysisID &ID>
|
||||||
Pass *New(const string &Message) {
|
Pass *New() {
|
||||||
return new PassPrinter<PassType, PassName>(Message, ID);
|
return new PassPrinter<PassType, PassName>(ID);
|
||||||
}
|
}
|
||||||
template <class PassType, class PassName>
|
template <class PassType, class PassName>
|
||||||
Pass *New(const string &Message) {
|
Pass *New() {
|
||||||
return new PassPrinter<PassType, PassName>(Message, PassName::ID);
|
return new PassPrinter<PassType, PassName>(PassName::ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Pass *createPrintFunctionPass(const string &Message) {
|
Pass *createPrintFunctionPass() {
|
||||||
return new PrintFunctionPass(Message, &std::cout);
|
return new PrintFunctionPass("", &std::cout);
|
||||||
}
|
}
|
||||||
Pass *createPrintModulePass(const string &Message) {
|
Pass *createPrintModulePass() {
|
||||||
return new PrintModulePass(&std::cout);
|
return new PrintModulePass(&std::cout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,13 +202,11 @@ struct Exprs : public FunctionPass {
|
|||||||
|
|
||||||
|
|
||||||
template<class TraitClass>
|
template<class TraitClass>
|
||||||
class PrinterPass : public TraitClass {
|
struct PrinterPass : public TraitClass {
|
||||||
const string Message;
|
PrinterPass() {}
|
||||||
public:
|
|
||||||
PrinterPass(const string &M) : Message(M) {}
|
|
||||||
|
|
||||||
virtual bool runOnFunction(Function &F) {
|
virtual bool runOnFunction(Function &F) {
|
||||||
std::cout << Message << " on function '" << F.getName() << "'\n";
|
std::cout << "Running on function '" << F.getName() << "'\n";
|
||||||
|
|
||||||
TraitClass::doit(F);
|
TraitClass::doit(F);
|
||||||
return false;
|
return false;
|
||||||
@ -220,8 +215,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
template<class PassClass>
|
template<class PassClass>
|
||||||
Pass *Create(const string &Message) {
|
Pass *Create() {
|
||||||
return new PassClass(Message);
|
return new PassClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -238,10 +233,16 @@ enum Ans {
|
|||||||
postdomset, postidom, postdomtree, postdomfrontier,
|
postdomset, postidom, postdomtree, postdomfrontier,
|
||||||
};
|
};
|
||||||
|
|
||||||
cl::String InputFilename ("", "Load <arg> file to analyze", cl::NoFlags, "-");
|
static cl::opt<string>
|
||||||
cl::Flag Quiet ("q", "Don't print analysis pass names");
|
InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"),
|
||||||
cl::Alias QuietA ("quiet", "Alias for -q", cl::NoFlags, Quiet);
|
cl::value_desc("filename"));
|
||||||
cl::EnumList<enum Ans> AnalysesList(cl::NoFlags,
|
|
||||||
|
static cl::opt<bool> Quiet("q", cl::desc("Don't print analysis pass names"));
|
||||||
|
static cl::alias QuietA("quiet", cl::desc("Alias for -q"),
|
||||||
|
cl::aliasopt(Quiet));
|
||||||
|
|
||||||
|
static cl::list<enum Ans>
|
||||||
|
AnalysesList(cl::values(
|
||||||
clEnumVal(print , "Print each function"),
|
clEnumVal(print , "Print each function"),
|
||||||
clEnumVal(intervals , "Print Interval Partitions"),
|
clEnumVal(intervals , "Print Interval Partitions"),
|
||||||
clEnumVal(exprs , "Classify Expressions"),
|
clEnumVal(exprs , "Classify Expressions"),
|
||||||
@ -265,12 +266,12 @@ cl::EnumList<enum Ans> AnalysesList(cl::NoFlags,
|
|||||||
clEnumVal(postidom , "Print Immediate Postdominators"),
|
clEnumVal(postidom , "Print Immediate Postdominators"),
|
||||||
clEnumVal(postdomtree , "Print Post Dominator Tree"),
|
clEnumVal(postdomtree , "Print Post Dominator Tree"),
|
||||||
clEnumVal(postdomfrontier, "Print Postdominance Frontier"),
|
clEnumVal(postdomfrontier, "Print Postdominance Frontier"),
|
||||||
0);
|
0));
|
||||||
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
enum Ans AnID;
|
enum Ans AnID;
|
||||||
Pass *(*PassConstructor)(const string &Message);
|
Pass *(*PassConstructor)();
|
||||||
} AnTable[] = {
|
} AnTable[] = {
|
||||||
// Global analyses
|
// Global analyses
|
||||||
{ print , createPrintFunctionPass },
|
{ print , createPrintFunctionPass },
|
||||||
@ -326,11 +327,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
for (unsigned j = 0; j < sizeof(AnTable)/sizeof(AnTable[0]); ++j) {
|
for (unsigned j = 0; j < sizeof(AnTable)/sizeof(AnTable[0]); ++j) {
|
||||||
if (AnTable[j].AnID == AnalysisPass) {
|
if (AnTable[j].AnID == AnalysisPass) {
|
||||||
string Message;
|
Analyses.add(AnTable[j].PassConstructor());
|
||||||
if (!Quiet)
|
|
||||||
Message = "\nRunning: '" +
|
|
||||||
string(AnalysesList.getArgDescription(AnalysisPass)) + "' analysis";
|
|
||||||
Analyses.add(AnTable[j].PassConstructor(Message));
|
|
||||||
break; // get an error later
|
break; // get an error later
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user