LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/logical - ccu_rep_and.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 66.7 % 27 18
Test Date: 2026-08-04 10:52:23 Functions: 75.0 % 4 3

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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              : #include "ccu_rep_v1.h"
      11              : #include "string_util.h"
      12              : #include "exception_util.h"
      13              : #include "ccu_api_exception.h"
      14              : #include "ccu_ins_generator_v1.h"
      15              : #include "ccu_kernel.h"
      16              : namespace hcomm {
      17              : namespace CcuRep {
      18              : 
      19            2 : CcuRepAnd::CcuRepAnd(CcuInsGeneratorBase* insGenPtr, const Variable &varC, const Variable &varA, const Variable &varB)
      20            2 :     : subType(AndSubType::VAR_AND_VAR_TO_VAR), varA(varA), varB(varB), varC(varC), insGenPtr(insGenPtr)
      21              : {
      22            2 :     type       = CcuRepType::AND;
      23            2 :     instrCount = insGenPtr->GetInstrCount(type);
      24            2 : }
      25              : 
      26            0 : CcuRepAnd::CcuRepAnd(CcuInsGeneratorBase* insGenPtr, const Variable &varC, const Variable &varB)
      27            0 :     : subType(AndSubType::SELF_AND_VAR_VARIABLE), varB(varB), varC(varC), insGenPtr(insGenPtr)
      28              : {
      29            0 :     type       = CcuRepType::AND;
      30            0 :     instrCount = insGenPtr->GetInstrCount(type);
      31            0 : }
      32              : 
      33            2 : bool CcuRepAnd::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &curInstrId, const TransDep &dep)
      34              : {
      35            2 :     Hccl::CHECK_NULLPTR(instr, "[CcuRepAnd::Translate] instr is nullptr!");
      36            2 :     this->instrId = curInstrId;
      37            2 :     translated    = true;
      38            2 :     instrCount = insGenPtr->GetInstrCount(type);
      39            2 :     insGenPtr->CcuRepAndTranslate(ccuKernel, instr, this, dep);
      40            2 :     CHK_PRT_THROW((curInstrId > UINT16_MAX - instrCount),
      41              :         HCCL_ERROR("[CcuRepAnd::Translate]uint16 integer overflow occurs, curInstrId = [%hu], instrCount = [%hu]", curInstrId, instrCount),
      42              :         Hccl::InternalException, "integer overflow");
      43            2 :     curInstrId += instrCount;
      44            2 :     return translated;
      45              : }
      46              : 
      47            2 : std::string CcuRepAnd::Describe()
      48              : {
      49            2 :     switch (subType) {
      50            2 :         case AndSubType::VAR_AND_VAR_TO_VAR: {
      51            2 :             return Hccl::StringFormat("Variable[%u] = Variable[%u] & Variable[%u]", varC.Id(), varA.Id(), varB.Id());
      52              :         }
      53            0 :         case AndSubType::SELF_AND_VAR_VARIABLE: {
      54            0 :             return Hccl::StringFormat("Variable[%u] &= Variable[%u]", varC.Id(), varB.Id());
      55              :         }
      56            0 :         default: {
      57            0 :             return Hccl::StringFormat("Invalid And");
      58              :         }
      59              :     }
      60              : }
      61              : 
      62              : }; // namespace CcuRep
      63              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1