[llvm] offload: Parse Triple using triple for amdgcn-amd-amdhsa (PR #190319)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 07:14:02 PDT 2026
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/190319
>From 6286d745725756681c39535d8d44399547d50af3 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 2 Apr 2026 21:07:16 +0200
Subject: [PATCH 1/2] offload: Parse Triple using triple for amdgcn-amd-amdhsa
Avoid hardcoding the exact triple.
---
offload/plugins-nextgen/amdgpu/src/rtl.cpp | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
index af0d09ebeb577..6026efa15988f 100644
--- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -212,11 +212,19 @@ static Error getTargetTripleAndFeatures(hsa_agent_t Agent,
if (Status != HSA_STATUS_SUCCESS)
return Status;
- llvm::StringRef TripleTarget(ISAName.begin(), Length);
- if (TripleTarget.consume_front("amdgcn-amd-amdhsa")) {
- auto Target = TripleTarget.ltrim('-').rtrim('\0');
- Targets.push_back(Target);
+ // The format returned here is a partially malformed triple, e.g.,
+ // "amdgcn-amd-amdhsa--gfx90a". The subtarget is in the position that is
+ // supposed to be the object format. Reconstitute the valid part of the
+ // triple for parsing, and take the appended subtarget name.
+ llvm::StringRef TripleLikeStr(ISAName.begin(), Length);
+ SmallVector<StringRef, 5> Components;
+ TripleLikeStr.split(Components, '-');
+ if (Components.size() == 5) {
+ llvm::Triple TripleTarget(Components[0], Components[1], Components[2]);
+ if (TripleTarget.isAMDGCN() && TripleTarget.getOS() == Triple::AMDHSA)
+ Targets.emplace_back(Components[4]);
}
+
return HSA_STATUS_SUCCESS;
});
return Err;
>From 535aa5bb19cc0dd44a8721f37f5939b00ec1df45 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 3 Apr 2026 16:13:15 +0200
Subject: [PATCH 2/2] Fix case with trailing -
---
offload/plugins-nextgen/amdgpu/src/rtl.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
index 6026efa15988f..ecf0953aac846 100644
--- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -213,12 +213,12 @@ static Error getTargetTripleAndFeatures(hsa_agent_t Agent,
return Status;
// The format returned here is a partially malformed triple, e.g.,
- // "amdgcn-amd-amdhsa--gfx90a". The subtarget is in the position that is
- // supposed to be the object format. Reconstitute the valid part of the
- // triple for parsing, and take the appended subtarget name.
- llvm::StringRef TripleLikeStr(ISAName.begin(), Length);
+ // "amdgcn-amd-amdhsa--gfx90a", or
+ // "amdgcn-amd-amdhsa--gfx90a:sramecc+:xnack-". The subtarget is in the
+ // position that is supposed to be the object format. Reconstitute the valid
+ // part of the triple for parsing, and take the appended subtarget name.
SmallVector<StringRef, 5> Components;
- TripleLikeStr.split(Components, '-');
+ llvm::StringRef(ISAName).split(Components, '-', /*MaxSplit=*/4);
if (Components.size() == 5) {
llvm::Triple TripleTarget(Components[0], Components[1], Components[2]);
if (TripleTarget.isAMDGCN() && TripleTarget.getOS() == Triple::AMDHSA)
More information about the llvm-commits
mailing list