]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blob - test/CodeGen/XCore/offset_folding.ll
[XCore] Support functions returning more than 4 words.
[opencl/llvm.git] / test / CodeGen / XCore / offset_folding.ll
1 ; RUN: llc < %s -march=xcore | FileCheck %s
3 @a = external constant [0 x i32], section ".cp.rodata"
4 @b = external global [0 x i32]
6 define i32 *@f1() nounwind {
7 entry:
8 ; CHECK-LABEL: f1:
9 ; CHECK: ldaw r11, cp[a+4]
10 ; CHECK: mov r0, r11
11         %0 = getelementptr [0 x i32]* @a, i32 0, i32 1
12         ret i32* %0
13 }
15 define i32 *@f2() nounwind {
16 entry:
17 ; CHECK-LABEL: f2:
18 ; CHECK: ldaw r0, dp[b+4]
19         %0 = getelementptr [0 x i32]* @b, i32 0, i32 1
20         ret i32* %0
21 }
23 ; Don't fold negative offsets into cp / dp accesses to avoid a relocation
24 ; error if the address + addend is less than the start of the cp / dp.
26 define i32 *@f3() nounwind {
27 entry:
28 ; CHECK-LABEL: f3:
29 ; CHECK: ldaw r11, cp[a]
30 ; CHECK: sub r0, r11, 4
31         %0 = getelementptr [0 x i32]* @a, i32 0, i32 -1
32         ret i32* %0
33 }
35 define i32 *@f4() nounwind {
36 entry:
37 ; CHECK-LABEL: f4:
38 ; CHECK: ldaw [[REG:r[0-9]+]], dp[b]
39 ; CHECK: sub r0, [[REG]], 4
40         %0 = getelementptr [0 x i32]* @b, i32 0, i32 -1
41         ret i32* %0
42 }