From 6e5a7642f3dc712dcd18387cfd1341a13d60289d 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: Wed, 12 Sep 2018 15:03:48 +0900 Subject: [PATCH] [coco] Introduce defined in Shuffle (#1465) This commit extends Shuffle class with defined method. This 'defined' method allows users to check whether a specified element is specified as a target in Shuffle instruction without using heavy range call. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Shuffle.h | 4 ++++ contrib/coco/core/src/IR/Shuffle.test.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/contrib/coco/core/include/coco/IR/Shuffle.h b/contrib/coco/core/include/coco/IR/Shuffle.h index 4f63c11..6536612 100644 --- a/contrib/coco/core/include/coco/IR/Shuffle.h +++ b/contrib/coco/core/include/coco/IR/Shuffle.h @@ -51,6 +51,10 @@ public: std::set range(void) const; public: + // @brief Return true if a given elem is updated after execution + bool defined(const ElemID &dst) const { return _content.find(dst) != _content.end(); } + +public: /** * Let M be the return of at(N). This means that N-th element in the destination * bag will be filled with the value of M-th element in the source bag. diff --git a/contrib/coco/core/src/IR/Shuffle.test.cpp b/contrib/coco/core/src/IR/Shuffle.test.cpp index c637cf7..a3aa79b 100644 --- a/contrib/coco/core/src/IR/Shuffle.test.cpp +++ b/contrib/coco/core/src/IR/Shuffle.test.cpp @@ -62,3 +62,13 @@ TEST_F(ShuffleTest, range) EXPECT_NE(range.count(coco::ElemID{2}), 0); EXPECT_NE(range.count(coco::ElemID{5}), 0); } + +TEST_F(ShuffleTest, defined) +{ + auto shuffle = allocate(); + + shuffle->insert(coco::ElemID{3}, coco::ElemID{2}); + + EXPECT_TRUE(shuffle->defined(coco::ElemID{2})); + EXPECT_FALSE(shuffle->defined(coco::ElemID{3})); +} -- 2.7.4