Package com.hpctoday.fada.pointers

Examples of com.hpctoday.fada.pointers.IntegerPointer


        if (parent.GetControl().IsIf())
          reverse_end = parent.GetID();
        else {
          if (!parent.GetSurroundedStatements().contains(statement)) {
            IntegerPointer last = new IntegerPointer();
            IntegerPointer rend = new IntegerPointer();
            parent.GetElseEnclosed(rend, last);

            reverse_end = rend.getValue();

            IntegerPointer _min = new IntegerPointer();
            IntegerPointer _max = new IntegerPointer();
            parent.GetEnclosed(_min, _max);
            to_be_avoided.put(_min.getValue(), _max.getValue());
          } else {
            IntegerPointer _min = new IntegerPointer();
            IntegerPointer _max = new IntegerPointer();
            parent.GetElseEnclosed(_min, _max);
            to_be_avoided.put(_min.getValue(), _max.getValue());
          }
        }

        local_if = Global.ComputeDependenciesConfigs(reverse_begin, reverse_end, stmt, array, __i, common, normalized_stmts);

        reverse_begin = parent.GetID();
        statement = parent;
        parent = statement.GetParent();
      }

      List<ElementaryDependence> valid = Global.EliminateValues2In(result, to_be_avoided);

      for (ElementaryDependence it : valid)
        result.add(it);

      // parent = loop
      if (!parent.IsProgram()) {
        IntegerPointer rbegin = new IntegerPointer();
        IntegerPointer rend = new IntegerPointer();

        parent.GetEnclosed(rend, rbegin);

        reverse_end = rend.getValue();
        reverse_begin = rbegin.getValue();

        List<ElementaryDependence> local = new ArrayList<ElementaryDependence>();
        if (was_while)
          local = Global.ComputeDependenciesConfigs(stmt, reverse_end, stmt, array, __i, common, normalized_stmts);
View Full Code Here


      for (Statement it : __stmt.GetSurroundedStatements())
        this.Normalize(it, new Condition(new Inequation(true)), __map, c);

      Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);

      IntegerPointer f = new IntegerPointer();
      IntegerPointer l = new IntegerPointer();
      IntegerPointer useless = new IntegerPointer();
      if (it.IsControl() && it.GetControl().IsIfElse())
        it.GetElseEnclosed(useless, l);
      else
        it.GetEnclosed(useless, l);

      it = __stmt.GetSurroundedStatements().get(0);
      it.GetEnclosed(f, useless);
      __stmt.SetEnclosed(f.getValue(), l.getValue());

      return;
    }

    if (__stmt.IsAssignment()) {

      int __id = normalized_stmts.size();

      List<Read_Reference> vr = new ArrayList<Read_Reference>();
      List<Written_Reference> vw = new ArrayList<Written_Reference>();

      Global.CollectReferences(__stmt.GetAssignment().GetLHSIndex(), vr);
      Global.CollectReferences(__stmt.GetAssignment().GetRHSExpression(), vr);

      Written_Reference wr = new Written_Reference(__stmt.GetAssignment().GetLHSArray(), __stmt.GetAssignment().GetLHSIndex());
      vw.add(wr);

      References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
      new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());

      __stmt.SetEnclosed(__id, __id);
      Global.Connect(__stmt, new_stmt);
      normalized_stmts.add(new_stmt);

      //log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));
      return;
    }

    if (__stmt.IsControl()) {

      if (__stmt.GetControl().IsWhileLoop()) {
        // cout<<"\nProgram::Normalize, while loops are not handled yet\n";
        // exit(EXIT_FAILURE);

        List<Read_Reference> vr = new ArrayList<Read_Reference>();
        List<Written_Reference> vw = new ArrayList<Written_Reference>();

        Global.CollectReferences(__stmt.GetControl().GetRegularDomain(), vr);

        int __id = normalized_stmts.size();

        __counters.add(__stmt.GetControl().GetCounter());
        Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());

        List<Expression> iteration = new ArrayList<Expression>();
        for (String it : __counters)
          iteration.add(new Expression(it));

        new_domain.GetRightChild().Instanciate(__id, iteration);
        __controls.put(__id, new DomainConstraint(new_domain.GetRightChild()));

        References new_stmt = new References(__id, __counters, new_domain, __controls, vr, vw, __stmt);
        new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
        Global.Connect(__stmt, new_stmt);
        normalized_stmts.add(new_stmt);
        //log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));

        for (Statement it : __stmt.GetSurroundedStatements())
          this.Normalize(it, new_domain, __controls, __counters);

        Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);

        IntegerPointer l = new IntegerPointer();
        IntegerPointer useless = new IntegerPointer();

        if (it.IsControl() && it.GetControl().IsIfElse())
          it.GetElseEnclosed(useless, l);
        else
          it.GetEnclosed(useless, l);

        __stmt.SetEnclosed(__id, l.getValue());
        return;
      }

      if (__stmt.GetControl().IsIf()) {
        int __id = normalized_stmts.size();
        List<Read_Reference> vr = new ArrayList<Read_Reference>();
        List<Written_Reference> vw = new ArrayList<Written_Reference>(); // no written variable

        Global.CollectReferences(__stmt.GetControl().GetRegularDomain(), vr);

        References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
        new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
        Global.Connect(__stmt, new_stmt);
        normalized_stmts.add(new_stmt);
        //log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));

        Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());
        List<Expression> iteration = new ArrayList<Expression>();

        for (String it : __counters)
          iteration.add(new Expression(it));

        new_domain.GetRightChild().Instanciate(__id, iteration);

        __controls.put(__id, new DomainConstraint(new_domain.GetRightChild())); // positive

        for (Statement it : __stmt.GetSurroundedStatements())
          this.Normalize(it, new_domain, __controls, __counters);

        Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);

        IntegerPointer l = new IntegerPointer();
        IntegerPointer useless = new IntegerPointer();

        if (it.IsControl() && it.GetControl().IsIfElse())
          it.GetElseEnclosed(useless, l);
        else
          it.GetEnclosed(useless, l);

        __stmt.SetEnclosed(__id, l.getValue());
       
        return;
      }

      if (__stmt.GetControl().IsIfElse()) {

        int __id = normalized_stmts.size();

        List<Read_Reference> vr = new ArrayList<Read_Reference>();
        List<Written_Reference> vw = new ArrayList<Written_Reference>(); // no written reference
        Global.CollectReferences(__stmt.GetControl().GetRegularDomain(), vr);

        References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
        new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
        Global.Connect(__stmt, new_stmt);
        normalized_stmts.add(new_stmt);
        //log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));

        Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());

        List<Expression> iteration = new ArrayList<Expression>();
        for (String it : __counters)
          iteration.add(new Expression(it));

        new_domain.GetRightChild().Instanciate(__id, iteration);

        Map<Integer, DomainConstraint> then = __controls = new HashMap<Integer, DomainConstraint>();
        then.put(__id, new DomainConstraint(new_domain.GetRightChild())); // positive

        for (Statement it : __stmt.GetSurroundedStatements())
          this.Normalize(it, new_domain, then, __counters);

        __controls.put(__id, new DomainConstraint(new_domain.GetRightChild(), false)); // positive

        Condition new_else_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl()
            .GetRegularDomain().FastNegation());

        for (Statement it : __stmt.GetElseSurroundedStatements())
          this.Normalize(it, new_else_domain, __controls, __counters);

        Statement it = __stmt.GetElseSurroundedStatements().get(__stmt.GetElseSurroundedStatements().size() - 1);

        IntegerPointer f = new IntegerPointer();
        IntegerPointer l = new IntegerPointer();
        IntegerPointer useless = new IntegerPointer();

        if (it.IsControl() && it.GetControl().IsIfElse())
          it.GetElseEnclosed(useless, l);
        else
          it.GetEnclosed(useless, l);

        it = __stmt.GetElseSurroundedStatements().get(0);

        it.GetEnclosed(f, useless);
        __stmt.SetElseEnclosed(f.getValue(), l.getValue());

        // it=__stmt.GetSurroundedStatements().begin();
        // it.GetEnclosed(&f,&useless);
        it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);

        if (it.IsControl() && it.GetControl().IsIfElse())
          it.GetElseEnclosed(useless, l);
        else
          it.GetEnclosed(useless, l);

        __stmt.SetEnclosed(__id, l.getValue());

        return;
      }

      if (__stmt.GetControl().IsForLoop()) {
        // cout<<"\nProgram::Normalize, it is a for loop\n";
        // exit(EXIT_FAILURE);

        List<Read_Reference> vr = new ArrayList<Read_Reference>();
        List<Written_Reference> vw = new ArrayList<Written_Reference>();

        Global.CollectReferences(__stmt.GetControl().GetForLowerBound(), vr);
        Global.CollectReferences(__stmt.GetControl().GetForUpperBound(), vr);
        int __id = normalized_stmts.size();

        References new_stmt = new References(__id, __counters, __domain, __controls, vr, vw, __stmt);
        new_stmt.SetPragmaConstraints(__stmt.GetPragmaConstraints());
        Global.Connect(__stmt, new_stmt);
        normalized_stmts.add(new_stmt);
        //log.trace(__id + ": " + __stmt.Regenerate_C_Code(""));

        Condition new_domain = new Condition(__domain, Condition.Logical_Operator.FADA_AND, __stmt.GetControl().GetRegularDomain());
        __counters.add(__stmt.GetControl().GetCounter());

        List<Expression> iteration = new ArrayList<Expression>();
        for (String it : __counters)
          iteration.add(new Expression(it));

        new_domain.GetRightChild().Instanciate(__id, iteration);
        __controls.put(__id, new DomainConstraint(new_domain.GetRightChild()));

        for (Statement it : __stmt.GetSurroundedStatements())
          this.Normalize(it, new_domain, __controls, __counters);

        Statement it = __stmt.GetSurroundedStatements().get(__stmt.GetSurroundedStatements().size() - 1);

        IntegerPointer l = new IntegerPointer();
        IntegerPointer useless = new IntegerPointer();

        if (it.IsControl() && it.GetControl().IsIfElse())
          it.GetElseEnclosed(useless, l);
        else
          it.GetEnclosed(useless, l);
View Full Code Here

 
  public String Print_str(int what_to_print) {
    String result = "";

    StringBuilder s = new StringBuilder();
    IntegerPointer stmt1 = new IntegerPointer(), stmt2 = new IntegerPointer();
    GetEnclosedAssignments(stmt1, stmt2);
    s.append("[").append(stmt1).append(",").append(stmt2).append("]");

    GetElsePartAssignments(stmt1, stmt2);
    s.append("[").append(stmt1).append(",").append(stmt2).append("]");
View Full Code Here

    return false;
  }

  public boolean IsEnclosed(int id) {
    IntegerPointer tf = new IntegerPointer();
    IntegerPointer tl = new IntegerPointer();
    GetEnclosed(tf, tl);
    if (IsControl() && GetControl().IsIfElse()) {
      IntegerPointer ef = new IntegerPointer();
      IntegerPointer el = new IntegerPointer();
      GetElseEnclosed(ef, el);
      return id >= tf.getValue() && id <= el.getValue();
    }
    return id >= tf.getValue() && id <= tl.getValue();
  }
View Full Code Here

    return id >= tf.getValue() && id <= tl.getValue();
  }

  public boolean IsInThenPart(int id) {
    if (IsControl() && GetControl().IsIfElse()) {
      IntegerPointer f = new IntegerPointer();
      IntegerPointer l = new IntegerPointer();
      GetEnclosed(f, l);
      return id >= f.getValue() && id <= l.getValue();
    }
    throw new RuntimeException("Statement::IsInThenPart .... fatal error (inaproriate case)");
  }
View Full Code Here

    throw new RuntimeException("Statement::IsInThenPart .... fatal error (inaproriate case)");
  }

  public boolean IsInElsePart(int id) {
    if (IsControl() && GetControl().IsIfElse()) {
      IntegerPointer f = new IntegerPointer();
      IntegerPointer l = new IntegerPointer();
      GetElseEnclosed(f, l);
      return id >= f.getValue() && id <= l.getValue();
    }
    throw new RuntimeException("Statement::IsInElsePart .... fatal error (inaproriate case)");
  }
View Full Code Here

TOP

Related Classes of com.hpctoday.fada.pointers.IntegerPointer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.