Skip to content

Commit 8f134d8

Browse files
committed
Stackify pass
Adds a Stackify ("--stackify") pass for converting normal Binaryen IR to Poppy IR. Like the existing construction of Stacky IR, Stackify depends on the BinaryenIRWriter to drive the emitting of instructions in correct stack machine order. As instructions are "emitted," Stackify replaces their children with pops and collects them in a list. At the end of each scope, Stackify creates a block containing all the collected instructions for that scope and injects that block into the enclosing scope. All tuple globals and instructions dealing with tuples are also expanded to remove all tuples from the program. The validator currently fails to validate many valid Poppy IR patterns produced in the tests, but fixing that is left as follow-on work to keep this PR focused on the Stackify pass itself. For now the tests simply skip validation.
1 parent 9ed635c commit 8f134d8

File tree

8 files changed

+981
-2
lines changed

8 files changed

+981
-2
lines changed

src/pass.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ struct PassRunner {
171171
PassRunner(const PassRunner&) = delete;
172172
PassRunner& operator=(const PassRunner&) = delete;
173173

174+
// But we can make it easy to create a nested runner
175+
// TODO: Go through and use this in more places
176+
explicit PassRunner(const PassRunner* runner)
177+
: wasm(runner->wasm), allocator(runner->allocator),
178+
options(runner->options), isNested(true) {}
179+
174180
void setDebug(bool debug) {
175181
options.debug = debug;
176182
// validate everything by default if debugging

src/passes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ set(passes_SOURCES
5757
PrintFeatures.cpp
5858
PrintFunctionMap.cpp
5959
RoundTrip.cpp
60+
Stackify.cpp
6061
StackIR.cpp
6162
Strip.cpp
6263
StripTargetFeatures.cpp

0 commit comments

Comments
 (0)