Commit 11910381 authored by Ballabriga Clément's avatar Ballabriga Clément
Browse files

analyse modulaire marche avec les tests unitaires + multi.c + fibcall

parent 6361ccb5
......@@ -433,7 +433,7 @@ class PPLDomain {
* @param v2 Second variable
* @return true if must be equal, false otherwise
*/
bool mustAlias(const Variable &v1, const Variable &v2) const;
bool mustAlias(const Variable &v1, const Variable &v2, int offset = 0) const;
/**
* Attempts to get the value of a a variable mapped to an identifier, if this value can be statically determined,
......
......@@ -483,8 +483,8 @@ bool PPLDomain::mayAlias(const Variable &v1, const Variable &v2) const {
return !poly.relation_with(v1 == v2).implies(PPL::Poly_Con_Relation::is_disjoint());
}
bool PPLDomain::mustAlias(const Variable &v1, const Variable &v2) const {
return poly.relation_with(v1 == v2).implies(PPL::Poly_Con_Relation::is_included());
bool PPLDomain::mustAlias(const Variable &v1, const Variable &v2, int offset) const {
return poly.relation_with(v1 == v2 + offset).implies(PPL::Poly_Con_Relation::is_included());
}
void PPLDomain::displayIdentMap(io::Output &out) const {
......@@ -743,6 +743,10 @@ PPLDomain PPLDomain::onCompose(const PPLDomain &summary) const {
// registers
for (MyHTable<Ident, int, HashIdent>::PairIterator it(out.id2axis); it; it++) {
if ((*it).fst.getType() == Ident::ID_REG_INPUT) {
/*
if ((*it).fst.getId() == 13)
break; // FIXME
*/
#ifdef POLY_DEBUG
cout << "Link input register: " << (*it).fst << endl;;
#endif
......@@ -763,6 +767,7 @@ PPLDomain PPLDomain::onCompose(const PPLDomain &summary) const {
bool changes = true;
Vector<Ident> input_done;
Vector<Ident> input_preserve;
cout << "out before link:" << out << endl;
while (changes) {
changes = false;
for (MyHTable<Ident, int, HashIdent>::PairIterator it(out.id2axis); it; it++) {
......@@ -778,6 +783,7 @@ PPLDomain PPLDomain::onCompose(const PPLDomain &summary) const {
Ident idFormalAddr((*it).fst.getId(), Ident::ID_MEM_ADDR);
Variable formalAddr = out.getVar(idFormalAddr);
Variable effectiveAddr = getVar((*it2).fst);
cout << "test " << formalAddr << " avec " << effectiveAddr << endl;
if (out.mustAlias(formalAddr, effectiveAddr)) {
found = true;
link_mem.add(idFormalAddr);
......@@ -839,7 +845,7 @@ PPLDomain PPLDomain::onCompose(const PPLDomain &summary) const {
Ident id_sfp(Ident::ID_START_FP, Ident::ID_SPECIAL);
Ident id_slr(Ident::ID_START_LR, Ident::ID_SPECIAL);
if (hasIdent(id_ssp) && out.hasIdent(id_ssp)) {
out.doNewConstraint(getVar(id_sp) - 4 == out.getVar(id_ssp));
out.doNewConstraint(getVar(id_sp) == out.getVar(id_ssp));
out.doNewConstraint(getVar(id_fp) == out.getVar(id_sfp));
out.doNewConstraint(getVar(id_slr) == out.getVar(id_slr));
}
......@@ -871,6 +877,22 @@ PPLDomain PPLDomain::onCompose(const PPLDomain &summary) const {
out.varKill(*it);
}
if (out.hasIdent(Ident(Ident::ID_START_SP, Ident::ID_SPECIAL))) {
out.varKill(Ident(Ident::ID_START_SP, Ident::ID_SPECIAL));
out.varKill(Ident(Ident::ID_START_FP, Ident::ID_SPECIAL));
out.varKill(Ident(Ident::ID_START_LR, Ident::ID_SPECIAL));
out.id2axis[Ident(Ident::ID_START_SP, Ident::ID_SPECIAL)]
= getVar(Ident(Ident::ID_START_SP, Ident::ID_SPECIAL)).id();
out.axis2id[getVar(Ident(Ident::ID_START_SP, Ident::ID_SPECIAL)).id()] = Ident(Ident::ID_START_SP, Ident::ID_SPECIAL);
out.id2axis[Ident(Ident::ID_START_FP, Ident::ID_SPECIAL)]
= getVar(Ident(Ident::ID_START_FP, Ident::ID_SPECIAL)).id();
out.axis2id[getVar(Ident(Ident::ID_START_FP, Ident::ID_SPECIAL)).id()] = Ident(Ident::ID_START_FP, Ident::ID_SPECIAL);
out.id2axis[Ident(Ident::ID_START_LR, Ident::ID_SPECIAL)]
= getVar(Ident(Ident::ID_START_LR, Ident::ID_SPECIAL)).id();
out.axis2id[getVar(Ident(Ident::ID_START_LR, Ident::ID_SPECIAL)).id()] = Ident(Ident::ID_START_LR, Ident::ID_SPECIAL);
}
#ifdef POLY_DEBUG
cout << "Taking care of side-effects..." << endl;
#endif
......@@ -1286,8 +1308,7 @@ PPLDomain PPLDomain::onSemInst(const sem::inst &si, int /*instaddr*/) const {
// we are summarizing
Ident idSSP(Ident::ID_START_SP, Ident::ID_SPECIAL);
const Variable &vSSP = s_out.getVar(idSSP);
// s_out.doNewConstraint(storeValue >= int(stackconf_t::STACK_TOP) + int(stackconf_t::STACK_SIZE));
s_out.doNewConstraint(storeValue >= vSSP + 4);
s_out.doNewConstraint(storeValue >= vSSP);
}
/*
......@@ -2364,6 +2385,10 @@ void PPLDomain::_doBinaryOp(int op, Variable *v, Variable *vs1, Variable *vs2) {
void PPLDomain::enableSummary() {
_summary = new PPLSummary();
/*
const Variable &spInput = varNew(Ident(13, Ident::ID_REG_INPUT));
doNewConstraint(spInput == getVar(Ident(13, Ident::ID_REG)));
*/
}
p::feature POLY_ANALYSIS_FEATURE("otawa::poly::POLY_ANALYSIS_FEATURE", new Maker<PolyAnalysis>());
......
......@@ -43,6 +43,7 @@ PPLManager::PPLManager(const PropList &props, WorkSpace *ws)
_init.doNewConstraint(var_sfp >= int(stackconf_t::STACK_TOP));
_init.doNewConstraint(var_ssp <= int(stackconf_t::STACK_TOP + 0x1000000));
_init.doNewConstraint(var_sfp <= int(stackconf_t::STACK_TOP + 0x1000000));
}
} // namespace poly
......
......@@ -69,7 +69,7 @@ PolyAnalysis::state_t PolyAnalysis::processHeader(ai::CFGGraph &graph, MyHTable<
backState.setBound(header->id(), bound);
PPLDomain linearBound = backState.getLinearExpr(Ident(header->id(), Ident::ID_LOOP));
// cout << "setBound: " << int(bound) << endl;
cout << "setLinBound: " << linearBound << endl;
backState.setLinBound(header->id(), linearBound);
#ifdef POLY_DEBUG
......@@ -141,7 +141,6 @@ void PolyAnalysis::processBB(PPLManager *man, ai::CFGGraph &graph, MyHTable<int,
cout << "Finished creating summary of " << subCFG->name() << ", returning to " << (*ana)->toSynth()->caller()->name() << endl;
SUMMARY(subCFG) = new PPLDomain(sum);
MAX_LINEAR(subCFG) = sublb;
#ifdef POLY_DEBUG
cout << "summary = " << endl;
cout << sum << endl;
cout << "parametric bounds = " << endl;
......@@ -149,6 +148,7 @@ void PolyAnalysis::processBB(PPLManager *man, ai::CFGGraph &graph, MyHTable<int,
cout << (*it).fst << " --> " << (*it).snd << endl;
}
cout << endl;
#ifdef POLY_DEBUG
#endif
} else {
cout << "Reusing to reusing existing summary." << endl;
......@@ -165,22 +165,25 @@ void PolyAnalysis::processBB(PPLManager *man, ai::CFGGraph &graph, MyHTable<int,
if (tmp.isBottom()) {
cout << "Failed to use summary due to constraint violation" << endl;
} else {
s = tmp;
compose_ok = true;
MyHTable<int, PPLDomain> *sublb = MAX_LINEAR(subCFG);
for (MyHTable<int, PPLDomain>::PairIterator it(*sublb); it; it++) {
PPLDomain composed((*it).snd);
cout << "linear bounds: " << composed << endl;
cout << "caller state: " << s << endl;
composed = s.onCompose(composed);
cout << "composed bounds: " << composed << endl;
composed = composed.getLinearExpr(Ident((*it).fst, Ident::ID_LOOP));
if (!lb.hasKey((*it).fst))
lb[(*it).fst] = PPLDomain();
lb[(*it).fst] = lb.get((*it).fst).value().onMerge(composed, false);
}
s = tmp;
#ifdef POLY_DEBUG
cout << "Composed state = " << endl;
cout << s << endl;
#ifdef POLY_DEBUG
#endif
}
}
......@@ -310,6 +313,7 @@ void PolyAnalysis::processBB(PPLManager *man, ai::CFGGraph &graph, MyHTable<int,
if (Dominance::dominates(e->sink(), e->source())) {
/* Back-Edge: increment virtual loop counter */
edgeState = edgeState.onLoopIter(e->sink()->id());
cout << "LOOPITER" << endl;
} else {
/* Entry-Edge: initialize virtal loop counter */
edgeState = edgeState.onLoopEntry(e->sink()->id());
......@@ -336,6 +340,9 @@ void PolyAnalysis::processBB(PPLManager *man, ai::CFGGraph &graph, MyHTable<int,
if (edgeState.isBottom())
continue;
}
#ifdef POLY_DEBUG
cout << "linbound for " << bb->id() << " is " << linBound << endl;
#endif
/*
if (bound >= 0) {
edgeState = edgeState.onLoopExit(bb->id(), bound);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment