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 : #include <climits>
13 :
14 : #include "string_util.h"
15 :
16 : namespace Hccl {
17 : namespace CcuRep {
18 :
19 13 : CcuRepLocPostSem::CcuRepLocPostSem(const MaskSignal& sem, uint16_t mask) : sem(sem), mask(mask)
20 : {
21 13 : type = CcuRepType::LOC_POST_SEM;
22 13 : instrCount = 1;
23 13 : }
24 :
25 11 : bool CcuRepLocPostSem::Translate(CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
26 : {
27 11 : this->instrId = instrId;
28 11 : translated = true;
29 :
30 11 : SetCKEInstr(instr++, sem.Id(), mask, 0, 0, 1);
31 :
32 11 : if (instrId > USHRT_MAX - instrCount) {
33 1 : THROW<InternalException>(StringFormat(
34 : "[CcuRepLocPostSem][Translate] instrId[%u] + instrCount[%u] exceeds the "
35 : "maximum value of unsigned short int.",
36 1 : instrId, instrCount));
37 : }
38 10 : instrId += instrCount;
39 :
40 10 : return translated;
41 : }
42 :
43 11 : std::string CcuRepLocPostSem::Describe() { return StringFormat("Set Sem[%u], mask[%04x]", sem.Id(), mask); }
44 :
45 : }; // namespace CcuRep
46 : }; // namespace Hccl
|