diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-05-21 13:25:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-21 13:25:14 -0700 |
commit | 1a3c1a58cc7e97a846f612baf7f74a370980458f (patch) | |
tree | cbe62ea58b2c0dd6d98225265419fea0b829aeab /src/ir/LocalGraph.cpp | |
parent | d78be9ac6c02910bbf8ac71118e68adff4fdc570 (diff) | |
download | binaryen-1a3c1a58cc7e97a846f612baf7f74a370980458f.tar.gz binaryen-1a3c1a58cc7e97a846f612baf7f74a370980458f.tar.bz2 binaryen-1a3c1a58cc7e97a846f612baf7f74a370980458f.zip |
Reflect instruction renaming in code (#2128)
- Reflected new renamed instruction names in code and tests:
- `get_local` -> `local.get`
- `set_local` -> `local.set`
- `tee_local` -> `local.tee`
- `get_global` -> `global.get`
- `set_global` -> `global.set`
- `current_memory` -> `memory.size`
- `grow_memory` -> `memory.grow`
- Removed APIs related to old instruction names in Binaryen.js and added
APIs with new names if they are missing.
- Renamed `typedef SortedVector LocalSet` to `SetsOfLocals` to prevent
name clashes.
- Resolved several TODO renaming items in wasm-binary.h:
- `TableSwitch` -> `BrTable`
- `I32ConvertI64` -> `I32WrapI64`
- `I64STruncI32` -> `I64SExtendI32`
- `I64UTruncI32` -> `I64UExtendI32`
- `F32ConvertF64` -> `F32DemoteI64`
- `F64ConvertF32` -> `F64PromoteF32`
- Renamed `BinaryenGetFeatures` and `BinaryenSetFeatures` to
`BinaryenModuleGetFeatures` and `BinaryenModuleSetFeatures` for
consistency.
Diffstat (limited to 'src/ir/LocalGraph.cpp')
-rw-r--r-- | src/ir/LocalGraph.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/ir/LocalGraph.cpp b/src/ir/LocalGraph.cpp index a66009ec2..dd7046351 100644 --- a/src/ir/LocalGraph.cpp +++ b/src/ir/LocalGraph.cpp @@ -31,7 +31,7 @@ struct Info { // actions occurring in this block: local.gets and local.sets std::vector<Expression*> actions; // for each index, the last local.set for it - std::unordered_map<Index, SetLocal*> lastSets; + std::unordered_map<Index, LocalSet*> lastSets; }; // flow helper class. flows the gets to their sets @@ -55,8 +55,8 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { // cfg traversal work - static void doVisitGetLocal(Flower* self, Expression** currp) { - auto* curr = (*currp)->cast<GetLocal>(); + static void doVisitLocalGet(Flower* self, Expression** currp) { + auto* curr = (*currp)->cast<LocalGet>(); // if in unreachable code, skip if (!self->currBasicBlock) { return; @@ -65,8 +65,8 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { self->locations[curr] = currp; } - static void doVisitSetLocal(Flower* self, Expression** currp) { - auto* curr = (*currp)->cast<SetLocal>(); + static void doVisitLocalSet(Flower* self, Expression** currp) { + auto* curr = (*currp)->cast<LocalSet>(); // if in unreachable code, skip if (!self->currBasicBlock) { return; @@ -95,11 +95,11 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { // scanning them linearly is efficient, avoiding hash computations (while // in Info, it's convenient to have a map so we can assign them easily, // where the last one seen overwrites the previous; and, we do that O(1)). - std::vector<std::pair<Index, SetLocal*>> lastSets; + std::vector<std::pair<Index, LocalSet*>> lastSets; }; auto numLocals = func->getNumLocals(); - std::vector<std::vector<GetLocal*>> allGets; + std::vector<std::vector<LocalGet*>> allGets; allGets.resize(numLocals); std::vector<FlowBlock*> work; @@ -158,11 +158,11 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { // move towards the front, handling things as we go for (int i = int(actions.size()) - 1; i >= 0; i--) { auto* action = actions[i]; - if (auto* get = action->dynCast<GetLocal>()) { + if (auto* get = action->dynCast<LocalGet>()) { allGets[get->index].push_back(get); } else { // This set is the only set for all those gets. - auto* set = action->cast<SetLocal>(); + auto* set = action->cast<LocalSet>(); auto& gets = allGets[set->index]; for (auto* get : gets) { getSetses[get].insert(set); @@ -202,7 +202,7 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { auto lastSet = std::find_if(pred->lastSets.begin(), pred->lastSets.end(), - [&](std::pair<Index, SetLocal*>& value) { + [&](std::pair<Index, LocalSet*>& value) { return value.first == index; }); if (lastSet != pred->lastSets.end()) { @@ -248,13 +248,13 @@ LocalGraph::LocalGraph(Function* func) { void LocalGraph::computeInfluences() { for (auto& pair : locations) { auto* curr = pair.first; - if (auto* set = curr->dynCast<SetLocal>()) { - FindAll<GetLocal> findAll(set->value); + if (auto* set = curr->dynCast<LocalSet>()) { + FindAll<LocalGet> findAll(set->value); for (auto* get : findAll.list) { getInfluences[get].insert(set); } } else { - auto* get = curr->cast<GetLocal>(); + auto* get = curr->cast<LocalGet>(); for (auto* set : getSetses[get]) { setInfluences[set].insert(get); } @@ -263,7 +263,7 @@ void LocalGraph::computeInfluences() { } void LocalGraph::computeSSAIndexes() { - std::unordered_map<Index, std::set<SetLocal*>> indexSets; + std::unordered_map<Index, std::set<LocalSet*>> indexSets; for (auto& pair : getSetses) { auto* get = pair.first; auto& sets = pair.second; @@ -273,7 +273,7 @@ void LocalGraph::computeSSAIndexes() { } for (auto& pair : locations) { auto* curr = pair.first; - if (auto* set = curr->dynCast<SetLocal>()) { + if (auto* set = curr->dynCast<LocalSet>()) { auto& sets = indexSets[set->index]; if (sets.size() == 1 && *sets.begin() != curr) { // While it has just one set, it is not the right one (us), |