[llvm] r285085 - [WebAssembly] Add immediate fields to call_indirect and memory operators.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 09:55:53 PDT 2016
Author: djg
Date: Tue Oct 25 11:55:52 2016
New Revision: 285085
URL: http://llvm.org/viewvc/llvm-project?rev=285085&view=rev
Log:
[WebAssembly] Add immediate fields to call_indirect and memory operators.
call_indirect, grow_memory, and current_memory now have immediate
operands in the 0xd binary encoding.
Removed:
llvm/trunk/test/CodeGen/WebAssembly/memory-addr64.ll
Modified:
llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td
llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
Modified: llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp?rev=285085&r1=285084&r2=285085&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp Tue Oct 25 11:55:52 2016
@@ -54,7 +54,12 @@ void WebAssemblyInstPrinter::printInst(c
const MCInstrDesc &Desc = MII.get(MI->getOpcode());
if (Desc.isVariadic())
for (auto i = Desc.getNumOperands(), e = MI->getNumOperands(); i < e; ++i) {
- if (i != 0)
+ // FIXME: For CALL_INDIRECT_VOID, don't print a leading comma, because
+ // we have an extra flags operand which is not currently printed, for
+ // compatiblity reasons.
+ if (i != 0 &&
+ (MI->getOpcode() != WebAssembly::CALL_INDIRECT_VOID ||
+ i != Desc.getNumOperands()))
OS << ", ";
printOperand(MI, i, OS);
}
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp?rev=285085&r1=285084&r2=285085&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyCallIndirectFixup.cpp Tue Oct 25 11:55:52 2016
@@ -100,8 +100,11 @@ bool WebAssemblyCallIndirectFixup::runOn
auto Uses = MI.explicit_uses();
MachineInstr::mop_iterator it = Uses.begin();
const MachineOperand MO = *it;
- unsigned num = MI.getOperandNo(it);
- MI.RemoveOperand(num);
+
+ // Set up the flags immediate, which currently has no defined flags
+ // so it's always zero.
+ it->ChangeToImmediate(0);
+
MI.addOperand(MF, MO);
DEBUG(dbgs() << " After transform: " << MI);
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td?rev=285085&r1=285084&r2=285085&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrCall.td Tue Oct 25 11:55:52 2016
@@ -35,7 +35,8 @@ multiclass CALL<WebAssemblyRegClass vt,
[(set vt:$dst, (WebAssemblycall1 I32:$callee))],
"PSEUDO CALL INDIRECT\t$callee">;
} // isCodeGenOnly = 1
- def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins variable_ops),
+
+ def CALL_INDIRECT_#vt : I<(outs vt:$dst), (ins i32imm:$flags, variable_ops),
[],
!strconcat(prefix, "call_indirect\t$dst"),
0x11>;
@@ -54,8 +55,9 @@ multiclass SIMD_CALL<ValueType vt, strin
(WebAssemblycall1 I32:$callee))],
"PSEUDO CALL INDIRECT\t$callee">;
} // isCodeGenOnly = 1
+
def CALL_INDIRECT_#vt : SIMD_I<(outs V128:$dst),
- (ins variable_ops),
+ (ins i32imm:$flags, variable_ops),
[],
!strconcat(prefix, "call_indirect\t$dst"),
0x11>;
@@ -79,7 +81,8 @@ let Uses = [SP32, SP64], isCall = 1 in {
[(WebAssemblycall0 I32:$callee)],
"PSEUDO CALL INDIRECT\t$callee">;
} // isCodeGenOnly = 1
- def CALL_INDIRECT_VOID : I<(outs), (ins variable_ops),
+
+ def CALL_INDIRECT_VOID : I<(outs), (ins i32imm:$flags, variable_ops),
[],
"call_indirect\t", 0x11>;
} // Uses = [SP32,SP64], isCall = 1
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrMemory.td?rev=285085&r1=285084&r2=285085&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrMemory.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrMemory.td Tue Oct 25 11:55:52 2016
@@ -667,23 +667,20 @@ def : Pat<(truncstorei32 I64:$val, (WebA
let Defs = [ARGUMENTS] in {
// Current memory size.
-def CURRENT_MEMORY_I32 : I<(outs I32:$dst), (ins),
- [(set I32:$dst, (int_wasm_current_memory))],
+def CURRENT_MEMORY_I32 : I<(outs I32:$dst), (ins i32imm:$flags),
+ [],
"current_memory\t$dst", 0x3f>,
Requires<[HasAddr32]>;
-def CURRENT_MEMORY_I64 : I<(outs I64:$dst), (ins),
- [(set I64:$dst, (int_wasm_current_memory))],
- "current_memory\t$dst">,
- Requires<[HasAddr64]>;
// Grow memory.
-def GROW_MEMORY_I32 : I<(outs), (ins I32:$delta),
- [(int_wasm_grow_memory I32:$delta)],
+def GROW_MEMORY_I32 : I<(outs), (ins i32imm:$flags, I32:$delta),
+ [],
"grow_memory\t$delta", 0x40>,
Requires<[HasAddr32]>;
-def GROW_MEMORY_I64 : I<(outs), (ins I64:$delta),
- [(int_wasm_grow_memory I64:$delta)],
- "grow_memory\t$delta">,
- Requires<[HasAddr64]>;
} // Defs = [ARGUMENTS]
+
+def : Pat<(int_wasm_current_memory),
+ (CURRENT_MEMORY_I32 0)>;
+def : Pat<(int_wasm_grow_memory I32:$delta),
+ (GROW_MEMORY_I32 0, $delta)>;
Removed: llvm/trunk/test/CodeGen/WebAssembly/memory-addr64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/memory-addr64.ll?rev=285084&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/memory-addr64.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/memory-addr64.ll (removed)
@@ -1,27 +0,0 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
-
-; Test that basic memory operations assemble as expected with 64-bit addresses.
-
-target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128"
-target triple = "wasm64-unknown-unknown"
-
-declare i64 @llvm.wasm.current.memory.i64() nounwind readonly
-declare void @llvm.wasm.grow.memory.i64(i64) nounwind
-
-; CHECK-LABEL: current_memory:
-; CHECK-NEXT: .result i64{{$}}
-; CHECK-NEXT: current_memory $push0={{$}}
-; CHECK-NEXT: return $pop0{{$}}
-define i64 @current_memory() {
- %a = call i64 @llvm.wasm.current.memory.i64()
- ret i64 %a
-}
-
-; CHECK-LABEL: grow_memory:
-; CHECK-NEXT: .param i64{{$}}
-; CHECK: grow_memory $0{{$}}
-; CHECK-NEXT: return{{$}}
-define void @grow_memory(i64 %n) {
- call void @llvm.wasm.grow.memory.i64(i64 %n)
- ret void
-}
More information about the llvm-commits
mailing list