llvm.org GIT mirror llvm / 97c35d1
[WebAssembly] Update grow_memory's return type. The grow_memory instruction now returns the previous memory size. Add the return type to the LLVM intrinsic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292322 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 3 years ago
3 changed file(s) with 10 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
1616 // Note that current_memory is not IntrNoMem because it must be sequenced with
1717 // respect to grow_memory calls.
1818 def int_wasm_current_memory : Intrinsic<[llvm_anyint_ty], [], [IntrReadMem]>;
19 def int_wasm_grow_memory : Intrinsic<[], [llvm_anyint_ty], []>;
19 def int_wasm_grow_memory : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], []>;
2020
2121 }
672672 Requires<[HasAddr32]>;
673673
674674 // Grow memory.
675 def GROW_MEMORY_I32 : I<(outs), (ins i32imm:$flags, I32:$delta),
675 def GROW_MEMORY_I32 : I<(outs I32:$dst), (ins i32imm:$flags, I32:$delta),
676676 [],
677 "grow_memory\t$delta", 0x40>,
677 "grow_memory\t$dst, $delta", 0x40>,
678678 Requires<[HasAddr32]>;
679679
680680 } // Defs = [ARGUMENTS]
55 target triple = "wasm32-unknown-unknown"
66
77 declare i32 @llvm.wasm.current.memory.i32() nounwind readonly
8 declare void @llvm.wasm.grow.memory.i32(i32) nounwind
8 declare i32 @llvm.wasm.grow.memory.i32(i32) nounwind
99
1010 ; CHECK-LABEL: current_memory:
1111 ; CHECK-NEXT: .result i32{{$}}
1818
1919 ; CHECK-LABEL: grow_memory:
2020 ; CHECK-NEXT: .param i32{{$}}
21 ; CHECK: grow_memory $0{{$}}
22 ; CHECK-NEXT: return{{$}}
23 define void @grow_memory(i32 %n) {
24 call void @llvm.wasm.grow.memory.i32(i32 %n)
25 ret void
21 ; CHECK-NEXT: .result i32{{$}}
22 ; CHECK: grow_memory $push0=, $0{{$}}
23 ; CHECK-NEXT: return $pop0{{$}}
24 define i32 @grow_memory(i32 %n) {
25 %a = call i32 @llvm.wasm.grow.memory.i32(i32 %n)
26 ret i32 %a
2627 }