forked from OSchip/llvm-project
Pull out a bunch of duplicated option handling code into its own
function and use for the targets that can easily support it. llvm-svn: 256230
This commit is contained in:
parent
b0fb6e8508
commit
49062a51b4
|
@ -52,6 +52,24 @@ using namespace clang::driver::tools;
|
|||
using namespace clang;
|
||||
using namespace llvm::opt;
|
||||
|
||||
static void handleTargetFeaturesGroup(const ArgList &Args,
|
||||
std::vector<const char *> &Features,
|
||||
OptSpecifier Group) {
|
||||
for (const Arg *A : Args.filtered(Group)) {
|
||||
StringRef Name = A->getOption().getName();
|
||||
A->claim();
|
||||
|
||||
// Skip over "-m".
|
||||
assert(Name.startswith("m") && "Invalid feature name.");
|
||||
Name = Name.substr(1);
|
||||
|
||||
bool IsNegative = Name.startswith("no-");
|
||||
if (IsNegative)
|
||||
Name = Name.substr(3);
|
||||
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
|
||||
}
|
||||
}
|
||||
|
||||
static const char *getSparcAsmModeForCPU(StringRef Name,
|
||||
const llvm::Triple &Triple) {
|
||||
if (Triple.getArch() == llvm::Triple::sparcv9) {
|
||||
|
@ -1410,19 +1428,7 @@ static std::string getPPCTargetCPU(const ArgList &Args) {
|
|||
static void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
||||
const ArgList &Args,
|
||||
std::vector<const char *> &Features) {
|
||||
for (const Arg *A : Args.filtered(options::OPT_m_ppc_Features_Group)) {
|
||||
StringRef Name = A->getOption().getName();
|
||||
A->claim();
|
||||
|
||||
// Skip over "-m".
|
||||
assert(Name.startswith("m") && "Invalid feature name.");
|
||||
Name = Name.substr(1);
|
||||
|
||||
bool IsNegative = Name.startswith("no-");
|
||||
if (IsNegative)
|
||||
Name = Name.substr(3);
|
||||
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
|
||||
}
|
||||
handleTargetFeaturesGroup(Args, Features, options::OPT_m_ppc_Features_Group);
|
||||
|
||||
ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args);
|
||||
if (FloatABI == ppc::FloatABI::Soft &&
|
||||
|
@ -2005,20 +2011,7 @@ static void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
|
|||
|
||||
// Now add any that the user explicitly requested on the command line,
|
||||
// which may override the defaults.
|
||||
for (const Arg *A : Args.filtered(options::OPT_m_x86_Features_Group)) {
|
||||
StringRef Name = A->getOption().getName();
|
||||
A->claim();
|
||||
|
||||
// Skip over "-m".
|
||||
assert(Name.startswith("m") && "Invalid feature name.");
|
||||
Name = Name.substr(1);
|
||||
|
||||
bool IsNegative = Name.startswith("no-");
|
||||
if (IsNegative)
|
||||
Name = Name.substr(3);
|
||||
|
||||
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
|
||||
}
|
||||
handleTargetFeaturesGroup(Args, Features, options::OPT_m_x86_Features_Group);
|
||||
}
|
||||
|
||||
void Clang::AddX86TargetArgs(const ArgList &Args,
|
||||
|
@ -2247,6 +2240,9 @@ static void getHexagonTargetFeatures(const ArgList &Args,
|
|||
std::vector<const char *> &Features) {
|
||||
bool HasHVX = false, HasHVXD = false;
|
||||
|
||||
// FIXME: This should be able to use handleTargetFeaturesGroup except it is
|
||||
// doing dependent option handling here rather than in initFeatureMap or a
|
||||
// similar handler.
|
||||
for (auto &A : Args) {
|
||||
auto &Opt = A->getOption();
|
||||
if (Opt.matches(options::OPT_mhexagon_hvx))
|
||||
|
@ -2268,20 +2264,7 @@ static void getHexagonTargetFeatures(const ArgList &Args,
|
|||
|
||||
static void getWebAssemblyTargetFeatures(const ArgList &Args,
|
||||
std::vector<const char *> &Features) {
|
||||
for (const Arg *A : Args.filtered(options::OPT_m_wasm_Features_Group)) {
|
||||
StringRef Name = A->getOption().getName();
|
||||
A->claim();
|
||||
|
||||
// Skip over "-m".
|
||||
assert(Name.startswith("m") && "Invalid feature name.");
|
||||
Name = Name.substr(1);
|
||||
|
||||
bool IsNegative = Name.startswith("no-");
|
||||
if (IsNegative)
|
||||
Name = Name.substr(3);
|
||||
|
||||
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
|
||||
}
|
||||
handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group);
|
||||
}
|
||||
|
||||
static void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple,
|
||||
|
|
Loading…
Reference in New Issue