• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -no-integrated-as | FileCheck %s
2
3; Test basic inline assembly. Pass -no-integrated-as since these aren't
4; actually valid assembly syntax.
5
6target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7target triple = "wasm32-unknown-unknown"
8
9; CHECK-LABEL: foo:
10; CHECK-NEXT: .param i32{{$}}
11; CHECK-NEXT: .result i32{{$}}
12; CHECK-NEXT: #APP{{$}}
13; CHECK-NEXT: # $0 = aaa($0){{$}}
14; CHECK-NEXT: #NO_APP{{$}}
15; CHECK-NEXT: return $0{{$}}
16define i32 @foo(i32 %r) {
17entry:
18  %0 = tail call i32 asm sideeffect "# $0 = aaa($1)", "=r,r"(i32 %r) #0, !srcloc !0
19  ret i32 %0
20}
21
22; CHECK-LABEL: bar:
23; CHECK-NEXT: .param i32, i32{{$}}
24; CHECK-NEXT: #APP{{$}}
25; CHECK-NEXT: # 0($1) = bbb(0($0)){{$}}
26; CHECK-NEXT: #NO_APP{{$}}
27; CHECK-NEXT: return{{$}}
28define void @bar(i32* %r, i32* %s) {
29entry:
30  tail call void asm sideeffect "# $0 = bbb($1)", "=*m,*m"(i32* %s, i32* %r) #0, !srcloc !1
31  ret void
32}
33
34; CHECK-LABEL: imm:
35; CHECK-NEXT: .result i32{{$}}
36; CHECK-NEXT: .local i32{{$}}
37; CHECK-NEXT: #APP{{$}}
38; CHECK-NEXT: # $0 = ccc(42){{$}}
39; CHECK-NEXT: #NO_APP{{$}}
40; CHECK-NEXT: return $0{{$}}
41define i32 @imm() {
42entry:
43  %0 = tail call i32 asm sideeffect "# $0 = ccc($1)", "=r,i"(i32 42) #0, !srcloc !2
44  ret i32 %0
45}
46
47; CHECK-LABEL: foo_i64:
48; CHECK-NEXT: .param i64{{$}}
49; CHECK-NEXT: .result i64{{$}}
50; CHECK-NEXT: #APP{{$}}
51; CHECK-NEXT: # $0 = aaa($0){{$}}
52; CHECK-NEXT: #NO_APP{{$}}
53; CHECK-NEXT: return $0{{$}}
54define i64 @foo_i64(i64 %r) {
55entry:
56  %0 = tail call i64 asm sideeffect "# $0 = aaa($1)", "=r,r"(i64 %r) #0, !srcloc !0
57  ret i64 %0
58}
59
60; CHECK-LABEL: X_i16:
61; CHECK: foo $1{{$}}
62; CHECK: i32.store16 $drop=, 0($0), $1{{$}}
63define void @X_i16(i16 * %t) {
64  call void asm sideeffect "foo $0", "=*X,~{dirflag},~{fpsr},~{flags},~{memory}"(i16* %t)
65  ret void
66}
67
68; CHECK-LABEL: X_ptr:
69; CHECK: foo $1{{$}}
70; CHECK: i32.store $drop=, 0($0), $1{{$}}
71define void @X_ptr(i16 ** %t) {
72  call void asm sideeffect "foo $0", "=*X,~{dirflag},~{fpsr},~{flags},~{memory}"(i16** %t)
73  ret void
74}
75
76; CHECK-LABEL: funcname:
77; CHECK: foo funcname{{$}}
78define void @funcname() {
79  tail call void asm sideeffect "foo $0", "i"(void ()* nonnull @funcname) #0, !srcloc !0
80  ret void
81}
82
83; CHECK-LABEL: varname:
84; CHECK: foo gv+37{{$}}
85@gv = global [0 x i8] zeroinitializer
86define void @varname() {
87  tail call void asm sideeffect "foo $0", "i"(i8* getelementptr inbounds ([0 x i8], [0 x i8]* @gv, i64 0, i64 37)) #0, !srcloc !0
88  ret void
89}
90
91attributes #0 = { nounwind }
92
93!0 = !{i32 47}
94!1 = !{i32 145}
95!2 = !{i32 231}
96