2018-10-23 08:12:49 +08:00
|
|
|
; RUN: llc < %s | llvm-mc -triple=wasm32-unknown-unknown | FileCheck --match-full-lines %s
|
|
|
|
|
|
|
|
; Test basic inline assembly can actually be assembled by the assembler.
|
|
|
|
|
|
|
|
; .ll code below is the result of this code run thru
|
|
|
|
; clang -target wasm32-unknown-unknown-wasm -O2 -S -emit-llvm test.c
|
|
|
|
|
|
|
|
; int main(int argc, const char *argv[]) {
|
|
|
|
; int src = 1;
|
|
|
|
; int dst;
|
|
|
|
; asm ("i32.const\t2\n"
|
2019-01-08 14:25:55 +08:00
|
|
|
; "\tlocal.get\t%1\n"
|
2018-10-23 08:12:49 +08:00
|
|
|
; "\ti32.add\n"
|
2019-01-08 14:25:55 +08:00
|
|
|
; "\tlocal.set\t%0"
|
2018-10-23 08:12:49 +08:00
|
|
|
; : "=r" (dst)
|
|
|
|
; : "r" (src));
|
|
|
|
; return dst != 3;
|
|
|
|
; }
|
|
|
|
|
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
|
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
|
|
|
|
; CHECK-LABEL: main:
|
2018-11-20 01:10:36 +08:00
|
|
|
; CHECK-NEXT: .functype main (i32, i32) -> (i32)
|
2018-10-23 08:12:49 +08:00
|
|
|
; CHECK-NEXT: .local i32
|
|
|
|
; CHECK-NEXT: i32.const 1
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: local.set [[SRC:[0-9]+]]
|
2018-10-23 08:12:49 +08:00
|
|
|
; CHECK-NEXT: i32.const 2
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: local.get [[SRC]]
|
2018-10-23 08:12:49 +08:00
|
|
|
; CHECK-NEXT: i32.add
|
2019-01-08 14:25:55 +08:00
|
|
|
; CHECK-NEXT: local.set [[DST:[0-9]+]]
|
|
|
|
; CHECK-NEXT: local.get [[DST]]
|
2018-10-23 08:12:49 +08:00
|
|
|
; CHECK-NEXT: i32.const 3
|
|
|
|
; CHECK-NEXT: i32.ne
|
|
|
|
|
|
|
|
define i32 @main(i32 %argc, i8** nocapture readnone %argv) #0 {
|
|
|
|
entry:
|
2019-01-08 14:25:55 +08:00
|
|
|
%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) #1
|
2018-10-23 08:12:49 +08:00
|
|
|
%cmp = icmp ne i32 %0, 3
|
|
|
|
%conv = zext i1 %cmp to i32
|
|
|
|
ret i32 %conv
|
|
|
|
}
|
|
|
|
|