2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "OperationCloner.h"
29 class OperationCloner : public OperationVisitor
32 #define OP(Name) void visit(const operation::Name &o) override;
33 #include "ir/Operations.lst"
37 std::unique_ptr<Operation> releaseClone();
40 std::unique_ptr<Operation> _return_op;
44 void OperationCloner::visit(const operation::Name &o) \
46 assert(!_return_op); \
47 _return_op = std::make_unique<operation::Name>(o); \
49 #include "ir/Operations.lst"
52 std::unique_ptr<Operation> OperationCloner::releaseClone()
55 return std::move(_return_op);
60 std::unique_ptr<Operation> clone(const IOperation &operation)
62 OperationCloner cloner;
63 operation.accept(cloner);
64 return cloner.releaseClone();