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_v1.h"
12 : #include "ccu_kernel.h"
13 : #include "ccu_interface_assist_v1.h"
14 :
15 : #include "string_util.h"
16 : #include "exception_util.h"
17 : #include "ccu_api_exception.h"
18 :
19 : #include "ccu_ins_generator_base.h"
20 :
21 : namespace hcomm {
22 : namespace CcuRep {
23 :
24 2 : FuncCall::FuncCall(CcuRepContext* context, std::string label) : context(context), label(label)
25 : {
26 2 : CcuInsGeneratorBase* insGenPtr = context->GetInsGenerator();
27 2 : Hccl::CHECK_NULLPTR(insGenPtr, "[FuncCall::FuncCall](label) insGenPtr is nullptr!");
28 2 : repFuncCall = std::make_shared<CcuRepFuncCall>(insGenPtr, label);
29 2 : }
30 :
31 1 : FuncCall::FuncCall(CcuRepContext* context, const Variable& funcAddr) : context(context)
32 : {
33 1 : CcuInsGeneratorBase* insGenPtr = context->GetInsGenerator();
34 1 : Hccl::CHECK_NULLPTR(insGenPtr, "[FuncCall::FuncCall](funcAddr) insGenPtr is nullptr!");
35 1 : repFuncCall = std::make_shared<CcuRepFuncCall>(insGenPtr, funcAddr);
36 1 : }
37 :
38 3 : void FuncCall::AppendToContext()
39 : {
40 3 : if (context == nullptr) {
41 0 : Hccl::THROW<Hccl::CcuApiException>("context is nullptr, func call, append to context");
42 : }
43 3 : return context->Append(repFuncCall);
44 : }
45 :
46 : }; // namespace CcuRep
47 : }; // namespace hcomm
|