aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/PTX/st.ll
blob: ed482b24a402ef20523acfef57f37ef83b83fa26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
; RUN: llc < %s -march=ptx | FileCheck %s

;CHECK: .extern .global .s32 array[];
@array = external global [10 x i32]

;CHECK: .extern .const .s32 array_constant[];
@array_constant = external addrspace(1) constant [10 x i32]

;CHECK: .extern .local .s32 array_local[];
@array_local = external addrspace(2) global [10 x i32]

;CHECK: .extern .shared .s32 array_shared[];
@array_shared = external addrspace(4) global [10 x i32]

define ptx_device void @t1(i32* %p, i32 %x) {
entry:
;CHECK: st.global.s32 [r1], r2;
  store i32 %x, i32* %p
  ret void
}

define ptx_device void @t2(i32* %p, i32 %x) {
entry:
;CHECK: st.global.s32 [r1+4], r2;
  %i = getelementptr i32* %p, i32 1
  store i32 %x, i32* %i
  ret void
}

define ptx_device void @t3(i32* %p, i32 %q, i32 %x) {
;CHECK: .reg .s32 r0;
entry:
;CHECK: shl.b32 r0, r2, 2;
;CHECK: st.global.s32 [r1+r0], r3;
  %i = getelementptr i32* %p, i32 %q
  store i32 %x, i32* %i
  ret void
}

define ptx_device void @t4_global(i32 %x) {
entry:
;CHECK: st.global.s32 [array], r1;
  %i = getelementptr [10 x i32]* @array, i32 0, i32 0
  store i32 %x, i32* %i
  ret void
}

define ptx_device void @t4_const(i32 %x) {
entry:
;CHECK: st.const.s32 [array_constant], r1;
  %i = getelementptr [10 x i32] addrspace(1)* @array_constant, i32 0, i32 0
  store i32 %x, i32 addrspace(1)* %i
  ret void
}

define ptx_device void @t4_local(i32 %x) {
entry:
;CHECK: st.local.s32 [array_local], r1;
  %i = getelementptr [10 x i32] addrspace(2)* @array_local, i32 0, i32 0
  store i32 %x, i32 addrspace(2)* %i
  ret void
}

define ptx_device void @t4_shared(i32 %x) {
entry:
;CHECK: st.shared.s32 [array_shared], r1;
  %i = getelementptr [10 x i32] addrspace(4)* @array_shared, i32 0, i32 0
  store i32 %x, i32 addrspace(4)* %i
  ret void
}

define ptx_device void @t5(i32 %x) {
entry:
;CHECK: st.global.s32 [array+4], r1;
  %i = getelementptr [10 x i32]* @array, i32 0, i32 1
  store i32 %x, i32* %i
  ret void
}