diff options
author | Thomas Lively <tlively@google.com> | 2023-01-10 13:53:12 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-10 11:53:12 -0800 |
commit | 36e2abbcdd22b2b1707757b49fb4ac8844f28e5d (patch) | |
tree | f869cebf2c8d772f8f85db83f39aadfd6ac6f7cb /test/lit/passes/optimize-instructions-gc-tnh.wast | |
parent | e6efd7b991a9c55115771ea121b0eff2bace7d3e (diff) | |
download | binaryen-36e2abbcdd22b2b1707757b49fb4ac8844f28e5d.tar.gz binaryen-36e2abbcdd22b2b1707757b49fb4ac8844f28e5d.tar.bz2 binaryen-36e2abbcdd22b2b1707757b49fb4ac8844f28e5d.zip |
Represent ref.as_{func,data,i31} with RefCast (#5413)
These operations are deprecated and directly representable as casts, so remove
their opcodes in the internal IR and parse them as casts instead. For now, add
logic to the printing and binary writing of RefCast to continue emitting the
legacy instructions to minimize test changes. The few test changes necessary are
because it is no longer valid to perform a ref.as_func on values outside the
func type hierarchy now that ref.as_func is subject to the ref.cast validation
rules.
RefAsExternInternalize, RefAsExternExternalize, and RefAsNonNull are left
unmodified. A future PR may remove RefAsNonNull as well, since it is also
expressible with casts.
Diffstat (limited to 'test/lit/passes/optimize-instructions-gc-tnh.wast')
-rw-r--r-- | test/lit/passes/optimize-instructions-gc-tnh.wast | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast index 948e03296..502590cde 100644 --- a/test/lit/passes/optimize-instructions-gc-tnh.wast +++ b/test/lit/passes/optimize-instructions-gc-tnh.wast @@ -86,9 +86,7 @@ ;; TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; TNH-NEXT: (drop ;; TNH-NEXT: (ref.cast $struct - ;; TNH-NEXT: (ref.as_data - ;; TNH-NEXT: (local.get $a) - ;; TNH-NEXT: ) + ;; TNH-NEXT: (local.get $a) ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; TNH-NEXT: (i32.const 0) @@ -96,9 +94,7 @@ ;; NO_TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (ref.cast $struct - ;; NO_TNH-NEXT: (ref.as_data - ;; NO_TNH-NEXT: (local.get $a) - ;; NO_TNH-NEXT: ) + ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (i32.const 0) @@ -140,23 +136,23 @@ ) ) - ;; TNH: (func $ref.is_func (type $anyref_=>_i32) (param $a anyref) (result i32) + ;; TNH: (func $ref.is_func (type $funcref_=>_i32) (param $a funcref) (result i32) ;; TNH-NEXT: (drop - ;; TNH-NEXT: (ref.as_func + ;; TNH-NEXT: (ref.as_non_null ;; TNH-NEXT: (local.get $a) ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; TNH-NEXT: (i32.const 1) ;; TNH-NEXT: ) - ;; NO_TNH: (func $ref.is_func (type $anyref_=>_i32) (param $a anyref) (result i32) + ;; NO_TNH: (func $ref.is_func (type $funcref_=>_i32) (param $a funcref) (result i32) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.as_func + ;; NO_TNH-NEXT: (ref.as_non_null ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (i32.const 1) ;; NO_TNH-NEXT: ) - (func $ref.is_func (param $a (ref null any)) (result i32) + (func $ref.is_func (param $a funcref) (result i32) ;; The check must succeed. We can return 1 here, and drop the rest, with or ;; without TNH (in particular, TNH should not just remove the cast but not ;; return a 1). |