fix merge errors
This commit is contained in:
@@ -197,6 +197,7 @@ set(TR_IMPLICIT_NONE _src/Transformations/set_implicit_none.cpp
|
||||
|
||||
set(TRANSFORMS
|
||||
${TR_DEAD_CODE}
|
||||
${TR_CP}
|
||||
${TR_VECTOR}
|
||||
${TR_ENDDO_LOOP}
|
||||
${TR_LOOP_NEST}
|
||||
|
||||
@@ -83,11 +83,8 @@
|
||||
#include "Transformations/private_removing.h"
|
||||
#include "Transformations/fix_common_blocks.h"
|
||||
#include "Transformations/convert_to_c.h"
|
||||
<<<<<<< HEAD
|
||||
#include "Transformations/set_implicit_none.h"
|
||||
=======
|
||||
#include "Transformations/dead_code.h"
|
||||
>>>>>>> master
|
||||
|
||||
#include "RenameSymbols/rename_symbols.h"
|
||||
#include "ProjectParameters/projectParameters.h"
|
||||
@@ -1175,10 +1172,8 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
getMaxMinBlockDistribution(file, min_max_block);
|
||||
else if (curr_regime == CONVERT_TO_C)
|
||||
covertToC(file);
|
||||
<<<<<<< HEAD
|
||||
else if (curr_regime == SET_IMPLICIT_NONE)
|
||||
ImplicitCheck(file);
|
||||
=======
|
||||
else if (curr_regime == INSERT_NO_DISTR_FLAGS_FROM_GUI)
|
||||
addPrivatesToArraysFromGUI(file, declaredArrays, distrStateFromGUI);
|
||||
else if (curr_regime == REMOVE_DEAD_CODE)
|
||||
@@ -1187,7 +1182,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
for (auto& func : funcsForFile)
|
||||
removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
|
||||
}
|
||||
>>>>>>> master
|
||||
else if (curr_regime == TEST_PASS)
|
||||
{
|
||||
//test pass
|
||||
@@ -2645,10 +2639,7 @@ int main(int argc, char **argv)
|
||||
else if (string(curr_arg) == "-passN")
|
||||
{
|
||||
i++;
|
||||
// test
|
||||
|
||||
curr_regime = getPassCode(argv[i]);
|
||||
curr_regime = 130;
|
||||
printf("code for pass %s is %d\n", argv[i], curr_regime);
|
||||
}
|
||||
else if (string(curr_arg) == "-passInfo")
|
||||
|
||||
@@ -356,11 +356,8 @@ static void setPassValues()
|
||||
passNames[REMOVE_COMMENTS] = "REMOVE_COMMENTS";
|
||||
passNames[GET_MIN_MAX_BLOCK_DIST] = "GET_MIN_MAX_BLOCK_DIST";
|
||||
passNames[CONVERT_TO_C] = "CONVERT_TO_C";
|
||||
<<<<<<< HEAD
|
||||
passNames[SET_IMPLICIT_NONE] = "SET_IMPLICIT_NONE";
|
||||
=======
|
||||
passNames[INSERT_NO_DISTR_FLAGS_FROM_GUI] = "INSERT_NO_DISTR_FLAGS_FROM_GUI";
|
||||
>>>>>>> master
|
||||
|
||||
passNames[TEST_PASS] = "TEST_PASS";
|
||||
}
|
||||
|
||||
@@ -22,13 +22,15 @@ const char commonIntLetters[6] = {'i', 'j', 'k', 'm', 'n', 'l'};
|
||||
|
||||
void InitTypes();
|
||||
void FillCommonTypes();
|
||||
void GetImplicitTypes(SgExpression* expr);
|
||||
|
||||
void ImplicitCheck(SgFile* file) {
|
||||
|
||||
auto implicitNoneDeclaration = new SgStatement(IMPL_DECL);
|
||||
auto hasImplicitNone = false;
|
||||
|
||||
InitTypes();
|
||||
FillCommonTypes();
|
||||
|
||||
for (SgStatement* i = file->firstStatement(); i = i->lexNext(); i != NULL) {
|
||||
|
||||
if (i->variant() == IMPL_DECL) {
|
||||
@@ -51,14 +53,11 @@ void ImplicitCheck(SgFile* file) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("%s\nvariant - %d\n\n", i->unparse(), i->variant());
|
||||
}
|
||||
}
|
||||
|
||||
// get all vars
|
||||
|
||||
for each (auto var in allVars)
|
||||
for (auto var : allVars)
|
||||
{
|
||||
SgStatement* declaredIn = declaratedInStmt(var);
|
||||
if (declaredIn == NULL) {
|
||||
@@ -69,7 +68,16 @@ void ImplicitCheck(SgFile* file) {
|
||||
// create decl
|
||||
// delete implicit
|
||||
|
||||
|
||||
if (!hasImplicitNone) {
|
||||
for (SgStatement* i = file->firstStatement(); ; i != NULL) {
|
||||
if (i->variant() == IMPL_DECL) {
|
||||
auto tmp = i;
|
||||
i = i->lexNext();
|
||||
tmp->deleteStmt();
|
||||
}
|
||||
}
|
||||
|
||||
auto firstRealStatementOfFile = file->firstStatement()->lexNext()->lexNext();
|
||||
firstRealStatementOfFile->insertStmtBefore(*implicitNoneDeclaration, *(firstRealStatementOfFile->controlParent()));
|
||||
}
|
||||
@@ -98,194 +106,3 @@ void FillCommonTypes() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GetImplicitTypes(SgExpression* expr) {
|
||||
if (expr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (expr->variant() == IMPL_TYPE) {
|
||||
auto letters = expr->operand(1);
|
||||
auto type = expr->type();
|
||||
|
||||
printf("letters - %s\n", letters->unparse());
|
||||
}
|
||||
|
||||
if (expr->lhs() != NULL) {
|
||||
GetImplicitTypes(expr->lhs());
|
||||
}
|
||||
if (expr->rhs() != NULL) {
|
||||
GetImplicitTypes(expr->rhs());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
auto x = implicitSt->numberOfImplicitTypes();
|
||||
printf("IMPLICIT\n%s", implicitSt->unparse());
|
||||
printf("number - %d\n", x);
|
||||
for (int j = 0; j < x; j++) {
|
||||
printf("%d - %s\n", j, implicitSt->implicitRangeList(j)->unparse());
|
||||
}
|
||||
printf("\n");
|
||||
*
|
||||
int coutOfFunctions;
|
||||
for (int j = 0; j < file->numberOfFunctions(); j++) {
|
||||
SgStatement* function = file->functions(j);
|
||||
|
||||
implicit.clear();
|
||||
vars.clear();
|
||||
toDecl.clear();
|
||||
|
||||
//fill implicit
|
||||
|
||||
for (int k = 0; k < function->numberOfChildrenList1(); k++) {
|
||||
SgStatement* state = function->childList1(k);
|
||||
|
||||
|
||||
|
||||
if (state->variant() == IMPL_DECL) {
|
||||
|
||||
if (state->expr(0) == NULL) {
|
||||
|
||||
}
|
||||
else {
|
||||
SgExpression* expression = state->expr(0);
|
||||
int n = 0;
|
||||
SgExpression* one = expression;
|
||||
|
||||
while (one != NULL && one->lhs() != NULL) {
|
||||
|
||||
string what_type = one->lhs()->sunparse();
|
||||
|
||||
if (what_type.find("kind=") != std::string::npos) {
|
||||
|
||||
SgType* baseType = new SgType(one->lhs()->type()->variant());
|
||||
|
||||
SgType* type = new SgType(T_ARRAY, NULL, baseType);
|
||||
|
||||
SgExpression* letters = one->lhs()->operand(1);
|
||||
|
||||
InsertToMap(type, letters);
|
||||
}
|
||||
else {
|
||||
|
||||
SgType* type = new SgType(one->lhs()->type()->variant());
|
||||
|
||||
SgExpression* letters = one->lhs()->operand(1);
|
||||
|
||||
InsertToMap(type, letters);
|
||||
}
|
||||
|
||||
one = one->rhs();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (state->variant() == CONTROL_END) {
|
||||
|
||||
SgStatement* state = new SgStatement(IMPL_DECL);
|
||||
auto cp = function->childList1(0)->controlParent();
|
||||
function->childList1(0)->insertStmtBefore(*state, *cp);
|
||||
|
||||
|
||||
InsertDefaultToMap();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CheckVariables(function);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void InsertToMap(SgType* type, SgExpression* letters) {
|
||||
|
||||
while (letters != NULL && letters->lhs() != NULL) {
|
||||
|
||||
string letter;
|
||||
|
||||
switch (letters->lhs()->sunparse().size()) {
|
||||
|
||||
case 3:
|
||||
letter = letters->lhs()->sunparse();
|
||||
implicit[letter[1]] = type;
|
||||
|
||||
break;
|
||||
case 7:
|
||||
letter = letters->lhs()->sunparse();
|
||||
|
||||
for (char i = letter[1]; i <= letter[5]; i++) {
|
||||
implicit[i] = type;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//printf("IMPLICIT bad format (can bew only {letter : letter} or {letter})");
|
||||
throw;
|
||||
}
|
||||
|
||||
letters = letters->rhs();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void InsertDefaultToMap() {
|
||||
SgType* intType = new SgType(T_INT);
|
||||
|
||||
SgType* realType = new SgType(T_FLOAT);
|
||||
|
||||
for (char i = 'a'; i <= 'z'; i++) {
|
||||
implicit[i] = realType;
|
||||
}
|
||||
|
||||
for (char i = 'i'; i <= 'n'; i++) {
|
||||
implicit[i] = intType;
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckVariables(SgStatement* function) {
|
||||
|
||||
for (int k = 0; k < function->numberOfChildrenList1(); k++) {
|
||||
SgStatement* state = function->childList1(k);
|
||||
|
||||
|
||||
if (state->expr(0) && (state->expr(0)->variant() == VAR_REF || state->expr(0)->variant() == ARRAY_REF)) {
|
||||
SgSymbol* symbol = state->expr(0)->symbol();
|
||||
auto x = declaratedInStmt(symbol, NULL, false);
|
||||
|
||||
if (vars.find(symbol) == vars.end() && x == NULL) {
|
||||
vars.insert(symbol);
|
||||
|
||||
char firstLetter = *symbol->identifier();
|
||||
|
||||
if (implicit.find(firstLetter) != implicit.end()) {
|
||||
if (implicit[firstLetter]->variant() != symbol->type()->variant()) {
|
||||
symbol->setType(implicit[firstLetter]);
|
||||
|
||||
if (symbol->declaredInStmt() == NULL) {
|
||||
toDecl.push_back(symbol);
|
||||
}
|
||||
}
|
||||
else {
|
||||
toDecl.push_back(symbol);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//printf("Variable - ");
|
||||
//printf(symbol->identifier());
|
||||
//printf(" - not found in IMPLICIT\n");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
makeDeclaration(toDecl, function, NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user