From 43b538f9ada3d4d7c512b3180baefe37ce735c59 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 28 Jun 2019 10:25:38 +0900 Subject: [PATCH] [loco] Introduce CanonicalNodeDecl.h (#4007) The current implementation requires users to include CanonicalNodeImpl.h additionally. To eliminate such burden, this commit introduces CanonicalNodeDecl.h and revises CanonicalNode.h to includes both decl/impl headers. Signed-off-by: Jonghyun Park --- contrib/loco/include/loco/IR/CanonicalNode.h | 30 +-------------- contrib/loco/include/loco/IR/CanonicalNodeDecl.h | 49 ++++++++++++++++++++++++ contrib/loco/include/loco/IR/Nodes.h | 2 +- contrib/loco/src/IR/CanonicalNode.test.cpp | 1 - 4 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 contrib/loco/include/loco/IR/CanonicalNodeDecl.h diff --git a/contrib/loco/include/loco/IR/CanonicalNode.h b/contrib/loco/include/loco/IR/CanonicalNode.h index 38a24a2..2dcc02e 100644 --- a/contrib/loco/include/loco/IR/CanonicalNode.h +++ b/contrib/loco/include/loco/IR/CanonicalNode.h @@ -17,33 +17,7 @@ #ifndef __LOCO_IR_CANONICAL_NODE_H__ #define __LOCO_IR_CANONICAL_NODE_H__ -#include "loco/IR/Node.h" -#include "loco/IR/Dialect.h" -#include "loco/IR/CanonicalOpcode.h" -#include "loco/IR/CanonicalNodeVisitor.forward.h" - -namespace loco -{ - -struct CanonicalNode : public Node -{ - virtual ~CanonicalNode() = default; - - const Dialect *dialect(void) const final; - virtual CanonicalOpcode opcode(void) const = 0; - - template T accept(CanonicalNodeVisitorBase *) const; - template T accept(CanonicalNodeMutableVisitorBase *); -}; - -template struct CanonicalNodeImpl : public CanonicalNode -{ - virtual ~CanonicalNodeImpl() = default; - - uint32_t opnum(void) const final { return static_cast(Code); } - CanonicalOpcode opcode(void) const final { return Code; } -}; - -} // namespace loco +#include "loco/IR/CanonicalNodeDecl.h" +#include "loco/IR/CanonicalNodeImpl.h" #endif // __LOCO_IR_CANONICAL_NODE_H__ diff --git a/contrib/loco/include/loco/IR/CanonicalNodeDecl.h b/contrib/loco/include/loco/IR/CanonicalNodeDecl.h new file mode 100644 index 0000000..6dadf88 --- /dev/null +++ b/contrib/loco/include/loco/IR/CanonicalNodeDecl.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LOCO_IR_CANONICAL_NODE_DECL_H__ +#define __LOCO_IR_CANONICAL_NODE_DECL_H__ + +#include "loco/IR/Node.h" +#include "loco/IR/Dialect.h" +#include "loco/IR/CanonicalOpcode.h" +#include "loco/IR/CanonicalNodeVisitor.forward.h" + +namespace loco +{ + +struct CanonicalNode : public Node +{ + virtual ~CanonicalNode() = default; + + const Dialect *dialect(void) const final; + virtual CanonicalOpcode opcode(void) const = 0; + + template T accept(CanonicalNodeVisitorBase *) const; + template T accept(CanonicalNodeMutableVisitorBase *); +}; + +template struct CanonicalNodeImpl : public CanonicalNode +{ + virtual ~CanonicalNodeImpl() = default; + + uint32_t opnum(void) const final { return static_cast(Code); } + CanonicalOpcode opcode(void) const final { return Code; } +}; + +} // namespace loco + +#endif // __LOCO_IR_CANONICAL_NODE_H__ diff --git a/contrib/loco/include/loco/IR/Nodes.h b/contrib/loco/include/loco/IR/Nodes.h index 355d629..112f567 100644 --- a/contrib/loco/include/loco/IR/Nodes.h +++ b/contrib/loco/include/loco/IR/Nodes.h @@ -29,7 +29,7 @@ #include "loco/IR/FeatureCodec.h" #include "loco/IR/FilterCodec.h" #include "loco/IR/NodeMixins.h" -#include "loco/IR/CanonicalNode.h" +#include "loco/IR/CanonicalNodeDecl.h" namespace loco { diff --git a/contrib/loco/src/IR/CanonicalNode.test.cpp b/contrib/loco/src/IR/CanonicalNode.test.cpp index 6d0229a..cb61b5e 100644 --- a/contrib/loco/src/IR/CanonicalNode.test.cpp +++ b/contrib/loco/src/IR/CanonicalNode.test.cpp @@ -15,7 +15,6 @@ */ #include "loco/IR/CanonicalNode.h" -#include "loco/IR/CanonicalNodeImpl.h" #include -- 2.7.4