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 :
50 : protected:
51 : std::shared_ptr<CcuPhyRes> phyRes{nullptr};
52 : CcuRepContext* context{nullptr};
53 : };
54 :
55 : class Variable : public CcuVirRes {
56 : public:
57 : explicit Variable(CcuRepContext* context = nullptr);
58 : Variable(const Variable& other);
59 : void operator=(Variable&& other);
60 :
61 : void operator=(uint64_t immediate);
62 : void operator=(const Variable& other);
63 : void operator=(CcuArithmeticOperator<Variable, Variable> op);
64 :
65 : CcuArithmeticOperator<Variable, Variable> operator+(const Variable& varB) const;
66 : CcuArithmeticOperator<Variable, Address> operator+(const Address& addrB) const;
67 :
68 : void operator+=(const Variable& other);
69 :
70 : CcuRelationalOperator<Variable, uint64_t> operator!=(uint64_t immediate) const;
71 : CcuRelationalOperator<Variable, uint64_t> operator==(uint64_t immediate) const;
72 : };
73 :
74 : class Address : public CcuVirRes {
75 : public:
76 : explicit Address(CcuRepContext* context = nullptr);
77 : Address(const Address& other);
78 : void operator=(Address&& other);
79 :
80 : void operator=(uint64_t immediate);
81 : void operator=(const Address& other);
82 : void operator=(const Variable& other);
83 :
84 : void operator=(CcuArithmeticOperator<Variable, Address> op);
85 : void operator=(CcuArithmeticOperator<Address, Variable> op);
86 : void operator=(CcuArithmeticOperator<Address, Address> op);
87 :
88 : CcuArithmeticOperator<Variable, Address> operator+(const Variable& varB) const;
89 : CcuArithmeticOperator<Address, Address> operator+(const Address& addrB) const;
90 :
91 : void operator+=(const Variable& other);
92 : };
93 :
94 : class MaskSignal : public CcuVirRes {
95 : public:
96 : explicit MaskSignal(CcuRepContext* context = nullptr);
97 : };
98 :
99 : class CcuBuffer : public CcuVirRes {
100 : public:
101 : explicit CcuBuffer(CcuRepContext* context = nullptr);
102 : uint16_t Id() const override;
103 : static constexpr uint16_t CCUBUFFER_DIE_ID_BIT = 0x8000; // bit15 表示MS所在的IO Die id
104 : };
105 :
106 : class Executor : public CcuVirRes {
107 : public:
108 : explicit Executor(CcuRepContext* context = nullptr);
109 : };
110 :
111 : class Memory {
112 : public:
113 245 : Memory() = default;
114 450 : Memory(Address addr, Variable token) : addr(addr), token(token) {}
115 : Address addr;
116 : Variable token;
117 : };
118 :
119 : }; // namespace CcuRep
120 : }; // namespace Hccl
121 : #endif // HCCL_CCU_DATATYPE_H
|