42 lines · plain
1; RUN: llc < %s | llvm-mc -triple=wasm32-unknown-unknown | FileCheck --match-full-lines %s2 3; Test basic inline assembly can actually be assembled by the assembler.4 5; .ll code below is the result of this code run thru6; clang -target wasm32-unknown-unknown-wasm -O2 -S -emit-llvm test.c7 8; int main(int argc, const char *argv[]) {9; int src = 1;10; int dst;11; asm ("i32.const\t2\n"12; "\tlocal.get\t%1\n"13; "\ti32.add\n"14; "\tlocal.set\t%0"15; : "=r" (dst)16; : "r" (src));17; return dst != 3;18; }19 20target triple = "wasm32-unknown-unknown"21 22; CHECK-LABEL: main:23; CHECK-NEXT: .functype main (i32, i32) -> (i32)24; CHECK-NEXT: .local i3225; CHECK-NEXT: i32.const 126; CHECK-NEXT: local.set [[SRC:[0-9]+]]27; CHECK-NEXT: i32.const 228; CHECK-NEXT: local.get [[SRC]]29; CHECK-NEXT: i32.add30; CHECK-NEXT: local.set [[DST:[0-9]+]]31; CHECK-NEXT: local.get [[DST]]32; CHECK-NEXT: i32.const 333; CHECK-NEXT: i32.ne34 35define i32 @main(i32 %argc, ptr nocapture readnone %argv) #0 {36entry:37 %0 = tail call i32 asm "i32.const\092\0A\09local.get\09$1\0A\09i32.add\0A\09local.set\09$0", "=r,r"(i32 1) #138 %cmp = icmp ne i32 %0, 339 %conv = zext i1 %cmp to i3240 ret i32 %conv41}42