Deleted Added
full compact
LegacyPassNameParser.h (288943) LegacyPassNameParser.h (314564)
1//===- LegacyPassNameParser.h -----------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 46 unchanged lines hidden (view full) ---

55 // ignorablePassImpl - Can be overriden in subclasses to refine the list of
56 // which passes we want to include.
57 //
58 virtual bool ignorablePassImpl(const PassInfo *P) const { return false; }
59
60 inline bool ignorablePass(const PassInfo *P) const {
61 // Ignore non-selectable and non-constructible passes! Ignore
62 // non-optimizations.
1//===- LegacyPassNameParser.h -----------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 46 unchanged lines hidden (view full) ---

55 // ignorablePassImpl - Can be overriden in subclasses to refine the list of
56 // which passes we want to include.
57 //
58 virtual bool ignorablePassImpl(const PassInfo *P) const { return false; }
59
60 inline bool ignorablePass(const PassInfo *P) const {
61 // Ignore non-selectable and non-constructible passes! Ignore
62 // non-optimizations.
63 return P->getPassArgument() == nullptr || *P->getPassArgument() == 0 ||
64 P->getNormalCtor() == nullptr || ignorablePassImpl(P);
63 return P->getPassArgument().empty() || P->getNormalCtor() == nullptr ||
64 ignorablePassImpl(P);
65 }
66
67 // Implement the PassRegistrationListener callbacks used to populate our map
68 //
69 void passRegistered(const PassInfo *P) override {
70 if (ignorablePass(P)) return;
65 }
66
67 // Implement the PassRegistrationListener callbacks used to populate our map
68 //
69 void passRegistered(const PassInfo *P) override {
70 if (ignorablePass(P)) return;
71 if (findOption(P->getPassArgument()) != getNumOptions()) {
71 if (findOption(P->getPassArgument().data()) != getNumOptions()) {
72 errs() << "Two passes with the same argument (-"
73 << P->getPassArgument() << ") attempted to be registered!\n";
74 llvm_unreachable(nullptr);
75 }
72 errs() << "Two passes with the same argument (-"
73 << P->getPassArgument() << ") attempted to be registered!\n";
74 llvm_unreachable(nullptr);
75 }
76 addLiteralOption(P->getPassArgument(), P, P->getPassName());
76 addLiteralOption(P->getPassArgument().data(), P, P->getPassName().data());
77 }
78 void passEnumerate(const PassInfo *P) override { passRegistered(P); }
79
80 // printOptionInfo - Print out information about this option. Override the
81 // default implementation to sort the table before we print...
82 void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const override {
83 PassNameParser *PNP = const_cast<PassNameParser*>(this);
84 array_pod_sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan);
85 cl::parser<const PassInfo*>::printOptionInfo(O, GlobalWidth);
86 }
87
88private:
89 // ValLessThan - Provide a sorting comparator for Values elements...
90 static int ValLessThan(const PassNameParser::OptionInfo *VT1,
91 const PassNameParser::OptionInfo *VT2) {
77 }
78 void passEnumerate(const PassInfo *P) override { passRegistered(P); }
79
80 // printOptionInfo - Print out information about this option. Override the
81 // default implementation to sort the table before we print...
82 void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const override {
83 PassNameParser *PNP = const_cast<PassNameParser*>(this);
84 array_pod_sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan);
85 cl::parser<const PassInfo*>::printOptionInfo(O, GlobalWidth);
86 }
87
88private:
89 // ValLessThan - Provide a sorting comparator for Values elements...
90 static int ValLessThan(const PassNameParser::OptionInfo *VT1,
91 const PassNameParser::OptionInfo *VT2) {
92 return std::strcmp(VT1->Name, VT2->Name);
92 return VT1->Name < VT2->Name;
93 }
94};
95
96///===----------------------------------------------------------------------===//
97/// FilteredPassNameParser class - Make use of the pass registration
98/// mechanism to automatically add a command line argument to opt for
99/// each pass that satisfies a filter criteria. Filter should return
100/// true for passes to be registered as command-line options.

--- 24 unchanged lines hidden (view full) ---

125/// PassList(cl::desc("Passes available:"));
126///
127/// Only the -anders_aa and -dse options will be available to the user.
128///
129template<const char *Args>
130class PassArgFilter {
131public:
132 bool operator()(const PassInfo &P) const {
93 }
94};
95
96///===----------------------------------------------------------------------===//
97/// FilteredPassNameParser class - Make use of the pass registration
98/// mechanism to automatically add a command line argument to opt for
99/// each pass that satisfies a filter criteria. Filter should return
100/// true for passes to be registered as command-line options.

--- 24 unchanged lines hidden (view full) ---

125/// PassList(cl::desc("Passes available:"));
126///
127/// Only the -anders_aa and -dse options will be available to the user.
128///
129template<const char *Args>
130class PassArgFilter {
131public:
132 bool operator()(const PassInfo &P) const {
133 return(std::strstr(Args, P.getPassArgument()));
133 return StringRef(Args).contains(P.getPassArgument());
134 }
135};
136
137} // End llvm namespace
138
139#endif
134 }
135};
136
137} // End llvm namespace
138
139#endif