File: inline-asm-s-constraint.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (70 lines) | stat: -rw-r--r-- 2,302 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -relocation-model=static < %s | FileCheck %s --check-prefix=RV32
; RUN: llc -mtriple=riscv64 -relocation-model=pic < %s | FileCheck %s --check-prefix=RV64

@var = external dso_local global i32, align 4
@a = external global [2 x [2 x i32]], align 4

define dso_local void @test() {
; RV32-LABEL: test:
; RV32:       # %bb.0: # %entry
; RV32-NEXT:    #APP
; RV32-NEXT:    # var a+12 test
; RV32-NEXT:    #NO_APP
; RV32-NEXT:    #APP
; RV32-NEXT:    # var a+12 test
; RV32-NEXT:    #NO_APP
; RV32-NEXT:    ret
;
; RV64-LABEL: test:
; RV64:       # %bb.0: # %entry
; RV64-NEXT:    #APP
; RV64-NEXT:    # var a+12 .Ltest$local
; RV64-NEXT:    #NO_APP
; RV64-NEXT:    #APP
; RV64-NEXT:    # var a+12 .Ltest$local
; RV64-NEXT:    #NO_APP
; RV64-NEXT:    ret
entry:
  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)

  ;; Implement "S" as an alias for "s".
  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)
  ret void
}

; Function Attrs: nofree nosync nounwind readnone
define dso_local ptr @test_label() {
; RV32-LABEL: test_label:
; RV32:       # %bb.0: # %entry
; RV32-NEXT:  .Ltmp0: # Block address taken
; RV32-NEXT:  # %bb.1: # %L1
; RV32-NEXT:    #APP
; RV32-NEXT:    # .Ltmp0
; RV32-NEXT:    #NO_APP
; RV32-NEXT:    #APP
; RV32-NEXT:    lui a0, %hi(.Ltmp0)
; RV32-NEXT:    addi a0, a0, %lo(.Ltmp0)
; RV32-NEXT:    #NO_APP
; RV32-NEXT:    ret
;
; RV64-LABEL: test_label:
; RV64:       # %bb.0: # %entry
; RV64-NEXT:  .Ltmp0: # Block address taken
; RV64-NEXT:  # %bb.1: # %L1
; RV64-NEXT:    #APP
; RV64-NEXT:    # .Ltmp0
; RV64-NEXT:    #NO_APP
; RV64-NEXT:    #APP
; RV64-NEXT:    lui a0, %hi(.Ltmp0)
; RV64-NEXT:    addi a0, a0, %lo(.Ltmp0)
; RV64-NEXT:    #NO_APP
; RV64-NEXT:    ret
entry:
  br label %L1

L1:
  call void asm sideeffect "// $0", "s,~{dirflag},~{fpsr},~{flags}"(ptr blockaddress(@test_label, %L1))
  %ret = tail call ptr asm "lui $0, %hi($1)\0Aaddi $0, $0, %lo($1)", "=r,S"(ptr blockaddress(@test_label, %L1))
  ret ptr %ret
}