mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[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. llvm-svn: 285085
This commit is contained in:
parent
5f785dc222
commit
be114b6520
@ -54,7 +54,12 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
|
||||
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);
|
||||
}
|
||||
|
@ -100,8 +100,11 @@ bool WebAssemblyCallIndirectFixup::runOnMachineFunction(MachineFunction &MF) {
|
||||
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);
|
||||
|
@ -35,7 +35,8 @@ multiclass CALL<WebAssemblyRegClass vt, string prefix> {
|
||||
[(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, string prefix> {
|
||||
(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
|
||||
|
@ -667,23 +667,20 @@ def : Pat<(truncstorei32 I64:$val, (WebAssemblywrapper texternalsym:$off)),
|
||||
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)>;
|
||||
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user