aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCUDA
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2012-05-20 21:08:35 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2012-05-20 21:08:35 +0000
commit4dc34ebf2a0716bf77ba110dab6777a3fc4397dd (patch)
tree3024562d1a661ae95d8f596d2182c63e5b9592ef /test/CodeGenCUDA
parente5f8372b5dccf5894f0263d018599c14d8f31273 (diff)
CUDA: add CodeGen support for global variable address spaces.
Because in CUDA types do not have associated address spaces, globals are declared in their "native" address space, and accessed by bitcasting the pointer to address space 0. This relies on address space 0 being a unified address space. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCUDA')
-rw-r--r--test/CodeGenCUDA/address-spaces.cu24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/CodeGenCUDA/address-spaces.cu b/test/CodeGenCUDA/address-spaces.cu
new file mode 100644
index 0000000000..2da61ec95a
--- /dev/null
+++ b/test/CodeGenCUDA/address-spaces.cu
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -fcuda-is-device -triple ptx32-unknown-unknown | FileCheck %s
+
+#include "../SemaCUDA/cuda.h"
+
+// CHECK: @i = global
+__device__ int i;
+
+// CHECK: @j = addrspace(1) global
+__constant__ int j;
+
+// CHECK: @k = addrspace(4) global
+__shared__ int k;
+
+__device__ void foo() {
+ // CHECK: load i32* @i
+ i++;
+
+ // CHECK: load i32* bitcast (i32 addrspace(1)* @j to i32*)
+ j++;
+
+ // CHECK: load i32* bitcast (i32 addrspace(4)* @k to i32*)
+ k++;
+}
+