LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/ccu/ccu_representation/reps/common - ccu_rep_block.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 92.3 % 26 24
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 8 8

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "ccu_rep.h"
      12              : 
      13              : #include "string_util.h"
      14              : 
      15              : namespace Hccl {
      16              : namespace CcuRep {
      17              : 
      18          213 :     CcuRepBlock::CcuRepBlock(const std::string& label) : label(label) { type = CcuRepType::BLOCK; }
      19              : 
      20          352 :     std::vector<std::shared_ptr<CcuRepBase>>& CcuRepBlock::GetReps() { return repVec; }
      21              : 
      22         2674 :     void CcuRepBlock::Append(std::shared_ptr<CcuRepBase> rep) { repVec.push_back(rep); }
      23              : 
      24          157 :     const std::string& CcuRepBlock::GetLabel() const { return label; }
      25              : 
      26           99 :     uint16_t CcuRepBlock::InstrCount()
      27              :     {
      28           99 :         instrCount = 0;
      29          338 :         for (const auto& repInBlock : repVec) {
      30          239 :             instrCount += repInBlock->InstrCount();
      31              :         }
      32           99 :         return instrCount;
      33              :     }
      34              : 
      35           53 :     bool CcuRepBlock::Translate(CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
      36              :     {
      37           53 :         this->instrId = instrId;
      38           53 :         translated = true;
      39              : 
      40          134 :         for (const auto& repInBlock : GetReps()) {
      41           81 :             repInBlock->Translate(instr, instrId, dep);
      42              :         }
      43              : 
      44           53 :         return translated;
      45              :     }
      46              : 
      47           39 :     std::string CcuRepBlock::Describe() { return StringFormat("RepBlock"); }
      48              : 
      49            1 :     std::shared_ptr<CcuRepBase> CcuRepBlock::GetRepByInstrId(uint16_t instrId)
      50              :     {
      51            1 :         for (const auto& rep : GetReps()) {
      52            1 :             const uint16_t repInstrCount = rep->InstrCount();
      53            1 :             if (repInstrCount == 0) {
      54            0 :                 continue;
      55              :             }
      56            1 :             const uint16_t startId = rep->StartInstrId();
      57            1 :             const uint16_t endId = startId + repInstrCount - 1;
      58            1 :             if (instrId >= startId && instrId <= endId) {
      59            1 :                 return rep;
      60              :             }
      61              :         }
      62            0 :         return nullptr;
      63              :     }
      64              : 
      65              : }; // namespace CcuRep
      66              : }; // namespace Hccl
        

Generated by: LCOV version 2.0-1