xref: /llvm-project/llvm/test/CodeGen/RISCV/inline-asm-s-constraint.ll (revision 10a55caccf4e2d397f94c1455b93d774591be45f)
1*10a55cacSFangrui Song; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2*10a55cacSFangrui Song; RUN: llc -mtriple=riscv32 -relocation-model=static < %s | FileCheck %s --check-prefix=RV32
3*10a55cacSFangrui Song; RUN: llc -mtriple=riscv64 -relocation-model=pic < %s | FileCheck %s --check-prefix=RV64
4*10a55cacSFangrui Song
5*10a55cacSFangrui Song@var = external dso_local global i32, align 4
6*10a55cacSFangrui Song@a = external global [2 x [2 x i32]], align 4
7*10a55cacSFangrui Song
8*10a55cacSFangrui Songdefine dso_local void @test() {
9*10a55cacSFangrui Song; RV32-LABEL: test:
10*10a55cacSFangrui Song; RV32:       # %bb.0: # %entry
11*10a55cacSFangrui Song; RV32-NEXT:    #APP
12*10a55cacSFangrui Song; RV32-NEXT:    # var a+12 test
13*10a55cacSFangrui Song; RV32-NEXT:    #NO_APP
14*10a55cacSFangrui Song; RV32-NEXT:    #APP
15*10a55cacSFangrui Song; RV32-NEXT:    # var a+12 test
16*10a55cacSFangrui Song; RV32-NEXT:    #NO_APP
17*10a55cacSFangrui Song; RV32-NEXT:    ret
18*10a55cacSFangrui Song;
19*10a55cacSFangrui Song; RV64-LABEL: test:
20*10a55cacSFangrui Song; RV64:       # %bb.0: # %entry
21*10a55cacSFangrui Song; RV64-NEXT:    #APP
22*10a55cacSFangrui Song; RV64-NEXT:    # var a+12 .Ltest$local
23*10a55cacSFangrui Song; RV64-NEXT:    #NO_APP
24*10a55cacSFangrui Song; RV64-NEXT:    #APP
25*10a55cacSFangrui Song; RV64-NEXT:    # var a+12 .Ltest$local
26*10a55cacSFangrui Song; RV64-NEXT:    #NO_APP
27*10a55cacSFangrui Song; RV64-NEXT:    ret
28*10a55cacSFangrui Songentry:
29*10a55cacSFangrui Song  call void asm sideeffect "// $0 $1 $2", "s,s,s,~{dirflag},~{fpsr},~{flags}"(ptr @var, ptr getelementptr inbounds ([2 x [2 x i32]], ptr @a, i64 0, i64 1, i64 1), ptr @test)
30*10a55cacSFangrui Song
31*10a55cacSFangrui Song  ;; Implement "S" as an alias for "s".
32*10a55cacSFangrui Song  call void asm sideeffect "// $0 $1 $2", "S,S,S,~{dirflag},~{fpsr},~{flags}"(ptr @var, ptr getelementptr inbounds ([2 x [2 x i32]], ptr @a, i64 0, i64 1, i64 1), ptr @test)
33*10a55cacSFangrui Song  ret void
34*10a55cacSFangrui Song}
35*10a55cacSFangrui Song
36*10a55cacSFangrui Song; Function Attrs: nofree nosync nounwind readnone
37*10a55cacSFangrui Songdefine dso_local ptr @test_label() {
38*10a55cacSFangrui Song; RV32-LABEL: test_label:
39*10a55cacSFangrui Song; RV32:       # %bb.0: # %entry
40*10a55cacSFangrui Song; RV32-NEXT:  .Ltmp0: # Block address taken
41*10a55cacSFangrui Song; RV32-NEXT:  # %bb.1: # %L1
42*10a55cacSFangrui Song; RV32-NEXT:    #APP
43*10a55cacSFangrui Song; RV32-NEXT:    # .Ltmp0
44*10a55cacSFangrui Song; RV32-NEXT:    #NO_APP
45*10a55cacSFangrui Song; RV32-NEXT:    #APP
46*10a55cacSFangrui Song; RV32-NEXT:    lui a0, %hi(.Ltmp0)
47*10a55cacSFangrui Song; RV32-NEXT:    addi a0, a0, %lo(.Ltmp0)
48*10a55cacSFangrui Song; RV32-NEXT:    #NO_APP
49*10a55cacSFangrui Song; RV32-NEXT:    ret
50*10a55cacSFangrui Song;
51*10a55cacSFangrui Song; RV64-LABEL: test_label:
52*10a55cacSFangrui Song; RV64:       # %bb.0: # %entry
53*10a55cacSFangrui Song; RV64-NEXT:  .Ltmp0: # Block address taken
54*10a55cacSFangrui Song; RV64-NEXT:  # %bb.1: # %L1
55*10a55cacSFangrui Song; RV64-NEXT:    #APP
56*10a55cacSFangrui Song; RV64-NEXT:    # .Ltmp0
57*10a55cacSFangrui Song; RV64-NEXT:    #NO_APP
58*10a55cacSFangrui Song; RV64-NEXT:    #APP
59*10a55cacSFangrui Song; RV64-NEXT:    lui a0, %hi(.Ltmp0)
60*10a55cacSFangrui Song; RV64-NEXT:    addi a0, a0, %lo(.Ltmp0)
61*10a55cacSFangrui Song; RV64-NEXT:    #NO_APP
62*10a55cacSFangrui Song; RV64-NEXT:    ret
63*10a55cacSFangrui Songentry:
64*10a55cacSFangrui Song  br label %L1
65*10a55cacSFangrui Song
66*10a55cacSFangrui SongL1:
67*10a55cacSFangrui Song  call void asm sideeffect "// $0", "s,~{dirflag},~{fpsr},~{flags}"(ptr blockaddress(@test_label, %L1))
68*10a55cacSFangrui Song  %ret = tail call ptr asm "lui $0, %hi($1)\0Aaddi $0, $0, %lo($1)", "=r,S"(ptr blockaddress(@test_label, %L1))
69*10a55cacSFangrui Song  ret ptr %ret
70*10a55cacSFangrui Song}
71