llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-driver

Author: Aditya Sinha (AdityaSinha149)

<details>
<summary>Changes</summary>

This PR is a prerequisite for #<!-- -->218337. It moved the function 
`normaliseForBundler` from `HIPUtility.cpp` to `OffloadBundler` so that it can 
be shared by both AOT compiler and clang-repl. There are no functional changes.

Assisted by Claude Opus 4.8

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


3 Files Affected:

- (modified) clang/include/clang/Driver/OffloadBundler.h (+2) 
- (modified) clang/lib/Driver/OffloadBundler.cpp (+8) 
- (modified) clang/lib/Driver/ToolChains/HIPUtility.cpp (+1-9) 


``````````diff
diff --git a/clang/include/clang/Driver/OffloadBundler.h 
b/clang/include/clang/Driver/OffloadBundler.h
index 96839240543af..8cc93e051320c 100644
--- a/clang/include/clang/Driver/OffloadBundler.h
+++ b/clang/include/clang/Driver/OffloadBundler.h
@@ -96,6 +96,8 @@ struct OffloadTargetInfo {
 /// <kind>-<triple>[-<target id>[:target features]]
 /// <triple> := <arch>-<vendor>-<os>-<env>
 bool checkOffloadBundleID(const llvm::StringRef Str);
+/// Constructs the normalized triple string used in an offload bundle entry ID.
+std::string normalizeForBundler(const llvm::Triple &T, bool HasTargetID);
 } // namespace clang
 
 #endif // LLVM_CLANG_DRIVER_OFFLOADBUNDLER_H
diff --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index b397ee4c5b075..2f69b45ede9ff 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -1750,3 +1750,11 @@ bool clang::checkOffloadBundleID(const llvm::StringRef 
Str) {
   Str.split(Components, '-', /*MaxSplit=*/5);
   return Components.size() == 5 || Components.size() == 6;
 }
+
+std::string clang::normalizeForBundler(const llvm::Triple &T,
+                                       bool HasTargetID) {
+  return HasTargetID ? (T.getArchName() + "-" + T.getVendorName() + "-" +
+                        T.getOSName() + "-" + T.getEnvironmentName())
+                           .str()
+                     : T.normalize(llvm::Triple::CanonicalForm::FOUR_IDENT);
+}
diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp 
b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index 001f9f3400a06..6a0c20ffe1257 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -9,6 +9,7 @@
 #include "HIPUtility.h"
 #include "clang/Driver/CommonArgs.h"
 #include "clang/Driver/Compilation.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "clang/Options/Options.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -38,15 +39,6 @@ namespace {
 const unsigned HIPCodeObjectAlign = 4096;
 } // namespace
 
-// Constructs a triple string for clang offload bundler.
-static std::string normalizeForBundler(const llvm::Triple &T,
-                                       bool HasTargetID) {
-  return HasTargetID ? (T.getArchName() + "-" + T.getVendorName() + "-" +
-                        T.getOSName() + "-" + T.getEnvironmentName())
-                           .str()
-                     : T.normalize(llvm::Triple::CanonicalForm::FOUR_IDENT);
-}
-
 // Collect undefined __hip_fatbin* and __hip_gpubin_handle* symbols from all
 // input object or archive files.
 class HIPUndefinedFatBinSymbols {

``````````

</details>


https://github.com/llvm/llvm-project/pull/225049
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to