def int_wasm_page_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
+def int_wasm_resize_memory : Intrinsic<[], [llvm_anyint_ty], []>;
}
def memory_size_I64 : I<(outs I64:$dst), (ins),
[(set I64:$dst, (int_wasm_memory_size))]>,
Requires<[HasAddr64]>;
+
+// Resize memory.
+def resize_memory_I32 : I<(outs), (ins I32:$delta),
+ [(int_wasm_resize_memory I32:$delta)]>,
+ Requires<[HasAddr32]>;
+def resize_memory_I64 : I<(outs), (ins I64:$delta),
+ [(int_wasm_resize_memory I64:$delta)]>,
+ Requires<[HasAddr64]>;
declare i32 @llvm.wasm.page.size.i32() nounwind readnone
declare i32 @llvm.wasm.memory.size.i32() nounwind readnone
+declare void @llvm.wasm.resize.memory.i32(i32) nounwind
; CHECK-LABEL: (func $page_size
; CHECK-NEXT: (result i32)
%a = call i32 @llvm.wasm.memory.size.i32()
ret i32 %a
}
+
+; CHECK-LABEL: (func $resize_memory
+; CHECK-NEXT: (param i32)
+; CHECK: (resize_memory @0)
+; CHECK-NEXT: (return)
+define void @resize_memory(i32 %n) {
+ call void @llvm.wasm.resize.memory.i32(i32 %n)
+ ret void
+}
declare i64 @llvm.wasm.page.size.i64() nounwind readnone
declare i64 @llvm.wasm.memory.size.i64() nounwind readnone
+declare void @llvm.wasm.resize.memory.i64(i64) nounwind
; CHECK-LABEL: (func $page_size
; CHECK-NEXT: (result i64)
%a = call i64 @llvm.wasm.memory.size.i64()
ret i64 %a
}
+
+; CHECK-LABEL: (func $resize_memory
+; CHECK-NEXT: (param i64)
+; CHECK: (resize_memory @0)
+; CHECK-NEXT: (return)
+define void @resize_memory(i64 %n) {
+ call void @llvm.wasm.resize.memory.i64(i64 %n)
+ ret void
+}