This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
programFile | |
:'Transformer' ID '{' transformBody (';' transformBody)* '}'; | |
transformBody | |
:transformScope '{' transformStatement+ '}' | |
|'Include Code' '{' sourceCode '}'; | |
transformScope | |
:'Within' '(' highLevelConstruct ID ')'; | |
highLevelConstruct | |
:'Function' | |
|'Struct' | |
|'Union' | |
|'File' | |
|'Project'; | |
transformStatement | |
: operation | |
| subTransform; | |
operation | |
:actionVariable ';' | |
|actionStatement ';' | |
|actionFunction ';' | |
|highLevelConstruct ID '=' actionRetrieve ';'; | |
subTransform | |
:transformLocation '{' operation+ '}'; | |
actionVariable | |
:'AddVariable' '(' typeName ',' ID (',' initializedVal)? ')' | |
|'DeleteVariable' '(' ID ')' | |
|'RenameVariable' '(' oldName=ID ',' newName=ID ')'; | |
actionStatement | |
:'AddCallStatement' '(' ID (',' callArgumentList)? ')' | |
|'AddCommentStatement''('ID')' | |
|'AddStatement' '(' statementType ')'; | |
actionFunction | |
:'RenameFunction' '(' oldName=ID ',' newName=ID ')'; | |
actionRetrieve | |
:'GetFunction' '(' ID ')' | |
|'GetFunctions' '(' prefix =ID? '*'? ')' | |
|'GetStruct' '(' ID ')' | |
|'GetVariable' '(' ID ')'; | |
transformLocation | |
: locationKeyword '(' statementType ')'; | |
locationKeyword | |
:'Around' | |
|'After' | |
|'Before' | |
|'Within'; | |
statementType | |
:assignmentStatement | |
|callStatement | |
|ifStatementWhole | |
|doStatement | |
|whileStatement | |
|forStatement | |
|declareStatement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProfilingMetaFile: public MetaFile{ | |
public: | |
ProfilingMetaFile(SgNode* astNode); | |
virtual bool translateDefinition(); | |
}; | |
bool ProfilingMetaFile::translateDefinition(){ | |
for(int i=0; i<functionList.size(); i++){ | |
pushScopeStack(functionList[i]->getFunctionBodyScope()); | |
functionList[i]->functionNormalization(); | |
vector<SgFunctionCallExp*> funCallList = functionList[i]->getFunctionCallList(); | |
for(int j=0; j<funCallList.size(); j++){ | |
string callerName = functionList[i]->getName(); | |
string calleeName = get_name(funCallList[j]); | |
SgStatement* targetStmt = functionList[i]->getStmtsContainFunctionCall(funCallList[j]); | |
string identifier = callerName + ":" + calleeName; | |
insertStatementBefore(targetStmt, buildFunctionCallStmt("profiling", new SgTypeVoid(),\ | |
buildParaList(identifier))); | |
insertStatementAfter(targetStmt, buildFunctionCallStmt("profiling", new SgTypeVoid(),\ | |
buildParaList(identifier))); | |
} | |
popScopeStack(); | |
} | |
} |
No comments:
Post a Comment