[WebAssembly] Add a resize_memory intrinsic.
authorDan Gohman <dan433584@gmail.com>
Fri, 2 Oct 2015 20:10:26 +0000 (20:10 +0000)
committerDan Gohman <dan433584@gmail.com>
Fri, 2 Oct 2015 20:10:26 +0000 (20:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249178 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/IntrinsicsWebAssembly.td
lib/Target/WebAssembly/WebAssemblyInstrMemory.td
test/CodeGen/WebAssembly/memory-addr32.ll
test/CodeGen/WebAssembly/memory-addr64.ll

index 8c67549c2c993b2f9a51458405f31f4bdc44c938..04edae5294fa9e2dac7177129beaee35506b7a0b 100644 (file)
@@ -16,5 +16,6 @@ let TargetPrefix = "wasm" in {  // All intrinsics start with "llvm.wasm.".
 
 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], []>;
 
 }
index 410fd47d370948478ceda3fe3beeebdc3be952d7..ec9a121b3a7e91d33833653807cb026494e43d9a 100644 (file)
@@ -106,3 +106,11 @@ def memory_size_I32 : I<(outs I32:$dst), (ins),
 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]>;
index 3c1173aaac32ee05f1871084c453ea0ab0a1fcfe..a74787fa322a06c5c4d1aa3ae650c1aed407c008 100644 (file)
@@ -7,6 +7,7 @@ target triple = "wasm32-unknown-unknown"
 
 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)
@@ -25,3 +26,12 @@ define i32 @memory_size() {
   %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
+}
index e4a6190b45ccfd177287e7f64870481b1a372d6d..e336179e7f16242792868227e028b837bc1606d9 100644 (file)
@@ -7,6 +7,7 @@ target triple = "wasm64-unknown-unknown"
 
 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)
@@ -25,3 +26,12 @@ define i64 @memory_size() {
   %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
+}