Class to gather some metrics about a region of interest.
| 715 | |
| 716 | // Class to gather some metrics about a region of interest. |
| 717 | void CodeMetrics::Analyze(const Loop& loop) { |
| 718 | CFG& cfg = *loop.GetContext()->cfg(); |
| 719 | |
| 720 | roi_size_ = 0; |
| 721 | block_sizes_.clear(); |
| 722 | |
| 723 | for (uint32_t id : loop.GetBlocks()) { |
| 724 | const BasicBlock* bb = cfg.block(id); |
| 725 | size_t bb_size = 0; |
| 726 | bb->ForEachInst([&bb_size](const Instruction* insn) { |
| 727 | if (insn->opcode() == spv::Op::OpLabel) return; |
| 728 | if (insn->IsNop()) return; |
| 729 | if (insn->opcode() == spv::Op::OpPhi) return; |
| 730 | bb_size++; |
| 731 | }); |
| 732 | block_sizes_[bb->id()] = bb_size; |
| 733 | roi_size_ += bb_size; |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | } // namespace opt |
| 738 | } // namespace spvtools |
no test coverage detected