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);
}
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);
[(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>;
(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>;
[(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
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)>;
+++ /dev/null
-; 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
-}