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_loc_record_event.h"
12 : #include <climits>
13 : #include "exception_util.h"
14 : #include "ccu_api_exception.h"
15 : #include "ccu_ins_generator_base.h"
16 :
17 : namespace hcomm {
18 : namespace CcuRep {
19 :
20 13 : CcuRepLocRecordEvent::CcuRepLocRecordEvent(CcuInsGeneratorBase* insGenPtr, const CompletedEvent &event, uint32_t mask)
21 13 : : insGenPtr(insGenPtr), event_(event), mask_(mask)
22 : {
23 13 : type = CcuRepType::LOC_RECORD_EVENT;
24 13 : instrCount = insGenPtr->GetInstrCount(type);
25 13 : }
26 :
27 7 : bool CcuRepLocRecordEvent::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
28 : {
29 7 : this->instrId = instrId;
30 7 : translated = true;
31 :
32 7 : insGenPtr->CcuRepLocRecordEventTranslate(ccuKernel, instr, this);
33 :
34 7 : CHK_PRT_THROW(instrId > USHRT_MAX - instrCount,
35 : HCCL_ERROR("[CcuRepLocRecordEvent][Translate] instrId[%u] + instrCount[%u] "
36 : "exceeds the maximum value of unsigned short int.", instrId, instrCount),
37 : Hccl::CcuApiException, "integer overflow");
38 :
39 7 : instrId += instrCount;
40 7 : return translated;
41 : }
42 :
43 7 : std::string CcuRepLocRecordEvent::Describe()
44 : {
45 7 : return Hccl::StringFormat("CcuRepLocRecordEvent=id[%u], mask[%04x]", event_.Id(), mask_);
46 : }
47 :
48 : }; // namespace CcuRep
49 : }; // namespace hcomm
|