LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/control - ccu_rep_jump_v1.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 7 7
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 7 7

            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              : 
      11              : #ifndef CCU_REPRESENTATION_JUMP_H
      12              : #define CCU_REPRESENTATION_JUMP_H
      13              : 
      14              : #include <memory>
      15              : 
      16              : #include "ccu_datatype_v1.h"
      17              : #include "ccu_rep_base_v1.h"
      18              : #include "ccu_rep_jumplabel_v1.h"
      19              : #include "ccu_types.h"
      20              : 
      21              : namespace hcomm {
      22              : namespace CcuRep {
      23              : 
      24              :     enum class ConditionType { EQUAL, NOT_EQUAL, GREATER_THAN, GREATER_EQUAL, LESS_THAN, LESS_EQUAL, DEFAULT, INVALID };
      25              : 
      26              :     class CcuRepJumpBase : public CcuRepBase {
      27              :     public:
      28              :         explicit CcuRepJumpBase(
      29              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId);
      30              :         explicit CcuRepJumpBase(
      31              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
      32              :             const Variable& expectedVar, const Variable& condition);
      33              :         void Reference(std::shared_ptr<CcuRepJumpLabel> refRep);
      34              :         void ValidateInsGeneratorForJump();
      35              : 
      36          140 :         std::shared_ptr<CcuRepJumpLabel> GetJumpLabel() { return jumpLabel; }
      37              : 
      38          265 :         Variable& GetTargetInstrId() { return targetInstrId; }
      39              : 
      40          112 :         Variable& GetCondition() { return condition; }
      41              : 
      42           25 :         Variable& GetExpectedVar() { return expectedVar; }
      43              : 
      44          112 :         uint64_t GetExpectedNum() { return expected; }
      45              : 
      46          245 :         CcuInstr* GetInstr() { return instr; }
      47              : 
      48           25 :         bool IsComparedWithImmd() { return comp2Immed; }
      49              : 
      50              :     protected:
      51              :         CcuResult InitInstr(CcuInstr*& instr, uint16_t& instrId);
      52              : 
      53              :         CcuInsGeneratorBase* insGeneratorPtr_;
      54              :         std::string label;
      55              :         std::shared_ptr<CcuRepJumpLabel> jumpLabel{nullptr};
      56              :         Variable targetInstrId;
      57              :         CcuInstr* instr{nullptr};
      58              : 
      59              :         bool comp2Immed{false};
      60              :         bool supportCcuV1{true}; // 暂定用于识别 使用特定的构造方法时是否支持A5的翻译流程
      61              : 
      62              :         Variable expectedVar;
      63              :         Variable condition;
      64              :         uint64_t expected{0};
      65              :     };
      66              : 
      67              :     class CcuRepJump : public CcuRepJumpBase {
      68              :     public:
      69              :         explicit CcuRepJump(CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId);
      70              :         bool Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep) override;
      71              :         std::string Describe() override;
      72              :     };
      73              : 
      74              :     class CcuRepJumpNE : public CcuRepJumpBase {
      75              :     public:
      76              :         CcuRepJumpNE(
      77              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
      78              :             const Variable& expectedVar, const Variable& condition, uint64_t expected);
      79              :         CcuRepJumpNE(
      80              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
      81              :             const Variable& condition, const Variable& expectedVar); // 仅用于A6翻译
      82              :         bool Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep) override;
      83              :         std::string Describe() override;
      84              :     };
      85              : 
      86              :     class CcuRepJumpEQ : public CcuRepJumpBase {
      87              :     public:
      88              :         CcuRepJumpEQ(
      89              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
      90              :             const Variable& expectedVar, const Variable& condition, uint64_t expected);
      91              :         CcuRepJumpEQ(
      92              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
      93              :             const Variable& condition, const Variable& expectedVar); // 仅用于A6翻译
      94              :         bool Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep) override;
      95              :         std::string Describe() override;
      96              :     };
      97              : 
      98              :     class CcuRepJumpLE : public CcuRepJumpBase {
      99              :     public:
     100              :         CcuRepJumpLE(
     101              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     102              :             const Variable& condition, const Variable& expectedVar);
     103              :         CcuRepJumpLE(
     104              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     105              :             const Variable& expectedVar, const Variable& condition, uint64_t expected);
     106              :         bool Translate(CcuKernel* ccuKernel, CcuInstr*& curInstr, uint16_t& curInstrId, const TransDep& dep) override;
     107              :         std::string Describe() override;
     108              :     };
     109              : 
     110              :     class CcuRepJumpGE : public CcuRepJumpBase {
     111              :     public:
     112              :         CcuRepJumpGE(
     113              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     114              :             const Variable& condition, const Variable& expectedVar);
     115              :         CcuRepJumpGE(
     116              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     117              :             const Variable& expectedVar, const Variable& condition, uint64_t expected);
     118              :         bool Translate(CcuKernel* ccuKernel, CcuInstr*& curInstr, uint16_t& curInstrId, const TransDep& dep) override;
     119              :         std::string Describe() override;
     120              :     };
     121              : 
     122              :     class CcuRepJumpGT : public CcuRepJumpBase {
     123              :     public:
     124              :         CcuRepJumpGT(
     125              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     126              :             const Variable& condition, const Variable& expectedVar);
     127              :         CcuRepJumpGT(
     128              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     129              :             const Variable& expectedVar, const Variable& condition, uint64_t expected);
     130              :         bool Translate(CcuKernel* ccuKernel, CcuInstr*& curInstr, uint16_t& curInstrId, const TransDep& dep) override;
     131              :         std::string Describe() override;
     132              :     };
     133              : 
     134              :     class CcuRepJumpLT : public CcuRepJumpBase {
     135              :     public:
     136              :         CcuRepJumpLT(
     137              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     138              :             const Variable& condition, const Variable& expectedVar);
     139              :         CcuRepJumpLT(
     140              :             CcuInsGeneratorBase* insGenPtr, const std::string& label, const Variable& targetInstrId,
     141              :             const Variable& expectedVar, const Variable& condition, uint64_t expected);
     142              :         bool Translate(CcuKernel* ccuKernel, CcuInstr*& curInstr, uint16_t& curInstrId, const TransDep& dep) override;
     143              :         std::string Describe() override;
     144              :     };
     145              : }; // namespace CcuRep
     146              : }; // namespace hcomm
     147              : #endif // _CCU_REPRESENTATION_JUMP_H
        

Generated by: LCOV version 2.0-1