diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2021-02-09 14:41:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-09 14:41:49 -0800 |
commit | 9752196fd1357fbc129d1e4f53e8eb22cd6219f9 (patch) | |
tree | fe22a97b4d536687f6567448b45485e4fe24b75d /src/wasm-type.h | |
parent | 3da8b08ecd57f5662bebc69ea73bf59e1928341e (diff) | |
download | binaryen-9752196fd1357fbc129d1e4f53e8eb22cd6219f9.tar.gz binaryen-9752196fd1357fbc129d1e4f53e8eb22cd6219f9.tar.bz2 binaryen-9752196fd1357fbc129d1e4f53e8eb22cd6219f9.zip |
Poppify pass (#3541)
Adds a Poppify ("--poppify") pass for converting normal Binaryen IR to Poppy IR.
Like the existing construction of Stacky IR, Poppify depends on the
BinaryenIRWriter to drive the emitting of instructions in correct stack machine
order. As instructions are "emitted," Poppify replaces their children with pops
and collects them in a list. At the end of each scope, Poppify 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 Poppify pass itself. For now the tests simply skip validation.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r-- | src/wasm-type.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index f5c2fb273..fe1b832bc 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -215,8 +215,11 @@ public: std::string toString() const; - struct Iterator - : std::iterator<std::random_access_iterator_tag, Type, long, Type*, Type&> { + struct Iterator : std::iterator<std::random_access_iterator_tag, + Type, + long, + Type*, + const Type&> { const Type* parent; size_t index; Iterator(const Type* parent, size_t index) : parent(parent), index(index) {} @@ -265,6 +268,12 @@ public: Iterator begin() const { return Iterator(this, 0); } Iterator end() const; + std::reverse_iterator<Iterator> rbegin() const { + return std::make_reverse_iterator(end()); + } + std::reverse_iterator<Iterator> rend() const { + return std::make_reverse_iterator(begin()); + } size_t size() const { return end() - begin(); } const Type& operator[](size_t i) const; }; |