aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJF Bastien <jfb@google.com>2015-10-20 01:26:54 +0000
committerJF Bastien <jfb@google.com>2015-10-20 01:26:54 +0000
commitc8f89e86d5ba6787b5c4ecdbfc935b64a5edfa31 (patch)
treed0bf8a3fbaf611eed50c8dd19ba264b063b04327
parentc4829deae8f42f45c0e10b1958e2345f3c5f3611 (diff)
downloadllvm-c8f89e86d5ba6787b5c4ecdbfc935b64a5edfa31.zip
llvm-c8f89e86d5ba6787b5c4ecdbfc935b64a5edfa31.tar.gz
llvm-c8f89e86d5ba6787b5c4ecdbfc935b64a5edfa31.tar.bz2
WebAssembly: fix call/return syntax.
They are now typeless, unlike other operations. llvm-svn: 250793
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp7
-rw-r--r--llvm/test/CodeGen/WebAssembly/func.ll6
-rw-r--r--llvm/test/CodeGen/WebAssembly/return-int32.ll10
3 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index fda95a5..e20ee69 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -105,7 +105,12 @@ static std::string OpcodeName(const WebAssemblyInstrInfo *TII,
bool HasType = std::string::npos != Under;
std::string::size_type NameEnd = HasType ? Under : Len;
std::string Name(&N[0], &N[NameEnd]);
- return HasType ? (std::string(&N[NameEnd + 1], &N[Len]) + '.' + Name) : Name;
+ if (!HasType)
+ return Name;
+ for (const char *typelessOpcode : { "return", "call" })
+ if (Name == typelessOpcode)
+ return Name;
+ return std::string(&N[NameEnd + 1], &N[Len]) + '.' + Name;
}
static std::string toSymbol(StringRef S) { return ("$" + S).str(); }
diff --git a/llvm/test/CodeGen/WebAssembly/func.ll b/llvm/test/CodeGen/WebAssembly/func.ll
index 7d16fd3..cd58496 100644
--- a/llvm/test/CodeGen/WebAssembly/func.ll
+++ b/llvm/test/CodeGen/WebAssembly/func.ll
@@ -17,7 +17,7 @@ define void @f0() {
; CHECK-NEXT: .local i32{{$}}
; CHECK-NEXT: i32.const 0{{$}}
; CHECK-NEXT: set_local 0, pop{{$}}
-; CHECK-NEXT: i32.return (get_local 0){{$}}
+; CHECK-NEXT: return (get_local 0){{$}}
; CHECK: .size f1,
define i32 @f1() {
ret i32 0
@@ -30,7 +30,7 @@ define i32 @f1() {
; CHECK-NEXT: .local i32{{$}}
; CHECK-NEXT: i32.const 0{{$}}
; CHECK-NEXT: set_local 2, pop{{$}}
-; CHECK-NEXT: i32.return (get_local 2){{$}}
+; CHECK-NEXT: return (get_local 2){{$}}
; CHECK: .size f2,
define i32 @f2(i32 %p1, float %p2) {
ret i32 0
@@ -40,7 +40,7 @@ define i32 @f2(i32 %p1, float %p2) {
; CHECK-NEXT: .param i32{{$}}
; CHECK-NEXT: .param f32{{$}}
; CHECK-NOT: .local
-; CHECK-NEXT: void.return{{$}}
+; CHECK-NEXT: return{{$}}
; CHECK: .size f3,
define void @f3(i32 %p1, float %p2) {
ret void
diff --git a/llvm/test/CodeGen/WebAssembly/return-int32.ll b/llvm/test/CodeGen/WebAssembly/return-int32.ll
new file mode 100644
index 0000000..e0f7957
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/return-int32.ll
@@ -0,0 +1,10 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+target datalayout = "e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+; CHECK-LABEL: return_i32:
+; CHECK: return (get_local 1){{$}}
+define i32 @return_i32(i32 %p) {
+ ret i32 %p
+}