diff options
author | Alon Zakai <azakai@google.com> | 2019-05-02 11:41:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-02 11:41:34 -0700 |
commit | 01a4bfdb5c28d54fd480d603cba2d35c943a0bf5 (patch) | |
tree | 0bdeeb9096c8c7dec33a990022f920ebadfbd252 /test/passes/alignment-lowering.wast | |
parent | 3b4d9013c6c2dd6cfa90e02e2307a758a0f91140 (diff) | |
download | binaryen-01a4bfdb5c28d54fd480d603cba2d35c943a0bf5.tar.gz binaryen-01a4bfdb5c28d54fd480d603cba2d35c943a0bf5.tar.bz2 binaryen-01a4bfdb5c28d54fd480d603cba2d35c943a0bf5.zip |
Add a pass to lower unaligned loads and stores (#2078)
This replaces the wasm2js code that lowered them to pessimistic (1-byte aligned) loads and stores. The new pass will do the optimal thing, keeping 2-byte alignment where possible.
This is also nicer as a standalone pass, which has the simple property that after it runs all loads and stores are aligned, instead of some code scattered inside wasm2js.
Diffstat (limited to 'test/passes/alignment-lowering.wast')
-rw-r--r-- | test/passes/alignment-lowering.wast | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/passes/alignment-lowering.wast b/test/passes/alignment-lowering.wast new file mode 100644 index 000000000..135fd281e --- /dev/null +++ b/test/passes/alignment-lowering.wast @@ -0,0 +1,63 @@ +(module + (memory $0 1 1) + (func $func_4 + (drop (i32.load (i32.const 4))) + (drop (i32.load align=1 (i32.const 4))) + (drop (i32.load align=2 (i32.const 4))) + (drop (i32.load align=4 (i32.const 4))) + (drop (i32.load offset=100 (i32.const 4))) + (drop (i32.load offset=100 align=1 (i32.const 4))) + (drop (i32.load offset=100 align=2 (i32.const 4))) + (drop (i32.load offset=100 align=4 (i32.const 4))) + (drop (i32.load offset=100 align=1 (unreachable))) + (i32.store (i32.const 4) (i32.const 8)) + (i32.store align=1 (i32.const 4) (i32.const 8)) + (i32.store align=2 (i32.const 4) (i32.const 8)) + (i32.store align=4 (i32.const 4) (i32.const 8)) + (i32.store offset=100 (i32.const 4) (i32.const 8)) + (i32.store offset=100 align=1 (i32.const 4) (i32.const 8)) + (i32.store offset=100 align=2 (i32.const 4) (i32.const 8)) + (i32.store offset=100 align=4 (i32.const 4) (i32.const 8)) + (i32.store offset=100 align=1 (unreachable) (i32.const 8)) + (i32.store offset=100 align=1 (i32.const 4) (unreachable)) + ) + (func $func_2 + (drop (i32.load16_u (i32.const 4))) + (drop (i32.load16_u align=1 (i32.const 4))) + (drop (i32.load16_u align=2 (i32.const 4))) + (drop (i32.load16_u offset=100 (i32.const 4))) + (drop (i32.load16_u offset=100 align=1 (i32.const 4))) + (drop (i32.load16_u offset=100 align=2 (i32.const 4))) + (drop (i32.load16_u offset=100 align=1 (unreachable))) + (i32.store16 (i32.const 4) (i32.const 8)) + (i32.store16 align=1 (i32.const 4) (i32.const 8)) + (i32.store16 align=2 (i32.const 4) (i32.const 8)) + (i32.store16 offset=100 (i32.const 4) (i32.const 8)) + (i32.store16 offset=100 align=1 (i32.const 4) (i32.const 8)) + (i32.store16 offset=100 align=2 (i32.const 4) (i32.const 8)) + (i32.store16 offset=100 align=1 (unreachable) (i32.const 8)) + (i32.store16 offset=100 align=1 (i32.const 4) (unreachable)) + ) + (func $func_1 + (drop (i32.load8_u (i32.const 4))) + (drop (i32.load8_u align=1 (i32.const 4))) + (drop (i32.load8_u offset=100 (i32.const 4))) + (drop (i32.load8_u offset=100 align=1 (i32.const 4))) + (drop (i32.load8_u offset=100 align=1 (unreachable))) + (i32.store8 (i32.const 4) (i32.const 8)) + (i32.store8 align=1 (i32.const 4) (i32.const 8)) + (i32.store8 offset=100 (i32.const 4) (i32.const 8)) + (i32.store8 offset=100 align=1 (i32.const 4) (i32.const 8)) + (i32.store8 offset=100 align=1 (unreachable) (i32.const 8)) + (i32.store8 offset=100 align=1 (i32.const 4) (unreachable)) + ) + (func $func_signed + (drop (i32.load16_s (i32.const 4))) + (drop (i32.load16_s align=1 (i32.const 4))) + (drop (i32.load16_s align=2 (i32.const 4))) + (drop (i32.load16_s offset=100 (i32.const 4))) + (drop (i32.load16_s offset=100 align=1 (i32.const 4))) + (drop (i32.load16_s offset=100 align=2 (i32.const 4))) + (drop (i32.load16_s offset=100 align=1 (unreachable))) + ) +) |