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_BASE
12 : #define CCU_REPRESENTATION_BASE
13 :
14 : #include <string>
15 :
16 : #include "ccu_common.h"
17 : #include "ccu_microcode_v1.h"
18 : #include "ccu_rep_type_v1.h"
19 : #include "hcomm_primitives.h"
20 :
21 : namespace hcomm {
22 :
23 : class CcuKernel;
24 :
25 : namespace CcuRep {
26 :
27 : class CcuInsGeneratorBase;
28 : class CcuInsGeneratorV1;
29 : class CcuInsGeneratorV2;
30 :
31 : struct TransDep {
32 : int32_t logicalId;
33 : uint16_t dieId;
34 : uint16_t reserveXnId;
35 : uint16_t reserveGsaId;
36 : uint16_t reserveCkeId;
37 : uint16_t reserveChannalId[2]; // 0: selfLoopBack; 1: inter die, 0xffff为无效值,rep翻译时检查
38 : uint64_t xnBaseAddr[CCU_MAX_IODIE_NUM];
39 : uint64_t ccuResSpaceTokenInfo;
40 : uint64_t memTokenInfo;
41 : uint16_t commXn[3]; // 3个Xn
42 : uint16_t commGsa[2]; // 2个GSA
43 : uint16_t commSignal; // 1个CKE
44 : uint16_t loadXnId;
45 : bool isFuncBlock;
46 : };
47 :
48 : class CcuRepBase {
49 : public:
50 : explicit CcuRepBase();
51 : virtual ~CcuRepBase();
52 : virtual bool Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep) = 0;
53 : virtual std::string Describe() = 0;
54 0 : virtual uint32_t GetId() { return 0; }
55 :
56 : CcuRepType Type() const;
57 : bool Translated() const;
58 : uint16_t StartInstrId() const;
59 : virtual uint16_t InstrCount();
60 :
61 : protected:
62 : CcuRepType type{CcuRepType::BASE};
63 : bool translated{false};
64 : uint16_t instrId{0};
65 : uint16_t instrCount{0};
66 : };
67 :
68 : }; // namespace CcuRep
69 : }; // namespace hcomm
70 : #endif // _CCU_REPRESENTATION_BASE
|