Skip to content

clang/AMDGPU: Remove StringSwitch over r600 aliases#209256

Merged
arsenm merged 1 commit into
mainfrom
users/arsenm/clang/amdgpu-remove-unnecessary-r600-alias-stringswitch
Jul 13, 2026
Merged

clang/AMDGPU: Remove StringSwitch over r600 aliases#209256
arsenm merged 1 commit into
mainfrom
users/arsenm/clang/amdgpu-remove-unnecessary-r600-alias-stringswitch

Conversation

@arsenm

@arsenm arsenm commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This will route to getArchNameR600 which should already handle
all the aliases.

This will route to getArchNameR600 which should already handle
all the aliases.

arsenm commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm requested review from jhuber6 and yxsamliu July 13, 2026 17:52
@arsenm arsenm requested review from shiltian and slinder1 July 13, 2026 17:52
@arsenm arsenm marked this pull request as ready for review July 13, 2026 17:52
@llvmorg-github-actions llvmorg-github-actions Bot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jul 13, 2026
@llvmorg-github-actions

llvmorg-github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

This will route to getArchNameR600 which should already handle
all the aliases.


Full diff: https://github.com/llvm/llvm-project/pull/209256.diff

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+4-13)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2bfa1fbb1c678..08c06951cf220 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -697,19 +697,10 @@ void tools::AddTargetFeature(const ArgList &Args,
 }
 
 /// Get the (LLVM) name of the AMDGPU gpu we are targeting.
-static std::string getAMDGPUTargetGPU(const llvm::Triple &T,
-                                      const ArgList &Args) {
+static StringRef getAMDGPUTargetGPU(const llvm::Triple &T,
+                                    const ArgList &Args) {
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
-    auto GPUName = getProcessorFromTargetID(T, A->getValue());
-    return llvm::StringSwitch<std::string>(GPUName)
-        .Cases({"rv630", "rv635"}, "r600")
-        .Cases({"rv610", "rv620", "rs780"}, "rs880")
-        .Case("rv740", "rv770")
-        .Case("palm", "cedar")
-        .Cases({"sumo", "sumo2"}, "sumo")
-        .Case("hemlock", "cypress")
-        .Case("aruba", "cayman")
-        .Default(GPUName.str());
+    return getProcessorFromTargetID(T, A->getValue());
   }
   return "";
 }
@@ -835,7 +826,7 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
 
   case llvm::Triple::amdgpu:
   case llvm::Triple::r600:
-    return getAMDGPUTargetGPU(T, Args);
+    return getAMDGPUTargetGPU(T, Args).str();
 
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:

@yxsamliu yxsamliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arsenm arsenm merged commit 7753c44 into main Jul 13, 2026
17 checks passed
@arsenm arsenm deleted the users/arsenm/clang/amdgpu-remove-unnecessary-r600-alias-stringswitch branch July 13, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants