[flang-commits] [clang] [flang] [lld] [llvm] AMDGPU: Introduce amdgpu triple arch (PR #206480)

Robert Imschweiler via flang-commits flang-commits at lists.llvm.org
Thu Jul 2 11:59:11 PDT 2026


================
@@ -1275,6 +1299,28 @@ GCNTargetMachine::getSubtargetImpl(const Function &F) const {
 
   auto &I = SubtargetMap[SubtargetKey];
   if (!I) {
+    AMDGPU::GPUKind Kind = AMDGPU::parseArchAMDGCN(GPU);
+    Triple::SubArchType GPUSubArch = AMDGPU::getSubArch(Kind);
+
+    // Enforce the subtarget is covered by the subarch. Tolerate no subarch for
+    // legacy compatibility.
+    const Triple &TT = getTargetTriple();
+    if (GPUSubArch != TT.getSubArch()) {
+      // Check if this is a generic subarch which has subtargets. Ignore
+      // unknown subtargets with a known subarch, since for whatever reason
+      // the convention is to just print a warning and ignore unrecognized
+      // subtargets.
+      if (Kind != AMDGPU::GK_NONE &&
+          TT.getSubArch() != AMDGPU::getMajorSubArch(GPUSubArch)) {
+        bool IsLegacyEmptySubArch = TT.getSubArch() == Triple::NoSubArch;
+        if (!IsLegacyEmptySubArch &&
+            AMDGPU::getMajorSubArch(GPUSubArch) != TT.getSubArch()) {
----------------
ro-i wrote:

re-tests `TT.getSubArch() != AMDGPU::getMajorSubArch(GPUSubArch)` from the parent if

https://github.com/llvm/llvm-project/pull/206480


More information about the flang-commits mailing list