1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -relocation-model=static < %s \
3 ; RUN: | FileCheck -check-prefix=RV32-STATIC %s
4 ; RUN: llc -mtriple=riscv32 -relocation-model=pic < %s \
5 ; RUN: | FileCheck -check-prefix=RV32-PIC %s
6 ; RUN: llc -mtriple=riscv64 -relocation-model=static < %s \
7 ; RUN: | FileCheck -check-prefix=RV64-STATIC %s
8 ; RUN: llc -mtriple=riscv64 -relocation-model=pic < %s \
9 ; RUN: | FileCheck -check-prefix=RV64-PIC %s
11 ; Check basic lowering of PIC addressing.
12 ; TODO: Check other relocation models?
14 @external_var = external global i32
15 @internal_var = internal global i32 42
20 define ptr @f1() nounwind {
21 ; RV32-STATIC-LABEL: f1:
22 ; RV32-STATIC: # %bb.0: # %entry
23 ; RV32-STATIC-NEXT: lui a0, %hi(external_var)
24 ; RV32-STATIC-NEXT: addi a0, a0, %lo(external_var)
25 ; RV32-STATIC-NEXT: ret
28 ; RV32-PIC: # %bb.0: # %entry
29 ; RV32-PIC-NEXT: .Lpcrel_hi0:
30 ; RV32-PIC-NEXT: auipc a0, %got_pcrel_hi(external_var)
31 ; RV32-PIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0)
34 ; RV64-STATIC-LABEL: f1:
35 ; RV64-STATIC: # %bb.0: # %entry
36 ; RV64-STATIC-NEXT: lui a0, %hi(external_var)
37 ; RV64-STATIC-NEXT: addi a0, a0, %lo(external_var)
38 ; RV64-STATIC-NEXT: ret
41 ; RV64-PIC: # %bb.0: # %entry
42 ; RV64-PIC-NEXT: .Lpcrel_hi0:
43 ; RV64-PIC-NEXT: auipc a0, %got_pcrel_hi(external_var)
44 ; RV64-PIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0)
53 define ptr @f2() nounwind {
54 ; RV32-STATIC-LABEL: f2:
55 ; RV32-STATIC: # %bb.0: # %entry
56 ; RV32-STATIC-NEXT: lui a0, %hi(internal_var)
57 ; RV32-STATIC-NEXT: addi a0, a0, %lo(internal_var)
58 ; RV32-STATIC-NEXT: ret
61 ; RV32-PIC: # %bb.0: # %entry
62 ; RV32-PIC-NEXT: .Lpcrel_hi1:
63 ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(internal_var)
64 ; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1)
67 ; RV64-STATIC-LABEL: f2:
68 ; RV64-STATIC: # %bb.0: # %entry
69 ; RV64-STATIC-NEXT: lui a0, %hi(internal_var)
70 ; RV64-STATIC-NEXT: addi a0, a0, %lo(internal_var)
71 ; RV64-STATIC-NEXT: ret
74 ; RV64-PIC: # %bb.0: # %entry
75 ; RV64-PIC-NEXT: .Lpcrel_hi1:
76 ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(internal_var)
77 ; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1)