diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-09-07 18:29:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-07 18:29:33 -0700 |
commit | a6816a287bd3f802cb6db51032e77145f036c8b7 (patch) | |
tree | 2b13779744aa126688055095bb1c747dc786f265 /src/wasm-type.h | |
parent | 775363a98002a14c64bdc4f8d591c6f37b1e1604 (diff) | |
download | binaryen-a6816a287bd3f802cb6db51032e77145f036c8b7.tar.gz binaryen-a6816a287bd3f802cb6db51032e77145f036c8b7.tar.bz2 binaryen-a6816a287bd3f802cb6db51032e77145f036c8b7.zip |
Stack utils (#3083)
Implement and test utilities for manipulating and analyzing a new
stacky form of Binaryen IR that is able to express arbitrary stack
machine code. This new Poppy IR will eventually replace Stack IR, and
new optimization passes will be built with these utilities. See #3059.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r-- | src/wasm-type.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h index 8a9e58ec9..135c2e751 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -186,15 +186,39 @@ public: return index == other.index && parent == other.parent; } bool operator!=(const Iterator& other) const { return !(*this == other); } - void operator++() { index++; } + Iterator& operator++() { + ++index; + return *this; + } + Iterator& operator--() { + --index; + return *this; + } + Iterator operator++(int) { + auto it = *this; + index++; + return it; + } + Iterator operator--(int) { + auto it = *this; + index--; + return it; + } Iterator& operator+=(difference_type off) { index += off; return *this; } - const Iterator operator+(difference_type off) const { + Iterator operator+(difference_type off) const { return Iterator(*this) += off; } - difference_type operator-(const Iterator& other) { + Iterator& operator-=(difference_type off) { + index -= off; + return *this; + } + Iterator operator-(difference_type off) const { + return Iterator(*this) -= off; + } + difference_type operator-(const Iterator& other) const { assert(parent == other.parent); return index - other.index; } |