1 ; RUN: llc < %s -mtriple=sparc -relocation-model=static -code-model=small | FileCheck --check-prefix=abs32 %s
2 ; RUN: llc < %s -mtriple=sparcv9 -relocation-model=static -code-model=small | FileCheck --check-prefix=abs32 %s
3 ; RUN: llc < %s -mtriple=sparcv9 -relocation-model=static -code-model=medium | FileCheck --check-prefix=abs44 %s
4 ; RUN: llc < %s -mtriple=sparcv9 -relocation-model=static -code-model=large | FileCheck --check-prefix=abs64 %s
5 ; RUN: llc < %s -mtriple=sparc -relocation-model=pic -code-model=medium | FileCheck --check-prefix=v8pic32 %s
6 ; RUN: llc < %s -mtriple=sparcv9 -relocation-model=pic -code-model=medium | FileCheck --check-prefix=v9pic32 %s
9 ; copied from test/CodeGen/Mips/blockaddr.ll and modified for SPARC
11 @reg = common global ptr null, align 4
13 define ptr @dummy(ptr %x) nounwind readnone noinline {
18 ; abs32-LABEL: func_block_addr:
19 ; abs32: sethi %hi([[BLK:.+]]), [[R:%[gilo][0-7]]]
21 ; abs32: add [[R]], %lo([[BLK]]), %o0
24 ; abs44-LABEL: func_block_addr:
25 ; abs44: sethi %h44([[BLK:.+]]), [[R:%[gilo][0-7]]]
26 ; abs44: add [[R]], %m44([[BLK]]), [[R1:%[gilo][0-7]]]
27 ; abs44: sllx [[R1]], 12, [[R2:%[gilo][0-7]]]
29 ; abs44: add [[R2]], %l44([[BLK]]), %o0
32 ; abs64-LABEL: func_block_addr:
33 ; abs64: sethi %hi([[BLK:.+]]), [[R:%[gilo][0-7]]]
34 ; abs64: add [[R]], %lo([[BLK]]), [[R1:%[gilo][0-7]]]
35 ; abs64: sethi %hh([[BLK]]), [[R2:%[gilo][0-7]]]
36 ; abs64: add [[R2]], %hm([[BLK]]), [[R3:%[gilo][0-7]]]
37 ; abs64: sllx [[R3]], 32, [[R4:%[gilo][0-7]]]
39 ; abs64: add [[R2]], [[R1]], %o0
43 ; v8pic32: func_block_addr
44 ; v8pic32: sethi %hi(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R:%[gilo][0-7]]]
45 ; v8pic32: or [[R]], %lo(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R1:%[gilo][0-7]]]
46 ; v8pic32: add [[R1]], %o7, %[[R2:[gilo][0-7]]]
47 ; v8pic32: sethi %hi([[BLK:.+]]), [[R3:%[gilo][0-7]]]
48 ; v8pic32: add [[R3]], %lo([[BLK]]), %[[R4:[gilo][0-7]]]
50 ; v8pic32: ld [%[[R2]]+%[[R4]]], %o0
54 ; v9pic32: func_block_addr
55 ; v9pic32: sethi %hi(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R:%[gilo][0-7]]]
56 ; v9pic32: or [[R]], %lo(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R1:%[gilo][0-7]]]
57 ; v9pic32: add [[R1]], %o7, %[[R2:[gilo][0-7]]]
58 ; v9pic32: sethi %hi([[BLK:.+]]), [[R3:%[gilo][0-7]]]
59 ; v9pic32: add [[R3]], %lo([[BLK]]), %[[R4:[gilo][0-7]]]
61 ; v9pic32: ldx [%[[R2]]+%[[R4]]], %o0
65 define void @func_block_addr() nounwind {
67 %call = tail call ptr @dummy(ptr blockaddress(@func_block_addr, %baz))
68 indirectbr ptr %call, [label %baz, label %foo]
70 foo: ; preds = %foo, %entry
71 store ptr blockaddress(@func_block_addr, %foo), ptr @reg, align 4
75 store ptr null, ptr @reg, align 4