[PATCH] Default to "nvptx[64]-unknown-cuda" triple for device-side CUDA compilation.

Artem Belevich tra at google.com
Tue Mar 17 13:45:42 PDT 2015


Hi eliben, echristo,

Default to "nvptx[64]-unknown-cuda" triple for device-side CUDA compilation.

http://reviews.llvm.org/D8393

Files:
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1840,8 +1840,15 @@
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
 
   // Use the default target triple if unspecified.
-  if (Opts.Triple.empty())
-    Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  if (Opts.Triple.empty()) {
+    if (Args.hasArg(OPT_fcuda_is_device)) {
+      llvm::Triple HostTriple(llvm::sys::getDefaultTargetTriple());
+      Opts.Triple = HostTriple.isArch64Bit()
+                        ? llvm::Triple::normalize("nvptx64-unknown-cuda")
+                        : llvm::Triple::normalize("nvptx-unknown-cuda");
+    } else
+      Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  }
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8393.22120.patch
Type: text/x-patch
Size: 913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150317/42094638/attachment.bin>


More information about the cfe-commits mailing list