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 #ifndef __LUCI_IR_CIRCLE_IF_H__
18 #define __LUCI_IR_CIRCLE_IF_H__
20 #include "luci/IR/CircleNodeDecl.h"
21 #include "luci/IR/CircleOpcode.h"
23 #include "luci/IR/VariadicArityNode.h"
33 class CircleIf final : public VariadicArityNode<CircleNodeImpl<CircleOpcode::IF>>
36 CircleIf(uint32_t arity, uint32_t out)
37 : VariadicArityNode<CircleNodeImpl<CircleOpcode::IF>>(arity + 1), _output_count(out)
44 uint32_t input_count(void) const { return arity() - 1; }
45 uint32_t output_count(void) const { return _output_count; }
48 Node *cond(void) const { return at(0)->node(); }
49 void cond(Node *node) { at(0)->node(node); }
51 Node *input(uint32_t index) const { return at(index + 1)->node(); }
52 void input(uint32_t index, Node *node) { at(index + 1)->node(node); }
55 int32_t then_branch(void) const { return _then_branch; }
56 void then_branch(int32_t then_branch) { _then_branch = then_branch; }
58 int32_t else_branch(void) const { return _else_branch; }
59 void else_branch(int32_t else_branch) { _else_branch = else_branch; }
62 loco::Graph *then_graph(void) const { return _then_graph; }
63 void then_graph(loco::Graph *then_graph) { _then_graph = then_graph; }
65 loco::Graph *else_graph(void) const { return _else_graph; }
66 void else_graph(loco::Graph *else_graph) { _else_graph = else_graph; }
69 uint32_t _output_count{0};
70 int32_t _then_branch{-1};
71 int32_t _else_branch{-1};
73 loco::Graph *_then_graph{nullptr};
74 loco::Graph *_else_graph{nullptr};
79 #endif // __LUCI_IR_CIRCLE_IF_H__