[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
erichkeane closed this revision. erichkeane added a comment. Forgot the svn commit message part, but closed by the related revision. r308530 https://reviews.llvm.org/D35572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
echristo added a comment. LGTM. -eric https://reviews.llvm.org/D35572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
echristo added a comment. In https://reviews.llvm.org/D35572#813520, @erichkeane wrote: > In https://reviews.llvm.org/D35572#813369, @echristo wrote: > > > Can you update the code in CGBuiltin to use this as part of this patch? :) > > > > Thanks! > > > I'm not sure which you're referring to? I don't see a bit in CGBuiltin that > checks for a subset of the "Features", however it is a much smaller list > (since it is only things that the compiler-rt can check). Is it perhaps more > closely related to that one? It's currently checking for a subset, but that's just because it was the subset that the compiler-rt support supported. After Craig's patch I think we can just support them all unless I'm misreading something. https://reviews.llvm.org/D35572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
erichkeane updated this revision to Diff 107310. erichkeane marked an inline comment as done. erichkeane added a comment. Changed fallthrough for Craig https://reviews.llvm.org/D35572 Files: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -963,8 +963,8 @@ // 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801, // 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell, // titan, rs64. - bool setCPU(const std::string ) override { -bool CPUKnown = llvm::StringSwitch(Name) + bool isValidCPUName(StringRef Name) const override { +return llvm::StringSwitch(Name) .Case("generic", true) .Case("440", true) .Case("450", true) @@ -1014,10 +1014,12 @@ .Case("powerpc64le", true) .Case("ppc64le", true) .Default(false); + } + bool setCPU(const std::string ) override { +bool CPUKnown = isValidCPUName(Name); if (CPUKnown) CPU = Name; - return CPUKnown; } @@ -2006,6 +2008,9 @@ // FIXME: implement return TargetInfo::CharPtrBuiltinVaList; } + bool isValidCPUName(StringRef Name) const override { +return StringToCudaArch(Name) != CudaArch::UNKNOWN; + } bool setCPU(const std::string ) override { GPU = StringToCudaArch(Name); return GPU != CudaArch::UNKNOWN; @@ -2367,6 +2372,13 @@ .Default(GK_NONE); } + bool isValidCPUName(StringRef Name) const override { +if (getTriple().getArch() == llvm::Triple::amdgcn) + return GK_NONE != parseAMDGCNName(Name); +else + return GK_NONE != parseR600Name(Name); + } + bool setCPU(const std::string ) override { if (getTriple().getArch() == llvm::Triple::amdgcn) GPU = parseAMDGCNName(Name); @@ -2873,6 +2885,87 @@ //@} } CPU = CK_Generic; + bool checkCPUKind(CPUKind Kind) const { +// Perform any per-CPU checks necessary to determine if this CPU is +// acceptable. +// FIXME: This results in terrible diagnostics. Clang just says the CPU is +// invalid without explaining *why*. +switch (Kind) { +case CK_Generic: + // No processor selected! + return false; + +case CK_i386: +case CK_i486: +case CK_WinChipC6: +case CK_WinChip2: +case CK_C3: +case CK_i586: +case CK_Pentium: +case CK_PentiumMMX: +case CK_i686: +case CK_PentiumPro: +case CK_Pentium2: +case CK_Pentium3: +case CK_Pentium3M: +case CK_PentiumM: +case CK_Yonah: +case CK_C3_2: +case CK_Pentium4: +case CK_Pentium4M: +case CK_Lakemont: +case CK_Prescott: +case CK_K6: +case CK_K6_2: +case CK_K6_3: +case CK_Athlon: +case CK_AthlonThunderbird: +case CK_Athlon4: +case CK_AthlonXP: +case CK_AthlonMP: +case CK_Geode: + // Only accept certain architectures when compiling in 32-bit mode. + if (getTriple().getArch() != llvm::Triple::x86) +return false; + +LLVM_FALLTHROUGH; +case CK_Nocona: +case CK_Core2: +case CK_Penryn: +case CK_Bonnell: +case CK_Silvermont: +case CK_Goldmont: +case CK_Nehalem: +case CK_Westmere: +case CK_SandyBridge: +case CK_IvyBridge: +case CK_Haswell: +case CK_Broadwell: +case CK_SkylakeClient: +case CK_SkylakeServer: +case CK_Cannonlake: +case CK_KNL: +case CK_Athlon64: +case CK_Athlon64SSE3: +case CK_AthlonFX: +case CK_K8: +case CK_K8SSE3: +case CK_Opteron: +case CK_OpteronSSE3: +case CK_AMDFAM10: +case CK_BTVER1: +case CK_BTVER2: +case CK_BDVER1: +case CK_BDVER2: +case CK_BDVER3: +case CK_BDVER4: +case CK_ZNVER1: +case CK_x86_64: + return true; +} +llvm_unreachable("Unhandled CPU kind"); + } + CPUKind getCPUKind(StringRef CPU) const { return llvm::StringSwitch(CPU) .Case("i386", CK_i386) @@ -3053,6 +3146,7 @@ initFeatureMap(llvm::StringMap , DiagnosticsEngine , StringRef CPU, const std::vector ) const override; + bool isValidFeatureName(StringRef Name) const override; bool hasFeature(StringRef Feature) const override; bool handleTargetFeatures(std::vector , DiagnosticsEngine ) override; @@ -3066,87 +3160,13 @@ return "no-mmx"; return ""; } - bool setCPU(const std::string ) override { -CPU = getCPUKind(Name); -// Perform any per-CPU checks necessary to determine if this CPU is -// acceptable. -// FIXME: This results in terrible diagnostics. Clang just says the CPU is -// invalid without explaining *why*. -switch (CPU) { -case CK_Generic: - // No processor selected! - return false; - -case CK_i386: -case CK_i486: -case CK_WinChipC6: -case CK_WinChip2: -case CK_C3: -case CK_i586: -
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
craig.topper added inline comments. Comment at: lib/Basic/Targets.cpp:2931 + + // Fallthrough +case CK_Nocona: Use LLVM_FALLTHROUGH? https://reviews.llvm.org/D35572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
erichkeane updated this revision to Diff 107183. erichkeane added a comment. Fixed a rebase issue, didn't do anything in CGBuiltin yet. https://reviews.llvm.org/D35572 Files: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -963,8 +963,8 @@ // 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801, // 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell, // titan, rs64. - bool setCPU(const std::string ) override { -bool CPUKnown = llvm::StringSwitch(Name) + bool isValidCPUName(StringRef Name) const override { +return llvm::StringSwitch(Name) .Case("generic", true) .Case("440", true) .Case("450", true) @@ -1014,10 +1014,12 @@ .Case("powerpc64le", true) .Case("ppc64le", true) .Default(false); + } + bool setCPU(const std::string ) override { +bool CPUKnown = isValidCPUName(Name); if (CPUKnown) CPU = Name; - return CPUKnown; } @@ -2006,6 +2008,9 @@ // FIXME: implement return TargetInfo::CharPtrBuiltinVaList; } + bool isValidCPUName(StringRef Name) const override { +return StringToCudaArch(Name) != CudaArch::UNKNOWN; + } bool setCPU(const std::string ) override { GPU = StringToCudaArch(Name); return GPU != CudaArch::UNKNOWN; @@ -2367,6 +2372,13 @@ .Default(GK_NONE); } + bool isValidCPUName(StringRef Name) const override { +if (getTriple().getArch() == llvm::Triple::amdgcn) + return GK_NONE != parseAMDGCNName(Name); +else + return GK_NONE != parseR600Name(Name); + } + bool setCPU(const std::string ) override { if (getTriple().getArch() == llvm::Triple::amdgcn) GPU = parseAMDGCNName(Name); @@ -2873,6 +2885,87 @@ //@} } CPU = CK_Generic; + bool checkCPUKind(CPUKind Kind) const { +// Perform any per-CPU checks necessary to determine if this CPU is +// acceptable. +// FIXME: This results in terrible diagnostics. Clang just says the CPU is +// invalid without explaining *why*. +switch (Kind) { +case CK_Generic: + // No processor selected! + return false; + +case CK_i386: +case CK_i486: +case CK_WinChipC6: +case CK_WinChip2: +case CK_C3: +case CK_i586: +case CK_Pentium: +case CK_PentiumMMX: +case CK_i686: +case CK_PentiumPro: +case CK_Pentium2: +case CK_Pentium3: +case CK_Pentium3M: +case CK_PentiumM: +case CK_Yonah: +case CK_C3_2: +case CK_Pentium4: +case CK_Pentium4M: +case CK_Lakemont: +case CK_Prescott: +case CK_K6: +case CK_K6_2: +case CK_K6_3: +case CK_Athlon: +case CK_AthlonThunderbird: +case CK_Athlon4: +case CK_AthlonXP: +case CK_AthlonMP: +case CK_Geode: + // Only accept certain architectures when compiling in 32-bit mode. + if (getTriple().getArch() != llvm::Triple::x86) +return false; + + // Fallthrough +case CK_Nocona: +case CK_Core2: +case CK_Penryn: +case CK_Bonnell: +case CK_Silvermont: +case CK_Goldmont: +case CK_Nehalem: +case CK_Westmere: +case CK_SandyBridge: +case CK_IvyBridge: +case CK_Haswell: +case CK_Broadwell: +case CK_SkylakeClient: +case CK_SkylakeServer: +case CK_Cannonlake: +case CK_KNL: +case CK_Athlon64: +case CK_Athlon64SSE3: +case CK_AthlonFX: +case CK_K8: +case CK_K8SSE3: +case CK_Opteron: +case CK_OpteronSSE3: +case CK_AMDFAM10: +case CK_BTVER1: +case CK_BTVER2: +case CK_BDVER1: +case CK_BDVER2: +case CK_BDVER3: +case CK_BDVER4: +case CK_ZNVER1: +case CK_x86_64: + return true; +} +llvm_unreachable("Unhandled CPU kind"); + } + CPUKind getCPUKind(StringRef CPU) const { return llvm::StringSwitch(CPU) .Case("i386", CK_i386) @@ -3053,6 +3146,7 @@ initFeatureMap(llvm::StringMap , DiagnosticsEngine , StringRef CPU, const std::vector ) const override; + bool isValidFeatureName(StringRef Name) const override; bool hasFeature(StringRef Feature) const override; bool handleTargetFeatures(std::vector , DiagnosticsEngine ) override; @@ -3066,87 +3160,13 @@ return "no-mmx"; return ""; } - bool setCPU(const std::string ) override { -CPU = getCPUKind(Name); -// Perform any per-CPU checks necessary to determine if this CPU is -// acceptable. -// FIXME: This results in terrible diagnostics. Clang just says the CPU is -// invalid without explaining *why*. -switch (CPU) { -case CK_Generic: - // No processor selected! - return false; - -case CK_i386: -case CK_i486: -case CK_WinChipC6: -case CK_WinChip2: -case CK_C3: -case CK_i586: -case CK_Pentium: -
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
erichkeane added a comment. In https://reviews.llvm.org/D35572#813369, @echristo wrote: > Can you update the code in CGBuiltin to use this as part of this patch? :) > > Thanks! I'm not sure which you're referring to? I don't see a bit in CGBuiltin that checks for a subset of the "Features", however it is a much smaller list (since it is only things that the compiler-rt can check). Is it perhaps more closely related to that one? https://reviews.llvm.org/D35572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
echristo added a comment. Can you update the code in CGBuiltin to use this as part of this patch? :) Thanks! https://reviews.llvm.org/D35572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo
erichkeane created this revision. These two functions are really useful for implementations of attributes (including attribute-target), so add the functionality. https://reviews.llvm.org/D35572 Files: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -963,8 +963,8 @@ // 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801, // 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell, // titan, rs64. - bool setCPU(const std::string ) override { -bool CPUKnown = llvm::StringSwitch(Name) + bool isValidCPUName(StringRef Name) const override { +return llvm::StringSwitch(Name) .Case("generic", true) .Case("440", true) .Case("450", true) @@ -1014,10 +1014,12 @@ .Case("powerpc64le", true) .Case("ppc64le", true) .Default(false); + } + bool setCPU(const std::string ) override { +bool CPUKnown = isValidCPUName(Name); if (CPUKnown) CPU = Name; - return CPUKnown; } @@ -2006,6 +2008,9 @@ // FIXME: implement return TargetInfo::CharPtrBuiltinVaList; } + bool isValidCPUName(StringRef Name) const override { +return StringToCudaArch(Name) != CudaArch::UNKNOWN; + } bool setCPU(const std::string ) override { GPU = StringToCudaArch(Name); return GPU != CudaArch::UNKNOWN; @@ -2367,6 +2372,13 @@ .Default(GK_NONE); } + bool isValidCPUName(StringRef Name) const override { +if (getTriple().getArch() == llvm::Triple::amdgcn) + return GK_NONE != parseAMDGCNName(Name); +else + return GK_NONE != parseR600Name(Name); + } + bool setCPU(const std::string ) override { if (getTriple().getArch() == llvm::Triple::amdgcn) GPU = parseAMDGCNName(Name); @@ -2873,6 +2885,87 @@ //@} } CPU = CK_Generic; + bool checkCPUKind(CPUKind Kind) const { +// Perform any per-CPU checks necessary to determine if this CPU is +// acceptable. +// FIXME: This results in terrible diagnostics. Clang just says the CPU is +// invalid without explaining *why*. +switch (Kind) { +case CK_Generic: + // No processor selected! + return false; + +case CK_i386: +case CK_i486: +case CK_WinChipC6: +case CK_WinChip2: +case CK_C3: +case CK_i586: +case CK_Pentium: +case CK_PentiumMMX: +case CK_i686: +case CK_PentiumPro: +case CK_Pentium2: +case CK_Pentium3: +case CK_Pentium3M: +case CK_PentiumM: +case CK_Yonah: +case CK_C3_2: +case CK_Pentium4: +case CK_Pentium4M: +case CK_Lakemont: +case CK_Prescott: +case CK_K6: +case CK_K6_2: +case CK_K6_3: +case CK_Athlon: +case CK_AthlonThunderbird: +case CK_Athlon4: +case CK_AthlonXP: +case CK_AthlonMP: +case CK_Geode: + // Only accept certain architectures when compiling in 32-bit mode. + if (getTriple().getArch() != llvm::Triple::x86) +return false; + + // Fallthrough +case CK_Nocona: +case CK_Core2: +case CK_Penryn: +case CK_Bonnell: +case CK_Silvermont: +case CK_Goldmont: +case CK_Nehalem: +case CK_Westmere: +case CK_SandyBridge: +case CK_IvyBridge: +case CK_Haswell: +case CK_Broadwell: +case CK_SkylakeClient: +case CK_SkylakeServer: +case CK_Cannonlake: +case CK_KNL: +case CK_Athlon64: +case CK_Athlon64SSE3: +case CK_AthlonFX: +case CK_K8: +case CK_K8SSE3: +case CK_Opteron: +case CK_OpteronSSE3: +case CK_AMDFAM10: +case CK_BTVER1: +case CK_BTVER2: +case CK_BDVER1: +case CK_BDVER2: +case CK_BDVER3: +case CK_BDVER4: +case CK_ZNVER1: +case CK_x86_64: + return true; +} +llvm_unreachable("Unhandled CPU kind"); + } + CPUKind getCPUKind(StringRef CPU) const { return llvm::StringSwitch(CPU) .Case("i386", CK_i386) @@ -3053,6 +3146,7 @@ initFeatureMap(llvm::StringMap , DiagnosticsEngine , StringRef CPU, const std::vector ) const override; + bool isValidFeatureName(StringRef Name) const override; bool hasFeature(StringRef Feature) const override; bool handleTargetFeatures(std::vector , DiagnosticsEngine ) override; @@ -3066,87 +3160,13 @@ return "no-mmx"; return ""; } - bool setCPU(const std::string ) override { -CPU = getCPUKind(Name); - -// Perform any per-CPU checks necessary to determine if this CPU is -// acceptable. -// FIXME: This results in terrible diagnostics. Clang just says the CPU is -// invalid without explaining *why*. -switch (CPU) { -case CK_Generic: - // No processor selected! - return false; -case CK_i386: -case CK_i486: -case CK_WinChipC6: -case CK_WinChip2: -case CK_C3: -case