From a58281ca114359cd6e65f5daaf086636aa18b0b0 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 4 Jan 2024 14:25:18 -0800 Subject: Require `then` and `else` with `if` (#6201) We previously supported (and primarily used) a non-standard text format for conditionals in which the condition, if-true expression, and if-false expression were all simply s-expression children of the `if` expression. The standard text format, however, requires the use of `then` and `else` forms to introduce the if-true and if-false arms of the conditional. Update the legacy text parser to require the standard format and update all tests to match. Update the printer to print the standard format as well. The .wast and .wat test inputs were mechanically updated with this script: https://gist.github.com/tlively/85ae7f01f92f772241ec994c840ccbb1 --- test/lit/wasm-split/instrument-funcs.wast | 4 ++-- test/lit/wasm-split/instrument-in-memory.wast | 2 +- test/lit/wasm-split/instrument-in-secondary-memory.wast | 2 +- test/lit/wasm-split/instrument-memory64.wast | 2 +- test/lit/wasm-split/jspi-secondary-export.wast | 4 +++- test/lit/wasm-split/jspi.wast | 4 +++- test/lit/wasm-split/multi-memory-lowering-export.wast | 12 ++++++++---- test/lit/wasm-split/multi-memory-lowering-import.wast | 12 ++++++++---- 8 files changed, 27 insertions(+), 15 deletions(-) (limited to 'test/lit/wasm-split') diff --git a/test/lit/wasm-split/instrument-funcs.wast b/test/lit/wasm-split/instrument-funcs.wast index cf3ca4af7..2dbd578f3 100644 --- a/test/lit/wasm-split/instrument-funcs.wast +++ b/test/lit/wasm-split/instrument-funcs.wast @@ -36,7 +36,7 @@ ;; CHECK-NEXT: (i32.eqz ;; CHECK-NEXT: (global.get $baz_timestamp) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (block +;; CHECK-NEXT: (then ;; CHECK-NEXT: (global.set $monotonic_counter ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (global.get $monotonic_counter) @@ -59,7 +59,7 @@ ;; CHECK-NEXT: (local.get $size) ;; CHECK-NEXT: (i32.const 16) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (block +;; CHECK-NEXT: (then ;; CHECK-NEXT: (i64.store align=1 ;; CHECK-NEXT: (local.get $addr) ;; CHECK-NEXT: (i64.const {{.*}}) diff --git a/test/lit/wasm-split/instrument-in-memory.wast b/test/lit/wasm-split/instrument-in-memory.wast index 3208b0b5d..91433d424 100644 --- a/test/lit/wasm-split/instrument-in-memory.wast +++ b/test/lit/wasm-split/instrument-in-memory.wast @@ -49,7 +49,7 @@ ;; CHECK-NEXT: (local.get $size) ;; CHECK-NEXT: (i32.const 16) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (block +;; CHECK-NEXT: (then ;; CHECK-NEXT: (i64.store align=1 ;; CHECK-NEXT: (local.get $addr) ;; CHECK-NEXT: (i64.const {{.*}}) diff --git a/test/lit/wasm-split/instrument-in-secondary-memory.wast b/test/lit/wasm-split/instrument-in-secondary-memory.wast index 26ac0ad18..18a8b0a4f 100644 --- a/test/lit/wasm-split/instrument-in-secondary-memory.wast +++ b/test/lit/wasm-split/instrument-in-secondary-memory.wast @@ -52,7 +52,7 @@ ;; CHECK-NEXT: (local.get $size) ;; CHECK-NEXT: (i32.const 16) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (block +;; CHECK-NEXT: (then ;; CHECK-NEXT: (i64.store $0 align=1 ;; CHECK-NEXT: (local.get $addr) ;; CHECK-NEXT: (i64.const {{.*}}) diff --git a/test/lit/wasm-split/instrument-memory64.wast b/test/lit/wasm-split/instrument-memory64.wast index ff2a56cad..65560d29e 100644 --- a/test/lit/wasm-split/instrument-memory64.wast +++ b/test/lit/wasm-split/instrument-memory64.wast @@ -30,7 +30,7 @@ ;; CHECK-NEXT: (local.get $size) ;; CHECK-NEXT: (i32.const 16) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (block +;; CHECK-NEXT: (then ;; CHECK-NEXT: (i64.store align=1 ;; CHECK-NEXT: (local.get $addr) ;; CHECK-NEXT: (i64.const {{.*}}) diff --git a/test/lit/wasm-split/jspi-secondary-export.wast b/test/lit/wasm-split/jspi-secondary-export.wast index 57fe849a9..3729ec00e 100644 --- a/test/lit/wasm-split/jspi-secondary-export.wast +++ b/test/lit/wasm-split/jspi-secondary-export.wast @@ -62,7 +62,9 @@ ;; PRIMARY-NEXT: (i32.eqz ;; PRIMARY-NEXT: (global.get $global$1) ;; PRIMARY-NEXT: ) -;; PRIMARY-NEXT: (call $__load_secondary_module) +;; PRIMARY-NEXT: (then +;; PRIMARY-NEXT: (call $__load_secondary_module) +;; PRIMARY-NEXT: ) ;; PRIMARY-NEXT: ) ;; PRIMARY-NEXT: (call_indirect (type $0) ;; PRIMARY-NEXT: (local.get $0) diff --git a/test/lit/wasm-split/jspi.wast b/test/lit/wasm-split/jspi.wast index 340b2acec..6866f02ff 100644 --- a/test/lit/wasm-split/jspi.wast +++ b/test/lit/wasm-split/jspi.wast @@ -43,7 +43,9 @@ ;; PRIMARY-NEXT: (i32.eqz ;; PRIMARY-NEXT: (global.get $global$1) ;; PRIMARY-NEXT: ) - ;; PRIMARY-NEXT: (call $__load_secondary_module) + ;; PRIMARY-NEXT: (then + ;; PRIMARY-NEXT: (call $__load_secondary_module) + ;; PRIMARY-NEXT: ) ;; PRIMARY-NEXT: ) ;; PRIMARY-NEXT: (call_indirect (type $0) ;; PRIMARY-NEXT: (i32.const 0) diff --git a/test/lit/wasm-split/multi-memory-lowering-export.wast b/test/lit/wasm-split/multi-memory-lowering-export.wast index 0721ba2a4..152aaf723 100644 --- a/test/lit/wasm-split/multi-memory-lowering-export.wast +++ b/test/lit/wasm-split/multi-memory-lowering-export.wast @@ -55,8 +55,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const -1) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (return -;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: (then +;; CHECK-NEXT: (return +;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (memory.copy @@ -100,8 +102,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const -1) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (return -;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: (then +;; CHECK-NEXT: (return +;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $return_size) diff --git a/test/lit/wasm-split/multi-memory-lowering-import.wast b/test/lit/wasm-split/multi-memory-lowering-import.wast index d62609108..37ccfa16c 100644 --- a/test/lit/wasm-split/multi-memory-lowering-import.wast +++ b/test/lit/wasm-split/multi-memory-lowering-import.wast @@ -52,8 +52,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const -1) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (return -;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: (then +;; CHECK-NEXT: (return +;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (memory.copy @@ -97,8 +99,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const -1) ;; CHECK-NEXT: ) -;; CHECK-NEXT: (return -;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: (then +;; CHECK-NEXT: (return +;; CHECK-NEXT: (i32.const -1) +;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $return_size) -- cgit v1.2.3