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 : #include "ccu_rep.h"
12 :
13 : #include "string_util.h"
14 :
15 : namespace Hccl {
16 : namespace CcuRep {
17 :
18 334 : CcuRepRemPostVar::CcuRepRemPostVar(
19 334 : Variable param, const CcuTransport& transport, uint16_t paramIndex, uint16_t semIndex, uint16_t mask)
20 334 : : param(param),
21 334 : transport(transport),
22 334 : paramIndex(paramIndex),
23 334 : semIndex(semIndex),
24 334 : mask(mask)
25 : {
26 334 : type = CcuRepType::REM_POST_VAR;
27 334 : instrCount = 1;
28 334 : }
29 :
30 39 : bool CcuRepRemPostVar::Translate(CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
31 : {
32 39 : this->instrId = instrId;
33 39 : translated = true;
34 :
35 195 : SyncXnInstr(
36 39 : instr++, transport.GetRmtXnByIndex(paramIndex), param.Id(), transport.GetChannelId(),
37 39 : transport.GetRmtCntCkeByIndex(semIndex), mask, 0, 0, 0, 0, 1);
38 39 : CHK_PRT_THROW(
39 : (instrId > UINT16_MAX - instrCount),
40 : HCCL_ERROR(
41 : "[CcuRepRemPostVar::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]",
42 : instrId, instrCount),
43 : InternalException, "integer overflow");
44 39 : instrId += instrCount;
45 :
46 39 : return translated;
47 : }
48 :
49 39 : std::string CcuRepRemPostVar::Describe()
50 : {
51 : return StringFormat(
52 78 : "Post Variable[%u] To ParamIndex[%u], Use semIndex[%u] and mask[%04x]", param.Id(), paramIndex, semIndex,
53 39 : mask);
54 : }
55 :
56 : }; // namespace CcuRep
57 : }; // namespace Hccl
|