Skip to content

Commit

Permalink
Trigger build
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusluizfb committed Jun 13, 2021
1 parent 960c69a commit 45f0cf6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
14 changes: 13 additions & 1 deletion src/main/rascal/lang/jimple/toolkit/ssa/Helpers.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lang::jimple::toolkit::FlowGraph;
import lang::jimple::core::Syntax;

public Variable returnStmtVariable(Node graphNode) {
stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
variableArg = assignStatement[0];

switch(variableArg) {
Expand All @@ -22,6 +22,18 @@ public Statement returnStmtNodeBody(Node stmtNode) {
}
}

public Variable returnPhiFunctionLeftHandSide(Expression phiFunctionExpr) {
switch(phiFunctionExpr) {
case phiFunction(leftHandSide, _): return leftHandSide;
}
}

public list[Variable] returnPhiFunctionRightHandSide(Expression phiFunctionExpr) {
switch(phiFunctionExpr) {
case phiFunction(_, rightHandSide): return rightHandSide;
}
}

public Variable returnLeftHandSideVariable(Node stmtNode) {
switch(stmtNode) {
case stmtNode(assign(leftHandSide, _)): return leftHandSide;
Expand Down
14 changes: 8 additions & 6 deletions src/main/rascal/lang/jimple/toolkit/ssa/PhiFunctionInsertion.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ module lang::jimple::toolkit::ssa::PhiFunctionInsertion
import demo::Dominators;
import Set;
import Relation;
import analysis::graphs::Graph;
import lang::jimple::toolkit::FlowGraph;
import lang::jimple::core::Syntax;
import Type;
import IO;
import Node;
import List;

import analysis::graphs::Graph;
import lang::jimple::toolkit::FlowGraph;
import lang::jimple::core::Syntax;
import lang::jimple::toolkit::ssa::Helpers;

public FlowGraph insertPhiFunctions(FlowGraph flowGraph, map[&T, set[&T]] dominanceFrontier) {
newFlowGraph = { <origin, destination> | <origin, destination> <- flowGraph };
variableList = { getStmtVariable(graphNode) | <graphNode, _> <- flowGraph, isVariable(graphNode) };
Expand Down Expand Up @@ -55,7 +57,7 @@ public bool isJoinNode(FlowGraph flowGraph, Node frontierNode) {
}

public &T getStmtVariable(Node graphNode) {
stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
variableArg = assignStatement[0];

return variableArg;
Expand All @@ -68,7 +70,7 @@ public list[Node] blocksWithVariable(FlowGraph flowGraph, Variable variable) {
public bool isVariable(Node graphNode) {
if (size(graphNode[..]) == 0) return false;

stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
if (size(assignStatement[..]) == 0) return false;

variableArg = assignStatement[0];
Expand All @@ -82,7 +84,7 @@ public bool isVariable(Node graphNode) {
public bool isSameVariable(Node graphNode, Variable variable) {
if (size(graphNode[..]) == 0) return false;

stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
if (size(assignStatement[..]) == 0) return false;

variableArg = assignStatement[0];
Expand Down
19 changes: 11 additions & 8 deletions src/main/rascal/lang/jimple/toolkit/ssa/VariableRenaming.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,12 @@ public bool isSkipableStatement(stmtArgument) {
}

public Node replacePhiFunctionVersion(map[Node, list[Node]] blockTree, Node variableNode) {
assignStatement = returnStmtNodeBody(variableNode);
assign(assignVariable, assignPhiFunction) = assignStatement;
phiFunction(phiFunctionVariable, variableVersionList) = assignPhiFunction;
assignVariable = returnLeftHandSideVariable(variableNode);
assignPhiFunction = returnRightHandSideExpression(variableNode);

phiFunctionVariable = returnPhiFunctionLeftHandSide(assignPhiFunction);
variableVersionList = returnPhiFunctionRightHandSide(assignPhiFunction);

variableName = phiFunctionVariable[0];
Immediate localVariableImmediate = local(variableName);
versionIndex = getVariableVersionStacked(localVariableImmediate);
Expand Down Expand Up @@ -274,7 +277,7 @@ public String returnCurrentVersionName(Immediate immediate) {
public bool isRenamed(Node assignNode) {
if(ignoreNode(assignNode)) return false;

stmtNode(assignStmt) = assignNode;
assignStmt = returnStmtNodeBody(assignNode);

switch(assignNode) {
case stmtNode(assign(localVariable(name), _)) : return contains(name, "version");
Expand Down Expand Up @@ -310,7 +313,7 @@ public bool ignoreNode(Node variableNode) {
public bool isOrdinaryAssignment(Node variableNode) {
if(ignoreNode(variableNode)) return false;

stmtNode(statement) = variableNode;
statement = returnStmtNodeBody(variableNode);
switch(statement) {
case assign(_, _): return true;
default: return false;
Expand All @@ -320,7 +323,7 @@ public bool isOrdinaryAssignment(Node variableNode) {
public bool isPhiFunctionAssigment(Node variableNode) {
if(ignoreNode(variableNode)) return false;

stmtNode(assignStatement) = variableNode;
assignStatement = returnStmtNodeBody(variableNode);
if(size(assignStatement[..]) != 2) return false;

possiblePhiFunction = assignStatement[1];
Expand All @@ -334,7 +337,7 @@ public bool isPhiFunctionAssigment(Node variableNode) {
public bool isVariable(Node graphNode) {
if (size(graphNode[..]) == 0) return false;

stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
variableArg = assignStatement[0];
typeOfVariableArg = typeOf(variableArg);

Expand All @@ -346,7 +349,7 @@ public bool isVariable(Node graphNode) {
public bool isSameVariable(Node graphNode, Variable variable) {
if (size(graphNode[..]) == 0) return false;

stmtNode(assignStatement) = graphNode;
assignStatement = returnStmtNodeBody(graphNode);
variableArg = assignStatement[0];
typeOfVariableArg = typeOf(variableArg);

Expand Down

0 comments on commit 45f0cf6

Please sign in to comment.