From 2aa0cf300998c62aea8cc6698f8325653a9f0895 Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Wed, 9 Sep 2020 13:01:21 -0700 Subject: Poppy IR wast parsing and validation (#3105) Adds an IR profile to each function so the validator can determine which validation rules to apply and adds a flag to have the wast parser set the profile to Poppy for testing purposes. --- src/ir/stack-utils.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/ir/stack-utils.h') diff --git a/src/ir/stack-utils.h b/src/ir/stack-utils.h index 89ec7d47e..fc23b6080 100644 --- a/src/ir/stack-utils.h +++ b/src/ir/stack-utils.h @@ -33,7 +33,10 @@ // stack type of each instruction. Pops may not have `unreachable` type. // // 4. Only control flow structures and instructions that have polymorphic -// unreachable behavior in WebAssembly may have unreachable type. +// unreachable behavior in WebAssembly may have unreachable type. Blocks may +// be unreachable when they are not branch targets and when they have an +// unreachable child. Note that this means a block may be unreachable even +// if it would otherwise have a concrete type, unlike in Binaryen IR. // // For example, the following Binaryen IR Function: // @@ -58,7 +61,10 @@ // ) // // Notice that the sequence of instructions in the block is now identical to the -// sequence of instructions in raw WebAssembly. +// sequence of instructions in raw WebAssembly. Also note that Poppy IR's +// validation rules are largely additional on top of the normal Binaryen IR +// validation rules, with the only exceptions being block body validation and +// block unreahchability rules. // #ifndef wasm_ir_stack_h @@ -75,6 +81,10 @@ namespace StackUtils { // Iterate through `block` and remove nops. void removeNops(Block* block); +// Whether `expr` may be unreachable in Poppy IR. True for control flow +// structures and polymorphic unreachable instructions. +bool mayBeUnreachable(Expression* expr); + } // namespace StackUtils // Stack signatures are like regular function signatures, but they are used to -- cgit v1.2.3