[clang] [llvm] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to support AMDGPU's generic target (PR #122629)
Yaxun Liu via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 17 09:53:31 PDT 2025
================
@@ -84,31 +84,27 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target,
: BundlerConfig(BC) {
// TODO: Add error checking from ClangOffloadBundler.cpp
- auto TargetFeatures = Target.split(':');
- auto TripleOrGPU = TargetFeatures.first.rsplit('-');
-
- if (clang::StringToOffloadArch(TripleOrGPU.second) !=
- clang::OffloadArch::UNKNOWN) {
- auto KindTriple = TripleOrGPU.first.split('-');
- this->OffloadKind = KindTriple.first;
-
- // Enforce optional env field to standardize bundles
- llvm::Triple t = llvm::Triple(KindTriple.second);
- this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
- t.getOSName(), t.getEnvironmentName());
-
- this->TargetID = Target.substr(Target.find(TripleOrGPU.second));
- } else {
- auto KindTriple = TargetFeatures.first.split('-');
- this->OffloadKind = KindTriple.first;
-
- // Enforce optional env field to standardize bundles
- llvm::Triple t = llvm::Triple(KindTriple.second);
- this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
- t.getOSName(), t.getEnvironmentName());
-
+ // <kind>-<triple>[-<target id>[:target features]]
+ // <triple> := <arch>-<vendor>-<os>-<env>
+ SmallVector<StringRef, 6> Components;
+ Target.split(Components, '-', /*MaxSplit=*/5);
+ assert((Components.size() == 5 || Components.size() == 6) &&
----------------
yxsamliu wrote:
We have users who executes clang-offload-bundler directly. What if they use `<arch>-<vendor>-<os>` as triple? Should we emit an error message instead of assert?
https://github.com/llvm/llvm-project/pull/122629
More information about the llvm-commits
mailing list