82 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=riscv32 -relocation-model=static < %s \3; RUN: | FileCheck -check-prefix=RV32-STATIC %s4; RUN: llc -mtriple=riscv32 -relocation-model=pic < %s \5; RUN: | FileCheck -check-prefix=RV32-PIC %s6; RUN: llc -mtriple=riscv64 -relocation-model=static < %s \7; RUN: | FileCheck -check-prefix=RV64-STATIC %s8; RUN: llc -mtriple=riscv64 -relocation-model=pic < %s \9; RUN: | FileCheck -check-prefix=RV64-PIC %s10 11; Check basic lowering of PIC addressing.12; TODO: Check other relocation models?13 14@external_var = external global i3215@internal_var = internal global i32 4216 17 18; external address19 20define ptr @f1() nounwind {21; RV32-STATIC-LABEL: f1:22; RV32-STATIC: # %bb.0: # %entry23; RV32-STATIC-NEXT: lui a0, %hi(external_var)24; RV32-STATIC-NEXT: addi a0, a0, %lo(external_var)25; RV32-STATIC-NEXT: ret26;27; RV32-PIC-LABEL: f1:28; RV32-PIC: # %bb.0: # %entry29; 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: ret33;34; RV64-STATIC-LABEL: f1:35; RV64-STATIC: # %bb.0: # %entry36; RV64-STATIC-NEXT: lui a0, %hi(external_var)37; RV64-STATIC-NEXT: addi a0, a0, %lo(external_var)38; RV64-STATIC-NEXT: ret39;40; RV64-PIC-LABEL: f1:41; RV64-PIC: # %bb.0: # %entry42; 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: ret46entry:47 ret ptr @external_var48}49 50 51; internal address52 53define ptr @f2() nounwind {54; RV32-STATIC-LABEL: f2:55; RV32-STATIC: # %bb.0: # %entry56; RV32-STATIC-NEXT: lui a0, %hi(internal_var)57; RV32-STATIC-NEXT: addi a0, a0, %lo(internal_var)58; RV32-STATIC-NEXT: ret59;60; RV32-PIC-LABEL: f2:61; RV32-PIC: # %bb.0: # %entry62; 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: ret66;67; RV64-STATIC-LABEL: f2:68; RV64-STATIC: # %bb.0: # %entry69; RV64-STATIC-NEXT: lui a0, %hi(internal_var)70; RV64-STATIC-NEXT: addi a0, a0, %lo(internal_var)71; RV64-STATIC-NEXT: ret72;73; RV64-PIC-LABEL: f2:74; RV64-PIC: # %bb.0: # %entry75; 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: ret79entry:80 ret ptr @internal_var81}82