From 21c2c99f8d6f0a37fadd91b0cc3877df5a4ab735 Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Mon, 22 Jul 2019 14:23:30 -0400 Subject: [PATCH] added loop interfaces for deep analysis --- include/inc-deep/deep.hpp | 3 ++ include/inc-deep/loops.hpp | 61 ++++++++++++++++++++++++++++++++++++++ include/irdb-deep | 1 + 3 files changed, 65 insertions(+) create mode 100644 include/inc-deep/loops.hpp diff --git a/include/inc-deep/deep.hpp b/include/inc-deep/deep.hpp index dfacd16..049ee45 100644 --- a/include/inc-deep/deep.hpp +++ b/include/inc-deep/deep.hpp @@ -50,6 +50,9 @@ namespace IRDB_SDK virtual unique_ptr<StaticGlobalStartMap_t > getStaticGlobalRanges() const = 0; virtual unique_ptr<RangeSentinelSet_t > getRangeSentinels() const = 0; + virtual unique_ptr<LoopNest_t> getLoopNest(const Function_t* f) const = 0; + virtual unique_ptr<LoopNest_t> getLoopNest(const ControlFlowGraph_t* cfg) const = 0; + // factories static unique_ptr<DeepAnalysis_t> factory(FileIR_t* firp, const AnalysisEngine_t& ae=aeSTARS, const vector<string>& options={}); }; diff --git a/include/inc-deep/loops.hpp b/include/inc-deep/loops.hpp new file mode 100644 index 0000000..32193af --- /dev/null +++ b/include/inc-deep/loops.hpp @@ -0,0 +1,61 @@ +/* + Copyright 2018-2019 Zephyr Software, LLC. + + 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 <irdb-core> +#include <irdb-cfg> +#include <set> + +namespace IRDB_SDK +{ + using namespace std; + + class Loop_t; // forward decl + + using LoopSet_t = set<Loop_t>; + + class Loop_t + { + protected: + Loop_t() {} + Loop_t(const Loop_t& copy) = delete; + + public: + virtual ~Loop_t(); + virtual BasicBlockSet_t getAllBlocks() const = 0; + virtual BasicBlockSet_t getOuterBlocks() const = 0; + virtual LoopSet_t getInnerLoops() const = 0; + + virtual bool isBlockInLoop (const BasicBlock_t* blk) const = 0; + virtual bool isBlockInInnerLoop (const BasicBlock_t* blk) const = 0; + virtual bool isBlockOuterLoopOnly(const BasicBlock_t* blk) const = 0; + }; + + class LoopNest_t + { + protected: + LoopNest_t() {} + LoopNest_t(const LoopNest_t& copy) = delete; + + public: + virtual ~LoopNest_t() {} + + virtual LoopSet_t getAllLoops() const = 0; + virtual LoopSet_t getOuterLoops() const = 0; + virtual Function_t* getFunction() const = 0; + virtual ControlFlowGraph_t* getCFG() const = 0; + }; +} diff --git a/include/irdb-deep b/include/irdb-deep index 67f6b39..79bc0f4 100644 --- a/include/irdb-deep +++ b/include/irdb-deep @@ -20,6 +20,7 @@ #define IRDB_SDK_deep +#include <inc-deep/loops.hpp> #include <inc-deep/deep.hpp> #endif -- GitLab