LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/ccu/ccu_representation/interface - ccu_condition.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 88.9 % 18 16
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 4 4

            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              : #include "ccu_interface_assist.h"
      13              : 
      14              : #include "string_util.h"
      15              : #include "exception_util.h"
      16              : #include "ccu_api_exception.h"
      17              : 
      18              : namespace Hccl {
      19              : namespace CcuRep {
      20              : 
      21           53 :     Condition::Condition(CcuRepContext* context, CcuRelationalOperator<Variable, uint64_t> rel) : context(context)
      22              :     {
      23           53 :         std::string label = "Condition";
      24           53 :         endLabel = std::make_shared<CcuRepJumpLabel>(label);
      25           53 :         Variable tmp;
      26           53 :         auto ret = CreateVariable(context, tmp);
      27           53 :         if (ret != HcclResult::HCCL_SUCCESS) {
      28            0 :             THROW<CcuApiException>("CreateVariable failed!");
      29              :         }
      30              :         // 当传入条件为真时, 执行Block, 对应不执行Jump
      31           53 :         if (rel.type == CcuRelationalOperatorType::NOT_EQUAL) {
      32           41 :             jump = std::make_shared<CcuRepJumpEQ>(label, tmp, rel.lhs, rel.rhs);
      33           12 :         } else if (rel.type == CcuRelationalOperatorType::EQUAL) {
      34           12 :             jump = std::make_shared<CcuRepJumpNE>(label, tmp, rel.lhs, rel.rhs);
      35              :         } else {
      36            0 :             THROW<CcuApiException>("Unsupported relational operation");
      37              :         }
      38           53 :         jump->Reference(endLabel);
      39              : 
      40           53 :         AppendToContext(context, jump);
      41           53 :     }
      42              : 
      43           53 :     Condition::~Condition() { DECTOR_TRY_CATCH("Condition", AppendToContext(context, endLabel)); }
      44              : 
      45           88 :     bool Condition::Check() const { return !isExecuted; }
      46              : 
      47           44 :     void Condition::Run() { isExecuted = true; }
      48              : 
      49              : }; // namespace CcuRep
      50              : }; // namespace Hccl
        

Generated by: LCOV version 2.0-1