#pragma once #include "../GraphLoop/graph_loops.h" #include "../CFGraph/CFGraph.h" using std::vector; using std::map; using std::string; using std::set; struct ArrayDimension { uint64_t start, step, tripCount; }; class AccessingSet { private: vector> allElements; public: AccessingSet(vector> input) : allElements(input) {}; AccessingSet() {}; vector> GetElements() const; void Insert(const vector& element); void Union(const AccessingSet& source); AccessingSet Intersect(const AccessingSet& secondSet) const; AccessingSet Diff(const AccessingSet& secondSet) const; bool ContainsElement(const vector& element) const; void FindCoveredBy(const vector& element, vector>& result) const; void FindUncovered(const vector& element, vector>& result) const; }; using ArrayAccessingIndexes = map; class Region: public SAPFOR::BasicBlock { public: Region() { header = nullptr; nextRegion = nullptr; } Region(SAPFOR::BasicBlock block) : SAPFOR::BasicBlock::BasicBlock(block) { header = nullptr; nextRegion = nullptr; }; //Region(LoopGraph* loop); Region* GetHeader() { return header; } set GetBasickBlocks() { return basickBlocks; } vector getPrevRegions() { return prevRegions; } Region* getNextRegion() { return nextRegion; } void setPrevRegion(Region* region) { prevRegions.push_back(region); } void setNextRegion(Region* region) { nextRegion = region; } ArrayAccessingIndexes array_def, array_use, array_out, array_in; private: set subRegions, basickBlocks; Region* header; Region* nextRegion; vector prevRegions; }; void Collapse(Region* region); void FindPrivateArrays(map>& loopGraph, map>& FullIR); void GetDimensionInfo(LoopGraph* loop, map>>& loopDimensionsInfo, int level); set GetBasicBlocksForLoop(LoopGraph* loop, vector);