summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2018-10-23 00:12:49 +0000
committerWouter van Oortmerssen <aardappel@gmail.com>2018-10-23 00:12:49 +0000
commita569c205873703a3b6fe769198e6cd03c660ff1b (patch)
tree0ddce27014cf94f069f3d19dbabf28f22beb7bbf
parentc8e9d2b5254a95166164aadb9afe4cc0a8ffc533 (diff)
downloadbcm5719-llvm-a569c205873703a3b6fe769198e6cd03c660ff1b.tar.gz
bcm5719-llvm-a569c205873703a3b6fe769198e6cd03c660ff1b.zip
[WebAssembly] Added test for inline assembly roundtrip.
Summary: Due to previous work to make WebAssembly MC by default stack-only inline assembly now "just works" (previously it didn't since it had no way to know types of registers), so no further work required. So far we only have tests (in inline-asm.ll) which test with non-existing instructions, so this adds a test that roundtrips both the inline assembly and its surrounding code thru the assembler. Reviewers: dschuff, sunfish Subscribers: sbc100, jgravelle-google, eraman, aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D52914 llvm-svn: 344977
-rw-r--r--llvm/test/CodeGen/WebAssembly/inline-asm-roundtrip.ll43
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/inline-asm-roundtrip.ll b/llvm/test/CodeGen/WebAssembly/inline-asm-roundtrip.ll
new file mode 100644
index 00000000000..7fcc3cf276a
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/inline-asm-roundtrip.ll
@@ -0,0 +1,43 @@
+; 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"
+; "\tget_local\t%1\n"
+; "\ti32.add\n"
+; "\tset_local\t%0"
+; : "=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:
+; CHECK-NEXT: .param i32, i32
+; CHECK-NEXT: .local i32
+; CHECK-NEXT: i32.const 1
+; CHECK-NEXT: set_local [[SRC:[0-9]+]]
+; CHECK-NEXT: i32.const 2
+; CHECK-NEXT: get_local [[SRC]]
+; CHECK-NEXT: i32.add
+; CHECK-NEXT: set_local [[DST:[0-9]+]]
+; CHECK-NEXT: get_local [[DST]]
+; CHECK-NEXT: i32.const 3
+; CHECK-NEXT: i32.ne
+
+define i32 @main(i32 %argc, i8** nocapture readnone %argv) #0 {
+entry:
+ %0 = tail call i32 asm "i32.const\092\0A\09get_local\09$1\0A\09i32.add\0A\09set_local\09$0", "=r,r"(i32 1) #1
+ %cmp = icmp ne i32 %0, 3
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
OpenPOWER on IntegriCloud