Package org.renjin.compiler.ir.tac.statements

Examples of org.renjin.compiler.ir.tac.statements.Assignment


//    xbar₄ ← primitive</>(τ₈, n₃)
   
    BasicBlock bb = new BasicBlock(null);
    LocalVariable lv1 = new LocalVariable("lambda", 1);
    bb.addStatement(
        new Assignment(
            var("n", 3),
            new ElementAccess(temp(4), lv1)));
    bb.addStatement(
        new Assignment(
            temp(5),
            primitiveCall("-")));
    bb.addStatement(
        new Assignment(
            temp(6),
            primitiveCall("*", temp(5), var("xbar", 3))));
    bb.addStatement(
        new Assignment(
            temp(7),
            primitiveCall("[", var("x", 0), var("n", 3))));
    bb.addStatement(
        new Assignment(
            temp(8),
            primitiveCall("+", temp(6), temp(7))));
    bb.addStatement(
        new Assignment(
            var("xbar", 4),
           primitiveCall("/", temp(8), var("n", 3))));

  
    TreeBuilder builder = new TreeBuilder();
View Full Code Here


        }
        stmt = X.replaceStatement(stmt, stmt.withRHS(rhs));
      }
     
      if(stmt instanceof Assignment) {
        Assignment assignment = (Assignment)stmt;
        if(assignment.getLHS() instanceof Variable) {
          Variable V = (Variable)assignment.getLHS();
          int i = C.get(V);
          X.replaceStatement(assignment, assignment.withLHS(new SsaVariable(V, i)));
          S.get(V).push(i);
          C.put(V, i + 1);
        }
      }
    }
   
    for(BasicBlock Y : cfg.getSuccessors(X)) {
      int j = whichPred(Y,X);
      for (Assignment A : Lists.newArrayList(Y.phiAssignments())) {
        PhiFunction rhs = (PhiFunction) A.getRHS();
        Variable V = rhs.getArgument(j);
        int i = Top(V);
        rhs = rhs.replaceVariable(j, i);
        Y.replaceStatement(A, new Assignment(A.getLHS(), rhs));
        // replace the j-th operand V in RHS(F) by V_i where i = Top(S(V))
      }
    }
    for(BasicBlock Y : dtree.getChildren(X)) {
      search(Y);
View Full Code Here

 
  private List<Statement> doBuild(BasicBlock block) {
    for(Statement stmt : block.getStatements()) {
      checkUses(stmt.getRHS());
      if(stmt instanceof Assignment) {
        Assignment assn = (Assignment) stmt;
        definition.put(assn.getLHS(), assn);
      }
      trees.add(stmt);
    }

    // variables that are only used once can be stored on the stack
View Full Code Here

  private void embed(TreeNode treeNode) {
    List<Expression> children = treeNode.getChildren();
    for(int i=0;i!=children.size();++i) {
      Expression child = children.get(i);
      if(usedOnce.contains(child)) {
        Assignment assignment = definition.get(child);
        if(assignment != null) {
          treeNode.setChild(i, assignment.getRHS());
          embeded.add(assignment);
        }
      } else {
        embed(child);
      }
View Full Code Here

    // evaluate "if true" expression
    builder.addLabel(trueTarget);
    Expression ifTrueResult = builder.translateExpression(context, call.getArgument(1));
   
    // assign this result to our temp value
    builder.addStatement(new Assignment(ifResult, ifTrueResult));

    builder.addStatement(new GotoStatement(endLabel));
   
    builder.addLabel(falseTarget);
   
    // next evaluate "if false" expression
    // if the false clause is absent, it evaluates to
    // NULL
    Expression ifFalseResult;
    if(hasElse(call)) {
      ifFalseResult = builder.translateSimpleExpression(context, call.getArgument(2));
    } else {
      ifFalseResult = new Constant(Null.INSTANCE);
    }
   
    builder.addStatement(new Assignment(ifResult, ifFalseResult));
   
    builder.addLabel(endLabel);
   
    return ifResult;
  }
View Full Code Here

    builder.addStatement(new IfStatement(condition1, firstTrue, falseLabel, firstNA));
   
    // first is true.
    // set the result to true and do the next test
    builder.addLabel(firstTrue);
    builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(true))));
    builder.addStatement(new GotoStatement(test2Label));
   
    // first is NA
    // set the result to NA and do the next test
    builder.addLabel(firstNA);
    builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(LogicalVector.NA))));
    builder.addStatement(new GotoStatement(test2Label));
   
    // check second condition
    builder.addLabel(test2Label);
    SimpleExpression condition2 = builder.translateSimpleExpression(context, call.getArgument(1));
    builder.addStatement(new IfStatement(condition2,
        finishLabel,  // if condition 2 is true, then the result is equal to condition2
        falseLabel, // if false, final result is false,
        naLabel));

    builder.addLabel(falseLabel);
    builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(false))));
    builder.addStatement(new GotoStatement(finishLabel));
   
    builder.addLabel(naLabel);
    builder.addStatement(new Assignment(result, new Constant(new LogicalArrayVector(LogicalVector.NA))));
   
    builder.addLabel(finishLabel);
  
    return result;
  }
View Full Code Here

    // since the rhs will be used as this expression's value,
    // we need to assure that it is not evaluated twice
    if(!(rhs instanceof Constant)) {
      // avoid evaluating RHS twice
      Temp temp = builder.newTemp();
      builder.addStatement(new Assignment(temp, rhs));
      rhs = temp;
    }
   
    addAssignment(builder, context, call, rhs);
    return rhs;
View Full Code Here

   
  }

  protected void doAssignment(IRBodyBuilder builder, LValue target, Expression rhs) {
    // make the final assignment to the target symbol
    builder.addStatement(new Assignment(target, rhs));
  }
View Full Code Here

      @Override
      public boolean apply(BasicBlock input) {
        for(Statement stmt : input.getStatements()) {
          if(stmt instanceof Assignment) {
            Assignment assignment = (Assignment) stmt;
            if(assignment.getLHS().equals(variable)) {
              return true;
            }
          }
        }
        return false;
View Full Code Here

      @Override
      public boolean apply(Statement input) {
        if(!(input instanceof Assignment)) {
          return false;
        }
        Assignment assignment = (Assignment) input;
        return assignment.getRHS() instanceof PhiFunction;
      }
    };
  }
View Full Code Here

TOP

Related Classes of org.renjin.compiler.ir.tac.statements.Assignment

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.