1 ; RUN: llc < %s -march=sparc -relocation-model=static -code-model=small | FileCheck --check-prefix=abs32 %s 2 ; RUN: llc < %s -march=sparcv9 -relocation-model=static -code-model=small | FileCheck --check-prefix=abs32 %s 3 ; RUN: llc < %s -march=sparcv9 -relocation-model=static -code-model=medium | FileCheck --check-prefix=abs44 %s 4 ; RUN: llc < %s -march=sparcv9 -relocation-model=static -code-model=large | FileCheck --check-prefix=abs64 %s 5 ; RUN: llc < %s -march=sparc -relocation-model=pic -code-model=medium | FileCheck --check-prefix=v8pic32 %s 6 ; RUN: llc < %s -march=sparcv9 -relocation-model=pic -code-model=medium | FileCheck --check-prefix=v9pic32 %s 7 8 ; 9 ; copied from test/CodeGen/Mips/blockaddr.ll and modified for SPARC 10 ; 11 @reg = common global i8* null, align 4 12 13 define i8* @dummy(i8* %x) nounwind readnone noinline { 14 entry: 15 ret i8* %x 16 } 17 18 ; abs32-LABEL: func_block_addr: 19 ; abs32: sethi %hi([[BLK:.+]]), [[R:%[gilo][0-7]]] 20 ; abs32: call dummy 21 ; abs32: add [[R]], %lo([[BLK]]), %o0 22 ; abs32: jmp %o0 23 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]]] 28 ; abs44: call dummy 29 ; abs44: add [[R2]], %l44([[BLK]]), %o0 30 ; abs44: jmp %o0 31 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]]] 38 ; abs64: call dummy 39 ; abs64: add [[R2]], [[R1]], %o0 40 ; abs64: jmp %o0 41 42 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]]] 49 ; v8pic32: call dummy 50 ; v8pic32: ld [%[[R2]]+%[[R4]]], %o0 51 ; v8pic32: jmp %o0 52 53 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]]] 60 ; v9pic32: call dummy 61 ; v9pic32: ldx [%[[R2]]+%[[R4]]], %o0 62 ; v9pic32: jmp %o0 63 64 65 define void @func_block_addr() nounwind { 66 entry: 67 %call = tail call i8* @dummy(i8* blockaddress(@func_block_addr, %baz)) 68 indirectbr i8* %call, [label %baz, label %foo] 69 70 foo: ; preds = %foo, %entry 71 store i8* blockaddress(@func_block_addr, %foo), i8** @reg, align 4 72 br label %foo 73 74 baz: ; preds = %entry 75 store i8* null, i8** @reg, align 4 76 ret void 77 } 78