Merge branch 'master' into task-create-implicit-pass
This commit is contained in:
@@ -25,6 +25,7 @@ extern "C" void exit(int status);
|
|||||||
|
|
||||||
#include "extcxx_low.h"
|
#include "extcxx_low.h"
|
||||||
extern "C" int number_of_ll_node;
|
extern "C" int number_of_ll_node;
|
||||||
|
extern "C" PTR_SYMB last_file_symbol;
|
||||||
|
|
||||||
#undef USER
|
#undef USER
|
||||||
|
|
||||||
@@ -1641,9 +1642,11 @@ SgFile &SgProject::file(int i)
|
|||||||
|
|
||||||
current_file_id = i;
|
current_file_id = i;
|
||||||
current_file = pt;
|
current_file = pt;
|
||||||
|
|
||||||
#ifdef __SPF
|
#ifdef __SPF
|
||||||
SgStatement::setCurrProcessFile(pt->filename());
|
SgStatement::setCurrProcessFile(pt->filename());
|
||||||
SgStatement::setCurrProcessLine(0);
|
SgStatement::setCurrProcessLine(0);
|
||||||
|
last_file_symbol = file->cur_symb;
|
||||||
#endif
|
#endif
|
||||||
return *pt;
|
return *pt;
|
||||||
}
|
}
|
||||||
@@ -1771,12 +1774,13 @@ int SgFile::switchToFile(const std::string &name)
|
|||||||
SgFile *file = &(CurrentProject->file(it->second.second));
|
SgFile *file = &(CurrentProject->file(it->second.second));
|
||||||
current_file_id = it->second.second;
|
current_file_id = it->second.second;
|
||||||
current_file = file;
|
current_file = file;
|
||||||
|
|
||||||
SgStatement::setCurrProcessFile(file->filename());
|
SgStatement::setCurrProcessFile(file->filename());
|
||||||
SgStatement::setCurrProcessLine(0);
|
SgStatement::setCurrProcessLine(0);
|
||||||
|
last_file_symbol = current_file->filept->cur_symb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return it->second.second;
|
return it->second.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ int getLastLabelId();
|
|||||||
int isItInSection();
|
int isItInSection();
|
||||||
int Init_Tool_Box();
|
int Init_Tool_Box();
|
||||||
void Message();
|
void Message();
|
||||||
|
|
||||||
PTR_BFND rec_num_near_search();
|
PTR_BFND rec_num_near_search();
|
||||||
PTR_BFND Redo_Bif_Next_Chain_Internal();
|
PTR_BFND Redo_Bif_Next_Chain_Internal();
|
||||||
PTR_SYMB duplicateSymbol();
|
PTR_SYMB duplicateSymbol();
|
||||||
@@ -94,7 +95,6 @@ enum typenode node_code_kind[LAST_CODE];
|
|||||||
char info_type[LAST_CODE][MAXFIELDTYPE];
|
char info_type[LAST_CODE][MAXFIELDTYPE];
|
||||||
char info_symb[LAST_CODE][MAXFIELDSYMB];
|
char info_symb[LAST_CODE][MAXFIELDSYMB];
|
||||||
char general_info[LAST_CODE][MAXFIELDSYMB];
|
char general_info[LAST_CODE][MAXFIELDSYMB];
|
||||||
|
|
||||||
/*static struct bif_stack_level *stack_level = NULL;*/
|
/*static struct bif_stack_level *stack_level = NULL;*/
|
||||||
/*static struct bif_stack_level *current_level = NULL;*/
|
/*static struct bif_stack_level *current_level = NULL;*/
|
||||||
|
|
||||||
@@ -549,6 +549,7 @@ void Message(char *s, int l)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/* A set of functions for dealing with a free list for low_level node */
|
/* A set of functions for dealing with a free list for low_level node */
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
@@ -1203,14 +1204,12 @@ int Init_Tool_Box()
|
|||||||
number_of_ll_node = CUR_FILE_NUM_LLNDS() + 1;
|
number_of_ll_node = CUR_FILE_NUM_LLNDS() + 1;
|
||||||
number_of_bif_node = CUR_FILE_NUM_BIFS() + 1;
|
number_of_bif_node = CUR_FILE_NUM_BIFS() + 1;
|
||||||
number_of_symb_node = CUR_FILE_NUM_SYMBS() + 1;
|
number_of_symb_node = CUR_FILE_NUM_SYMBS() + 1;
|
||||||
last_file_symbol = CUR_FILE_CUR_SYMB(); /* podd 23.06.15 */
|
|
||||||
|
|
||||||
if (CUR_FILE_NAME()) strcpy(Current_File_name, CUR_FILE_NAME());
|
if (CUR_FILE_NAME()) strcpy(Current_File_name, CUR_FILE_NAME());
|
||||||
if (ToolBOX_INIT)
|
if (ToolBOX_INIT)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ToolBOX_INIT = 1;
|
ToolBOX_INIT = 1;
|
||||||
|
|
||||||
make_a_malloc_stack();
|
make_a_malloc_stack();
|
||||||
|
|
||||||
/* initialisation des noeuds */
|
/* initialisation des noeuds */
|
||||||
|
|||||||
@@ -736,10 +736,11 @@ void Init_Unparser()
|
|||||||
/* set the first tabulation */
|
/* set the first tabulation */
|
||||||
TabNumber = 1;
|
TabNumber = 1;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
{
|
else
|
||||||
if (Parser_Initiated != C_Initialized)
|
{
|
||||||
{
|
if (Parser_Initiated != C_Initialized)
|
||||||
|
{
|
||||||
#define DEFNODECODE(SYM, NAME, TYPE, LENGTH, NT) Unparse_Def[SYM].str = create_unp_str( NAME);
|
#define DEFNODECODE(SYM, NAME, TYPE, LENGTH, NT) Unparse_Def[SYM].str = create_unp_str( NAME);
|
||||||
#include"unparseC++.def"
|
#include"unparseC++.def"
|
||||||
#undef DEFNODECODE
|
#undef DEFNODECODE
|
||||||
@@ -747,12 +748,15 @@ void Init_Unparser()
|
|||||||
#define DEFNODECODE(SYM, NAME, TYPE, LENGTH, NT) Unparse_Def[SYM].fct = NULL;
|
#define DEFNODECODE(SYM, NAME, TYPE, LENGTH, NT) Unparse_Def[SYM].fct = NULL;
|
||||||
#include"unparseC++.def"
|
#include"unparseC++.def"
|
||||||
#undef DEFNODECODE
|
#undef DEFNODECODE
|
||||||
Parser_Initiated = C_Initialized;
|
Parser_Initiated = C_Initialized;
|
||||||
/* init precedence table of operators for C++ */
|
/* set the first tabulation */
|
||||||
for(i=BIT_COMPLEMENT_OP - EQ_OP; i<=RSHIFT_ASSGN_OP-EQ_OP;i++)
|
TabNumber = 0;
|
||||||
precedence_C[i] = precedence2_C[i-BIT_COMPLEMENT_OP+EQ_OP];
|
|
||||||
}
|
/* init precedence table of operators for C++ */
|
||||||
}
|
for(i=BIT_COMPLEMENT_OP - EQ_OP; i<=RSHIFT_ASSGN_OP-EQ_OP;i++)
|
||||||
|
precedence_C[i] = precedence2_C[i-BIT_COMPLEMENT_OP+EQ_OP];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* initialize the number of flag */
|
/* initialize the number of flag */
|
||||||
|
|||||||
@@ -83,11 +83,14 @@ void InitializeACC()
|
|||||||
type_CudaIndexType = NULL;
|
type_CudaIndexType = NULL;
|
||||||
type_with_len_DvmType = NULL;
|
type_with_len_DvmType = NULL;
|
||||||
declaration_cmnt = NULL;
|
declaration_cmnt = NULL;
|
||||||
|
indexType_int = indexType_long = indexType_llong = NULL;
|
||||||
dvmh_targets = options.isOn(NO_CUDA) ? HOST_DEVICE : HOST_DEVICE | CUDA_DEVICE;
|
dvmh_targets = options.isOn(NO_CUDA) ? HOST_DEVICE : HOST_DEVICE | CUDA_DEVICE;
|
||||||
|
|
||||||
SpecialSymbols.insert(std::pair<char, const char*>('\n', "\\n\"\n\""));
|
SpecialSymbols.insert(std::pair<char, const char*>('\n', "\\n\"\n\""));
|
||||||
SpecialSymbols.insert(std::pair<char, const char*>('"', "\\\""));
|
SpecialSymbols.insert(std::pair<char, const char*>('"', "\\\""));
|
||||||
SpecialSymbols.insert(std::pair<char, const char*>('\\', "\\\\"));
|
SpecialSymbols.insert(std::pair<char, const char*>('\\', "\\\\"));
|
||||||
|
|
||||||
|
InitializeAcrossACC();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *filenameACC()
|
char *filenameACC()
|
||||||
|
|||||||
@@ -40,15 +40,13 @@ void DeclarationCreateReductionBlocksAcross(int, SgExpression*);
|
|||||||
AnalyzeReturnGpuO1 analyzeLoopBody(int type);
|
AnalyzeReturnGpuO1 analyzeLoopBody(int type);
|
||||||
|
|
||||||
// local static variables
|
// local static variables
|
||||||
static SgSymbol *red_first;
|
static SgSymbol *red_first = NULL;
|
||||||
static bool declaration_include = true;
|
|
||||||
static bool createBodyKernel = false;
|
static bool createBodyKernel = false;
|
||||||
static bool createConvert_XY = true;
|
static bool createConvert_XY = true;
|
||||||
static const int numLoopVars = 16;
|
static const int numLoopVars = 16;
|
||||||
static bool ifReadLvlMode = false;
|
static bool ifReadLvlMode = false;
|
||||||
static vector <stack <SgStatement*> > copyOfBody;
|
static vector <stack <SgStatement*> > copyOfBody;
|
||||||
static vector<SgSymbol*> allRegNames;
|
static vector<SgSymbol*> allRegNames;
|
||||||
static unsigned countOfCopies;
|
|
||||||
static vector<ParamsForAllVariants> allVariants;
|
static vector<ParamsForAllVariants> allVariants;
|
||||||
|
|
||||||
static const char *funcDvmhConvXYfortVer = " attributes(device) subroutine dvmh_convert_XY_int(x,y,Rx,Ry,slash,idx)\n implicit none\n integer ,value:: x\n integer ,value:: y\n integer ,value:: Rx\n integer ,value:: Ry\n integer ,value:: slash\n integer ,device:: idx \n \n if(slash .eq. 0) then\n if(Rx .eq. Ry) then\n if(x + y .lt. Rx) then\n idx = y + (1+x+y)*(x+y)/2\n else\n idx = Rx*(Rx-1)+x-(2*Rx-x-y-1)*(2*Rx-x-y-2)/2\n endif \n elseif(Rx .lt. Ry) then\n if(x + y .lt. Rx) then\n idx = y + ((1+x+y)*(x+y)) / 2\n elseif(x + y .lt. Ry) then\n idx = ((1+Rx)*Rx) / 2 + Rx - x - 1 + Rx * (x+y-Rx)\n else\n idx = Rx*Ry-Ry+y-(((Rx+Ry-y-x-1)*(Rx+Ry-y-x-2))/2)\n endif\n else\n if(x + y .lt. Ry) then\n idx = x + (1+x+y)*(x+y) / 2\n elseif(x + y .lt. Rx) then\n idx = (1+Ry)*Ry/2 + (Ry-y-1) + Ry * (x+y-Ry)\n else\n idx = Rx*Ry-Rx+x-((Rx+Ry-y-x-1)*(Rx+Ry-y-x-2)/2)\n endif\n endif\n else\n if(Rx .eq. Ry) then\n if(x + Rx-1-y .lt. Rx) then\n idx = Rx-1-y + (x+Rx-y)*(x+Rx-1-y)/2\n else\n idx = Rx*(Rx-1) + x - (Rx-x+y)*(Rx-x+y-1)/2\n endif\n elseif(Rx .lt. Ry) then\n if(x + Ry-1-y .lt. Rx) then \n idx = Ry-1-y + ((x+Ry-y)*(x+Ry-1-y)) / 2\n elseif(x + Ry-1-y .lt. Ry) then\n idx = ((1+Rx)*Rx)/2+Rx-x-1+Rx*(x+Ry-1-y-Rx)\n else\n idx = Rx*Ry-1-y-(((Rx+y-x)*(Rx+y-x-1))/2)\n endif\n else\n if(x + Ry-1-y .lt. Ry) then\n idx = x + (1+x+Ry-1-y)*(x+Ry-1-y)/2\n elseif(x + Ry-1-y .lt. Rx) then\n idx = (1+Ry)*Ry/2 + y + Ry * (x-y-1)\n else\n idx = Rx*Ry-Rx+x-((Rx+y-x)*(Rx+y-x-1)/2)\n endif\n endif\n endif\n end subroutine\n";
|
static const char *funcDvmhConvXYfortVer = " attributes(device) subroutine dvmh_convert_XY_int(x,y,Rx,Ry,slash,idx)\n implicit none\n integer ,value:: x\n integer ,value:: y\n integer ,value:: Rx\n integer ,value:: Ry\n integer ,value:: slash\n integer ,device:: idx \n \n if(slash .eq. 0) then\n if(Rx .eq. Ry) then\n if(x + y .lt. Rx) then\n idx = y + (1+x+y)*(x+y)/2\n else\n idx = Rx*(Rx-1)+x-(2*Rx-x-y-1)*(2*Rx-x-y-2)/2\n endif \n elseif(Rx .lt. Ry) then\n if(x + y .lt. Rx) then\n idx = y + ((1+x+y)*(x+y)) / 2\n elseif(x + y .lt. Ry) then\n idx = ((1+Rx)*Rx) / 2 + Rx - x - 1 + Rx * (x+y-Rx)\n else\n idx = Rx*Ry-Ry+y-(((Rx+Ry-y-x-1)*(Rx+Ry-y-x-2))/2)\n endif\n else\n if(x + y .lt. Ry) then\n idx = x + (1+x+y)*(x+y) / 2\n elseif(x + y .lt. Rx) then\n idx = (1+Ry)*Ry/2 + (Ry-y-1) + Ry * (x+y-Ry)\n else\n idx = Rx*Ry-Rx+x-((Rx+Ry-y-x-1)*(Rx+Ry-y-x-2)/2)\n endif\n endif\n else\n if(Rx .eq. Ry) then\n if(x + Rx-1-y .lt. Rx) then\n idx = Rx-1-y + (x+Rx-y)*(x+Rx-1-y)/2\n else\n idx = Rx*(Rx-1) + x - (Rx-x+y)*(Rx-x+y-1)/2\n endif\n elseif(Rx .lt. Ry) then\n if(x + Ry-1-y .lt. Rx) then \n idx = Ry-1-y + ((x+Ry-y)*(x+Ry-1-y)) / 2\n elseif(x + Ry-1-y .lt. Ry) then\n idx = ((1+Rx)*Rx)/2+Rx-x-1+Rx*(x+Ry-1-y-Rx)\n else\n idx = Rx*Ry-1-y-(((Rx+y-x)*(Rx+y-x-1))/2)\n endif\n else\n if(x + Ry-1-y .lt. Ry) then\n idx = x + (1+x+Ry-1-y)*(x+Ry-1-y)/2\n elseif(x + Ry-1-y .lt. Rx) then\n idx = (1+Ry)*Ry/2 + y + Ry * (x-y-1)\n else\n idx = Rx*Ry-Rx+x-((Rx+y-x)*(Rx+y-x-1)/2)\n endif\n endif\n endif\n end subroutine\n";
|
||||||
@@ -58,6 +56,17 @@ static const char* fermiPreprocDir = "CUDA_FERMI_ARCH";
|
|||||||
// local variables
|
// local variables
|
||||||
SgStatement *kernelScope, *block;
|
SgStatement *kernelScope, *block;
|
||||||
|
|
||||||
|
void InitializeAcrossACC()
|
||||||
|
{
|
||||||
|
red_first = NULL;
|
||||||
|
createBodyKernel = false;
|
||||||
|
createConvert_XY = true;
|
||||||
|
ifReadLvlMode = false;
|
||||||
|
copyOfBody.clear();
|
||||||
|
allRegNames.clear();
|
||||||
|
allVariants.clear();
|
||||||
|
}
|
||||||
|
|
||||||
static inline int pow(int n)
|
static inline int pow(int n)
|
||||||
{
|
{
|
||||||
int tmp = 1;
|
int tmp = 1;
|
||||||
@@ -716,9 +725,6 @@ ArgsForKernel *Create_C_Adapter_Function_Across(SgSymbol *sadapter)
|
|||||||
{
|
{
|
||||||
if (allVariants[i].acrossV != 1)
|
if (allVariants[i].acrossV != 1)
|
||||||
ifOne = false;
|
ifOne = false;
|
||||||
|
|
||||||
if ((unsigned)allVariants[i].acrossV == countOfCopies + 1)
|
|
||||||
countOfCopies++;
|
|
||||||
}
|
}
|
||||||
// set global if true
|
// set global if true
|
||||||
if (ifOne)
|
if (ifOne)
|
||||||
@@ -1787,11 +1793,8 @@ vector<ArgsForKernel> Create_C_Adapter_Function_Across_variants(SgSymbol *sadapt
|
|||||||
st_end = st_hedr->lexNext();
|
st_end = st_hedr->lexNext();
|
||||||
fe = st_hedr->expr(0);
|
fe = st_hedr->expr(0);
|
||||||
first_exec = st_end;
|
first_exec = st_end;
|
||||||
if (declaration_include)
|
if (declaration_cmnt == NULL)
|
||||||
{
|
|
||||||
declaration_cmnt = "#include <cstdio>\n#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))\n#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))";
|
declaration_cmnt = "#include <cstdio>\n#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))\n#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))";
|
||||||
declaration_include = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mywarn(" end: create fuction header ");
|
mywarn(" end: create fuction header ");
|
||||||
mywarn("start: create dummy argument list ");
|
mywarn("start: create dummy argument list ");
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
FILE *fout = NULL;
|
FILE *fout = NULL;
|
||||||
FILE *fout_cuf = NULL, *fout_C_cu = NULL, *fout_info = NULL; /*ACC*/
|
FILE *fout_cuf = NULL, *fout_C_cu = NULL, *fout_info = NULL; /*ACC*/
|
||||||
const char *fout_name = "out.DVMH.f";
|
const char *fout_name = NULL;
|
||||||
char *fout_name_cuf; /*ACC*/
|
char *fout_name_cuf; /*ACC*/
|
||||||
char *fout_name_C_cu; /*ACC*/
|
char *fout_name_C_cu; /*ACC*/
|
||||||
char *fout_name_info_C; /*ACC*/
|
char *fout_name_info_C; /*ACC*/
|
||||||
@@ -389,22 +389,22 @@ int main(int argc, char *argv[])
|
|||||||
ProjectStructure(project);
|
ProjectStructure(project);
|
||||||
Private_Vars_Project_Analyzer();
|
Private_Vars_Project_Analyzer();
|
||||||
//----------------------------
|
//----------------------------
|
||||||
|
|
||||||
initVariantNames(); //for project
|
initVariantNames(); //for project
|
||||||
initIntrinsicFunctionNames(); //for project
|
initIntrinsicFunctionNames(); //for project
|
||||||
initSupportedVars(); // for project, acc_f2c.cpp
|
initSupportedVars(); // for project, acc_f2c.cpp
|
||||||
initF2C_FunctionCalls(); // for project, acc_f2c.cpp
|
initF2C_FunctionCalls(); // for project, acc_f2c.cpp
|
||||||
for(int id=project.numberOfFiles()-1; id >= 0; id--)
|
for(int id=project.numberOfFiles()-1; id >= 0; id--)
|
||||||
{
|
{
|
||||||
file = &(project.file(id)); //file->unparsestdout();
|
file = &(project.file(id)); //file->unparsestdout();
|
||||||
fin_name = new char[strlen(project.fileName(id))+2];
|
fin_name = new char[strlen(project.fileName(id))+2];
|
||||||
sprintf(fin_name, "%s%s", project.fileName(id), " ");
|
sprintf(fin_name, "%s%s", project.fileName(id), " ");
|
||||||
//fin_name = strcat(project.fileName(0)," ");
|
//fin_name = strcat(project.fileName(0)," ");
|
||||||
// for call of function 'tpoint'
|
// for call of function 'tpoint'
|
||||||
//added one symbol to input-file name
|
//added one symbol to input-file name
|
||||||
//printf("%s",fin_name); //!!! debug
|
//printf("%s",fin_name); //!!! debug
|
||||||
if(a_mode || project.numberOfFiles()>1)
|
if(!fout_name)
|
||||||
fout_name = doOutFileName(file->filename()); //project.fileName(id);
|
fout_name = doOutFileName(file->filename());
|
||||||
else if (fout_name && source_name && !strcmp(source_name, fout_name))
|
else if (fout_name && source_name && !strcmp(source_name, fout_name))
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "Output file has the same name as source file\n");
|
(void)fprintf(stderr, "Output file has the same name as source file\n");
|
||||||
@@ -417,7 +417,7 @@ int main(int argc, char *argv[])
|
|||||||
fout_name_info_C = ChangeFto_info_C(fout_name); /*ACC*/
|
fout_name_info_C = ChangeFto_info_C(fout_name); /*ACC*/
|
||||||
|
|
||||||
//set the last symbol of file
|
//set the last symbol of file
|
||||||
last_file_symbol = CUR_FILE_CUR_SYMB(); //LastSymbolOfFile(file)->thesymb; //for low_level.c
|
last_file_symbol = file->filept->cur_symb; //for low_level.c and not only
|
||||||
initLibNames(); //for every file
|
initLibNames(); //for every file
|
||||||
InitDVM(file); //for every file
|
InitDVM(file); //for every file
|
||||||
current_file = file; // global variable (used in SgTypeComplex)
|
current_file = file; // global variable (used in SgTypeComplex)
|
||||||
@@ -542,6 +542,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fout_name = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v_print)
|
if (v_print)
|
||||||
|
|||||||
@@ -1004,6 +1004,7 @@ SgStatement *doIfThenConstrForLoop_GPU(SgExpression *ref,SgStatement *endhost,Sg
|
|||||||
SgStatement *doIfThenConstrForLoop_GPU(SgExpression *ref,SgStatement *endhost,SgStatement *dowhile);
|
SgStatement *doIfThenConstrForLoop_GPU(SgExpression *ref,SgStatement *endhost,SgStatement *dowhile);
|
||||||
SgSymbol *KernelSymbol(SgStatement *st_do);
|
SgSymbol *KernelSymbol(SgStatement *st_do);
|
||||||
void Blocks_Off_Symbol();
|
void Blocks_Off_Symbol();
|
||||||
|
void InitializeACC();
|
||||||
void InitializeAcrossACC();
|
void InitializeAcrossACC();
|
||||||
void InitializeInFuncACC();
|
void InitializeInFuncACC();
|
||||||
SgSymbol *GPUModuleSymb(SgStatement *global_st);
|
SgSymbol *GPUModuleSymb(SgStatement *global_st);
|
||||||
|
|||||||
@@ -32,12 +32,11 @@ extern "C" int out_line_unlimit;
|
|||||||
extern "C" int out_line_length;
|
extern "C" int out_line_length;
|
||||||
extern "C" PTR_SYMB last_file_symbol;
|
extern "C" PTR_SYMB last_file_symbol;
|
||||||
|
|
||||||
static int convertFile(int argc, char* argv[], const string& fileToConv,
|
static int convertFile(int argc, char* argv[], const set<string>& filesInProj, const set<string>& moduleDeclsInFiles)
|
||||||
const set<string>& filesInProj, const set<string>& moduleDeclsInFiles)
|
|
||||||
{
|
{
|
||||||
FILE* fout = NULL;
|
FILE* fout = NULL;
|
||||||
FILE* fout_cuf = NULL, * fout_C_cu = NULL, * fout_info = NULL; /*ACC*/
|
FILE* fout_cuf = NULL, * fout_C_cu = NULL, * fout_info = NULL; /*ACC*/
|
||||||
const char* fout_name = "out.DVMH.f";
|
const char* fout_name = NULL;
|
||||||
char* fout_name_cuf; /*ACC*/
|
char* fout_name_cuf; /*ACC*/
|
||||||
char* fout_name_C_cu; /*ACC*/
|
char* fout_name_C_cu; /*ACC*/
|
||||||
char* fout_name_info_C; /*ACC*/
|
char* fout_name_info_C; /*ACC*/
|
||||||
@@ -54,7 +53,8 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|||||||
while ((argc > 1) && (*argv)[0] == '-')
|
while ((argc > 1) && (*argv)[0] == '-')
|
||||||
{
|
{
|
||||||
if ((*argv)[1] == 'o' && ((*argv)[2] == '\0')) {
|
if ((*argv)[1] == 'o' && ((*argv)[2] == '\0')) {
|
||||||
fout_name = argv[1];
|
if (filesInProj.size() == 1)
|
||||||
|
fout_name = argv[1];
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,8 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|||||||
static int id = 0;
|
static int id = 0;
|
||||||
|
|
||||||
vector<char*> filesList;
|
vector<char*> filesList;
|
||||||
filesList.push_back((char*)fileToConv.c_str());
|
for (auto& file : filesInProj)
|
||||||
|
filesList.push_back((char*)file.c_str());
|
||||||
|
|
||||||
SgProject project((proj_name + to_string(id++)).c_str(), filesList.data(), filesList.size());
|
SgProject project((proj_name + to_string(id++)).c_str(), filesList.data(), filesList.size());
|
||||||
|
|
||||||
@@ -317,7 +318,7 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|||||||
removeExecutableFromModuleDeclaration(&(project.file(z)), filesInProj, tmp);
|
removeExecutableFromModuleDeclaration(&(project.file(z)), filesInProj, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
SgFile* file;
|
SgFile* file = NULL;
|
||||||
addNumberOfFileToAttribute(&project);
|
addNumberOfFileToAttribute(&project);
|
||||||
|
|
||||||
//----------------------------
|
//----------------------------
|
||||||
@@ -331,23 +332,26 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|||||||
initF2C_FunctionCalls(); // for project, acc_f2c.cpp
|
initF2C_FunctionCalls(); // for project, acc_f2c.cpp
|
||||||
for (int id = project.numberOfFiles() - 1; id >= 0; id--)
|
for (int id = project.numberOfFiles() - 1; id >= 0; id--)
|
||||||
{
|
{
|
||||||
file = &(project.file(id)); //file->unparsestdout();
|
file = &(project.file(id));
|
||||||
fin_name = new char[strlen(project.fileName(id)) + 2];
|
fin_name = new char[strlen(project.fileName(id)) + 2];
|
||||||
sprintf(fin_name, "%s%s", project.fileName(id), " ");
|
sprintf(fin_name, "%s%s", project.fileName(id), " ");
|
||||||
fout_name = doOutFileName(file->filename()); //project.fileName(id);
|
|
||||||
|
if (fout_name == NULL)
|
||||||
|
fout_name = doOutFileName(file->filename());
|
||||||
|
|
||||||
if (fout_name && source_name && !strcmp(source_name, fout_name))
|
if (fout_name && source_name && !strcmp(source_name, fout_name))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Output file has the same name as source file\n");
|
fprintf(stderr, "Output file has the same name as source file\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("convert %d to %s\n", id, fout_name);
|
||||||
|
|
||||||
fout_name_cuf = ChangeFtoCuf(fout_name); /*ACC*/
|
fout_name_cuf = ChangeFtoCuf(fout_name); /*ACC*/
|
||||||
fout_name_C_cu = ChangeFto_C_Cu(fout_name); /*ACC*/
|
fout_name_C_cu = ChangeFto_C_Cu(fout_name); /*ACC*/
|
||||||
fout_name_info_C = ChangeFto_info_C(fout_name); /*ACC*/
|
fout_name_info_C = ChangeFto_info_C(fout_name); /*ACC*/
|
||||||
|
|
||||||
//set the last symbol of file
|
//set the last symbol of file
|
||||||
last_file_symbol = CUR_FILE_CUR_SYMB();
|
|
||||||
initLibNames(); //for every file
|
initLibNames(); //for every file
|
||||||
InitDVM(file); //for every file
|
InitDVM(file); //for every file
|
||||||
current_file = file; // global variable (used in SgTypeComplex)
|
current_file = file; // global variable (used in SgTypeComplex)
|
||||||
@@ -402,7 +406,22 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|||||||
UnparseTo_CufAndCu_Files(file, fout_cuf, fout_C_cu, fout_info);
|
UnparseTo_CufAndCu_Files(file, fout_cuf, fout_C_cu, fout_info);
|
||||||
|
|
||||||
const string fileN = file->filename();
|
const string fileN = file->filename();
|
||||||
hideUnnecessary(file, fileN, moduleDeclsInFiles, true);
|
set<SgStatement*> toRemove;
|
||||||
|
|
||||||
|
for (SgStatement* st = file->firstStatement(); st; st = st->lexNext())
|
||||||
|
{
|
||||||
|
if (st->fileName() != fileN)
|
||||||
|
{
|
||||||
|
if (st->variant() == MODULE_STMT && moduleDeclsInFiles.find(st->fileName()) != moduleDeclsInFiles.end())
|
||||||
|
{
|
||||||
|
toRemove.insert(st);
|
||||||
|
st = st->lastNodeOfStmt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& toRem : toRemove)
|
||||||
|
toRem->extractStmt();
|
||||||
|
|
||||||
if (unparse_functions)
|
if (unparse_functions)
|
||||||
UnparseFunctionsOfFile(file, fout);
|
UnparseFunctionsOfFile(file, fout);
|
||||||
@@ -434,7 +453,7 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fout_name = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v_print)
|
if (v_print)
|
||||||
@@ -467,11 +486,11 @@ void convertFiles(int argc, char* argv[], const char* proj_name)
|
|||||||
|
|
||||||
const string fileText = readFileToStr(proj_name);
|
const string fileText = readFileToStr(proj_name);
|
||||||
vector<string> files;
|
vector<string> files;
|
||||||
set<string> filesinSet;
|
set<string> filesInSet;
|
||||||
splitString(fileText, '\n', files);
|
splitString(fileText, '\n', files);
|
||||||
|
|
||||||
for (auto& file : files)
|
for (auto& file : files)
|
||||||
filesinSet.insert(file);
|
filesInSet.insert(file);
|
||||||
|
|
||||||
map<string, set<string>> moduleUsesByFile;
|
map<string, set<string>> moduleUsesByFile;
|
||||||
map<string, string> moduleDecls;
|
map<string, string> moduleDecls;
|
||||||
@@ -482,9 +501,9 @@ void convertFiles(int argc, char* argv[], const char* proj_name)
|
|||||||
moduleDeclsInFiles.insert(elem.second);
|
moduleDeclsInFiles.insert(elem.second);
|
||||||
|
|
||||||
int codes = 0;
|
int codes = 0;
|
||||||
for (auto& file : files)
|
//for (auto& file : files)
|
||||||
{
|
{
|
||||||
codes += convertFile(args_v.size() - 1, args_v.data(), file, filesinSet, moduleDeclsInFiles);
|
codes += convertFile(args_v.size(), args_v.data(), filesInSet, moduleDeclsInFiles);
|
||||||
|
|
||||||
cur_node = node_list = NULL;
|
cur_node = node_list = NULL;
|
||||||
InitializeTable();
|
InitializeTable();
|
||||||
|
|||||||
@@ -1107,11 +1107,13 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
{
|
{
|
||||||
auto itFound = loopGraph.find(file->filename());
|
auto itFound = loopGraph.find(file->filename());
|
||||||
if (itFound != loopGraph.end())
|
if (itFound != loopGraph.end())
|
||||||
removePrivatesAnalysis(itFound->second, getObjectForFileFromMap(file_name, SPF_messages), usersDirectives, commonBlocks, allFuncInfo);
|
removePrivatesAnalysis(file_name, itFound->second, getObjectForFileFromMap(file_name, SPF_messages),
|
||||||
|
usersDirectives, commonBlocks, allFuncInfo);
|
||||||
}
|
}
|
||||||
else if (curr_regime == PRIVATE_REMOVING)
|
else if (curr_regime == PRIVATE_REMOVING)
|
||||||
{
|
{
|
||||||
removePrivates(file, getObjectForFileFromMap(file_name, SPF_messages), countOfTransform);
|
removePrivates(file_name, getObjectForFileFromMap(file_name, SPF_messages),
|
||||||
|
commonBlocks, allFuncInfo, countOfTransform);
|
||||||
}
|
}
|
||||||
else if (curr_regime == CREATE_INTER_TREE)
|
else if (curr_regime == CREATE_INTER_TREE)
|
||||||
{
|
{
|
||||||
@@ -2501,15 +2503,8 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
|||||||
case REMOVE_OMP_DIRS_TRANSFORM:
|
case REMOVE_OMP_DIRS_TRANSFORM:
|
||||||
case REMOVE_COMMENTS:
|
case REMOVE_COMMENTS:
|
||||||
case INSERT_NO_DISTR_FLAGS_FROM_GUI:
|
case INSERT_NO_DISTR_FLAGS_FROM_GUI:
|
||||||
runAnalysis(*project, curr_regime, true, "", folderName);
|
|
||||||
break;
|
|
||||||
case PRIVATE_REMOVING:
|
case PRIVATE_REMOVING:
|
||||||
runAnalysis(*project, curr_regime, false, "", folderName);
|
runAnalysis(*project, curr_regime, true, "", folderName);
|
||||||
runPass(REVERT_SUBST_EXPR_RD, proj_name, folderName);
|
|
||||||
if (folderName)
|
|
||||||
runAnalysis(*project, UNPARSE_FILE, true, "", folderName);
|
|
||||||
else
|
|
||||||
__spf_print(1, "can not run UNPARSE_FILE - folder name is null\n");
|
|
||||||
break;
|
break;
|
||||||
case INLINE_PROCEDURES:
|
case INLINE_PROCEDURES:
|
||||||
runAnalysis(*project, curr_regime, false);
|
runAnalysis(*project, curr_regime, false);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using std::set;
|
|||||||
|
|
||||||
using std::remove_if;
|
using std::remove_if;
|
||||||
|
|
||||||
#define PRINT_USELESS_STATEMENTS 0
|
#define PRINT_USELESS_STATEMENTS 1
|
||||||
|
|
||||||
static void updateUseDefForInstruction(SAPFOR::BasicBlock* block, SAPFOR::Instruction* instr,
|
static void updateUseDefForInstruction(SAPFOR::BasicBlock* block, SAPFOR::Instruction* instr,
|
||||||
set<SAPFOR::Argument*>& use, set<SAPFOR::Argument*>& def,
|
set<SAPFOR::Argument*>& use, set<SAPFOR::Argument*>& def,
|
||||||
@@ -329,10 +329,22 @@ public:
|
|||||||
|
|
||||||
void removeDeadCode(SgStatement* func,
|
void removeDeadCode(SgStatement* func,
|
||||||
const map<string, vector<FuncInfo*>>& allFuncs,
|
const map<string, vector<FuncInfo*>>& allFuncs,
|
||||||
const map<string, CommonBlock*>& commonBlocks)
|
const map<string, CommonBlock*>& commonBlocks,
|
||||||
|
SgStatement* intervalDelStart, SgStatement* intervalDelEnd)
|
||||||
{
|
{
|
||||||
|
if (intervalDelStart && !intervalDelEnd || !intervalDelStart && intervalDelEnd)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
SgProgHedrStmt* prog = isSgProgHedrStmt(func);
|
SgProgHedrStmt* prog = isSgProgHedrStmt(func);
|
||||||
|
|
||||||
|
if (intervalDelStart)
|
||||||
|
if (intervalDelStart->lineNumber() < prog->lineNumber() || intervalDelStart->lineNumber() > prog->lastNodeOfStmt()->lineNumber())
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
if (intervalDelEnd)
|
||||||
|
if (intervalDelEnd->lineNumber() < prog->lineNumber() || intervalDelEnd->lineNumber() > prog->lastNodeOfStmt()->lineNumber())
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, false, false, false, false), commonBlocks, allFuncs);
|
auto cfg = buildCFGforCurrentFunc(func, SAPFOR::CFG_Settings(true, false, false, false, false, false, false), commonBlocks, allFuncs);
|
||||||
|
|
||||||
if(cfg.size() != 1)
|
if(cfg.size() != 1)
|
||||||
@@ -422,11 +434,8 @@ void removeDeadCode(SgStatement* func,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO: need to add [intervalDelStart; intervalDelEnd]
|
||||||
// remove dead statements
|
// remove dead statements
|
||||||
|
|
||||||
SgStatement* end = func->lastNodeOfStmt(), *st = func;
|
|
||||||
|
|
||||||
set<int> removable =
|
set<int> removable =
|
||||||
{
|
{
|
||||||
ASSIGN_STAT,
|
ASSIGN_STAT,
|
||||||
@@ -435,49 +444,52 @@ void removeDeadCode(SgStatement* func,
|
|||||||
READ_STAT
|
READ_STAT
|
||||||
};
|
};
|
||||||
|
|
||||||
while (st != end)
|
vector<SgStatement*> remove;
|
||||||
|
for (auto st = func; st != func->lastNodeOfStmt(); st = st->lexNext())
|
||||||
{
|
{
|
||||||
SgStatement* next = st->lexNext();
|
|
||||||
|
|
||||||
if (removable.find(st->variant()) != removable.end() && useful.find(st) == useful.end())
|
if (removable.find(st->variant()) != removable.end() && useful.find(st) == useful.end())
|
||||||
|
{
|
||||||
|
remove.push_back(st);
|
||||||
|
st = st->lastNodeOfStmt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& rem : remove)
|
||||||
|
{
|
||||||
|
__spf_print(PRINT_USELESS_STATEMENTS, "[Useless statement on line %d and file %s]\n", rem->lineNumber(), rem->fileName());
|
||||||
|
rem->deleteStmt();
|
||||||
|
}
|
||||||
|
|
||||||
|
remove.clear();
|
||||||
|
//remove empty blocks
|
||||||
|
for (auto st = func; st != func->lastNodeOfStmt(); st = st->lexNext())
|
||||||
|
{
|
||||||
|
const int var = st->variant();
|
||||||
|
if ((var == FOR_NODE || var == WHILE_NODE || var == IF_NODE || var == SWITCH_NODE) &&
|
||||||
|
st->lexNext()->variant() == CONTROL_END)
|
||||||
{
|
{
|
||||||
__spf_print(PRINT_USELESS_STATEMENTS, "[Useless statement '%s' on line %d]\n", st->unparse(), st->lineNumber());
|
remove.push_back(st);
|
||||||
|
continue;
|
||||||
st->deleteStmt();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isSgControlEndStmt(st))
|
|
||||||
{
|
|
||||||
SgStatement* parent = st->controlParent();
|
|
||||||
SgStatement* parent_end;
|
|
||||||
|
|
||||||
if (parent && (parent_end = parent->lastNodeOfStmt()) && parent_end == st)
|
|
||||||
{
|
|
||||||
bool empty_parent = false;
|
|
||||||
|
|
||||||
switch (parent->variant())
|
|
||||||
{
|
|
||||||
case IF_NODE:
|
|
||||||
empty_parent =
|
|
||||||
parent->lexNext() == parent_end || // IF THEN ENDIF
|
|
||||||
isSgControlEndStmt(parent->lexNext()) &&
|
|
||||||
parent->lexNext()->lexNext() == parent_end; // IF THEN ELSE ENDIF
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
empty_parent = parent->lexNext() == parent_end; // DO, WHILE
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty_parent)
|
|
||||||
parent->deleteStmt();
|
|
||||||
else if(isSgIfStmt(parent) && isSgControlEndStmt(parent_end->lexPrev())) // IF with empty ELSE branch
|
|
||||||
parent_end->deleteStmt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
st = next;
|
if (var == IF_NODE)
|
||||||
|
{
|
||||||
|
SgStatement* ifS = st;
|
||||||
|
while (ifS->lexNext()->variant() == ELSEIF_NODE)
|
||||||
|
ifS = ifS->lexNext();
|
||||||
|
|
||||||
|
if (ifS->lexNext()->variant() == CONTROL_END)
|
||||||
|
remove.push_back(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: SWITCH and other block statements
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (auto& rem : remove)
|
||||||
|
{
|
||||||
|
__spf_print(PRINT_USELESS_STATEMENTS, "[Useless block statement on line %d and file %s]\n", rem->lineNumber(), rem->fileName());
|
||||||
|
rem->deleteStmt();
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteCFG(cfg);
|
deleteCFG(cfg);
|
||||||
|
|||||||
@@ -11,4 +11,5 @@
|
|||||||
|
|
||||||
void removeDeadCode(SgStatement* func,
|
void removeDeadCode(SgStatement* func,
|
||||||
const std::map<std::string, std::vector<FuncInfo*>>&allFuncs,
|
const std::map<std::string, std::vector<FuncInfo*>>&allFuncs,
|
||||||
const std::map<std::string, CommonBlock*>& commonBlocks);
|
const std::map<std::string, CommonBlock*>& commonBlocks,
|
||||||
|
SgStatement* intervalDelStart = NULL, SgStatement* intervalDelEnd = NULL);
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../Utils/SgUtils.h"
|
#include "../Utils/SgUtils.h"
|
||||||
#include "../Utils/utils.h"
|
#include "../Utils/utils.h"
|
||||||
#include "../ExpressionTransform/expr_transform.h"
|
#include "../ExpressionTransform/expr_transform.h"
|
||||||
|
#include "dead_code.h"
|
||||||
|
|
||||||
using std::make_pair;
|
using std::make_pair;
|
||||||
using std::map;
|
using std::map;
|
||||||
@@ -16,17 +17,48 @@ using std::wstring;
|
|||||||
using CFG_Type = map<FuncInfo*, vector<SAPFOR::BasicBlock*>>;
|
using CFG_Type = map<FuncInfo*, vector<SAPFOR::BasicBlock*>>;
|
||||||
using UsersDirectives = map<pair<string, int>, set<SgStatement*>>;
|
using UsersDirectives = map<pair<string, int>, set<SgStatement*>>;
|
||||||
|
|
||||||
|
// RegularExpr represents expressions like ( coefA * I + coefB ),
|
||||||
|
// where I is a variable and coefA or coefB can be equal to zero
|
||||||
|
struct RegularExpr {
|
||||||
|
int coefA = 0;
|
||||||
|
int coefB;
|
||||||
|
string var;
|
||||||
|
|
||||||
|
RegularExpr(): coefA(0), coefB(0), var("") {}
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool operator==(const RegularExpr& left, const RegularExpr& right)
|
||||||
|
{
|
||||||
|
return left.var == right.var && left.coefA == right.coefA && left.coefB == right.coefB;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool operator<(const RegularExpr& left, const RegularExpr& right)
|
||||||
|
{
|
||||||
|
if (left.var == right.var && left.coefA < right.coefA && left.coefB <= right.coefB)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (left.var == right.var && left.coefA == right.coefA && left.coefB < right.coefB)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// FixedSubscript represents subscript of array. Subscript is fixed if it is INT_VAL value
|
// FixedSubscript represents subscript of array. Subscript is fixed if it is INT_VAL value
|
||||||
struct FixedSubscript {
|
struct FixedSubscript {
|
||||||
bool isFixed;
|
bool isFixed;
|
||||||
int value;
|
int value;
|
||||||
};
|
|
||||||
|
|
||||||
// RegularExpr represents expressions like ( coefA * I + coefB ),
|
bool isRegIndex;
|
||||||
// where I is a variable and coefA or coefB can be equal to zero
|
RegularExpr regExprStart;
|
||||||
struct RegularExpr {
|
RegularExpr regExprEnd;
|
||||||
int coefA;
|
|
||||||
int coefB;
|
FixedSubscript() {
|
||||||
|
isFixed = false;
|
||||||
|
value = 0;
|
||||||
|
isRegIndex = false;
|
||||||
|
regExprStart = RegularExpr{};
|
||||||
|
regExprEnd = RegularExpr{};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// DefUseStmtsPair represents pair of DEF and USE statements for private variable
|
// DefUseStmtsPair represents pair of DEF and USE statements for private variable
|
||||||
@@ -106,15 +138,50 @@ static bool isArrayRefInVector(SgArrayRefExp* ref, const vector<SgArrayRefExp*>&
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// findAnyVar returns first found VAR_REF in expr
|
||||||
|
static SgSymbol* findAnyVar(SgExpression* expr)
|
||||||
|
{
|
||||||
|
if (expr == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if (expr->variant() == VAR_REF)
|
||||||
|
return expr->symbol();
|
||||||
|
|
||||||
|
SgSymbol* res = findAnyVar(expr->lhs());
|
||||||
|
if (res != nullptr)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
return findAnyVar(expr->rhs());
|
||||||
|
}
|
||||||
|
|
||||||
// checkAndFillRegularExpr checks if expr is regular and fills regularExpr struct
|
// checkAndFillRegularExpr checks if expr is regular and fills regularExpr struct
|
||||||
// with info about expr
|
// with info about expr
|
||||||
static bool checkAndFillRegularExpr(SgExpression* expr, RegularExpr& regularExpr, SgSymbol* iterationVar)
|
static bool checkAndFillRegularExpr(SgExpression* expr, RegularExpr& regularExpr, SgSymbol* iterationVar)
|
||||||
{
|
{
|
||||||
|
if (expr == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// hack for cases when iterationVar doesn't matter:
|
||||||
|
if (iterationVar == nullptr)
|
||||||
|
iterationVar = findAnyVar(expr);
|
||||||
|
|
||||||
|
bool deleteTmpVar = false;
|
||||||
|
if (iterationVar == nullptr)
|
||||||
|
{
|
||||||
|
iterationVar = new SgSymbol(VARIABLE_NAME, "tmp");
|
||||||
|
deleteTmpVar = true;
|
||||||
|
}
|
||||||
|
|
||||||
pair<int, int> retCoefs;
|
pair<int, int> retCoefs;
|
||||||
getCoefsOfSubscript(retCoefs, expr, iterationVar);
|
getCoefsOfSubscript(retCoefs, expr, iterationVar);
|
||||||
|
|
||||||
regularExpr.coefA = retCoefs.first;
|
regularExpr.coefA = retCoefs.first;
|
||||||
regularExpr.coefB = retCoefs.second;
|
regularExpr.coefB = retCoefs.second;
|
||||||
|
if (!deleteTmpVar)
|
||||||
|
regularExpr.var = iterationVar->identifier();
|
||||||
|
|
||||||
|
if (deleteTmpVar)
|
||||||
|
delete iterationVar;
|
||||||
|
|
||||||
if (retCoefs.first != 0 || retCoefs.second != 0)
|
if (retCoefs.first != 0 || retCoefs.second != 0)
|
||||||
return true;
|
return true;
|
||||||
@@ -218,6 +285,33 @@ static bool isSymbolInExpression(SgSymbol* symbol, SgExpression* exp)
|
|||||||
isSymbolInExpression(symbol, exp->rhs());
|
isSymbolInExpression(symbol, exp->rhs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FuncInfo* findFunc(string fileName, string funcName, const map<string, vector<FuncInfo*>>& allFuncInfo)
|
||||||
|
{
|
||||||
|
auto fileInfo = allFuncInfo.find(fileName);
|
||||||
|
if (fileInfo == allFuncInfo.end())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
for (auto funcInfo : fileInfo->second)
|
||||||
|
if (funcInfo->funcName == funcName)
|
||||||
|
return funcInfo;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FuncInfo* getCurrectFunc(SgStatement* stmt, const map<string, vector<FuncInfo*>>& allFuncInfo)
|
||||||
|
{
|
||||||
|
auto fileInfo = allFuncInfo.find(stmt->fileName());
|
||||||
|
if (fileInfo == allFuncInfo.end())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
int stmtLine = stmt->lineNumber();
|
||||||
|
for (auto funcInfo : fileInfo->second)
|
||||||
|
if (funcInfo->linesNum.first <= stmtLine && stmtLine <= funcInfo->linesNum.second)
|
||||||
|
return funcInfo;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************** *
|
/* ************************************** *
|
||||||
* End of block of common used functions: *
|
* End of block of common used functions: *
|
||||||
* ************************************** */
|
* ************************************** */
|
||||||
@@ -505,38 +599,39 @@ static bool isVarChangedBetween(string var, SgStatement* first, SgStatement* sec
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove if needless
|
||||||
// removeDeadCodeFromLoop removes assign statements to private scalar vars which are not read in loop
|
// removeDeadCodeFromLoop removes assign statements to private scalar vars which are not read in loop
|
||||||
static void removeDeadCodeFromLoop(LoopGraph* loop)
|
//static void removeDeadCodeFromLoop(LoopGraph* loop)
|
||||||
{
|
//{
|
||||||
SgForStmt* loopStmt = (SgForStmt*) loop->loop->GetOriginal();
|
// SgForStmt* loopStmt = (SgForStmt*) loop->loop->GetOriginal();
|
||||||
set<Symbol*> privateVars;
|
// set<Symbol*> privateVars;
|
||||||
for (auto data : getAttributes<SgStatement*, SgStatement*>(loopStmt, set<int>{ SPF_ANALYSIS_DIR }))
|
// for (auto data : getAttributes<SgStatement*, SgStatement*>(loopStmt, set<int>{ SPF_ANALYSIS_DIR }))
|
||||||
fillPrivatesFromComment(new Statement(data), privateVars);
|
// fillPrivatesFromComment(new Statement(data), privateVars);
|
||||||
|
//
|
||||||
set<string> privates;
|
// set<string> privates;
|
||||||
for (Symbol* symbol : privateVars)
|
// for (Symbol* symbol : privateVars)
|
||||||
privates.insert(OriginalSymbol((SgSymbol*)symbol)->identifier());
|
// privates.insert(OriginalSymbol((SgSymbol*)symbol)->identifier());
|
||||||
|
//
|
||||||
vector<SgStatement*> stmtsToDelete;
|
// vector<SgStatement*> stmtsToDelete;
|
||||||
for (SgStatement* st = loopStmt->lexNext(); st != loopStmt->lastNodeOfStmt(); st = st->lexNext())
|
// for (SgStatement* st = loopStmt->lexNext(); st != loopStmt->lastNodeOfStmt(); st = st->lexNext())
|
||||||
{
|
// {
|
||||||
if (st->variant() != ASSIGN_STAT)
|
// if (st->variant() != ASSIGN_STAT)
|
||||||
continue;
|
// continue;
|
||||||
|
//
|
||||||
SgSymbol* var = st->expr(0)->symbol();
|
// SgSymbol* var = st->expr(0)->symbol();
|
||||||
if (var == nullptr || var->variant() != VARIABLE_NAME)
|
// if (var == nullptr || var->variant() != VARIABLE_NAME)
|
||||||
continue;
|
// continue;
|
||||||
|
//
|
||||||
if (privates.find(var->identifier()) != privates.end() && !isVarReadInLoop(var, loopStmt))
|
// if (privates.find(var->identifier()) != privates.end() && !isVarReadInLoop(var, loopStmt))
|
||||||
stmtsToDelete.push_back(st);
|
// stmtsToDelete.push_back(st);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (auto stmt : stmtsToDelete)
|
// for (auto stmt : stmtsToDelete)
|
||||||
stmt->deleteStmt();
|
// stmt->deleteStmt();
|
||||||
|
//
|
||||||
for (auto childLoop : loop->children)
|
// for (auto childLoop : loop->children)
|
||||||
removeDeadCodeFromLoop(childLoop);
|
// removeDeadCodeFromLoop(childLoop);
|
||||||
}
|
//}
|
||||||
|
|
||||||
// fillReadShortFixedSumscripts fills all short fixed subscripts vectors of array var,
|
// fillReadShortFixedSumscripts fills all short fixed subscripts vectors of array var,
|
||||||
// which are used for reading from array var in exp
|
// which are used for reading from array var in exp
|
||||||
@@ -603,30 +698,31 @@ static void removeExcessiveDefs(const PrivateToRemove& var)
|
|||||||
st->deleteStmt();
|
st->deleteStmt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove is needless
|
||||||
// removeEmptyLoops removes loops with empty body and create messages
|
// removeEmptyLoops removes loops with empty body and create messages
|
||||||
static void removeEmptyLoops(LoopGraph* loop, vector<Messages>& messages)
|
//static void removeEmptyLoops(LoopGraph* loop, vector<Messages>& messages)
|
||||||
{
|
//{
|
||||||
vector<LoopGraph*> loopsToDelete;
|
// vector<LoopGraph*> loopsToDelete;
|
||||||
vector<LoopGraph*> newChildrenVector;
|
// vector<LoopGraph*> newChildrenVector;
|
||||||
for (auto childLoop : loop->children)
|
// for (auto childLoop : loop->children)
|
||||||
{
|
// {
|
||||||
SgStatement* loopStmt = childLoop->loop->GetOriginal();
|
// SgStatement* loopStmt = childLoop->loop->GetOriginal();
|
||||||
if (loopStmt->lastNodeOfStmt() == loopStmt->lexNext())
|
// if (loopStmt->lastNodeOfStmt() == loopStmt->lexNext())
|
||||||
loopsToDelete.push_back(childLoop);
|
// loopsToDelete.push_back(childLoop);
|
||||||
else
|
// else
|
||||||
newChildrenVector.push_back(childLoop);
|
// newChildrenVector.push_back(childLoop);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (auto loopToDelete : loopsToDelete)
|
// for (auto loopToDelete : loopsToDelete)
|
||||||
{
|
// {
|
||||||
addMessageRemoveLoop(messages, loopToDelete->lineNum);
|
// addMessageRemoveLoop(messages, loopToDelete->lineNum);
|
||||||
loopToDelete->loop->extractStmt();
|
// loopToDelete->loop->extractStmt();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
loop->children.swap(newChildrenVector);
|
// loop->children.swap(newChildrenVector);
|
||||||
for (auto childLoop : loop->children)
|
// for (auto childLoop : loop->children)
|
||||||
removeEmptyLoops(childLoop, messages);
|
// removeEmptyLoops(childLoop, messages);
|
||||||
}
|
//}
|
||||||
|
|
||||||
// removeVarFromPrivateAttributes removes var from SPF ANALYSIS PRIVATE attributes of loop
|
// removeVarFromPrivateAttributes removes var from SPF ANALYSIS PRIVATE attributes of loop
|
||||||
static void removeVarFromPrivateAttributes(SgSymbol* var, LoopGraph* loop)
|
static void removeVarFromPrivateAttributes(SgSymbol* var, LoopGraph* loop)
|
||||||
@@ -726,30 +822,36 @@ static set<vector<int>> removeArray(string filename, const PrivateToRemove& arra
|
|||||||
|
|
||||||
SgExpression* substExp = substituteExpressions(useStmt->expr(i), refToExpMap);
|
SgExpression* substExp = substituteExpressions(useStmt->expr(i), refToExpMap);
|
||||||
useStmt->setExpression(i, *substExp);
|
useStmt->setExpression(i, *substExp);
|
||||||
|
|
||||||
// don't revert substitutions in useStmt:
|
|
||||||
cancelRevertionForStatement(filename, useStmt, i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return removedFixedSubscripts;
|
return removedFixedSubscripts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removePrivates(SgFile* file, vector<Messages>& messages, int& countOfTransform)
|
void removePrivates(string filename, vector<Messages>& messages,
|
||||||
|
const map<string, CommonBlock*>& commonBlocks,
|
||||||
|
const map<string, vector<FuncInfo*>>& allFuncInfo,
|
||||||
|
int& countOfTransform)
|
||||||
{
|
{
|
||||||
for (auto& varToRemove : privatesToRemoveGlobal)
|
for (auto& varToRemove : privatesToRemoveGlobal)
|
||||||
{
|
{
|
||||||
if (string(file->filename()) != varToRemove.loop->fileName)
|
if (filename != varToRemove.loop->fileName)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto removedDimensions = removeArray(file->filename(), varToRemove);
|
auto removedDimensions = removeArray(filename, varToRemove);
|
||||||
countOfTransform++;
|
countOfTransform++;
|
||||||
|
|
||||||
//removeDeadCodeFromLoop(varToRemove.loop); // TODO: problem with reverting substitution
|
//removeDeadCodeFromLoop(varToRemove.loop);
|
||||||
removeExcessiveDefs(varToRemove);
|
removeExcessiveDefs(varToRemove);
|
||||||
removeEmptyLoops(varToRemove.loop, messages);
|
//removeEmptyLoops(varToRemove.loop, messages);
|
||||||
|
|
||||||
SgForStmt* loopStmt = (SgForStmt*)varToRemove.loop->loop->GetOriginal();
|
SgForStmt* loopStmt = (SgForStmt*)varToRemove.loop->loop->GetOriginal();
|
||||||
|
FuncInfo* currFunc = getCurrectFunc(loopStmt, allFuncInfo);
|
||||||
|
if (currFunc == nullptr)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
|
removeDeadCode(currFunc->funcPointer, allFuncInfo, commonBlocks);
|
||||||
|
|
||||||
vector<SgArrayRefExp*> varRefs = getDirectArrayRefs(loopStmt, varToRemove.varSymbol);
|
vector<SgArrayRefExp*> varRefs = getDirectArrayRefs(loopStmt, varToRemove.varSymbol);
|
||||||
int loopLineNum = varToRemove.loop->lineNum;
|
int loopLineNum = varToRemove.loop->lineNum;
|
||||||
string varName = varToRemove.varSymbol->identifier();
|
string varName = varToRemove.varSymbol->identifier();
|
||||||
@@ -780,7 +882,7 @@ void removePrivates(SgFile* file, vector<Messages>& messages, int& countOfTransf
|
|||||||
{
|
{
|
||||||
varName = getDimensionVarName(varToRemove.varSymbol, removedDimension,
|
varName = getDimensionVarName(varToRemove.varSymbol, removedDimension,
|
||||||
fixedDimensions, varToRemove.regime);
|
fixedDimensions, varToRemove.regime);
|
||||||
addMessageRemovePrivateVarPart(messages, varName, loopLineNum);
|
addMessageRemovePrivateVar(messages, varName, loopLineNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -800,6 +902,7 @@ struct Context {
|
|||||||
const map<string, vector<FuncInfo*>>& allFuncInfo;
|
const map<string, vector<FuncInfo*>>& allFuncInfo;
|
||||||
const map<string, CommonBlock*>& commonBlocks;
|
const map<string, CommonBlock*>& commonBlocks;
|
||||||
vector<Messages>& messages;
|
vector<Messages>& messages;
|
||||||
|
string filename;
|
||||||
|
|
||||||
Regime regime;
|
Regime regime;
|
||||||
LoopGraph* loop;
|
LoopGraph* loop;
|
||||||
@@ -1042,9 +1145,35 @@ static vector<bool> getFixedDimensionsMask(Context* ctx)
|
|||||||
return resultMask;
|
return resultMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getScopeLoopStmt returns least outer scope loop statement
|
||||||
|
static SgForStmt* getScopeLoopStmt(SgStatement* stmt)
|
||||||
|
{
|
||||||
|
while (stmt != nullptr && stmt->variant() != FOR_NODE)
|
||||||
|
stmt = stmt->controlParent();
|
||||||
|
|
||||||
|
return (SgForStmt*)stmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// getLoopStmtForVar searches for loop with iteration var equal loopVar starting from from stmt
|
||||||
|
static SgForStmt* getLoopStmtForVar(SgStatement* stmt, string loopVar)
|
||||||
|
{
|
||||||
|
while (stmt != nullptr)
|
||||||
|
{
|
||||||
|
SgForStmt* loopStmt = getScopeLoopStmt(stmt);
|
||||||
|
|
||||||
|
if (loopStmt->doName()->identifier() == loopVar)
|
||||||
|
return loopStmt;
|
||||||
|
|
||||||
|
stmt = stmt->controlParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// getFixedSubscriptsVector returns vector of fixed INT_VAL subscripts of arrayRef
|
// getFixedSubscriptsVector returns vector of fixed INT_VAL subscripts of arrayRef
|
||||||
// true - subscript is fixed, false - it isn't
|
// true - subscript is fixed, false - it isn't
|
||||||
static vector<FixedSubscript> getFixedSubscriptsVector(SgArrayRefExp* arrayRef, int dimensionsNum = 0)
|
static vector<FixedSubscript> getFixedSubscriptsVector(SgArrayRefExp* arrayRef, int dimensionsNum = 0,
|
||||||
|
SgStatement* stmt = nullptr)
|
||||||
{
|
{
|
||||||
if (arrayRef->numberOfSubscripts() == 0)
|
if (arrayRef->numberOfSubscripts() == 0)
|
||||||
return vector<FixedSubscript>(dimensionsNum);
|
return vector<FixedSubscript>(dimensionsNum);
|
||||||
@@ -1052,42 +1181,50 @@ static vector<FixedSubscript> getFixedSubscriptsVector(SgArrayRefExp* arrayRef,
|
|||||||
vector<FixedSubscript> subscriptsVector;
|
vector<FixedSubscript> subscriptsVector;
|
||||||
for (int i = 0; i < arrayRef->numberOfSubscripts(); ++i)
|
for (int i = 0; i < arrayRef->numberOfSubscripts(); ++i)
|
||||||
{
|
{
|
||||||
if (arrayRef->subscript(i)->variant() == INT_VAL)
|
SgExpression* subscriptExpr = arrayRef->subscript(i);
|
||||||
subscriptsVector.push_back(FixedSubscript{ true, arrayRef->subscript(i)->valueInteger() });
|
FixedSubscript sub;
|
||||||
else
|
|
||||||
subscriptsVector.push_back(FixedSubscript{ false, 0 });
|
if (subscriptExpr->variant() == INT_VAL)
|
||||||
|
{
|
||||||
|
sub.isFixed = true;
|
||||||
|
sub.value = subscriptExpr->valueInteger();
|
||||||
|
}
|
||||||
|
else if (stmt != nullptr && subscriptExpr->variant() == VAR_REF)
|
||||||
|
{
|
||||||
|
SgForStmt* loopStmt = getLoopStmtForVar(stmt, subscriptExpr->symbol()->identifier());
|
||||||
|
if (loopStmt != nullptr)
|
||||||
|
{
|
||||||
|
RegularExpr regExprStep;
|
||||||
|
SgExpression* step = loopStmt->step();
|
||||||
|
if (step == nullptr || checkAndFillRegularExpr(step, regExprStep, nullptr) && regExprStep.coefA == 0)
|
||||||
|
{
|
||||||
|
SgExpression* start = loopStmt->start();
|
||||||
|
SgExpression* end = loopStmt->end();
|
||||||
|
if (regExprStep.coefB < 0)
|
||||||
|
std::swap(start, end);
|
||||||
|
|
||||||
|
bool isRegular = true;
|
||||||
|
isRegular = isRegular && checkAndFillRegularExpr(start, sub.regExprStart, nullptr);
|
||||||
|
isRegular = isRegular && checkAndFillRegularExpr(end, sub.regExprEnd, nullptr);
|
||||||
|
sub.isRegIndex = isRegular;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RegularExpr regExpr;
|
||||||
|
if (checkAndFillRegularExpr(subscriptExpr, regExpr, nullptr)) {
|
||||||
|
sub.isRegIndex = true;
|
||||||
|
sub.regExprStart = regExpr;
|
||||||
|
sub.regExprEnd = regExpr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subscriptsVector.push_back(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
return subscriptsVector;
|
return subscriptsVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FuncInfo* findFunc(string fileName, string funcName, const map<string, vector<FuncInfo*>>& allFuncInfo)
|
|
||||||
{
|
|
||||||
auto fileInfo = allFuncInfo.find(fileName);
|
|
||||||
if (fileInfo == allFuncInfo.end())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
for (auto funcInfo : fileInfo->second)
|
|
||||||
if (funcInfo->funcName == funcName)
|
|
||||||
return funcInfo;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FuncInfo* getCurrectFunc(SgStatement* stmt, const map<string, vector<FuncInfo*>>& allFuncInfo)
|
|
||||||
{
|
|
||||||
auto fileInfo = allFuncInfo.find(stmt->fileName());
|
|
||||||
if (fileInfo == allFuncInfo.end())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
int stmtLine = stmt->lineNumber();
|
|
||||||
for (auto funcInfo : fileInfo->second)
|
|
||||||
if (funcInfo->linesNum.first <= stmtLine && stmtLine <= funcInfo->linesNum.second)
|
|
||||||
return funcInfo;
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// checkImplicitDirectUsage returns masks of array implicit usage (as out argument)
|
// checkImplicitDirectUsage returns masks of array implicit usage (as out argument)
|
||||||
// in any function call in exp and writes message about each usage
|
// in any function call in exp and writes message about each usage
|
||||||
static void checkImplicitDirectUsage(Context* ctx, SgExpression* exp, int stmtLineNum,
|
static void checkImplicitDirectUsage(Context* ctx, SgExpression* exp, int stmtLineNum,
|
||||||
@@ -1474,7 +1611,8 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
|||||||
|
|
||||||
set<int> RD_defArgs = RD_forUseArg->second; // make copy
|
set<int> RD_defArgs = RD_forUseArg->second; // make copy
|
||||||
|
|
||||||
// delete recursive definition from RD def args:
|
// delete recursive and uninit definition from RD def args:
|
||||||
|
set<int> tmpRD_defArgs;
|
||||||
for (int defArgNum : RD_defArgs)
|
for (int defArgNum : RD_defArgs)
|
||||||
{
|
{
|
||||||
if (defArgNum == SAPFOR::CFG_VAL::UNINIT)
|
if (defArgNum == SAPFOR::CFG_VAL::UNINIT)
|
||||||
@@ -1487,11 +1625,11 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
|||||||
SgStatement* defStmt = defInsAndBlock.first->getOperator();
|
SgStatement* defStmt = defInsAndBlock.first->getOperator();
|
||||||
auto defInsertedStmt = findInsertedStmt(insertedStmts, defStmt);
|
auto defInsertedStmt = findInsertedStmt(insertedStmts, defStmt);
|
||||||
if (useInsertedStmt.relatedToStmt == defInsertedStmt->relatedToStmt)
|
if (useInsertedStmt.relatedToStmt == defInsertedStmt->relatedToStmt)
|
||||||
{
|
continue;
|
||||||
RD_defArgs.erase(defArgNum);
|
|
||||||
break;
|
tmpRD_defArgs.insert(defArgNum);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
RD_defArgs.swap(tmpRD_defArgs);
|
||||||
|
|
||||||
if (RD_defArgs.size() == 0) // argument is not initialized
|
if (RD_defArgs.size() == 0) // argument is not initialized
|
||||||
{
|
{
|
||||||
@@ -1551,6 +1689,9 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto defInsAndBlock = getInstructionAndBlockByNumber(CFGraph, *RD_defArgs.begin());
|
auto defInsAndBlock = getInstructionAndBlockByNumber(CFGraph, *RD_defArgs.begin());
|
||||||
|
if (defInsAndBlock.first == nullptr)
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
defStmt = defInsAndBlock.first->getOperator();
|
defStmt = defInsAndBlock.first->getOperator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1576,14 +1717,14 @@ static vector<DefUseStmtsPair> buildDefUsePairs(Context* ctx, const CFG_Type& CF
|
|||||||
return defUsePairs;
|
return defUsePairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getScopeLoopStmt returns least outer scope loop statement
|
//// getScopeLoopStmt returns least outer scope loop statement
|
||||||
static SgForStmt* getScopeLoopStmt(SgStatement* stmt)
|
//static SgForStmt* getScopeLoopStmt(SgStatement* stmt)
|
||||||
{
|
//{
|
||||||
while (stmt != nullptr && stmt->variant() != FOR_NODE)
|
// while (stmt != nullptr && stmt->variant() != FOR_NODE)
|
||||||
stmt = stmt->controlParent();
|
// stmt = stmt->controlParent();
|
||||||
|
//
|
||||||
return (SgForStmt*)stmt;
|
// return (SgForStmt*)stmt;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// findChildLoop returns LoopGraph for provided loop statement
|
// findChildLoop returns LoopGraph for provided loop statement
|
||||||
static LoopGraph* findLoop(LoopGraph* outerLoop, SgForStmt* loopStmt)
|
static LoopGraph* findLoop(LoopGraph* outerLoop, SgForStmt* loopStmt)
|
||||||
@@ -1649,7 +1790,8 @@ static LoopGraph* leastCommonAncestor(LoopGraph* a, LoopGraph* b, LoopGraph* par
|
|||||||
// fillFullFixedSubscriptsVectorsOfAllVars return vector of pairs (name of var, its fixed subscripts vector)
|
// fillFullFixedSubscriptsVectorsOfAllVars return vector of pairs (name of var, its fixed subscripts vector)
|
||||||
// of all VAR_REF and ARRAY_REF vars in exp
|
// of all VAR_REF and ARRAY_REF vars in exp
|
||||||
static void fillFixedSubscriptsVectorsOfAllVars(SgExpression* exp,
|
static void fillFixedSubscriptsVectorsOfAllVars(SgExpression* exp,
|
||||||
vector<pair<string, vector<FixedSubscript>>>& vec)
|
vector<pair<string, vector<FixedSubscript>>>& vec,
|
||||||
|
SgStatement* stmt = nullptr)
|
||||||
{
|
{
|
||||||
if (exp == nullptr)
|
if (exp == nullptr)
|
||||||
return;
|
return;
|
||||||
@@ -1667,22 +1809,54 @@ static void fillFixedSubscriptsVectorsOfAllVars(SgExpression* exp,
|
|||||||
else if (exp->variant() == ARRAY_REF)
|
else if (exp->variant() == ARRAY_REF)
|
||||||
{
|
{
|
||||||
vec.push_back(make_pair(exp->symbol()->identifier(),
|
vec.push_back(make_pair(exp->symbol()->identifier(),
|
||||||
getFixedSubscriptsVector((SgArrayRefExp*)exp)));
|
getFixedSubscriptsVector((SgArrayRefExp*)exp, 0, stmt)));
|
||||||
|
|
||||||
SgExprListExp* exprList = (SgExprListExp*)exp->lhs();
|
SgExprListExp* exprList = (SgExprListExp*)exp->lhs();
|
||||||
for (int i = 0; i < exprList->length(); ++i)
|
for (int i = 0; i < exprList->length(); ++i)
|
||||||
fillFixedSubscriptsVectorsOfAllVars(exprList->elem(i), vec);
|
fillFixedSubscriptsVectorsOfAllVars(exprList->elem(i), vec, stmt);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fillFixedSubscriptsVectorsOfAllVars(exp->lhs(), vec);
|
fillFixedSubscriptsVectorsOfAllVars(exp->lhs(), vec, stmt);
|
||||||
fillFixedSubscriptsVectorsOfAllVars(exp->rhs(), vec);
|
fillFixedSubscriptsVectorsOfAllVars(exp->rhs(), vec, stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixedSubscriptLess checks if left FixedSubscript is less than right
|
||||||
|
static bool fixedSubscriptLess(const FixedSubscript& left, const FixedSubscript& right)
|
||||||
|
{
|
||||||
|
if (left.isFixed && right.isFixed && left.value < right.value)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (left.isFixed && right.isRegIndex
|
||||||
|
&& right.regExprStart.coefA == 0 && left.value < right.regExprStart.coefB)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (left.isRegIndex && right.isFixed
|
||||||
|
&& left.regExprEnd.coefA == 0 && left.regExprEnd.coefB < right.value)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (left.isRegIndex && right.isRegIndex)
|
||||||
|
return left.regExprEnd < right.regExprStart;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixedSubscriptLess checks if left and right FixedSubscripts are different,
|
||||||
|
// using empirical methods
|
||||||
|
static bool possibleDifferent(FixedSubscript left, FixedSubscript right)
|
||||||
|
{
|
||||||
|
// TODO: add warning?
|
||||||
|
if (left.isFixed && right.isRegIndex && right.regExprStart == right.regExprEnd) {
|
||||||
|
return true; // in general, this is not true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// isDifferentRefs checks if exp (var reference) is different from var. Refs are different
|
// isDifferentRefs checks if exp (var reference) is different from var. Refs are different
|
||||||
// if they has at least one different fixed subscript: arr(i, 1) is different from arr(j, 2)
|
// if they has at least one different fixed subscript: arr(i, 1) is different from arr(j, 2)
|
||||||
static bool isDifferentRefs(SgExpression* exp, const pair<string, vector<FixedSubscript>>& var)
|
static bool isDifferentRefs(SgExpression* exp, const pair<string, vector<FixedSubscript>>& var, SgStatement* stmt)
|
||||||
{
|
{
|
||||||
if (exp->symbol()->identifier() != var.first)
|
if (exp->symbol()->identifier() != var.first)
|
||||||
return true;
|
return true;
|
||||||
@@ -1690,16 +1864,25 @@ static bool isDifferentRefs(SgExpression* exp, const pair<string, vector<FixedSu
|
|||||||
if (exp->variant() == VAR_REF)
|
if (exp->variant() == VAR_REF)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
vector<FixedSubscript> leftVec = getFixedSubscriptsVector((SgArrayRefExp*)exp);
|
vector<FixedSubscript> leftVec = getFixedSubscriptsVector((SgArrayRefExp*)exp, 0, stmt);
|
||||||
|
|
||||||
|
if (leftVec.size() != var.second.size())
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
|
||||||
for (int i = 0; i < leftVec.size(); i++)
|
for (int i = 0; i < leftVec.size(); i++)
|
||||||
if (leftVec[i].isFixed && var.second[i].isFixed && leftVec[i].value != var.second[i].value)
|
{
|
||||||
|
if (fixedSubscriptLess(leftVec[i], var.second[i])
|
||||||
|
|| fixedSubscriptLess(var.second[i], leftVec[i])
|
||||||
|
|| possibleDifferent(leftVec[i], var.second[i]))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<SAPFOR::Argument*, set<int>> findVarInRDSet(map<SAPFOR::Argument*, set<int>> RD_In, string var)
|
static pair<SAPFOR::Argument*, set<int>> findVarInRDSet(const map<SAPFOR::Argument*, set<int>>& RD_In, const string& var)
|
||||||
{
|
{
|
||||||
for (auto& RD_InElem : RD_In)
|
for (auto& RD_InElem : RD_In)
|
||||||
{
|
{
|
||||||
@@ -1717,7 +1900,7 @@ pair<SAPFOR::Argument*, set<int>> findVarInRDSet(map<SAPFOR::Argument*, set<int>
|
|||||||
|
|
||||||
// checkDefUsePair checks if def statement from pair can be substituted into use statement
|
// checkDefUsePair checks if def statement from pair can be substituted into use statement
|
||||||
// and creates messages
|
// and creates messages
|
||||||
static bool checkDefUsePair(Context* ctx, DefUseStmtsPair defUse, const CFG_Type& CFGraph)
|
static bool checkDefUsePair(Context* ctx, const DefUseStmtsPair& defUse, const CFG_Type& CFGraph)
|
||||||
{
|
{
|
||||||
if (defUse.first->lineNumber() > defUse.second->lineNumber())
|
if (defUse.first->lineNumber() > defUse.second->lineNumber())
|
||||||
return false;
|
return false;
|
||||||
@@ -1733,7 +1916,7 @@ static bool checkDefUsePair(Context* ctx, DefUseStmtsPair defUse, const CFG_Type
|
|||||||
SgExpression* expToSubst = defUse.first->rhs()->copyPtr();
|
SgExpression* expToSubst = defUse.first->rhs()->copyPtr();
|
||||||
expToSubst = replaceVarsWithExps(expToSubst, varToExpMap);
|
expToSubst = replaceVarsWithExps(expToSubst, varToExpMap);
|
||||||
|
|
||||||
fillFixedSubscriptsVectorsOfAllVars(expToSubst, dependOnVars);
|
fillFixedSubscriptsVectorsOfAllVars(expToSubst, dependOnVars, defUse.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<SgSymbol*> iterationVars{};
|
vector<SgSymbol*> iterationVars{};
|
||||||
@@ -1780,29 +1963,16 @@ static bool checkDefUsePair(Context* ctx, DefUseStmtsPair defUse, const CFG_Type
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
// TODO: ^^^^^
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RTMP <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RHS <20><><EFBFBD><EFBFBD><EFBFBD> LU.
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> rsd <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
|
||||||
// rsd(1,i,j,2) = ...
|
|
||||||
// do k = 4, nz - 3
|
|
||||||
// rsd(1, i, j, k) = ...
|
|
||||||
// enddo
|
|
||||||
// rsd(1, i, j, nz - 2) = ...
|
|
||||||
|
|
||||||
// checking arrays:
|
// checking arrays:
|
||||||
auto defLoopStmt = getScopeLoopStmt(defUse.first);
|
auto defLoopStmt = getScopeLoopStmt(defUse.first);
|
||||||
auto useLoopStmt = getScopeLoopStmt(defUse.second);
|
auto useLoopStmt = getScopeLoopStmt(defUse.second);
|
||||||
|
|
||||||
LoopGraph* loop = ctx->loop;
|
LoopGraph* loop = ctx->loop;
|
||||||
while (loop->perfectLoop != 1) // (what is it? - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>)
|
while (loop->perfectLoop != 1) // (what is it? - TODO: may be remove it)
|
||||||
loop = loop->children[0];
|
loop = loop->children[0];
|
||||||
|
|
||||||
auto defLoop = findLoop(loop, defLoopStmt);
|
LoopGraph* defLoop = findLoop(loop, defLoopStmt);
|
||||||
auto useLoop = findLoop(loop, useLoopStmt);
|
LoopGraph* useLoop = findLoop(loop, useLoopStmt);
|
||||||
|
|
||||||
if (!defLoopStmt || !useLoopStmt || !defLoop || !useLoop)
|
if (!defLoopStmt || !useLoopStmt || !defLoop || !useLoop)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
@@ -1846,7 +2016,9 @@ static bool checkDefUsePair(Context* ctx, DefUseStmtsPair defUse, const CFG_Type
|
|||||||
{
|
{
|
||||||
for (SgStatement* st = startStmt; st != endStmt; st = st->lexNext())
|
for (SgStatement* st = startStmt; st != endStmt; st = st->lexNext())
|
||||||
{
|
{
|
||||||
if (st->variant() == ASSIGN_STAT && !isDifferentRefs(st->expr(0), var))
|
if (st == defUse.second)
|
||||||
|
continue;
|
||||||
|
if (st->variant() == ASSIGN_STAT && !isDifferentRefs(st->expr(0), var, st))
|
||||||
{
|
{
|
||||||
addMessageDependOnNonInvariant(ctx->messages, arrayName,
|
addMessageDependOnNonInvariant(ctx->messages, arrayName,
|
||||||
var.first, defUse.first->lineNumber());
|
var.first, defUse.first->lineNumber());
|
||||||
@@ -1910,9 +2082,19 @@ void removePrivateAnalyze(Context *ctx)
|
|||||||
{
|
{
|
||||||
vector<DefUseStmtsPair> resultDefUsePairs;
|
vector<DefUseStmtsPair> resultDefUsePairs;
|
||||||
for (auto& pair : defUseStmtsPairs)
|
for (auto& pair : defUseStmtsPairs)
|
||||||
|
{
|
||||||
if (checkDefUsePair(ctx, pair, CFG_ForFunc))
|
if (checkDefUsePair(ctx, pair, CFG_ForFunc))
|
||||||
|
{
|
||||||
resultDefUsePairs.push_back(pair);
|
resultDefUsePairs.push_back(pair);
|
||||||
|
|
||||||
|
// don't revert substitutions in use and def stmts:
|
||||||
|
cancelRevertionForStatement(ctx->filename, pair.first, 1);
|
||||||
|
cancelRevertionForStatement(ctx->filename, pair.second, 0);
|
||||||
|
cancelRevertionForStatement(ctx->filename, pair.second, 1);
|
||||||
|
cancelRevertionForStatement(ctx->filename, pair.second, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PrivateToRemove newPrivateToRemove;
|
PrivateToRemove newPrivateToRemove;
|
||||||
newPrivateToRemove.loop = ctx->loop;
|
newPrivateToRemove.loop = ctx->loop;
|
||||||
newPrivateToRemove.varSymbol = ctx->arraySymbol;
|
newPrivateToRemove.varSymbol = ctx->arraySymbol;
|
||||||
@@ -1931,7 +2113,8 @@ void removePrivateAnalyze(Context *ctx)
|
|||||||
deleteCFG(CFG_ForFunc);
|
deleteCFG(CFG_ForFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removePrivatesAnalysis(vector<LoopGraph*>& loopGraphs,
|
void removePrivatesAnalysis(string filename,
|
||||||
|
vector<LoopGraph*>& loopGraphs,
|
||||||
vector<Messages>& messages,
|
vector<Messages>& messages,
|
||||||
const UsersDirectives& usersDirectives,
|
const UsersDirectives& usersDirectives,
|
||||||
const map<string, CommonBlock*>& commonBlocks,
|
const map<string, CommonBlock*>& commonBlocks,
|
||||||
@@ -1978,7 +2161,7 @@ void removePrivatesAnalysis(vector<LoopGraph*>& loopGraphs,
|
|||||||
if (arrayToRemove == nullptr) // no array to remove
|
if (arrayToRemove == nullptr) // no array to remove
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Context context = Context{allFuncInfo, commonBlocks, messages};
|
Context context = Context{allFuncInfo, commonBlocks, messages, filename};
|
||||||
context.regime = Regime::DEFLT;
|
context.regime = Regime::DEFLT;
|
||||||
context.loop = loop;
|
context.loop = loop;
|
||||||
context.loopStmt = loopStmt;
|
context.loopStmt = loopStmt;
|
||||||
@@ -2000,20 +2183,17 @@ void removePrivatesAnalysis(vector<LoopGraph*>& loopGraphs,
|
|||||||
{
|
{
|
||||||
removePrivateAnalyze(&context);
|
removePrivateAnalyze(&context);
|
||||||
}
|
}
|
||||||
else
|
else if (checkRegularIndexRefs(&context))
|
||||||
{
|
{
|
||||||
if (checkRegularIndexRefs(&context))
|
context.regime = Regime::REGULAR_INDEXES;
|
||||||
{
|
context.fixedDimensionsMask = vector<bool>{};
|
||||||
context.regime = Regime::REGULAR_INDEXES;
|
removePrivateAnalyze(&context);
|
||||||
context.fixedDimensionsMask = vector<bool>{};
|
|
||||||
removePrivateAnalyze(&context);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
addMessageDoesNotMatchMask(messages, context.arraySymbol->identifier(), context.loop->lineNum);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
addMessageDoesNotMatchMask(messages, context.arraySymbol->identifier(), context.loop->lineNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (LoopGraph* loop : loopGraphs)
|
for (LoopGraph* loop : loopGraphs)
|
||||||
removePrivatesAnalysis(loop->children, messages, usersDirectives, commonBlocks, allFuncInfo);
|
removePrivatesAnalysis(filename, loop->children, messages, usersDirectives, commonBlocks, allFuncInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,16 @@ struct PrivateToRemove {
|
|||||||
|
|
||||||
// removePrivates removes all privates from vector privatesToRemoveGloval
|
// removePrivates removes all privates from vector privatesToRemoveGloval
|
||||||
// and add info messages
|
// and add info messages
|
||||||
void removePrivates(SgFile* file, std::vector<Messages>& messages, int& countOfTransform);
|
void removePrivates(std::string filename, std::vector<Messages>& messages,
|
||||||
|
const std::map<std::string, CommonBlock*>& commonBlocks,
|
||||||
|
const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo,
|
||||||
|
int& countOfTransform);
|
||||||
|
|
||||||
// removePrivatesAnalysis checks all private variables in loopGraphs specified by usersDirectives
|
// removePrivatesAnalysis checks all private variables in loopGraphs specified by usersDirectives
|
||||||
// if they can be removed, and adds those that can to vector privatesToRemoveGloval.
|
// if they can be removed, and adds those that can to vector privatesToRemoveGloval.
|
||||||
// if private var cannot be removed, the error message is returned with vector messages
|
// if private var cannot be removed, the error message is returned with vector messages
|
||||||
void removePrivatesAnalysis(std::vector<LoopGraph*>& loopGraphs,
|
void removePrivatesAnalysis(std::string filename,
|
||||||
|
std::vector<LoopGraph*>& loopGraphs,
|
||||||
std::vector<Messages>& messages,
|
std::vector<Messages>& messages,
|
||||||
const std::map<std::pair<std::string, int>, std::set<SgStatement*>>& usersDirectives,
|
const std::map<std::pair<std::string, int>, std::set<SgStatement*>>& usersDirectives,
|
||||||
const std::map<std::string, CommonBlock*>& commonBlocks,
|
const std::map<std::string, CommonBlock*>& commonBlocks,
|
||||||
|
|||||||
@@ -212,7 +212,8 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
|
|
||||||
Pass(BUILD_IR) <= Pass(SUBST_EXPR_RD) <= Pass(SUBST_EXPR_RD_AND_UNPARSE);
|
Pass(BUILD_IR) <= Pass(SUBST_EXPR_RD) <= Pass(SUBST_EXPR_RD_AND_UNPARSE);
|
||||||
|
|
||||||
list({ LOOP_ANALYZER_DATA_DIST_S1, SUBST_EXPR_RD } ) <= Pass(PRIVATE_REMOVING_ANALYSIS) <= Pass(PRIVATE_REMOVING);
|
list({ LOOP_ANALYZER_DATA_DIST_S1, SUBST_EXPR_RD } ) <= Pass(PRIVATE_REMOVING_ANALYSIS);
|
||||||
|
list({ PRIVATE_REMOVING_ANALYSIS, REVERT_SUBST_EXPR_RD }) <= Pass(PRIVATE_REMOVING);
|
||||||
|
|
||||||
Pass(RESTORE_LOOP_FROM_ASSIGN) <= list({ SUBST_EXPR_AND_UNPARSE, SUBST_EXPR_RD_AND_UNPARSE });
|
Pass(RESTORE_LOOP_FROM_ASSIGN) <= list({ SUBST_EXPR_AND_UNPARSE, SUBST_EXPR_RD_AND_UNPARSE });
|
||||||
|
|
||||||
@@ -242,7 +243,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
|
|
||||||
Pass(MACRO_EXPANSION) <= Pass(CALL_GRAPH);
|
Pass(MACRO_EXPANSION) <= Pass(CALL_GRAPH);
|
||||||
|
|
||||||
list({ PREPROC_SPF, PROCESS_IO, CALL_GRAPH2, CONVERT_SAVE_TO_MODULE, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD }) <= Pass(CREATE_CHECKPOINTS);
|
list({ PREPROC_SPF, PROCESS_IO, CALL_GRAPH2, CONVERT_SAVE_TO_MODULE, REVERT_SUBST_EXPR_RD }) <= Pass(CREATE_CHECKPOINTS);
|
||||||
|
|
||||||
Pass(FILL_PAR_REGIONS_LINES) <= Pass(VERIFY_EQUIVALENCE);
|
Pass(FILL_PAR_REGIONS_LINES) <= Pass(VERIFY_EQUIVALENCE);
|
||||||
|
|
||||||
@@ -254,9 +255,9 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
|
|
||||||
list({ PREPROC_SPF, CALL_GRAPH2, FILL_PAR_REGIONS_LINES }) <= Pass(FILL_PAR_REGIONS) <= Pass(RESOLVE_PAR_REGIONS);
|
list({ PREPROC_SPF, CALL_GRAPH2, FILL_PAR_REGIONS_LINES }) <= Pass(FILL_PAR_REGIONS) <= Pass(RESOLVE_PAR_REGIONS);
|
||||||
|
|
||||||
list({ REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN }) <= Pass(RESOLVE_PAR_REGIONS);
|
list({ REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN }) <= Pass(RESOLVE_PAR_REGIONS);
|
||||||
|
|
||||||
list({ REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD }) <= Pass(EXPAND_EXTRACT_PAR_REGION);
|
Pass(REVERT_SUBST_EXPR_RD) <= Pass(EXPAND_EXTRACT_PAR_REGION);
|
||||||
|
|
||||||
Pass(FILL_PAR_REGIONS) <= Pass(PRINT_PAR_REGIONS_ERRORS);
|
Pass(FILL_PAR_REGIONS) <= Pass(PRINT_PAR_REGIONS_ERRORS);
|
||||||
|
|
||||||
@@ -268,33 +269,33 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
|
|
||||||
Pass(CALL_GRAPH2) <= list({ PURE_SAVE_TO_PARAMS, PURE_MODULE_TO_PARAMS, PURE_COMMON_TO_PARAMS, PURE_INTENT_INSERT });
|
Pass(CALL_GRAPH2) <= list({ PURE_SAVE_TO_PARAMS, PURE_MODULE_TO_PARAMS, PURE_COMMON_TO_PARAMS, PURE_INTENT_INSERT });
|
||||||
|
|
||||||
list({ REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD }) <= list({ PURE_SAVE_TO_PARAMS, PURE_MODULE_TO_PARAMS, PURE_COMMON_TO_PARAMS, PURE_INTENT_INSERT });
|
Pass(REVERT_SUBST_EXPR_RD) <= list({ PURE_SAVE_TO_PARAMS, PURE_MODULE_TO_PARAMS, PURE_COMMON_TO_PARAMS, PURE_INTENT_INSERT });
|
||||||
|
|
||||||
list({ CORRECT_VAR_DECL, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD, VERIFY_INCLUDE }) <= list({ CONVERT_TO_ENDDO, CORRECT_CODE_STYLE, REMOVE_DVM_DIRS, REMOVE_DVM_DIRS_TO_COMMENTS, REMOVE_DVM_INTERVALS });
|
list({ CORRECT_VAR_DECL, REVERT_SUBST_EXPR_RD, VERIFY_INCLUDE }) <= list({ CONVERT_TO_ENDDO, CORRECT_CODE_STYLE, REMOVE_DVM_DIRS, REMOVE_DVM_DIRS_TO_COMMENTS, REMOVE_DVM_INTERVALS });
|
||||||
|
|
||||||
list({ CALL_GRAPH2, CONVERT_LOOP_TO_ASSIGN, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD, RESTORE_LOOP_FROM_ASSIGN }) <= Pass(INLINE_PROCEDURES);
|
list({ CALL_GRAPH2, CONVERT_LOOP_TO_ASSIGN, REVERT_SUBST_EXPR_RD, RESTORE_LOOP_FROM_ASSIGN }) <= Pass(INLINE_PROCEDURES);
|
||||||
|
|
||||||
list({ CONVERT_LOOP_TO_ASSIGN, CORRECT_FORMAT_PLACE }) <= list({ CONVERT_TO_ENDDO, CORRECT_CODE_STYLE, INSERT_INCLUDES, REMOVE_DVM_DIRS, REMOVE_DVM_DIRS_TO_COMMENTS, REMOVE_DVM_INTERVALS });
|
list({ CONVERT_LOOP_TO_ASSIGN, CORRECT_FORMAT_PLACE }) <= list({ CONVERT_TO_ENDDO, CORRECT_CODE_STYLE, INSERT_INCLUDES, REMOVE_DVM_DIRS, REMOVE_DVM_DIRS_TO_COMMENTS, REMOVE_DVM_INTERVALS });
|
||||||
|
|
||||||
list({ CORRECT_VAR_DECL, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD }) <= list({ INSERT_INCLUDES, UNPARSE_FILE, SET_TO_ALL_DECL_INIT_ZERO });
|
list({ CORRECT_VAR_DECL, REVERT_SUBST_EXPR_RD }) <= list({ INSERT_INCLUDES, UNPARSE_FILE, SET_TO_ALL_DECL_INIT_ZERO });
|
||||||
|
|
||||||
Pass(CALL_GRAPH2) <= Pass(PRIVATE_ARRAYS_SHRINKING_ANALYSIS) <= Pass(PRIVATE_ARRAYS_SHRINKING);
|
Pass(CALL_GRAPH2) <= Pass(PRIVATE_ARRAYS_SHRINKING_ANALYSIS) <= Pass(PRIVATE_ARRAYS_SHRINKING);
|
||||||
|
|
||||||
list({ CALL_GRAPH2, LOOP_ANALYZER_ALIGNS, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD }) <= list({ PRIVATE_ARRAYS_EXPANSION, PRIVATE_ARRAYS_SHRINKING });
|
list({ CALL_GRAPH2, LOOP_ANALYZER_ALIGNS, REVERT_SUBST_EXPR_RD }) <= list({ PRIVATE_ARRAYS_EXPANSION, PRIVATE_ARRAYS_SHRINKING });
|
||||||
|
|
||||||
list({ GCOV_PARSER, CREATE_INTER_TREE, CALL_GRAPH, CALL_GRAPH2 }) <= Pass(CREATE_PARALLEL_REGIONS);
|
list({ GCOV_PARSER, CREATE_INTER_TREE, CALL_GRAPH, CALL_GRAPH2 }) <= Pass(CREATE_PARALLEL_REGIONS);
|
||||||
|
|
||||||
list({ PRIVATE_CALL_GRAPH_STAGE1, PRIVATE_CALL_GRAPH_STAGE2, MACRO_EXPANSION, CONVERT_ASSIGN_TO_LOOP, DEF_USE_STAGE1, DEF_USE_STAGE2, LOOP_GRAPH, CALL_GRAPH, PRIVATE_ANALYSIS_IR, FIND_FUNC_TO_INCLUDE }) <= Pass(INSERT_REGIONS);
|
list({ PRIVATE_CALL_GRAPH_STAGE1, PRIVATE_CALL_GRAPH_STAGE2, MACRO_EXPANSION, CONVERT_ASSIGN_TO_LOOP, DEF_USE_STAGE1, DEF_USE_STAGE2, LOOP_GRAPH, CALL_GRAPH, PRIVATE_ANALYSIS_IR, FIND_FUNC_TO_INCLUDE }) <= Pass(INSERT_REGIONS);
|
||||||
|
|
||||||
list({ LOOP_ANALYZER_DATA_DIST_S1, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD }) <= list({ LOOPS_SPLITTER, LOOPS_COMBINER, UNROLL_LOOPS, INSERT_REGIONS });
|
list({ LOOP_ANALYZER_DATA_DIST_S1, REVERT_SUBST_EXPR_RD }) <= list({ LOOPS_SPLITTER, LOOPS_COMBINER, UNROLL_LOOPS, INSERT_REGIONS });
|
||||||
|
|
||||||
list({ CALL_GRAPH2, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN, RESTORE_LOOP_FROM_ASSIGN }) <= list({ DUPLICATE_FUNCTIONS, REMOVE_UNUSED_FUNCTIONS });
|
list({ CALL_GRAPH2, REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN, RESTORE_LOOP_FROM_ASSIGN }) <= list({ DUPLICATE_FUNCTIONS, REMOVE_UNUSED_FUNCTIONS });
|
||||||
|
|
||||||
list({ CONVERT_LOOP_TO_ASSIGN, RESTORE_LOOP_FROM_ASSIGN }) <= list({ LOOPS_SPLITTER, LOOPS_COMBINER, PRIVATE_ARRAYS_EXPANSION, PRIVATE_ARRAYS_SHRINKING, CREATE_PARALLEL_REGIONS, PURE_SAVE_TO_PARAMS, PURE_MODULE_TO_PARAMS, PURE_COMMON_TO_PARAMS, PURE_INTENT_INSERT });
|
list({ CONVERT_LOOP_TO_ASSIGN, RESTORE_LOOP_FROM_ASSIGN }) <= list({ LOOPS_SPLITTER, LOOPS_COMBINER, PRIVATE_ARRAYS_EXPANSION, PRIVATE_ARRAYS_SHRINKING, CREATE_PARALLEL_REGIONS, PURE_SAVE_TO_PARAMS, PURE_MODULE_TO_PARAMS, PURE_COMMON_TO_PARAMS, PURE_INTENT_INSERT });
|
||||||
|
|
||||||
list({ GET_ALL_ARRAY_DECL, FILL_PARALLEL_REG_IR }) <= Pass(CONVERT_ASSIGN_TO_LOOP);
|
list({ GET_ALL_ARRAY_DECL, FILL_PARALLEL_REG_IR }) <= Pass(CONVERT_ASSIGN_TO_LOOP);
|
||||||
|
|
||||||
list({ CALL_GRAPH2, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD }) <= Pass(RENAME_SYMBOLS);
|
list({ CALL_GRAPH2, REVERT_SUBST_EXPR_RD }) <= Pass(RENAME_SYMBOLS);
|
||||||
|
|
||||||
list({ BUILD_IR, CALL_GRAPH }) <= Pass(LIVE_ANALYSIS_IR);
|
list({ BUILD_IR, CALL_GRAPH }) <= Pass(LIVE_ANALYSIS_IR);
|
||||||
|
|
||||||
@@ -307,7 +308,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
Pass(REMOVE_OMP_DIRS) <= Pass(REMOVE_OMP_DIRS_TRANSFORM);
|
Pass(REMOVE_OMP_DIRS) <= Pass(REMOVE_OMP_DIRS_TRANSFORM);
|
||||||
|
|
||||||
Pass(CALL_GRAPH2) <= Pass(REMOVE_DEAD_CODE);
|
Pass(CALL_GRAPH2) <= Pass(REMOVE_DEAD_CODE);
|
||||||
list({ REMOVE_DEAD_CODE, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN, RESTORE_LOOP_FROM_ASSIGN }) <= Pass(REMOVE_DEAD_CODE_AND_UNPARSE);
|
list({ REMOVE_DEAD_CODE, REVERT_SUBST_EXPR_RD, CONVERT_LOOP_TO_ASSIGN, RESTORE_LOOP_FROM_ASSIGN }) <= Pass(REMOVE_DEAD_CODE_AND_UNPARSE);
|
||||||
|
|
||||||
passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS,
|
passesIgnoreStateDone.insert({ CREATE_PARALLEL_DIRS, INSERT_PARALLEL_DIRS, INSERT_SHADOW_DIRS, EXTRACT_PARALLEL_DIRS,
|
||||||
EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW,
|
EXTRACT_SHADOW_DIRS, CREATE_REMOTES, UNPARSE_FILE, REMOVE_AND_CALC_SHADOW,
|
||||||
@@ -318,7 +319,7 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
|||||||
//only for print
|
//only for print
|
||||||
if (printTree)
|
if (printTree)
|
||||||
{
|
{
|
||||||
list({ CREATE_PARALLEL_DIRS, PRIVATE_ANALYSIS_IR, CREATE_REMOTES, REVERT_SUBST_EXPR, REVERT_SUBST_EXPR_RD, UNPARSE_FILE, EXTRACT_PARALLEL_DIRS }) <= Pass(INSERT_PARALLEL_DIRS);
|
list({ CREATE_PARALLEL_DIRS, PRIVATE_ANALYSIS_IR, CREATE_REMOTES, REVERT_SUBST_EXPR_RD, UNPARSE_FILE, EXTRACT_PARALLEL_DIRS }) <= Pass(INSERT_PARALLEL_DIRS);
|
||||||
depsToGraphViz(passDepsIn);
|
depsToGraphViz(passDepsIn);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ static int reverseVar(SgStatement* st)
|
|||||||
static map<SgStatement*, map<int, set<string>>> insertedIncludes;
|
static map<SgStatement*, map<int, set<string>>> insertedIncludes;
|
||||||
static set<SgFile*> genVersionDone;
|
static set<SgFile*> genVersionDone;
|
||||||
|
|
||||||
set<int> hideUnnecessary(SgFile* file, const string& fileN, const set<string>& moduleDeclsInFiles, bool dontReplaceIncludes)
|
static set<int> hideUnnecessary(SgFile* file, const string& fileN, const set<string>& moduleDeclsInFiles, bool dontReplaceIncludes)
|
||||||
{
|
{
|
||||||
set<int> changedVars;
|
set<int> changedVars;
|
||||||
for (SgStatement* st = file->firstStatement(); st; st = st->lexNext())
|
for (SgStatement* st = file->firstStatement(); st; st = st->lexNext())
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ SgStatement* declaratedInStmt(SgSymbol *toFind, std::vector<SgStatement*> *allDe
|
|||||||
#include "DefUseList.h"
|
#include "DefUseList.h"
|
||||||
#include "CommonBlock.h"
|
#include "CommonBlock.h"
|
||||||
|
|
||||||
std::set<int> hideUnnecessary(SgFile* file, const std::string& fileN, const std::set<std::string>& moduleDeclsInFiles, const bool dontReplaceIncludes);
|
|
||||||
std::string removeIncludeStatsAndUnparse(SgFile *file, const char *fileName, const char *fout, std::set<std::string> &allIncludeFiles, bool outFree, const std::map<std::string, std::set<std::string>> &moduleUsesByFile, const std::map<std::string, std::string>& moduleDelcs, const std::map<SgStatement*, std::vector<SgStatement*>>& exctactedModuleStats, bool toString, bool dontReplaceIncls = false);
|
std::string removeIncludeStatsAndUnparse(SgFile *file, const char *fileName, const char *fout, std::set<std::string> &allIncludeFiles, bool outFree, const std::map<std::string, std::set<std::string>> &moduleUsesByFile, const std::map<std::string, std::string>& moduleDelcs, const std::map<SgStatement*, std::vector<SgStatement*>>& exctactedModuleStats, bool toString, bool dontReplaceIncls = false);
|
||||||
SgSymbol* findSymbolOrCreate(SgFile *file, const std::string toFind, SgType *type = NULL, SgStatement *scope = NULL);
|
SgSymbol* findSymbolOrCreate(SgFile *file, const std::string toFind, SgType *type = NULL, SgStatement *scope = NULL);
|
||||||
void recExpressionPrint(SgExpression *exp);
|
void recExpressionPrint(SgExpression *exp);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2285"
|
#define VERSION_SPF "2290"
|
||||||
|
|||||||
Reference in New Issue
Block a user