From f12024b34808eb5f5b11461936ab3270dcb07630 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, 11 Oct 2018 09:43:54 +0900 Subject: [PATCH] [coco] PadF as a Op tree node (#1817) With this commit, PadF may serve as a node of Op tree. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/PadF.h | 9 +++++++++ contrib/coco/core/src/IR/PadF.cpp | 11 ++++++++++- contrib/coco/core/src/IR/PadF.test.cpp | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/contrib/coco/core/include/coco/IR/PadF.h b/contrib/coco/core/include/coco/IR/PadF.h index fb6cf38..4e3229d 100644 --- a/contrib/coco/core/include/coco/IR/PadF.h +++ b/contrib/coco/core/include/coco/IR/PadF.h @@ -18,6 +18,7 @@ #define __COCO_IR_PAD_F_H__ #include "coco/IR/Op.h" +#include "coco/IR/Part.h" #include "coco/IR/Padding2D.h" namespace coco @@ -43,10 +44,18 @@ public: const PadF *asPadF(void) const override { return this; } public: + Op *arg(void) const { return _arg.child(); } + void arg(Op *arg) { _arg.child(arg); } + +public: Padding2D *pad(void) { return &_pad; } const Padding2D *pad(void) const { return &_pad; } private: + // @brief An argument of PadF operation (= IFM) + Part _arg; + +private: Padding2D _pad; }; diff --git a/contrib/coco/core/src/IR/PadF.cpp b/contrib/coco/core/src/IR/PadF.cpp index 8604165..2b79b86 100644 --- a/contrib/coco/core/src/IR/PadF.cpp +++ b/contrib/coco/core/src/IR/PadF.cpp @@ -19,7 +19,7 @@ namespace coco { -PadF::PadF() +PadF::PadF() : _arg{this} { // DO NOTHING } @@ -28,6 +28,15 @@ std::set PadF::uses(void) const { // NOTE PadF accesses no object std::set res; + + if (auto ifm = arg()) + { + for (auto obj : ifm->uses()) + { + res.insert(obj); + } + } + return res; } diff --git a/contrib/coco/core/src/IR/PadF.test.cpp b/contrib/coco/core/src/IR/PadF.test.cpp index 28ffedd..670213c 100644 --- a/contrib/coco/core/src/IR/PadF.test.cpp +++ b/contrib/coco/core/src/IR/PadF.test.cpp @@ -58,6 +58,9 @@ TEST_F(PadFTest, initialization) // parent() should be nullptr on construction ASSERT_EQ(op->parent(), nullptr); + // arg() should be nullptr on construction + ASSERT_EQ(op->arg(), nullptr); + // pad() should be a valid ASSERT_NE(op->pad(), nullptr); } -- 2.7.4