llvm.org GIT mirror llvm / 216303e
[WebAssembly] Add a resize_memory intrinsic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249178 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 4 years ago
4 changed file(s) with 29 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1515
1616 def int_wasm_page_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1717 def int_wasm_memory_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
18 def int_wasm_resize_memory : Intrinsic<[], [llvm_anyint_ty], []>;
1819
1920 }
105105 def memory_size_I64 : I<(outs I64:$dst), (ins),
106106 [(set I64:$dst, (int_wasm_memory_size))]>,
107107 Requires<[HasAddr64]>;
108
109 // Resize memory.
110 def resize_memory_I32 : I<(outs), (ins I32:$delta),
111 [(int_wasm_resize_memory I32:$delta)]>,
112 Requires<[HasAddr32]>;
113 def resize_memory_I64 : I<(outs), (ins I64:$delta),
114 [(int_wasm_resize_memory I64:$delta)]>,
115 Requires<[HasAddr64]>;
66
77 declare i32 @llvm.wasm.page.size.i32() nounwind readnone
88 declare i32 @llvm.wasm.memory.size.i32() nounwind readnone
9 declare void @llvm.wasm.resize.memory.i32(i32) nounwind
910
1011 ; CHECK-LABEL: (func $page_size
1112 ; CHECK-NEXT: (result i32)
2425 %a = call i32 @llvm.wasm.memory.size.i32()
2526 ret i32 %a
2627 }
28
29 ; CHECK-LABEL: (func $resize_memory
30 ; CHECK-NEXT: (param i32)
31 ; CHECK: (resize_memory @0)
32 ; CHECK-NEXT: (return)
33 define void @resize_memory(i32 %n) {
34 call void @llvm.wasm.resize.memory.i32(i32 %n)
35 ret void
36 }
66
77 declare i64 @llvm.wasm.page.size.i64() nounwind readnone
88 declare i64 @llvm.wasm.memory.size.i64() nounwind readnone
9 declare void @llvm.wasm.resize.memory.i64(i64) nounwind
910
1011 ; CHECK-LABEL: (func $page_size
1112 ; CHECK-NEXT: (result i64)
2425 %a = call i64 @llvm.wasm.memory.size.i64()
2526 ret i64 %a
2627 }
28
29 ; CHECK-LABEL: (func $resize_memory
30 ; CHECK-NEXT: (param i64)
31 ; CHECK: (resize_memory @0)
32 ; CHECK-NEXT: (return)
33 define void @resize_memory(i64 %n) {
34 call void @llvm.wasm.resize.memory.i64(i64 %n)
35 ret void
36 }