Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / CodeGen / RISCV / pic-models.ll
blob1a10c04b344e50b11f2b891740ff815c5c7dbe57
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
18 ; external address
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
27 ; RV32-PIC-LABEL: f1:
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)
32 ; RV32-PIC-NEXT:    ret
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
40 ; RV64-PIC-LABEL: f1:
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)
45 ; RV64-PIC-NEXT:    ret
46 entry:
47   ret ptr @external_var
51 ; internal address
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
60 ; RV32-PIC-LABEL: f2:
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)
65 ; RV32-PIC-NEXT:    ret
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
73 ; RV64-PIC-LABEL: f2:
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)
78 ; RV64-PIC-NEXT:    ret
79 entry:
80   ret ptr @internal_var