[clang] [llvm] [LLVM][Triple][NFCI] Add function to test for offloading triples (PR #126956)

Nick Sarnie via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 24 10:56:24 PST 2025


================
@@ -1109,6 +1109,11 @@ class Triple {
            Env == llvm::Triple::EABIHF;
   }
 
+  /// Tests if the target represents a device which can be offloaded to.
+  bool isOffloadingTarget() const {
+    return isAMDGPU() || isNVPTX() || isSPIRV();
+  }
----------------
sarnex wrote:

Sorry for late response.

So for cases like in the linked PR, we want to know if we are offloading by checking the main/aux triple through the ASTContext. Once we are into the middle end that information won't be available as far as I can tell. 

Do you have an idea on how we can detect offloading at all phases in the compiler without solely using the triple?

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


More information about the llvm-commits mailing list