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 % 10 10
Test Date: 2026-07-28 12:11:00 Functions: 100.0 % 5 5

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

Generated by: LCOV version 2.0-1