Examples of Temp


Examples of IRTree2.TEMP

  }

  public Exp visit(TVarDecl n)
  {
    Access ac = currFrame.allocLocal(false);
    return new Nx(new IRTree2.MOVE(ac.exp(new TEMP(currFrame.FP())),new IRTree2.CONST(0)));
  }
View Full Code Here

Examples of IRTree2.TEMP

  {
          IRTree2.Exp e = n.e.accept(this).unEx();
      ExpList params = new ExpList(e, null);
      Temp t = new Temp();
     
      return new Ex(new ESEQ(new MOVE(new TEMP(t), currFrame.externalCall("newArray", params)),
              new TEMP(t)));
  }
View Full Code Here

Examples of IRTree2.TEMP

                  (n.e.accept(this)).unEx()));
  }

  public Exp visit(TIdentifier n)
  {
    return new Ex(new TEMP(currFrame.FP()));
  }
View Full Code Here

Examples of compiler.frames.Temp

    }
    /** NAME */
    else if (expr instanceof ImcNAME)
    {
      // Name as an expression, load label
      Temp val = new Temp();
     
      LinkedList<Temp> defs = new LinkedList<Temp>();
      defs.add(val);
     
      LinkedList<Label> lbls = new LinkedList<Label>();
      lbls.add(((ImcNAME)expr).label);
     
      instructions.add(new AsmOPER("ldr `d0, =" + lbls.get(0).name(), defs, new LinkedList<Temp>(), lbls));
     
      return val;
    }
    else
    {
      System.err.println(" -- " + expr.getClass().toString());
    }
   
    return new Temp();
  };
View Full Code Here

Examples of compiler.frames.Temp

        instructions.add(new AsmOPER("ldr `d0, =" + constValue, def, new LinkedList<Temp>()));
      }
    }
    else if (move.dst instanceof ImcTEMP && move.src instanceof ImcExpr)
    {
      Temp val = munch(move.src);
      instructions.add(new AsmMOVE("mov `d0, [`s0]", ((ImcTEMP)move.dst).temp, val));
    }
    // STR
    else if (move.dst instanceof ImcMEM)
    {
      Temp value = munch((ImcExpr)move.src);
      ImcMEM mem = (ImcMEM)move.dst;
     
      // Check if it's a label or a register with offset
     
      // NAME
      if (mem.expr instanceof ImcNAME)
      {
        LinkedList<Temp> src = new LinkedList<Temp>();
        src.add(value);
       
        instructions.add(new AsmOPER("str `s0, =" + ((ImcNAME)mem.expr).label.name(), new LinkedList<Temp>(), src));
      }
      else if (mem.expr instanceof ImcBINOP && ((ImcBINOP)mem.expr).rimc instanceof ImcCONST)
      {
        LinkedList<Temp> src = new LinkedList<Temp>();
        src.add(value);
        src.add(munch(((ImcBINOP)mem.expr).limc));
       
        int offset = ((ImcCONST)((ImcBINOP)mem.expr).rimc).value;
       
        instructions.add(new AsmOPER("str `s0, [`s1, #" + offset + "]", new LinkedList<Temp>(), src));
      }
      // Address that evaluates
      else if (((ImcBINOP)mem.expr).rimc instanceof ImcCONST)
      {
        Temp addr = munch((ImcExpr)mem.expr);
       
        LinkedList<Temp> src = new LinkedList<Temp>();
        src.add(addr);
        src.add(munch(((ImcBINOP)mem.expr).limc));
       
View Full Code Here

Examples of compiler.frames.Temp

  /**
   * Munch CJUMP
   */
  private void munch(ImcCJUMP jump)
  {
    Temp conditionResult = munch(jump.cond);
   
    LinkedList<Temp> src = new LinkedList<Temp>();
    src.add(conditionResult);
   
    // Test if condition is true
View Full Code Here

Examples of compiler.frames.Temp

    instructions.add(new AsmOPER("str `s0, [sp]", new LinkedList<Temp>(), uses));
    addComment("Store arguments");
    int offset = 4;
    for (ImcExpr arg : call.args)
    {
      Temp val = munch(arg);
     
      // Store on stack (r14 is stack pointer) and increment it (!)
      LinkedList<Temp> src = new LinkedList<Temp>();
      src.add(val);

      instructions.add(new AsmOPER("str `s0, [sp, #" + offset + "]", new LinkedList<Temp>(), src));
     
      offset += 4;
    }
   
    // JUMP
    LinkedList<Label> lbls = new LinkedList<Label>();
    lbls.add(call.label);
   
    // Store registers
    instructions.add(new AsmOPER("b " + call.label.name(), new LinkedList<Temp>(), new LinkedList<Temp>(), lbls));
   
    return new Temp();
  }
View Full Code Here

Examples of compiler.frames.Temp

      case ImcBINOP.OR:
        return munchLogical(binop);
   
      default:
        System.err.println("Unimplemented BINOP operation " + binop.op);
        return new Temp();
    }
  }
View Full Code Here

Examples of compiler.frames.Temp

   * Munch CONST
   */
  private Temp munch(ImcCONST constant)
  {
    // Load constant to a register and return it
    Temp constreg = new Temp();
    int val = constant.value;
   
    LinkedList<Temp> dst = new LinkedList<Temp>();
    dst.add(constreg);
   
View Full Code Here

Examples of compiler.frames.Temp

   * Munch MEM
   */
  private Temp munch(ImcMEM mem)
  {
    // Create LDR command depending on the parameters
    Temp dest = new Temp();
   
    LinkedList<Temp> defs = new LinkedList<Temp>();
    defs.add(dest);
   
    if (mem.expr instanceof ImcNAME)
    {
      Label label = ((ImcNAME)mem.expr).label;
     
      LinkedList<Label> lbls = new LinkedList<Label>();
      lbls.add(label);
     
      instructions.add(new AsmOPER("ldr `d0, =" + label.name(), defs, new LinkedList<Temp>(), lbls));
    }
    else if (mem.expr instanceof ImcBINOP && ((ImcBINOP)mem.expr).rimc instanceof ImcCONST)
    {
      Temp left = munch(((ImcBINOP)mem.expr).limc);
      LinkedList<Temp> src = new LinkedList<Temp>();
      src.add(left);
     
      int offset = ((ImcCONST)((ImcBINOP)mem.expr).rimc).value;
     
      instructions.add(new AsmOPER("ldr `d0, [`s0, #" + offset + "]", defs, src));
    }
    else
    {
      Temp addr = munch(mem.expr);
     
      LinkedList<Temp> src = new LinkedList<Temp>();
      src.add(addr);
     
      instructions.add(new AsmOPER("ldr, `d0, [`s0]", defs, src));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.