2 * Copyright (c) 2019 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 #ifndef __LOCOEX_IR_CIRCLENODE_VISITOR_H__
18 #define __LOCOEX_IR_CIRCLENODE_VISITOR_H__
20 #include "CircleNode.h"
22 #include <oops/InternalExn.h>
28 * DO NOT use this class. Use CircleNodeVisitor instead.
30 template <typename T> struct CircleNodeVisitorBase
32 virtual ~CircleNodeVisitorBase() = default;
34 #define CIRCLE_NODE(OPCODE, Circle_CLASS) virtual T visit(const Circle_CLASS *) = 0;
36 #include "CircleNodes.lst"
40 template <typename T> struct CircleNodeVisitor : public CircleNodeVisitorBase<T>
42 virtual ~CircleNodeVisitor() = default;
44 #define CIRCLE_NODE(OPCODE, Circle_CLASS) \
46 virtual T visit(const Circle_CLASS *node) { return visit(static_cast<const CircleNode *>(node)); }
48 #include "CircleNodes.lst"
51 /// @brief Default fallback
52 virtual T visit(const CircleNode *) { INTERNAL_EXN("CircleNodeVisistor: NYI node"); }
56 * DO NOT use this class. Use CircleNodeMutableVisitor instead.
58 template <typename T> struct CircleNodeMutableVisitorBase
60 virtual ~CircleNodeMutableVisitorBase() = default;
62 #define CIRCLE_NODE(OPCODE, Circle_CLASS) virtual T visit(Circle_CLASS *) = 0;
64 #include "CircleNodes.lst"
68 template <typename T> struct CircleNodeMutableVisitor : public CircleNodeMutableVisitorBase<T>
70 virtual ~CircleNodeMutableVisitor() = default;
72 #define CIRCLE_NODE(OPCODE, Circle_CLASS) \
74 virtual T visit(Circle_CLASS *node) { return visit(static_cast<CircleNode *>(node)); }
76 #include "CircleNodes.lst"
79 /// @brief Default fallback
80 virtual T visit(CircleNode *) { INTERNAL_EXN("CircleMutableNodeVisistor: NYI node"); }
85 #endif // __LOCOEX_IR_CIRCLENODE_VISITOR_H__