void mtac::LiveVariableAnalysisProblem::meet(ProblemDomain& out, const ProblemDomain& in){
    if(out.top()){
        out = in;
        return;
    } else if(in.top()){
        //out does not change
        return;
    }

    for(auto& value : in.values()){
        out.values().insert(value);
    }
}
void mtac::LiveVariableAnalysisProblem::transfer(mtac::basic_block_p/* basic_block*/, mtac::Quadruple& quadruple, ProblemDomain& in){
    if(in.top()){
        ProblemDomain::Values values;
        in.int_values = values;
    }

    if(quadruple.op != mtac::Operator::NOP){
        if(mtac::erase_result(quadruple.op)){
            in.values().erase(quadruple.result);
        } else {
            in.values().insert(quadruple.result);
        }

        if_init<std::shared_ptr<Variable>>(quadruple.arg1, [&in](std::shared_ptr<Variable>& var){in.values().insert(var);});
        if_init<std::shared_ptr<Variable>>(quadruple.arg2, [&in](std::shared_ptr<Variable>& var){in.values().insert(var);});
    }
}
Exemplo n.º 3
0
void mtac::global_cse::meet(ProblemDomain& in, const ProblemDomain& out){
    eddic_assert(!in.top() || !out.top(), "At least one lattice should not be a top element");

    if(in.top()){
        in = out;
    } else if(out.top()){
        //in does not change
    } else {
        auto& first = in.values();
        auto& second = out.values();
        
        std::set<expression> intersection;

        std::set_intersection(first.begin(), first.end(), second.begin(), second.end(), std::inserter(intersection, intersection.begin()));

        in.values() = std::move(intersection);
    }
}
ProblemDomain mtac::LiveVariableAnalysisProblem::meet(ProblemDomain& out, ProblemDomain& in){
    if(out.top()){
        return in;
    } else if(in.top()){
        return out;
    }

    typename ProblemDomain::Values values;
    ProblemDomain result(values);

    for(auto& value : in.values()){
        result.values().insert(value);
    }
    
    for(auto& value : out.values()){
        result.values().insert(value);
    }

    return result;
}
void mtac::LiveVariableAnalysisProblem::transfer(mtac::basic_block_p B, ProblemDomain& x){
    auto& x_values = x.values();

    //Compute x - def(B)

    for(auto& v : def[B]){
        x_values.erase(v);
    }

    //Compute use(B) U (x - def(B))
     
    for(auto& v : use[B]){
        x_values.insert(v);
    }
}
Exemplo n.º 6
0
void mtac::global_cse::transfer(mtac::basic_block_p basic_block, ProblemDomain& out){
    auto& out_values = out.values();
    auto it = out_values.begin();

    //Compute AEin - Kill(i)

    while(it != out_values.end()){
        if(Kill[basic_block].find(*it) != Kill[basic_block].end()){
            it = out_values.erase(it);
            continue;
        }

        ++it;
    }

    //Compute Eval(i) U (AEin - Kill(i))

    for(auto& expression : Eval[basic_block]){
        out_values.insert(expression);
    }
}