diff options
author | Diego Novillo <dnovillo@google.com> | 2017-11-08 12:40:02 -0500 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2017-11-08 14:03:08 -0500 |
commit | d2938e48427cb6e8d5996712c23496d62e3c08d1 (patch) | |
tree | f3d683cf92c471dfa3ad308ac013bbc1671a8723 /source/opt/compact_ids_pass.cpp | |
parent | f32d11f74b75eb7660375ab295fb9c150c429948 (diff) |
Re-format files in source, source/opt, source/util, source/val and tools.
NFC. This just makes sure every file is formatted following the
formatting definition in .clang-format.
Re-formatted with:
$ clang-format -i $(find source tools include -name '*.cpp')
$ clang-format -i $(find source tools include -name '*.h')
Diffstat (limited to 'source/opt/compact_ids_pass.cpp')
-rw-r--r-- | source/opt/compact_ids_pass.cpp | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/source/opt/compact_ids_pass.cpp b/source/opt/compact_ids_pass.cpp index 5a7c4855..380b75cc 100644 --- a/source/opt/compact_ids_pass.cpp +++ b/source/opt/compact_ids_pass.cpp @@ -30,35 +30,38 @@ Pass::Status CompactIdsPass::Process(ir::IRContext* c) { bool modified = false; std::unordered_map<uint32_t, uint32_t> result_id_mapping; - c->module()->ForEachInst([&result_id_mapping, &modified] (Instruction* inst) { - auto operand = inst->begin(); - while (operand != inst->end()) { - const auto type = operand->type; - if (spvIsIdType(type)) { - assert(operand->words.size() == 1); - uint32_t& id = operand->words[0]; - auto it = result_id_mapping.find(id); - if (it == result_id_mapping.end()) { - const uint32_t new_id = - static_cast<uint32_t>(result_id_mapping.size()) + 1; - const auto insertion_result = result_id_mapping.emplace(id, new_id); - it = insertion_result.first; - assert(insertion_result.second); - } - if (id != it->second) { - modified = true; - id = it->second; - // Update data cached in the instruction object. - if (type == SPV_OPERAND_TYPE_RESULT_ID) { - inst->SetResultId(id); - } else if (type == SPV_OPERAND_TYPE_TYPE_ID) { - inst->SetResultType(id); + c->module()->ForEachInst( + [&result_id_mapping, &modified](Instruction* inst) { + auto operand = inst->begin(); + while (operand != inst->end()) { + const auto type = operand->type; + if (spvIsIdType(type)) { + assert(operand->words.size() == 1); + uint32_t& id = operand->words[0]; + auto it = result_id_mapping.find(id); + if (it == result_id_mapping.end()) { + const uint32_t new_id = + static_cast<uint32_t>(result_id_mapping.size()) + 1; + const auto insertion_result = + result_id_mapping.emplace(id, new_id); + it = insertion_result.first; + assert(insertion_result.second); + } + if (id != it->second) { + modified = true; + id = it->second; + // Update data cached in the instruction object. + if (type == SPV_OPERAND_TYPE_RESULT_ID) { + inst->SetResultId(id); + } else if (type == SPV_OPERAND_TYPE_TYPE_ID) { + inst->SetResultType(id); + } + } } + ++operand; } - } - ++operand; - } - }, true); + }, + true); if (modified) c->SetIdBound(static_cast<uint32_t>(result_id_mapping.size() + 1)); |