From d8e0fe617af3c9fb60a680ecb2ff765b71ef3c1d Mon Sep 17 00:00:00 2001 From: Justin Holewinski Date: Thu, 22 Sep 2011 17:57:40 +0000 Subject: [PATCH] PTX: Clean up target options code git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140320 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 106 +++++++++++------------------------------- 1 file changed, 27 insertions(+), 79 deletions(-) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 43a9dce276..5e25f69f41 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -880,10 +880,32 @@ namespace { class PTXTargetInfo : public TargetInfo { static const char * const GCCRegNames[]; static const Builtin::Info BuiltinInfo[]; + std::vector AvailableFeatures; public: PTXTargetInfo(const std::string& triple) : TargetInfo(triple) { TLSSupported = false; LongWidth = LongAlign = 64; + // Define available target features + // These must be defined in sorted order! + AvailableFeatures.push_back("compute10"); + AvailableFeatures.push_back("compute11"); + AvailableFeatures.push_back("compute12"); + AvailableFeatures.push_back("compute13"); + AvailableFeatures.push_back("compute20"); + AvailableFeatures.push_back("double"); + AvailableFeatures.push_back("no-fma"); + AvailableFeatures.push_back("ptx20"); + AvailableFeatures.push_back("ptx21"); + AvailableFeatures.push_back("ptx22"); + AvailableFeatures.push_back("ptx23"); + AvailableFeatures.push_back("sm10"); + AvailableFeatures.push_back("sm11"); + AvailableFeatures.push_back("sm12"); + AvailableFeatures.push_back("sm13"); + AvailableFeatures.push_back("sm20"); + AvailableFeatures.push_back("sm21"); + AvailableFeatures.push_back("sm22"); + AvailableFeatures.push_back("sm23"); } virtual void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { @@ -942,87 +964,13 @@ namespace { bool PTXTargetInfo::setFeatureEnabled(llvm::StringMap &Features, const std::string &Name, bool Enabled) const { - if (Enabled) { - if (Name == "double") - Features["double"] = true; - else if (Name == "no-fma") - Features["no-fma"] = true; - else if (Name == "compute10") - Features["compute10"] = true; - else if (Name == "compute11") - Features["compute11"] = true; - else if (Name == "compute12") - Features["compute12"] = true; - else if (Name == "compute13") - Features["compute13"] = true; - else if (Name == "compute20") - Features["compute20"] = true; - else if (Name == "ptx20") - Features["ptx20"] = true; - else if (Name == "ptx21") - Features["ptx21"] = true; - else if (Name == "ptx22") - Features["ptx22"] = true; - else if (Name == "ptx23") - Features["ptx23"] = true; - else if (Name == "sm10") - Features["sm10"] = true; - else if (Name == "sm11") - Features["sm11"] = true; - else if (Name == "sm12") - Features["sm12"] = true; - else if (Name == "sm13") - Features["sm13"] = true; - else if (Name == "sm20") - Features["sm20"] = true; - else if (Name == "sm21") - Features["sm21"] = true; - else if (Name == "sm22") - Features["sm22"] = true; - else if (Name == "sm23") - Features["sm23"] = true; + if(std::binary_search(AvailableFeatures.begin(), AvailableFeatures.end(), + Name)) { + Features[Name] = Enabled; + return true; } else { - if (Name == "double") - Features["double"] = false; - else if (Name == "no-fma") - Features["no-fma"] = false; - else if (Name == "compute10") - Features["compute10"] = false; - else if (Name == "compute11") - Features["compute11"] = false; - else if (Name == "compute12") - Features["compute12"] = false; - else if (Name == "compute13") - Features["compute13"] = false; - else if (Name == "compute20") - Features["compute20"] = false; - else if (Name == "ptx20") - Features["ptx20"] = false; - else if (Name == "ptx21") - Features["ptx21"] = false; - else if (Name == "ptx22") - Features["ptx22"] = false; - else if (Name == "ptx23") - Features["ptx23"] = false; - else if (Name == "sm10") - Features["sm10"] = false; - else if (Name == "sm11") - Features["sm11"] = false; - else if (Name == "sm12") - Features["sm12"] = false; - else if (Name == "sm13") - Features["sm13"] = false; - else if (Name == "sm20") - Features["sm20"] = false; - else if (Name == "sm21") - Features["sm21"] = false; - else if (Name == "sm22") - Features["sm22"] = false; - else if (Name == "sm23") - Features["sm23"] = false; + return false; } - - return true; } class PTX32TargetInfo : public PTXTargetInfo { -- 2.40.0