llvm.org GIT mirror llvm / 0ff4287
[NVPTX] Add support for selecting CUDA vs OCL mode based on triple IR for CUDA should use "nvptx[64]-nvidia-cuda", and IR for NV OpenCL should use "nvptx[64]-nvidia-nvcl" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184579 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Holewinski 7 years ago
9 changed file(s) with 29 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
8080 BGP,
8181 BGQ,
8282 Freescale,
83 IBM
83 IBM,
84 NVIDIA
8485 };
8586 enum OSType {
8687 UnknownOS,
106107 NaCl, // Native Client
107108 CNK, // BG/P Compute-Node Kernel
108109 Bitrig,
109 AIX
110 AIX,
111 CUDA, // NVIDIA CUDA
112 NVCL // NVIDIA OpenCL
110113 };
111114 enum EnvironmentType {
112115 UnknownEnvironment,
103103 case BGQ: return "bgq";
104104 case Freescale: return "fsl";
105105 case IBM: return "ibm";
106 case NVIDIA: return "nvidia";
106107 }
107108
108109 llvm_unreachable("Invalid VendorType!");
134135 case CNK: return "cnk";
135136 case Bitrig: return "bitrig";
136137 case AIX: return "aix";
138 case CUDA: return "cuda";
139 case NVCL: return "nvcl";
137140 }
138141
139142 llvm_unreachable("Invalid OSType");
259262 .Case("bgq", Triple::BGQ)
260263 .Case("fsl", Triple::Freescale)
261264 .Case("ibm", Triple::IBM)
265 .Case("nvidia", Triple::NVIDIA)
262266 .Default(Triple::UnknownVendor);
263267 }
264268
286290 .StartsWith("cnk", Triple::CNK)
287291 .StartsWith("bitrig", Triple::Bitrig)
288292 .StartsWith("aix", Triple::AIX)
293 .StartsWith("cuda", Triple::CUDA)
294 .StartsWith("nvcl", Triple::NVCL)
289295 .Default(Triple::UnknownOS);
290296 }
291297
7676 namespace NVPTX {
7777 enum DrvInterface {
7878 NVCL,
79 CUDA,
80 TEST
79 CUDA
8180 };
8281
8382 // A field inside TSFlags needs a shift and a mask. The usage is
1818
1919 using namespace llvm;
2020
21 // Select Driver Interface
22 #include "llvm/Support/CommandLine.h"
23 namespace {
24 cl::opt DriverInterface(
25 cl::desc("Choose driver interface:"),
26 cl::values(clEnumValN(NVPTX::NVCL, "drvnvcl", "Nvidia OpenCL driver"),
27 clEnumValN(NVPTX::CUDA, "drvcuda", "Nvidia CUDA driver"),
28 clEnumValN(NVPTX::TEST, "drvtest", "Plain Test"), clEnumValEnd),
29 cl::init(NVPTX::NVCL));
30 }
3121
3222 NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
3323 const std::string &FS, bool is64Bit)
3424 : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0),
3525 SmVersion(20) {
3626
37 drvInterface = DriverInterface;
27 Triple T(TT);
28
29 if (T.getOS() == Triple::NVCL)
30 drvInterface = NVPTX::NVCL;
31 else
32 drvInterface = NVPTX::CUDA;
3833
3934 // Provide the default CPU if none
4035 std::string defCPU = "sm_20";
None ; RUN: llc < %s -march=nvptx -mcpu=sm_20 -drvcuda | FileCheck %s
0 ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
11
22 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
3 target triple = "nvptx-nvidia-cuda"
34
45 ; Ensure global variables in address space 0 are promoted to address space 1
56
None ; RUN: llc < %s -march=nvptx -mcpu=sm_20 -drvcuda | FileCheck %s
0 ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
11
22 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
3
3 target triple = "nvptx-nvidia-cuda"
44
55 ; CHECK: .visible .global .align 1 .u8 mypred
66 @mypred = addrspace(1) global i1 true, align 1
None ; RUN: llc < %s -march=nvptx -mcpu=sm_20 -drvcuda | FileCheck %s
0 ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
11
22 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
3 target triple = "nvptx-nvidia-cuda"
34
45 ; Make sure predicate (i1) operands to kernels get expanded out to .u8
56
None ; RUN: llc < %s -march=nvptx -mcpu=sm_20 -drvcuda | FileCheck %s
0 ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
11
22 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
3
3 target triple = "nvptx-nvidia-cuda"
44
55 define void @main(i1* %a1, i32 %a2, i32* %arg3) {
66 ; CHECK: ld.u8
None ; RUN: llc < %s -march=nvptx -mcpu=sm_20 -drvcuda | FileCheck %s
0 ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
1
2 target triple = "nvptx-nvidia-cuda"
13
24 ; Function Attrs: nounwind
35 ; CHECK: .entry foo