[PATCH] D14587: [WebAssembly] Fix printing of global operands

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 14:06:40 PST 2015


dschuff created this revision.
dschuff added a reviewer: sunfish.
dschuff added subscribers: llvm-commits, jfb.
Herald added a subscriber: dschuff.

They still need to be printed as "i32.const" rather than "global".
(Fixed from r252656 which wasn't quite NFC)

http://reviews.llvm.org/D14587

Files:
  lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  test/CodeGen/WebAssembly/global.ll

Index: test/CodeGen/WebAssembly/global.ll
===================================================================
--- test/CodeGen/WebAssembly/global.ll
+++ test/CodeGen/WebAssembly/global.ll
@@ -9,6 +9,13 @@
 ; CHECK-NOT: llvm.metadata
 @llvm.used = appending global [1 x i32*] [i32* @g], section "llvm.metadata"
 
+; CHECK: foo:
+; CHECK: i32.const push, $answer
+define i32 @foo() {
+  %a = load i32, i32* @answer
+  ret i32 %a
+}
+
 ; CHECK: .type   g, at object
 ; CHECK: .align  2{{$}}
 ; CHECK-NEXT: g:
Index: lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -249,6 +249,10 @@
   case TargetOpcode::COPY:
     OS << "get_local push, " << regToString(MI->getOperand(1));
     break;
+  case WebAssembly::GLOBAL:
+    // TODO: wasm64
+    OS << "i32.const push, " << toSymbol(MI->getOperand(1).getGlobal()->getName());
+    break;
   case WebAssembly::ARGUMENT_I32:
   case WebAssembly::ARGUMENT_I64:
   case WebAssembly::ARGUMENT_F32:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14587.39973.patch
Type: text/x-patch
Size: 1111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151111/bc889697/attachment.bin>


More information about the llvm-commits mailing list