xref: /llvm-project/llvm/test/CodeGen/LoongArch/global-variable-code-model.ll (revision b2e69f52bb5da067109b9a7d1f73d0dd1a6bb5ad)
116094cb6Shev; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
29d4f7f44Swanglei; RUN: llc --mtriple=loongarch64 -mattr=+d < %s | FileCheck %s
316094cb6Shev
416094cb6Shev@a= external dso_local global i32, code_model "small", align 4
516094cb6Shev
616094cb6Shevdefine dso_local signext i32 @local_small() #0 {
716094cb6Shev; CHECK-LABEL: local_small:
816094cb6Shev; CHECK:       # %bb.0:
916094cb6Shev; CHECK-NEXT:    pcalau12i $a0, %pc_hi20(a)
10*b2e69f52Shev; CHECK-NEXT:    ld.w $a0, $a0, %pc_lo12(a)
1116094cb6Shev; CHECK-NEXT:    ret
1216094cb6Shev  %1 = load i32, ptr @a, align 4
1316094cb6Shev  ret i32 %1
1416094cb6Shev}
1516094cb6Shev
1616094cb6Shev@b= external dso_local global i32, code_model "large", align 4
1716094cb6Shev
1816094cb6Shevdefine dso_local signext i32 @local_large() #0 {
1916094cb6Shev; CHECK-LABEL: local_large:
2016094cb6Shev; CHECK:       # %bb.0:
2116094cb6Shev; CHECK-NEXT:    pcalau12i $a0, %pc_hi20(b)
220e6f64cdShev; CHECK-NEXT:    addi.d $a1, $zero, %pc_lo12(b)
230e6f64cdShev; CHECK-NEXT:    lu32i.d $a1, %pc64_lo20(b)
240e6f64cdShev; CHECK-NEXT:    lu52i.d $a1, $a1, %pc64_hi12(b)
25*b2e69f52Shev; CHECK-NEXT:    ldx.w $a0, $a1, $a0
2616094cb6Shev; CHECK-NEXT:    ret
2716094cb6Shev  %1 = load i32, ptr @b, align 4
2816094cb6Shev  ret i32 %1
2916094cb6Shev}
3016094cb6Shev
3116094cb6Shev@c= external global i32, code_model "large", align 4
3216094cb6Shev
3316094cb6Shevdefine dso_local signext i32 @non_local_large() #0 {
3416094cb6Shev; CHECK-LABEL: non_local_large:
3516094cb6Shev; CHECK:       # %bb.0:
3616094cb6Shev; CHECK-NEXT:    pcalau12i $a0, %got_pc_hi20(c)
3716094cb6Shev; CHECK-NEXT:    ld.d $a0, $a0, %got_pc_lo12(c)
3816094cb6Shev; CHECK-NEXT:    ld.w $a0, $a0, 0
3916094cb6Shev; CHECK-NEXT:    ret
4016094cb6Shev  %1 = load i32, ptr @c, align 4
4116094cb6Shev  ret i32 %1
4216094cb6Shev}
43