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