diff options
author | Alon Zakai <azakai@google.com> | 2024-05-09 15:00:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 15:00:13 -0700 |
commit | 7b2e0190213487b5d2505fe86aa9bbbd30e80fcc (patch) | |
tree | 2ae614b27102d83452b0f075612c7558c4493aa6 /src/wasm.h | |
parent | 006181bb98118c70d36e84e6f1f72b5d60264817 (diff) | |
download | binaryen-7b2e0190213487b5d2505fe86aa9bbbd30e80fcc.tar.gz binaryen-7b2e0190213487b5d2505fe86aa9bbbd30e80fcc.tar.bz2 binaryen-7b2e0190213487b5d2505fe86aa9bbbd30e80fcc.zip |
[StackIR] Run StackIR during binary writing and not as a pass (#6568)
Previously we had passes --generate-stack-ir, --optimize-stack-ir, --print-stack-ir
that could be run like any other passes. After generating StackIR it was stashed on
the function and invalidated if we modified BinaryenIR. If it wasn't invalidated then
it was used during binary writing. This PR switches things so that we optionally
generate, optimize, and print StackIR only during binary writing. It also removes
all traces of StackIR from wasm.h - after this, StackIR is a feature of binary writing
(and printing) logic only.
This is almost NFC, but there are some minor noticeable differences:
1. We no longer print has StackIR in the text format when we see it is there. It
will not be there during normal printing, as it is only present during binary writing.
(but --print-stack-ir still works as before; as mentioned above it runs during writing).
2. --generate/optimize/print-stack-ir change from being passes to being flags that
control that behavior instead. As passes, their order on the commandline mattered,
while now it does not, and they only "globally" affect things during writing.
3. The C API changes slightly, as there is no need to pass it an option "optimize" to
the StackIR APIs. Whether we optimize is handled by --optimize-stack-ir which is
set like other optimization flags on the PassOptions object, so we don't need the
old option to those C APIs.
The main benefit here is simplifying the code, so we don't need to think about
StackIR in more places than just binary writing. That may also allow future
improvements to our usage of StackIR.
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/src/wasm.h b/src/wasm.h index d852950e8..ebc7b908d 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2136,14 +2136,6 @@ struct BinaryLocations { std::unordered_map<Function*, FunctionLocations> functions; }; -// Forward declarations of Stack IR, as functions can contain it, see -// the stackIR property. -// Stack IR is a secondary IR to the main IR defined in this file (Binaryen -// IR). See wasm-stack.h. -class StackInst; - -using StackIR = std::vector<StackInst*>; - class Function : public Importable { public: HeapType type = HeapType(Signature()); // parameters and return value @@ -2153,16 +2145,6 @@ public: // The body of the function Expression* body = nullptr; - // If present, this stack IR was generated from the main Binaryen IR body, - // and possibly optimized. If it is present when writing to wasm binary, - // it will be emitted instead of the main Binaryen IR. - // - // Note that no special care is taken to synchronize the two IRs - if you - // emit stack IR and then optimize the main IR, you need to recompute the - // stack IR. The Pass system will throw away Stack IR if a pass is run - // that declares it may modify Binaryen IR. - std::unique_ptr<StackIR> stackIR; - // local names. these are optional. std::unordered_map<Index, Name> localNames; std::unordered_map<Name, Index> localIndices; @@ -2511,8 +2493,6 @@ std::ostream& operator<<(std::ostream& o, wasm::Function& func); std::ostream& operator<<(std::ostream& o, wasm::Expression& expression); std::ostream& operator<<(std::ostream& o, wasm::ModuleExpression pair); std::ostream& operator<<(std::ostream& o, wasm::ShallowExpression expression); -std::ostream& operator<<(std::ostream& o, wasm::StackInst& inst); -std::ostream& operator<<(std::ostream& o, wasm::StackIR& ir); } // namespace std |