summaryrefslogtreecommitdiff
path: root/test/lit/wasm-split/multi-memory-lowering-export.wast
diff options
context:
space:
mode:
authorAshley Nelson <nashley@google.com>2023-01-03 12:37:35 -0800
committerGitHub <noreply@github.com>2023-01-03 20:37:35 +0000
commit5fefa9361a0d958dd7977907eaf1ae8facf3ba48 (patch)
treebdc3f2973213f34233f57a92e60b2cc9e9d98199 /test/lit/wasm-split/multi-memory-lowering-export.wast
parentf36229b509ddb59e7ab20cd6fd3ccd962e9990a5 (diff)
downloadbinaryen-5fefa9361a0d958dd7977907eaf1ae8facf3ba48.tar.gz
binaryen-5fefa9361a0d958dd7977907eaf1ae8facf3ba48.tar.bz2
binaryen-5fefa9361a0d958dd7977907eaf1ae8facf3ba48.zip
Maintain first memory import/export in Multi-Memory Lowering Pass (#5363)
This PR maintains the first memory's import/export in the single combined memory after multi-memories are lowered.
Diffstat (limited to 'test/lit/wasm-split/multi-memory-lowering-export.wast')
-rw-r--r--test/lit/wasm-split/multi-memory-lowering-export.wast107
1 files changed, 107 insertions, 0 deletions
diff --git a/test/lit/wasm-split/multi-memory-lowering-export.wast b/test/lit/wasm-split/multi-memory-lowering-export.wast
new file mode 100644
index 000000000..e4572d2b4
--- /dev/null
+++ b/test/lit/wasm-split/multi-memory-lowering-export.wast
@@ -0,0 +1,107 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+
+;; RUN: wasm-opt %s --multi-memory-lowering -all -S -o - | filecheck %s
+
+(module
+ (memory $memory1 1)
+ (memory $memory2 1 1)
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (type $i32_=>_i32 (func (param i32) (result i32)))
+
+ ;; CHECK: (global $memory2_byte_offset (mut i32) (i32.const 65536))
+
+ ;; CHECK: (memory $combined_memory 1 1)
+
+ ;; CHECK: (export "mem" (memory $combined_memory))
+ (export "mem" (memory $memory1))
+)
+
+;; CHECK: (func $memory1_size (type $none_=>_i32) (result i32)
+;; CHECK-NEXT: (return
+;; CHECK-NEXT: (i32.div_u
+;; CHECK-NEXT: (global.get $memory2_byte_offset)
+;; CHECK-NEXT: (i32.const 65536)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+
+;; CHECK: (func $memory2_size (type $none_=>_i32) (result i32)
+;; CHECK-NEXT: (return
+;; CHECK-NEXT: (i32.sub
+;; CHECK-NEXT: (memory.size)
+;; CHECK-NEXT: (i32.div_u
+;; CHECK-NEXT: (global.get $memory2_byte_offset)
+;; CHECK-NEXT: (i32.const 65536)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+
+;; CHECK: (func $memory1_grow (type $i32_=>_i32) (param $page_delta i32) (result i32)
+;; CHECK-NEXT: (local $return_size i32)
+;; CHECK-NEXT: (local $memory_size i32)
+;; CHECK-NEXT: (local.set $return_size
+;; CHECK-NEXT: (call $memory1_size)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (local.set $memory_size
+;; CHECK-NEXT: (memory.size)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (if
+;; CHECK-NEXT: (i32.eq
+;; CHECK-NEXT: (memory.grow
+;; CHECK-NEXT: (local.get $page_delta)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (i32.const -1)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (return
+;; CHECK-NEXT: (i32.const -1)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (memory.copy
+;; CHECK-NEXT: (i32.add
+;; CHECK-NEXT: (global.get $memory2_byte_offset)
+;; CHECK-NEXT: (i32.mul
+;; CHECK-NEXT: (local.get $page_delta)
+;; CHECK-NEXT: (i32.const 65536)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (global.get $memory2_byte_offset)
+;; CHECK-NEXT: (i32.sub
+;; CHECK-NEXT: (i32.mul
+;; CHECK-NEXT: (local.get $memory_size)
+;; CHECK-NEXT: (i32.const 65536)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (global.get $memory2_byte_offset)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (global.set $memory2_byte_offset
+;; CHECK-NEXT: (i32.add
+;; CHECK-NEXT: (global.get $memory2_byte_offset)
+;; CHECK-NEXT: (i32.mul
+;; CHECK-NEXT: (local.get $page_delta)
+;; CHECK-NEXT: (i32.const 65536)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (local.get $return_size)
+;; CHECK-NEXT: )
+
+;; CHECK: (func $memory2_grow (type $i32_=>_i32) (param $page_delta i32) (result i32)
+;; CHECK-NEXT: (local $return_size i32)
+;; CHECK-NEXT: (local.set $return_size
+;; CHECK-NEXT: (call $memory2_size)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (if
+;; CHECK-NEXT: (i32.eq
+;; CHECK-NEXT: (memory.grow
+;; CHECK-NEXT: (local.get $page_delta)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (i32.const -1)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (return
+;; CHECK-NEXT: (i32.const -1)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (local.get $return_size)
+;; CHECK-NEXT: )