From: Derek Schuff Date: Tue, 17 Nov 2015 00:20:44 +0000 (+0000) Subject: [WebAssembly] Fix printing of global operands X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=36eebaa409ab1bceb9ad0d4fb8ad7e47d61bd31c;p=oota-llvm.git [WebAssembly] Fix printing of global operands This was regressed in r252656 which wasn't quite NFC. Instead of using a custom instruction as before, use a pattern to select CONST_I32 for the global addrs. Differential Revision: http://reviews.llvm.org/D14587 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253276 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td index c4adeab4c6a..9d595198220 100644 --- a/lib/Target/WebAssembly/WebAssemblyInstrInfo.td +++ b/lib/Target/WebAssembly/WebAssemblyInstrInfo.td @@ -106,10 +106,10 @@ def CONST_F64 : I<(outs F64:$res), (ins f64imm:$imm), [(set F64:$res, fpimm:$imm)], "f64.const\t$res, $imm">; -// Special types of immediates. FIXME: Hard-coded as 32-bit for now. -def GLOBAL : I<(outs I32:$dst), (ins global:$addr), - [(set I32:$dst, (WebAssemblywrapper tglobaladdr:$addr))], - "global\t$dst, $addr">; + +def : Pat<(i32 (WebAssemblywrapper tglobaladdr :$dst)), + (CONST_I32 tglobaladdr :$dst)>; + def JUMP_TABLE : I<(outs I32:$dst), (ins tjumptable_op:$addr), [(set I32:$dst, (WebAssemblywrapper tjumptable:$addr))], "jump_table\t$dst, $addr">; diff --git a/test/CodeGen/WebAssembly/global.ll b/test/CodeGen/WebAssembly/global.ll index 70bbbe7906a..1d818d1e5e6 100644 --- a/test/CodeGen/WebAssembly/global.ll +++ b/test/CodeGen/WebAssembly/global.ll @@ -9,6 +9,13 @@ target triple = "wasm32-unknown-unknown" ; 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,@object ; CHECK: .align 2{{$}} ; CHECK-NEXT: g: