1 ; RUN: llc -mtriple=xcore-unknown-unknown < %s | FileCheck %s
2 ; RUN: llc -mtriple=xcore-unknown-unknown -O=0 < %s | FileCheck %s -check-prefix=PHINODE
4 declare ptr addrspace(1) @llvm.xcore.getst.p1.p1(ptr addrspace(1) %r)
5 declare void @llvm.xcore.msync.p1(ptr addrspace(1) %r)
6 declare void @llvm.xcore.ssync()
7 declare void @llvm.xcore.mjoin.p1(ptr addrspace(1) %r)
8 declare void @llvm.xcore.initsp.p1(ptr addrspace(1) %r, ptr %value)
9 declare void @llvm.xcore.initpc.p1(ptr addrspace(1) %r, ptr %value)
10 declare void @llvm.xcore.initlr.p1(ptr addrspace(1) %r, ptr %value)
11 declare void @llvm.xcore.initcp.p1(ptr addrspace(1) %r, ptr %value)
12 declare void @llvm.xcore.initdp.p1(ptr addrspace(1) %r, ptr %value)
14 define ptr addrspace(1) @test_getst(ptr addrspace(1) %r) {
15 ; CHECK-LABEL: test_getst:
16 ; CHECK: getst r0, res[r0]
17 %result = call ptr addrspace(1) @llvm.xcore.getst.p1.p1(ptr addrspace(1) %r)
18 ret ptr addrspace(1) %result
21 define void @test_ssync() {
22 ; CHECK-LABEL: test_ssync:
24 call void @llvm.xcore.ssync()
28 define void @test_mjoin(ptr addrspace(1) %r) {
29 ; CHECK-LABEL: test_mjoin:
30 ; CHECK: mjoin res[r0]
31 call void @llvm.xcore.mjoin.p1(ptr addrspace(1) %r)
35 define void @test_initsp(ptr addrspace(1) %t, ptr %src) {
36 ; CHECK-LABEL: test_initsp:
37 ; CHECK: init t[r0]:sp, r1
38 call void @llvm.xcore.initsp.p1(ptr addrspace(1) %t, ptr %src)
42 define void @test_initpc(ptr addrspace(1) %t, ptr %src) {
43 ; CHECK-LABEL: test_initpc:
44 ; CHECK: init t[r0]:pc, r1
45 call void @llvm.xcore.initpc.p1(ptr addrspace(1) %t, ptr %src)
49 define void @test_initlr(ptr addrspace(1) %t, ptr %src) {
50 ; CHECK-LABEL: test_initlr:
51 ; CHECK: init t[r0]:lr, r1
52 call void @llvm.xcore.initlr.p1(ptr addrspace(1) %t, ptr %src)
56 define void @test_initcp(ptr addrspace(1) %t, ptr %src) {
57 ; CHECK-LABEL: test_initcp:
58 ; CHECK: init t[r0]:cp, r1
59 call void @llvm.xcore.initcp.p1(ptr addrspace(1) %t, ptr %src)
63 define void @test_initdp(ptr addrspace(1) %t, ptr %src) {
64 ; CHECK-LABEL: test_initdp:
65 ; CHECK: init t[r0]:dp, r1
66 call void @llvm.xcore.initdp.p1(ptr addrspace(1) %t, ptr %src)
70 @tl = thread_local global [3 x i32] zeroinitializer
71 @tle = external thread_local global [2 x i32]
76 ; CHECK: ldaw [[R0:r[0-9]]], dp[tl]
77 ; CHECK: ldc [[R1:r[0-9]]], 8
78 ; CHECK: ldc [[R2:r[0-9]]], 12
79 ; r0 = id*12 + 8 + &tl
80 ; CHECK: lmul {{r[0-9]}}, r0, r11, [[R2]], [[R0]], [[R1]]
81 ret ptr getelementptr inbounds ([3 x i32], ptr @tl, i32 0, i32 2)
87 ; CHECK: shl [[R0:r[0-9]]], r11, 3
88 ; CHECK: ldaw [[R1:r[0-9]]], dp[tle]
90 ; CHECK: add r0, [[R1]], [[R0]]
94 define i32 @f_tlExpr () {
95 ; CHECK-LABEL: f_tlExpr:
97 ; CHECK: shl [[R0:r[0-9]]], r11, 3
98 ; CHECK: ldaw [[R1:r[0-9]]], dp[tle]
99 ; CHECK: add [[R2:r[0-9]]], [[R1]], [[R0]]
100 ; CHECK: add r0, [[R2]], [[R2]]
102 i32 ptrtoint( ptr @tle to i32),
103 i32 ptrtoint( ptr @tle to i32))
106 define void @phiNode1() {
107 ; N.B. lowering of duplicate constexpr in a PHI node requires -O=0
108 ; PHINODE-LABEL: phiNode1:
109 ; PHINODE: get r11, id
110 ; PHINODE-LABEL: .LBB11_1:
111 ; PHINODE: get r11, id
112 ; PHINODE: bu .LBB11_1
114 br label %ConstantExpPhiNode
116 %ptr = phi ptr [ getelementptr inbounds ([3 x i32], ptr @tl, i32 0, i32 1), %entry ],
117 [ getelementptr inbounds ([3 x i32], ptr @tl, i32 0, i32 1), %ConstantExpPhiNode ]
118 br label %ConstantExpPhiNode
123 define void @phiNode2( i1 %bool) {
124 ; N.B. check an extra 'Node_crit_edge' (LBB12_1) is inserted
125 ; PHINODE-LABEL: phiNode2:
126 ; PHINODE: bf {{r[0-9]}}, .LBB12_3
127 ; PHINODE: bu .LBB12_1
128 ; PHINODE-LABEL: .LBB12_1:
129 ; PHINODE: get r11, id
130 ; PHINODE-LABEL: .LBB12_2:
131 ; PHINODE: get r11, id
132 ; PHINODE: bu .LBB12_2
133 ; PHINODE-LABEL: .LBB12_3:
135 br i1 %bool, label %ConstantExpPhiNode, label %exit
137 %ptr = phi ptr [ getelementptr inbounds ([3 x i32], ptr @tl, i32 0, i32 1), %entry ],
138 [ getelementptr inbounds ([3 x i32], ptr @tl, i32 0, i32 1), %ConstantExpPhiNode ]
139 br label %ConstantExpPhiNode