[llvm] r250793 - WebAssembly: fix call/return syntax.
JF Bastien via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 18:26:54 PDT 2015
Author: jfb
Date: Mon Oct 19 20:26:54 2015
New Revision: 250793
URL: http://llvm.org/viewvc/llvm-project?rev=250793&view=rev
Log:
WebAssembly: fix call/return syntax.
They are now typeless, unlike other operations.
Added:
llvm/trunk/test/CodeGen/WebAssembly/return-int32.ll
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/trunk/test/CodeGen/WebAssembly/func.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp?rev=250793&r1=250792&r2=250793&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp Mon Oct 19 20:26:54 2015
@@ -105,7 +105,12 @@ static std::string OpcodeName(const WebA
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(); }
Modified: llvm/trunk/test/CodeGen/WebAssembly/func.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/func.ll?rev=250793&r1=250792&r2=250793&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/func.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/func.ll Mon Oct 19 20:26:54 2015
@@ -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
Added: llvm/trunk/test/CodeGen/WebAssembly/return-int32.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/return-int32.ll?rev=250793&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/return-int32.ll (added)
+++ llvm/trunk/test/CodeGen/WebAssembly/return-int32.ll Mon Oct 19 20:26:54 2015
@@ -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
+}
More information about the llvm-commits
mailing list