Compare commits
43 Commits
private_ar
...
private_ar
| Author | SHA1 | Date | |
|---|---|---|---|
| fc98972bc2 | |||
| ca77cc05d5 | |||
|
|
a04ee16023 | ||
|
|
0c4f9465df | ||
| 9dbbe9fcdc | |||
| f5d2ecf549 | |||
| eee6f30f94 | |||
|
|
11b3ecba2e | ||
|
|
d4e7b39acd | ||
|
|
d8e5c1bdf6 | ||
|
|
9afdf2a98b | ||
|
|
6091fa474d | ||
|
|
bc9c7cba5c | ||
|
|
c1d94be0be | ||
|
|
d78753888f | ||
|
|
025bbbe259 | ||
|
|
076a0c9699 | ||
|
|
90b311d049 | ||
|
|
5a1377e7ea | ||
|
|
b90d200fad | ||
|
|
331d4f9d99 | ||
|
|
904292f109 | ||
|
|
c36326660c | ||
|
|
ec08e3af0e | ||
|
|
b1ef5d0b67 | ||
| d6c046ea57 | |||
|
|
af85311480 | ||
|
|
d9f54739d2 | ||
|
|
6907f44ac5 | ||
|
|
582d2d5e70 | ||
|
|
1c37336459 | ||
|
|
f527deb02c | ||
| d09e92a947 | |||
|
|
029da32719 | ||
|
|
085e6312a3 | ||
|
|
c5927fe80f | ||
|
|
8728f84546 | ||
|
|
9e4db270fc | ||
|
|
0c20b37923 | ||
|
|
61c6ad1363 | ||
|
|
e5fa2e41b3 | ||
|
|
3b9e4653b6 | ||
|
|
2d84aaff1f |
@@ -10,7 +10,6 @@
|
||||
using namespace std;
|
||||
|
||||
static SgStatement* declPlace = NULL;
|
||||
static unordered_set<SgStatement*> changed;;
|
||||
|
||||
static bool CheckConstIndexes(SgExpression* exp)
|
||||
{
|
||||
@@ -37,13 +36,13 @@ static bool CheckConstIndexes(SgExpression* exp)
|
||||
|
||||
static SgExpression* CreateVar(int& variableNumber, SgType* type)
|
||||
{
|
||||
string varName = "tmp_prop_var";
|
||||
string varName = "__tmp_prop_var";
|
||||
string name = varName + std::to_string(variableNumber) + "__";
|
||||
variableNumber++;
|
||||
|
||||
SgSymbol* varSymbol = new SgSymbol(VARIABLE_NAME, name.c_str(), *type, *declPlace->controlParent());
|
||||
|
||||
const string commonBlockName = "propagation_common__";
|
||||
const string commonBlockName = "__propagation_common__";
|
||||
|
||||
SgStatement* funcStart = declPlace->controlParent();
|
||||
SgStatement* commonStat = NULL;
|
||||
@@ -170,7 +169,8 @@ static SgExpression* CreateVar(int& variableNumber, SgType* type)
|
||||
|
||||
commonList->setLhs(varList);
|
||||
}
|
||||
return new SgExpression(VAR_REF, NULL, NULL, varSymbol, type->copyPtr());
|
||||
|
||||
return new SgExpression(VAR_REF, NULL, NULL, varSymbol, type->copyPtr());
|
||||
}
|
||||
|
||||
static void TransformRightPart(SgStatement* st, SgExpression* exp, unordered_map<string, SgExpression*>& arrayToVariable, int& variableNumber)
|
||||
@@ -227,8 +227,6 @@ static void TransformLeftPart(SgStatement* st, SgExpression* exp, unordered_map<
|
||||
{
|
||||
if (exp->symbol()->type()->variant() == T_STRING)
|
||||
return;
|
||||
if (changed.find(st) != changed.end())
|
||||
return;
|
||||
string expUnparsed = exp->unparse();
|
||||
if (arrayToVariable.find(expUnparsed) == arrayToVariable.end() && exp->symbol()->type()->baseType())
|
||||
{
|
||||
@@ -236,62 +234,12 @@ static void TransformLeftPart(SgStatement* st, SgExpression* exp, unordered_map<
|
||||
}
|
||||
SgStatement* newStatement = new SgStatement(ASSIGN_STAT, NULL, NULL, arrayToVariable[expUnparsed]->copyPtr(), st->expr(1)->copyPtr(), NULL);
|
||||
|
||||
newStatement->setFileId(st->getFileId());
|
||||
newStatement->setFileId(st->getFileId());
|
||||
newStatement->setProject(st->getProject());
|
||||
|
||||
newStatement->setlineNumber(getNextNegativeLineNumber());
|
||||
newStatement->setLocalLineNumber(st->lineNumber());
|
||||
st->insertStmtBefore(*newStatement, *st->controlParent());
|
||||
changed.insert(st);
|
||||
}
|
||||
|
||||
static void TransformBorder(SgStatement* st, SgExpression* exp, unordered_map<string, SgExpression*>& arrayToVariable, int& variableNumber)
|
||||
{
|
||||
SgStatement* firstStatement = declPlace->lexPrev();
|
||||
st = st->lexPrev();
|
||||
string array = exp->unparse();
|
||||
arrayToVariable[array] = CreateVar(variableNumber, exp->symbol()->type()->baseType());
|
||||
while (st != firstStatement)
|
||||
{
|
||||
if (st->variant() == ASSIGN_STAT && arrayToVariable.find(st->expr(0)->unparse()) != arrayToVariable.end())
|
||||
{
|
||||
if (st->expr(1))
|
||||
{
|
||||
TransformRightPart(st, st->expr(1), arrayToVariable, variableNumber);
|
||||
}
|
||||
if (st->expr(0) && st->expr(0)->variant() == ARRAY_REF && CheckConstIndexes(st->expr(0)->lhs()) && arrayToVariable.find(st->expr(0)->unparse()) != arrayToVariable.end())
|
||||
{
|
||||
TransformLeftPart(st, st->expr(0), arrayToVariable, variableNumber);
|
||||
}
|
||||
}
|
||||
st = st->lexPrev();
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckVariable(SgStatement* st, SgExpression* exp, unordered_map<string, SgExpression*>& arrayToVariable, int& variableNumber)
|
||||
{
|
||||
SgStatement* firstStatement = declPlace->lexPrev();
|
||||
st = st->lexPrev();
|
||||
string varName = exp->unparse();
|
||||
while (st != firstStatement)
|
||||
{
|
||||
if (st->variant() == ASSIGN_STAT && st->expr(0)->symbol() == exp->symbol())
|
||||
{
|
||||
TransformRightPart(st, st->expr(1), arrayToVariable, variableNumber);
|
||||
}
|
||||
if (st->variant() == ASSIGN_STAT && arrayToVariable.find(st->expr(0)->unparse()) != arrayToVariable.end())
|
||||
{
|
||||
if (st->expr(1))
|
||||
{
|
||||
TransformRightPart(st, st->expr(1), arrayToVariable, variableNumber);
|
||||
}
|
||||
if (st->expr(0) && st->expr(0)->variant() == ARRAY_REF && CheckConstIndexes(st->expr(0)->lhs()) && arrayToVariable.find(st->expr(0)->unparse()) != arrayToVariable.end())
|
||||
{
|
||||
TransformLeftPart(st, st->expr(0), arrayToVariable, variableNumber);
|
||||
}
|
||||
}
|
||||
st = st->lexPrev();
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayConstantPropagation(SgProject& project)
|
||||
@@ -314,29 +262,40 @@ void ArrayConstantPropagation(SgProject& project)
|
||||
|
||||
for (; st != lastNode; st = st->lexNext())
|
||||
{
|
||||
if (st->variant() == FOR_NODE)
|
||||
if (st->variant() == ASSIGN_STAT)
|
||||
{
|
||||
if (st->expr(1))
|
||||
{
|
||||
TransformRightPart(st, st->expr(1), arrayToVariable, variableNumber);
|
||||
}
|
||||
if (st->expr(0) && st->expr(0)->variant() == ARRAY_REF && CheckConstIndexes(st->expr(0)->lhs()))
|
||||
{
|
||||
TransformLeftPart(st, st->expr(0), arrayToVariable, variableNumber);
|
||||
}
|
||||
}
|
||||
else if (st->variant() == FOR_NODE)
|
||||
{
|
||||
SgExpression* lowerBound = st->expr(0)->lhs();
|
||||
SgExpression* upperBound = st->expr(0)->rhs();
|
||||
string lowerBoundUnparsed = lowerBound->unparse(), upperBoundUnparsed = upperBound->unparse();
|
||||
if (upperBound->variant() == ARRAY_REF && upperBound->symbol()->type()->baseType() && CheckConstIndexes(upperBound->lhs()))
|
||||
{
|
||||
TransformBorder(st, upperBound, arrayToVariable, variableNumber);
|
||||
if (arrayToVariable.find(upperBoundUnparsed) == arrayToVariable.end())
|
||||
{
|
||||
arrayToVariable[upperBoundUnparsed] = CreateVar(variableNumber, upperBound->symbol()->type()->baseType());
|
||||
}
|
||||
st->expr(0)->setRhs(arrayToVariable[upperBoundUnparsed]->copyPtr());
|
||||
}
|
||||
else if (upperBound->variant() == VAR_REF)
|
||||
CheckVariable(st, upperBound, arrayToVariable, variableNumber);
|
||||
|
||||
if (lowerBound->variant() == ARRAY_REF && lowerBound->symbol()->type()->baseType() && CheckConstIndexes(lowerBound->lhs()))
|
||||
{
|
||||
TransformBorder(st, lowerBound, arrayToVariable, variableNumber);
|
||||
if (arrayToVariable.find(lowerBoundUnparsed) == arrayToVariable.end())
|
||||
{
|
||||
arrayToVariable[lowerBoundUnparsed] = CreateVar(variableNumber, lowerBound->symbol()->type()->baseType());
|
||||
}
|
||||
st->expr(0)->setLhs(arrayToVariable[lowerBoundUnparsed]->copyPtr());
|
||||
}
|
||||
else if (lowerBound->variant() == VAR_REF)
|
||||
CheckVariable(st, lowerBound, arrayToVariable, variableNumber);
|
||||
}
|
||||
}
|
||||
cout << file->functions(i)->unparse() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ static void Collapse(Region* region)
|
||||
|
||||
RegionInstruction instruction;
|
||||
instruction.def = move(region->array_def);
|
||||
|
||||
|
||||
|
||||
for (auto& byBlock : region->getBasickBlocks())
|
||||
{
|
||||
@@ -107,13 +107,13 @@ static void Collapse(Region* region)
|
||||
region->array_priv[arrayName] = useUnionB[arrayName].Diff(region->array_use[arrayName]);
|
||||
|
||||
instruction.use = move(region->array_use);
|
||||
|
||||
|
||||
for (Region* prevBlock : region->getHeader()->getPrevRegions())
|
||||
{
|
||||
prevBlock->replaceInNextRegions(region, region->getHeader());
|
||||
region->addPrevRegion(prevBlock);
|
||||
}
|
||||
|
||||
|
||||
for (Region* nextBlock : region->getHeader()->getNextRegions())
|
||||
{
|
||||
nextBlock->replaceInPrevRegions(region, region->getHeader());
|
||||
@@ -123,7 +123,7 @@ static void Collapse(Region* region)
|
||||
|
||||
}
|
||||
|
||||
static void SolveDataFlowIteratively(Region* DFG)
|
||||
static void SolveDataFlowIteratively(Region* DFG)
|
||||
{
|
||||
auto blocks = DFG->getBasickBlocks();
|
||||
std::unordered_set<Region*> worklist(blocks.begin(), blocks.end());
|
||||
@@ -150,7 +150,7 @@ static void SolveDataFlowIteratively(Region* DFG)
|
||||
for (const auto& [arrayName, accessSet] : prevBlock->array_out)
|
||||
{
|
||||
if (newIn.find(arrayName) != newIn.end())
|
||||
newIn[arrayName] = newIn[arrayName].Intersect(accessSet);
|
||||
newIn[arrayName] = newIn[arrayName].Intersect(accessSet);
|
||||
else
|
||||
newIn[arrayName] = AccessingSet();
|
||||
}
|
||||
@@ -160,7 +160,7 @@ static void SolveDataFlowIteratively(Region* DFG)
|
||||
b->array_in = move(newIn);
|
||||
ArrayAccessingIndexes newOut;
|
||||
|
||||
if (b->array_def.empty())
|
||||
if (b->array_def.empty())
|
||||
newOut = b->array_in;
|
||||
else if (b->array_in.empty())
|
||||
newOut = b->array_def;
|
||||
@@ -176,12 +176,11 @@ static void SolveDataFlowIteratively(Region* DFG)
|
||||
}
|
||||
|
||||
/* can not differ */
|
||||
if (newOut != b->array_out)
|
||||
if (newOut != b->array_out)
|
||||
b->array_out = newOut;
|
||||
else
|
||||
worklist.erase(b);
|
||||
}
|
||||
while (!worklist.empty());
|
||||
} while (!worklist.empty());
|
||||
}
|
||||
|
||||
static void SolveForBasickBlock(Region* block)
|
||||
@@ -365,7 +364,7 @@ static void AddPrivateArraysToLoop(LoopGraph* loop, const ArrayAccessingIndexes&
|
||||
}
|
||||
toAdd->setLhs(new SgVarRefExp(elem));
|
||||
}
|
||||
|
||||
|
||||
if (arraysToInsert.size() != 0)
|
||||
{
|
||||
loop->loop->insertStmtBefore(*spfStat, *loop->loop->controlParent());
|
||||
@@ -373,8 +372,8 @@ static void AddPrivateArraysToLoop(LoopGraph* loop, const ArrayAccessingIndexes&
|
||||
}
|
||||
}
|
||||
|
||||
void FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR, set<SgStatement*> &insertedPrivates)
|
||||
{
|
||||
void FindPrivateArrays(map<string, vector<LoopGraph*>>& loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR, set<SgStatement*>& insertedPrivates)
|
||||
{
|
||||
map<LoopGraph*, ArrayAccessingIndexes> result;
|
||||
for (const auto& [fileName, loops] : loopGraph)
|
||||
{
|
||||
@@ -388,8 +387,8 @@ void FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*
|
||||
while (search_func && (!isSgProgHedrStmt(search_func)))
|
||||
search_func = search_func->controlParent();
|
||||
|
||||
for (const auto& [funcInfo, blocks]: FullIR)
|
||||
{
|
||||
for (const auto& [funcInfo, blocks] : FullIR)
|
||||
{
|
||||
if (funcInfo->fileName == fileName && funcInfo->funcPointer->GetOriginal() == search_func)
|
||||
{
|
||||
Region* loopRegion = new Region(loop, blocks);
|
||||
@@ -409,4 +408,4 @@ void FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*
|
||||
AddPrivateArraysToLoop(loop, result[loop], insertedPrivates);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ static ArrayDimension* DimensionIntersection(const ArrayDimension& dim1, const A
|
||||
vector<uint64_t> partSolution = FindParticularSolution(dim1, dim2);
|
||||
if (partSolution.empty())
|
||||
return NULL;
|
||||
|
||||
|
||||
int64_t x0 = partSolution[0], y0 = partSolution[1];
|
||||
/* x = x_0 + c * t */
|
||||
/* y = y_0 + d * t */
|
||||
@@ -44,10 +44,10 @@ static ArrayDimension* DimensionIntersection(const ArrayDimension& dim1, const A
|
||||
uint64_t tMax = min(tXMax, tYMax);
|
||||
if (tMin > tMax)
|
||||
return NULL;
|
||||
|
||||
|
||||
uint64_t start3 = dim1.start + x0 * dim1.step;
|
||||
uint64_t step3 = c * dim1.step;
|
||||
ArrayDimension* result = new(ArrayDimension){ start3, step3, tMax + 1 , dim1.array};
|
||||
ArrayDimension* result = new(ArrayDimension){ start3, step3, tMax + 1 , dim1.array };
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ static vector<ArrayDimension> DimensionDifference(const ArrayDimension& dim1, co
|
||||
ArrayDimension* intersection = DimensionIntersection(dim1, dim2);
|
||||
if (!intersection)
|
||||
return { dim1 };
|
||||
|
||||
|
||||
vector<ArrayDimension> result;
|
||||
/* add the part before intersection */
|
||||
if (dim1.start < intersection->start)
|
||||
result.push_back({ dim1.start, dim1.step, (intersection->start - dim1.start) / dim1.step, dim1.array});
|
||||
|
||||
if (dim1.start < intersection->start)
|
||||
result.push_back({ dim1.start, dim1.step, (intersection->start - dim1.start) / dim1.step, dim1.array });
|
||||
|
||||
/* add the parts between intersection steps */
|
||||
if (intersection->step > dim1.step)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ static vector<ArrayDimension> DimensionDifference(const ArrayDimension& dim1, co
|
||||
uint64_t interValue = intersection->start;
|
||||
for (int64_t i = start; interValue <= intersection->start + intersection->step * (intersection->tripCount - 1); i++)
|
||||
{
|
||||
result.push_back({interValue + dim1.step, dim1.step, intersection->step / dim1.step, dim1.array});
|
||||
result.push_back({ interValue + dim1.step, dim1.step, intersection->step / dim1.step, dim1.array });
|
||||
interValue += intersection->step;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ static vector<ArrayDimension> ElementsIntersection(const vector<ArrayDimension>&
|
||||
{
|
||||
if (firstElement.empty() || secondElement.empty())
|
||||
return {};
|
||||
|
||||
|
||||
size_t dimAmount = firstElement.size();
|
||||
/* check if there is no intersecction */
|
||||
for (size_t i = 0; i < dimAmount; i++)
|
||||
@@ -136,12 +136,12 @@ static vector<vector<ArrayDimension>> ElementsDifference(const vector<ArrayDimen
|
||||
return {};
|
||||
if (secondElement.empty())
|
||||
return { firstElement };
|
||||
|
||||
|
||||
vector<ArrayDimension> intersection = ElementsIntersection(firstElement, secondElement);
|
||||
vector<vector<ArrayDimension>> result;
|
||||
if (intersection.empty())
|
||||
return { firstElement };
|
||||
|
||||
|
||||
for (int i = 0; i < firstElement.size(); i++)
|
||||
{
|
||||
auto dimDiff = DimensionDifference(firstElement[i], secondElement[i]);
|
||||
@@ -293,4 +293,4 @@ bool operator!=(const ArrayAccessingIndexes& lhs, const ArrayAccessingIndexes& r
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -64,14 +64,14 @@ static void BuildLoopIndex(map<string, LoopGraph*>& loopForIndex, LoopGraph* loo
|
||||
static string FindIndexName(int pos, SAPFOR::BasicBlock* block, map<string, LoopGraph*>& loopForIndex) {
|
||||
unordered_set<SAPFOR::Argument*> args = { block->getInstructions()[pos]->getInstruction()->getArg1() };
|
||||
|
||||
for (int i = pos - 1; i >= 0; i--)
|
||||
for (int i = pos - 1; i >= 0; i--)
|
||||
{
|
||||
SAPFOR::Argument* res = block->getInstructions()[i]->getInstruction()->getResult();
|
||||
if (res && args.find(res) != args.end())
|
||||
if (res && args.find(res) != args.end())
|
||||
{
|
||||
SAPFOR::Argument* arg1 = block->getInstructions()[i]->getInstruction()->getArg1();
|
||||
SAPFOR::Argument* arg2 = block->getInstructions()[i]->getInstruction()->getArg2();
|
||||
if (arg1)
|
||||
if (arg1)
|
||||
{
|
||||
string name = arg1->getValue();
|
||||
int idx = name.find('%');
|
||||
@@ -95,7 +95,7 @@ static string FindIndexName(int pos, SAPFOR::BasicBlock* block, map<string, Loop
|
||||
return "";
|
||||
}
|
||||
|
||||
static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAccessingIndexes& def, ArrayAccessingIndexes& use, ArrayAccessingIndexes& all_use, Region* region) {
|
||||
static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAccessingIndexes& def, ArrayAccessingIndexes& use, Region* region) {
|
||||
auto instructions = block->getInstructions();
|
||||
map<string, LoopGraph*> loopForIndex;
|
||||
BuildLoopIndex(loopForIndex, loop);
|
||||
@@ -166,7 +166,7 @@ static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAcces
|
||||
}
|
||||
|
||||
}
|
||||
coeffsForDims = {coeffsForDims.rbegin(), coeffsForDims.rend()};
|
||||
coeffsForDims = { coeffsForDims.rbegin(), coeffsForDims.rend() };
|
||||
|
||||
while (!index_vars.empty() && !refPos.empty() && !coeffsForDims.empty())
|
||||
{
|
||||
@@ -180,22 +180,22 @@ static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAcces
|
||||
string name, full_name = var->getValue();
|
||||
int pos = full_name.find('%');
|
||||
LoopGraph* currentLoop;
|
||||
if (pos != -1)
|
||||
if (pos != -1)
|
||||
{
|
||||
name = full_name.substr(pos + 1);
|
||||
if (loopForIndex.find(name) != loopForIndex.end())
|
||||
currentLoop = loopForIndex[name];
|
||||
currentLoop = loopForIndex[name];
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
name = FindIndexName(currentVarPos, block, loopForIndex);
|
||||
if (name == "")
|
||||
return -1;
|
||||
|
||||
if (loopForIndex.find(name) != loopForIndex.end())
|
||||
currentLoop = loopForIndex[name];
|
||||
currentLoop = loopForIndex[name];
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
@@ -227,7 +227,6 @@ static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAcces
|
||||
else
|
||||
{
|
||||
instruction.use[array_name] = { { accessPoint } };
|
||||
all_use[array_name].Insert(accessPoint);
|
||||
if (def.find(array_name) == def.end())
|
||||
use[array_name].Insert(accessPoint);
|
||||
else
|
||||
@@ -286,7 +285,7 @@ static void SetConnections(unordered_map<SAPFOR::BasicBlock*, Region*>& bbToRegi
|
||||
for (SAPFOR::BasicBlock* nextBlock : block->getNext())
|
||||
if (bbToRegion.find(nextBlock) != bbToRegion.end())
|
||||
bbToRegion[block]->addNextRegion(bbToRegion[nextBlock]);
|
||||
|
||||
|
||||
for (SAPFOR::BasicBlock* prevBlock : block->getPrev())
|
||||
if (bbToRegion.find(prevBlock) != bbToRegion.end())
|
||||
bbToRegion[block]->addPrevRegion(bbToRegion[prevBlock]);
|
||||
@@ -299,17 +298,17 @@ static Region* CreateSubRegion(LoopGraph* loop, const vector<SAPFOR::BasicBlock*
|
||||
auto [header, blockSet] = GetBasicBlocksForLoop(loop, Blocks);
|
||||
RemoveHeaderConnection(header, blockSet, bbToRegion);
|
||||
if (bbToRegion.find(header) != bbToRegion.end())
|
||||
region->setHeader(bbToRegion.at(header));
|
||||
region->setHeader(bbToRegion.at(header));
|
||||
else
|
||||
{
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (SAPFOR::BasicBlock* block : blockSet)
|
||||
if (bbToRegion.find(block) != bbToRegion.end())
|
||||
region->addBasickBlocks(bbToRegion.at(block));
|
||||
|
||||
|
||||
for (LoopGraph* childLoop : loop->children)
|
||||
{
|
||||
if (!childLoop->isFor())
|
||||
@@ -328,7 +327,7 @@ Region::Region(LoopGraph* loop, const vector<SAPFOR::BasicBlock*>& Blocks)
|
||||
{
|
||||
bbToRegion[poiner] = new Region(*poiner);
|
||||
this->basickBlocks.push_back(bbToRegion[poiner]);
|
||||
GetDefUseArray(poiner, loop, bbToRegion[poiner]->array_def, bbToRegion[poiner]->array_use, bbToRegion[poiner]->array_all_use, bbToRegion[poiner]);
|
||||
GetDefUseArray(poiner, loop, bbToRegion[poiner]->array_def, bbToRegion[poiner]->array_use, bbToRegion[poiner]);
|
||||
|
||||
}
|
||||
this->header = bbToRegion[header];
|
||||
@@ -342,4 +341,4 @@ Region::Region(LoopGraph* loop, const vector<SAPFOR::BasicBlock*>& Blocks)
|
||||
subRegions.insert(CreateSubRegion(childLoop, Blocks, bbToRegion));
|
||||
}
|
||||
TopologySort(basickBlocks, this->header);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
std::unordered_set<Region*>& getNextRegions() { return nextRegions; }
|
||||
|
||||
void removeNextRegion(Region* region)
|
||||
void removeNextRegion(Region* region)
|
||||
{
|
||||
if (nextRegions.find(region) != nextRegions.end())
|
||||
nextRegions.erase(region);
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
std::vector<RegionInstruction> instructions;
|
||||
|
||||
ArrayAccessingIndexes array_def, array_use, array_out, array_in, array_priv, array_all_use;
|
||||
ArrayAccessingIndexes array_def, array_use, array_out, array_in, array_priv;
|
||||
|
||||
private:
|
||||
std::vector<Region*> basickBlocks;
|
||||
@@ -79,4 +79,4 @@ private:
|
||||
Region* header;
|
||||
};
|
||||
|
||||
void TopologySort(std::vector<Region*>& basikBlocks, Region* header);
|
||||
void TopologySort(std::vector<Region*>& basikBlocks, Region* header);
|
||||
Reference in New Issue
Block a user