diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/string-gathering.wast | 20 | ||||
-rw-r--r-- | test/lit/passes/string-lowering-instructions.wast | 95 |
2 files changed, 115 insertions, 0 deletions
diff --git a/test/lit/passes/string-gathering.wast b/test/lit/passes/string-gathering.wast index 657858fc0..8c315ddc1 100644 --- a/test/lit/passes/string-gathering.wast +++ b/test/lit/passes/string-gathering.wast @@ -27,12 +27,22 @@ ;; CHECK: (global $global2 stringref (global.get $string.const_bar)) ;; LOWER: (type $0 (func)) + ;; LOWER: (type $1 (array (mut i16))) + + ;; LOWER: (type $2 (func (param (ref null $1) i32 i32) (result (ref extern)))) + + ;; LOWER: (type $3 (func (param i32) (result (ref extern)))) + ;; LOWER: (import "string.const" "0" (global $string.const_bar (ref extern))) ;; LOWER: (import "string.const" "1" (global $string.const_other (ref extern))) ;; LOWER: (import "string.const" "2" (global $global (ref extern))) + ;; LOWER: (import "wasm:js-string" "fromCharCodeArray" (func $fromCharCodeArray (type $2) (param (ref null $1) i32 i32) (result (ref extern)))) + + ;; LOWER: (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint (type $3) (param i32) (result (ref extern)))) + ;; LOWER: (global $global2 externref (global.get $string.const_bar)) (global $global2 (ref null string) (string.const "bar")) @@ -111,6 +121,12 @@ ;; Multiple possible reusable globals. Also test ignoring of imports. (module ;; CHECK: (import "a" "b" (global $import (ref string))) + ;; LOWER: (type $0 (array (mut i16))) + + ;; LOWER: (type $1 (func (param (ref null $0) i32 i32) (result (ref extern)))) + + ;; LOWER: (type $2 (func (param i32) (result (ref extern)))) + ;; LOWER: (import "a" "b" (global $import (ref extern))) (import "a" "b" (global $import (ref string))) @@ -122,6 +138,10 @@ ;; LOWER: (import "string.const" "1" (global $global4 (ref extern))) + ;; LOWER: (import "wasm:js-string" "fromCharCodeArray" (func $fromCharCodeArray (type $1) (param (ref null $0) i32 i32) (result (ref extern)))) + + ;; LOWER: (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint (type $2) (param i32) (result (ref extern)))) + ;; LOWER: (global $global2 (ref extern) (global.get $global1)) (global $global2 (ref string) (string.const "foo")) diff --git a/test/lit/passes/string-lowering-instructions.wast b/test/lit/passes/string-lowering-instructions.wast new file mode 100644 index 000000000..05d555ef0 --- /dev/null +++ b/test/lit/passes/string-lowering-instructions.wast @@ -0,0 +1,95 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; RUN: foreach %s %t wasm-opt --string-lowering -all -S -o - | filecheck %s + +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (type $array16 (array (mut i16))) + (type $array16 (array (mut i16))) + + ;; CHECK: (rec + ;; CHECK-NEXT: (type $2 (func (param (ref $array16)))) + + ;; CHECK: (type $3 (func (param externref externref externref externref))) + + ;; CHECK: (type $4 (func (param (ref null $array16) i32 i32) (result (ref extern)))) + + ;; CHECK: (type $5 (func (param i32) (result (ref extern)))) + + ;; CHECK: (import "colliding" "name" (func $fromCodePoint (type $0))) + (import "colliding" "name" (func $fromCodePoint)) + + ;; CHECK: (import "wasm:js-string" "fromCharCodeArray" (func $fromCharCodeArray (type $4) (param (ref null $array16) i32 i32) (result (ref extern)))) + + ;; CHECK: (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint_5 (type $5) (param i32) (result (ref extern)))) + + ;; CHECK: (func $string.as (type $3) (param $a externref) (param $b externref) (param $c externref) (param $d externref) + ;; CHECK-NEXT: (local.set $b + ;; CHECK-NEXT: (local.get $a) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $c + ;; CHECK-NEXT: (local.get $a) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $d + ;; CHECK-NEXT: (local.get $a) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string.as + (param $a stringref) + (param $b stringview_wtf8) + (param $c stringview_wtf16) + (param $d stringview_iter) + ;; These operations all vanish in the lowering, as they all become extref + ;; (JS strings). + (local.set $b + (string.as_wtf8 + (local.get $a) + ) + ) + (local.set $c + (string.as_wtf16 + (local.get $a) + ) + ) + (local.set $d + (string.as_iter + (local.get $a) + ) + ) + ) + + ;; CHECK: (func $string.new.gc (type $2) (param $array16 (ref $array16)) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $fromCharCodeArray + ;; CHECK-NEXT: (local.get $array16) + ;; CHECK-NEXT: (i32.const 7) + ;; CHECK-NEXT: (i32.const 8) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string.new.gc (param $array16 (ref $array16)) + (drop + (string.new_wtf16_array + (local.get $array16) + (i32.const 7) + (i32.const 8) + ) + ) + ) + + ;; CHECK: (func $string.from_code_point (type $0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $fromCodePoint_5 + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string.from_code_point + (drop + (string.from_code_point + (i32.const 1) + ) + ) + ) +) |