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: 93.9 % 33 31
Test Date: 2026-07-28 12:11:00 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          227 : CcuRepBlock::CcuRepBlock(const std::string &label) : label(label)
      19              : {
      20          227 :     type = CcuRepType::BLOCK;
      21          227 : }
      22              : 
      23          871 : std::vector<std::shared_ptr<CcuRepBase>> &CcuRepBlock::GetReps()
      24              : {
      25          871 :     return repVec;
      26              : }
      27              : 
      28         2970 : void CcuRepBlock::Append(std::shared_ptr<CcuRepBase> rep)
      29              : {
      30         2970 :     repVec.push_back(rep);
      31         2970 : }
      32              : 
      33          204 : const std::string &CcuRepBlock::GetLabel() const
      34              : {
      35          204 :     return label;
      36              : }
      37              : 
      38          131 : uint16_t CcuRepBlock::InstrCount()
      39              : {
      40          131 :     instrCount = 0;
      41          554 :     for (const auto &repInBlock : repVec) {
      42          423 :         instrCount += repInBlock->InstrCount();
      43              :     }
      44          131 :     return instrCount;
      45              : }
      46              : 
      47           65 : bool CcuRepBlock::Translate(CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
      48              : {
      49           65 :     this->instrId = instrId;
      50           65 :     translated    = true;
      51              : 
      52          202 :     for (const auto &repInBlock : GetReps()) {
      53          137 :         repInBlock->Translate(instr, instrId, dep);
      54              :     }
      55              : 
      56           65 :     return translated;
      57              : }
      58              : 
      59           43 : std::string CcuRepBlock::Describe()
      60              : {
      61           43 :     return StringFormat("RepBlock");
      62              : }
      63              : 
      64            1 : std::shared_ptr<CcuRepBase> CcuRepBlock::GetRepByInstrId(uint16_t instrId)
      65              : {
      66            1 :     for (const auto& rep : GetReps()) {
      67            1 :         const uint16_t repInstrCount = rep->InstrCount();
      68            1 :         if (repInstrCount == 0) {
      69            0 :             continue;
      70              :         }
      71            1 :         const uint16_t startId = rep->StartInstrId();
      72            1 :         const uint16_t endId = startId + repInstrCount - 1;
      73            1 :         if (instrId >= startId && instrId <= endId) {
      74            1 :             return rep;
      75              :         }
      76              :     }
      77            0 :     return nullptr;
      78              : }
      79              : 
      80              : }; // namespace CcuRep
      81              : }; // namespace Hccl
        

Generated by: LCOV version 2.0-1