[Hexagon] Use handleTargetFeaturesGroup to process target-specific features

llvm-svn: 280093
This commit is contained in:
Krzysztof Parzyszek 2016-08-30 14:17:10 +00:00
parent d8858cafa9
commit 7cd30bd7e6
2 changed files with 32 additions and 31 deletions

View File

@ -6180,6 +6180,9 @@ public:
bool handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) override;
void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
bool Enabled) const override;
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
@ -6248,6 +6251,17 @@ void HexagonTargetInfo::getTargetDefines(const LangOptions &Opts,
}
}
bool HexagonTargetInfo::initFeatureMap(llvm::StringMap<bool> &Features,
DiagnosticsEngine &Diags, StringRef CPU,
const std::vector<std::string> &FeaturesVec) const {
// Default for v60: -hvx, -hvx-double.
Features["hvx"] = false;
Features["hvx-double"] = false;
Features["long-calls"] = false;
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
bool HexagonTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) {
for (auto &F : Features) {
@ -6262,19 +6276,22 @@ bool HexagonTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
if (F == "+long-calls")
UseLongCalls = true;
else if (F == "-long-calls")
UseLongCalls = false;
}
return true;
}
bool HexagonTargetInfo::initFeatureMap(llvm::StringMap<bool> &Features,
DiagnosticsEngine &Diags, StringRef CPU,
const std::vector<std::string> &FeaturesVec) const {
// Default for v60: -hvx, -hvx-double.
Features["hvx"] = false;
Features["hvx-double"] = false;
Features["long-calls"] = false;
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
void HexagonTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
StringRef Name, bool Enabled) const {
if (Enabled) {
if (Name == "hvx-double")
Features["hvx"] = true;
} else {
if (Name == "hvx")
Features["hvx-double"] = false;
}
Features[Name] = Enabled;
}
const char *const HexagonTargetInfo::GCCRegNames[] = {

View File

@ -2484,32 +2484,16 @@ static void getAArch64TargetFeatures(const Driver &D, const ArgList &Args,
static void getHexagonTargetFeatures(const ArgList &Args,
std::vector<const char *> &Features) {
bool HasHVX = false, HasHVXD = false, UseLongCalls = false;
handleTargetFeaturesGroup(Args, Features,
options::OPT_m_hexagon_Features_Group);
// 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))
HasHVX = true;
else if (Opt.matches(options::OPT_mno_hexagon_hvx))
HasHVXD = HasHVX = false;
else if (Opt.matches(options::OPT_mhexagon_hvx_double))
HasHVXD = HasHVX = true;
else if (Opt.matches(options::OPT_mno_hexagon_hvx_double))
HasHVXD = false;
else if (Opt.matches(options::OPT_mlong_calls))
bool UseLongCalls = false;
if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
options::OPT_mno_long_calls)) {
if (A->getOption().matches(options::OPT_mlong_calls))
UseLongCalls = true;
else if (Opt.matches(options::OPT_mno_long_calls))
UseLongCalls = false;
else
continue;
A->claim();
}
Features.push_back(HasHVX ? "+hvx" : "-hvx");
Features.push_back(HasHVXD ? "+hvx-double" : "-hvx-double");
Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
}