From 3cdca2736a5916c0a4f85493f75ade695d604f89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 25 Oct 2018 09:36:38 +0900 Subject: [PATCH] [coco] Remove reads/updates from Instr (#1968) With this commit, there is no need to implement reads/updates method for each Instr, which makes it easy to introduce a new instruction. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Instr.h | 8 ----- contrib/coco/core/include/coco/IR/Instrs.h | 12 ------- contrib/coco/core/src/IR/Copy.cpp | 52 ------------------------------ contrib/coco/core/src/IR/Eval.cpp | 38 ---------------------- contrib/coco/core/src/IR/Eval.test.cpp | 2 -- contrib/coco/core/src/IR/Shuffle.cpp | 18 ----------- contrib/coco/core/src/IR/Shuffle.test.cpp | 2 -- 7 files changed, 132 deletions(-) delete mode 100644 contrib/coco/core/src/IR/Copy.cpp diff --git a/contrib/coco/core/include/coco/IR/Instr.h b/contrib/coco/core/include/coco/IR/Instr.h index 8de9e0f..66afc4c 100644 --- a/contrib/coco/core/include/coco/IR/Instr.h +++ b/contrib/coco/core/include/coco/IR/Instr.h @@ -25,8 +25,6 @@ #include "coco/ADT/DLinkedList.h" -#include - #include namespace coco @@ -170,12 +168,6 @@ public: void accept(IMutator &&m) { return accept(&m); } public: - /** @brief Returns a set of bags that Instr reads during execution */ - virtual std::set reads(void) const = 0; - /** @brief Returns a set of bags that Instr updates during execution */ - virtual std::set updates(void) const = 0; - -public: const InstrIndex &index(void) const { return _index; } private: diff --git a/contrib/coco/core/include/coco/IR/Instrs.h b/contrib/coco/core/include/coco/IR/Instrs.h index 6411973..a303463 100644 --- a/contrib/coco/core/include/coco/IR/Instrs.h +++ b/contrib/coco/core/include/coco/IR/Instrs.h @@ -49,10 +49,6 @@ public: const Eval *asEval(void) const override { return this; } public: - std::set reads(void) const override; - std::set updates(void) const override; - -public: Instr *loc(void) override { return this; } public: @@ -98,10 +94,6 @@ public: const Copy *asCopy(void) const override { return this; } public: - std::set reads(void) const override; - std::set updates(void) const override; - -public: Instr *loc(void) override { return this; } public: @@ -133,10 +125,6 @@ public: const Shuffle *asShuffle(void) const override { return this; } public: - std::set reads(void) const override; - std::set updates(void) const override; - -public: Instr *loc(void) override { return this; } public: diff --git a/contrib/coco/core/src/IR/Copy.cpp b/contrib/coco/core/src/IR/Copy.cpp deleted file mode 100644 index bc50501..0000000 --- a/contrib/coco/core/src/IR/Copy.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ - -#include "coco/IR/Instrs.h" - -namespace coco -{ - -std::set Copy::reads(void) const -{ - std::set res; - - if (auto o = _from.value()) - { - if (auto b = o->bag()) - { - res.insert(b); - } - } - - return res; -} - -std::set Copy::updates(void) const -{ - std::set res; - - if (auto o = _into.value()) - { - if (auto b = o->bag()) - { - res.insert(b); - } - } - - return res; -} - -} // namespace coco diff --git a/contrib/coco/core/src/IR/Eval.cpp b/contrib/coco/core/src/IR/Eval.cpp index c8fb822..dcf5790 100644 --- a/contrib/coco/core/src/IR/Eval.cpp +++ b/contrib/coco/core/src/IR/Eval.cpp @@ -17,20 +17,6 @@ #include "coco/IR/Instrs.h" #include "coco/IR/Op.h" -#include - -namespace -{ -std::set &operator+=(std::set &res, const coco::Object *o) -{ - if (o != nullptr && o->bag() != nullptr) - { - res.insert(o->bag()); - } - return res; -} -} // namespace - namespace coco { @@ -39,28 +25,4 @@ Eval::Eval() : _out{this}, _step{this} // DO NOTHING } -std::set Eval::reads(void) const -{ - std::set res; - - if (auto e = op()) - { - for (auto obj : e->uses()) - { - res += obj; - } - } - - return res; -} - -std::set Eval::updates(void) const -{ - std::set res; - - res += out(); - - return res; -} - } // namespace coco diff --git a/contrib/coco/core/src/IR/Eval.test.cpp b/contrib/coco/core/src/IR/Eval.test.cpp index 88db660..6469f67 100644 --- a/contrib/coco/core/src/IR/Eval.test.cpp +++ b/contrib/coco/core/src/IR/Eval.test.cpp @@ -46,8 +46,6 @@ TEST_F(EvalTest, constructor) ASSERT_EQ(ins->out(), nullptr); ASSERT_EQ(ins->op(), nullptr); - ASSERT_TRUE(ins->reads().empty()); - ASSERT_TRUE(ins->updates().empty()); } TEST_F(EvalTest, asEval) diff --git a/contrib/coco/core/src/IR/Shuffle.cpp b/contrib/coco/core/src/IR/Shuffle.cpp index 2269906..6f8a9d2 100644 --- a/contrib/coco/core/src/IR/Shuffle.cpp +++ b/contrib/coco/core/src/IR/Shuffle.cpp @@ -47,24 +47,6 @@ std::set Shuffle::range(void) const void Shuffle::insert(const ElemID &from, const ElemID &into) { _content[into] = from; } -std::set Shuffle::reads(void) const -{ - std::set res; - - res += from(); - - return res; -} - -std::set Shuffle::updates(void) const -{ - std::set res; - - res += into(); - - return res; -} - void Shuffle::from(Bag *b) { _from.bag(b); } void Shuffle::into(Bag *b) { _into.bag(b); } diff --git a/contrib/coco/core/src/IR/Shuffle.test.cpp b/contrib/coco/core/src/IR/Shuffle.test.cpp index ab21808..f564c08 100644 --- a/contrib/coco/core/src/IR/Shuffle.test.cpp +++ b/contrib/coco/core/src/IR/Shuffle.test.cpp @@ -46,8 +46,6 @@ TEST_F(ShuffleTest, constructor) ASSERT_EQ(ins->from(), nullptr); ASSERT_EQ(ins->into(), nullptr); - ASSERT_TRUE(ins->reads().empty()); - ASSERT_TRUE(ins->updates().empty()); } TEST_F(ShuffleTest, asShuffle) -- 2.7.4