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 : #ifndef HCCL_CCU_DATATYPE_H
12 : #define HCCL_CCU_DATATYPE_H
13 :
14 : #include <memory>
15 :
16 : #include "ccu_rep_base.h"
17 : #include "../reps/arithmetic/ccu_operator.h"
18 : #include "ccu_rep_context.h"
19 :
20 : namespace Hccl {
21 : namespace CcuRep {
22 :
23 : class Variable;
24 : class Address;
25 :
26 : class CcuPhyRes {
27 : public:
28 56836 : CcuPhyRes() = default;
29 : ~CcuPhyRes() = default;
30 : void Reset(uint16_t id);
31 : void SetDieId(uint16_t dieId);
32 : uint16_t Id() const;
33 : uint16_t DieId() const;
34 :
35 : private:
36 : uint16_t dieId{0};
37 : uint16_t id{0};
38 : };
39 :
40 : class CcuVirRes {
41 : public:
42 : CcuVirRes(CcuRepContext *context);
43 82031 : virtual ~CcuVirRes() = default;
44 : void Reset(uint16_t id);
45 : void Reset(uint16_t id, uint16_t dieId);
46 : void SetDieId(uint16_t dieId);
47 : virtual uint16_t Id() const;
48 : uint16_t DieId() const;
49 : protected:
50 : std::shared_ptr<CcuPhyRes> phyRes{nullptr};
51 : CcuRepContext *context{nullptr};
52 : };
53 :
54 : class Variable : public CcuVirRes {
55 : public:
56 : explicit Variable(CcuRepContext *context = nullptr);
57 : Variable(const Variable& other);
58 : void operator=(Variable&& other);
59 :
60 : void operator=(uint64_t immediate);
61 : void operator=(const Variable &other);
62 : void operator=(CcuArithmeticOperator<Variable, Variable> op);
63 :
64 : CcuArithmeticOperator<Variable, Variable> operator+(const Variable &varB) const;
65 : CcuArithmeticOperator<Variable, Address> operator+(const Address &addrB) const;
66 :
67 : void operator+=(const Variable &other);
68 :
69 : CcuRelationalOperator<Variable, uint64_t> operator!=(uint64_t immediate) const;
70 : CcuRelationalOperator<Variable, uint64_t> operator==(uint64_t immediate) const;
71 : };
72 :
73 : class Address : public CcuVirRes {
74 : public:
75 : explicit Address(CcuRepContext *context = nullptr);
76 : Address(const Address& other);
77 : void operator=(Address&& other);
78 :
79 : void operator=(uint64_t immediate);
80 : void operator=(const Address &other);
81 : void operator=(const Variable &other);
82 :
83 : void operator=(CcuArithmeticOperator<Variable, Address> op);
84 : void operator=(CcuArithmeticOperator<Address, Variable> op);
85 : void operator=(CcuArithmeticOperator<Address, Address> op);
86 :
87 : CcuArithmeticOperator<Variable, Address> operator+(const Variable &varB) const;
88 : CcuArithmeticOperator<Address, Address> operator+(const Address &addrB) const;
89 :
90 : void operator+=(const Variable &other);
91 : };
92 :
93 : class MaskSignal : public CcuVirRes {
94 : public:
95 : explicit MaskSignal(CcuRepContext *context = nullptr);
96 : };
97 :
98 : class CcuBuffer : public CcuVirRes {
99 : public:
100 : explicit CcuBuffer(CcuRepContext *context = nullptr);
101 : uint16_t Id() const override;
102 : static constexpr uint16_t CCUBUFFER_DIE_ID_BIT = 0x8000; // bit15 表示MS所在的IO Die id
103 : };
104 :
105 : class Executor : public CcuVirRes {
106 : public:
107 : explicit Executor(CcuRepContext *context = nullptr);
108 : };
109 :
110 : class Memory {
111 : public:
112 245 : Memory() = default;
113 450 : Memory(Address addr, Variable token) : addr(addr), token(token)
114 : {
115 450 : }
116 : Address addr;
117 : Variable token;
118 : };
119 :
120 : }; // namespace CcuRep
121 : }; // namespace Hccl
122 : #endif // HCCL_CCU_DATATYPE_H
|