Skip to content

Commit

Permalink
Merge branch 'jump_table_multi_slices' of https://github.com/mxz297/d…
Browse files Browse the repository at this point in the history
…yninst into new-parallel-parsing
  • Loading branch information
wrwilliams committed May 17, 2017
2 parents a38bacc + 8442f1a commit cec8fc8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
10 changes: 10 additions & 0 deletions parseAPI/src/IndirectASTVisitor.C
Expand Up @@ -312,6 +312,16 @@ bool JumpTableFormatVisitor::PotentialIndexing(AST::Ptr ast) {
if (ast->getID() == AST::V_RoseAST) {
RoseAST::Ptr r = boost::static_pointer_cast<RoseAST>(ast);
if (r->val().op == ROSEOperation::uMultOp || r->val().op == ROSEOperation::sMultOp) return true;
if (r->val().op == ROSEOperation::addOp) {
// The index can be subtracted
if (r->child(0)->getID() == AST::V_RoseAST && r->child(1)->getID() == AST::V_ConstantAST) {
RoseAST::Ptr lc = boost::static_pointer_cast<RoseAST>(r->child(0));
ConstantAST::Ptr rc = boost::static_pointer_cast<ConstantAST>(r->child(1));
if (lc->val().op == ROSEOperation::invertOp && rc->val().val == 1) {
return PotentialIndexing(lc->child(0));
}
}
}
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions parseAPI/src/IndirectAnalyzer.C
Expand Up @@ -205,6 +205,7 @@ void IndirectControlFlowAnalyzer::ReadTable(AST::Ptr jumpTargetExpr,
}

int IndirectControlFlowAnalyzer::GetMemoryReadSize(Assignment::Ptr memLoc) {
if (!memLoc) return 0;
Instruction::Ptr i = memLoc->insn();
std::vector<Operand> ops;
i->getOperands(ops);
Expand Down
2 changes: 2 additions & 0 deletions parseAPI/src/JumpTableFormatPred.C
Expand Up @@ -154,6 +154,7 @@ bool JumpTableFormatPred::modifyCurrentFrame(Slicer::SliceFrame &frame, Graph::P
// The last expression should be the jump target
jumpTarget = exp;
}
parsing_printf("Check expression %s\n", jumpTarget->format().c_str());
JumpTableFormatVisitor jtfv(block);
jumpTarget->accept(&jtfv);
if (jtfv.findIncorrectFormat) {
Expand All @@ -178,6 +179,7 @@ bool JumpTableFormatPred::modifyCurrentFrame(Slicer::SliceFrame &frame, Graph::P
findIndex = true;
}
if (jtfv.findIndex && jtfv.findTableBase) {
parsing_printf("\tRecord jump target expr\n");
jumpTargetExpr = jumpTarget;
return false;
}
Expand Down
22 changes: 2 additions & 20 deletions parseAPI/src/JumpTableFormatPred.h
Expand Up @@ -18,18 +18,6 @@ class JumpTableFormatPred : public Slicer::Predicates {
ThunkData &thunks;
SymbolicExpression &se;

Address targetBase;
// If tableReadSize == 0, this does not represent a memory access
// Otherwise, tableReadSize reprenents the number bytes of the access
int tableReadSize;
int tableStride;

// On ARM, the table content is often multiplied by 4 before adding with targetBase
int tcMultiply;
bool isInverted;
bool isSubReadContent;
bool isZeroExtend;

bool jumpTableFormat;
bool unknownInstruction;
bool findIndex;
Expand All @@ -48,21 +36,15 @@ class JumpTableFormatPred : public Slicer::Predicates {
ThunkData &t,
SymbolicExpression &sym):
func(f), block(b), rf(r), thunks(t), se(sym) {
targetBase = 0;
tableReadSize = 0;
tcMultiply = 1;
isInverted = false;
isSubReadContent = false;
isZeroExtend = false;
jumpTableFormat = true;
jumpTableFormat = true;
unknownInstruction = false;
findIndex = false;
firstMemoryRead = true;
}

virtual bool modifyCurrentFrame(Slicer::SliceFrame &frame, Graph::Ptr g);
std::string format();
bool isJumpTableFormat() { return jumpTableFormat && findIndex; }
bool isJumpTableFormat() { return jumpTableFormat && findIndex && jumpTargetExpr;}
bool findSpillRead(Graph::Ptr g, SliceNode::Ptr &);
void adjustActiveMap(Slicer::SliceFrame &frame, SliceNode::Ptr);
};
Expand Down

0 comments on commit cec8fc8

Please sign in to comment.