diff --git a/include/inc-deep/deep.hpp b/include/inc-deep/deep.hpp index dfacd1646d93b32e6d6cdf2bd9665f9f08803b08..049ee4564129340a6d55d30525e770994b93537a 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 0000000000000000000000000000000000000000..32193af8bd8fa422ac67ada864101c43b25adaf3 --- /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 67f6b3920ac8c3c5bf6e85ae873af4b0a1457aad..79bc0f4f211546748873c5882c4482657a6ab07b 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