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: get_local $push0=, 0{{$}} 16; CHECK-NEXT: return $pop0{{$}} 17define i32 @foo(i32 %r) { 18entry: 19 %0 = tail call i32 asm sideeffect "# $0 = aaa($1)", "=r,r"(i32 %r) #0, !srcloc !0 20 ret i32 %0 21} 22 23; CHECK-LABEL: imm: 24; CHECK-NEXT: .result i32{{$}} 25; CHECK-NEXT: .local i32{{$}} 26; CHECK-NEXT: #APP{{$}} 27; CHECK-NEXT: # 0 = ccc(42){{$}} 28; CHECK-NEXT: #NO_APP{{$}} 29; CHECK-NEXT: get_local $push0=, 0{{$}} 30; CHECK-NEXT: return $pop0{{$}} 31define i32 @imm() { 32entry: 33 %0 = tail call i32 asm sideeffect "# $0 = ccc($1)", "=r,i"(i32 42) #0, !srcloc !2 34 ret i32 %0 35} 36 37; CHECK-LABEL: foo_i64: 38; CHECK-NEXT: .param i64{{$}} 39; CHECK-NEXT: .result i64{{$}} 40; CHECK-NEXT: #APP{{$}} 41; CHECK-NEXT: # 0 = aaa(0){{$}} 42; CHECK-NEXT: #NO_APP{{$}} 43; CHECK-NEXT: get_local $push0=, 0{{$}} 44; CHECK-NEXT: return $pop0{{$}} 45define i64 @foo_i64(i64 %r) { 46entry: 47 %0 = tail call i64 asm sideeffect "# $0 = aaa($1)", "=r,r"(i64 %r) #0, !srcloc !0 48 ret i64 %0 49} 50 51; CHECK-LABEL: X_i16: 52; CHECK: foo 1{{$}} 53; CHECK: get_local $push[[S0:[0-9]+]]=, 0{{$}} 54; CHECK-NEXT: get_local $push[[S1:[0-9]+]]=, 1{{$}} 55; CHECK-NEXT: i32.store16 0($pop[[S0]]), $pop[[S1]]{{$}} 56define void @X_i16(i16 * %t) { 57 call void asm sideeffect "foo $0", "=*X,~{dirflag},~{fpsr},~{flags},~{memory}"(i16* %t) 58 ret void 59} 60 61; CHECK-LABEL: X_ptr: 62; CHECK: foo 1{{$}} 63; CHECK: get_local $push[[S0:[0-9]+]]=, 0{{$}} 64; CHECK-NEXT: get_local $push[[S1:[0-9]+]]=, 1{{$}} 65; CHECK-NEXT: i32.store 0($pop[[S0]]), $pop[[S1]]{{$}} 66define void @X_ptr(i16 ** %t) { 67 call void asm sideeffect "foo $0", "=*X,~{dirflag},~{fpsr},~{flags},~{memory}"(i16** %t) 68 ret void 69} 70 71; CHECK-LABEL: funcname: 72; CHECK: foo funcname{{$}} 73define void @funcname() { 74 tail call void asm sideeffect "foo $0", "i"(void ()* nonnull @funcname) #0, !srcloc !0 75 ret void 76} 77 78; CHECK-LABEL: varname: 79; CHECK: foo gv+37{{$}} 80@gv = global [0 x i8] zeroinitializer 81define void @varname() { 82 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 83 ret void 84} 85 86; CHECK-LABEL: r_constraint 87; CHECK: i32.const $push[[S0:[0-9]+]]=, 0{{$}} 88; CHECK-NEXT: set_local [[L0:[0-9]+]], $pop[[S0]]{{$}} 89; CHECK-NEXT: i32.const $push[[S1:[0-9]+]]=, 37{{$}} 90; CHECK-NEXT: set_local [[L1:[0-9]+]], $pop[[S1]]{{$}} 91; CHECK: foo [[L2:[0-9]+]], 1, [[L0]], [[L1]]{{$}} 92; CHECK: get_local $push{{[0-9]+}}=, [[L2]]{{$}} 93define hidden i32 @r_constraint(i32 %a, i32 %y) { 94entry: 95 %z = bitcast i32 0 to i32 96 %t0 = tail call i32 asm "foo $0, $1, $2, $3", "=r,r,r,r"(i32 %y, i32 %z, i32 37) #0, !srcloc !0 97 ret i32 %t0 98} 99 100attributes #0 = { nounwind } 101 102!0 = !{i32 47} 103!1 = !{i32 145} 104!2 = !{i32 231} 105