/**
  * Given a symbolic register, return a code that gives the physical register type to hold the
  * value of the symbolic register.
  *
  * @param r a symbolic register
  * @return one of INT_REG, DOUBLE_REG
  */
 public static int getPhysicalRegisterType(Register r) {
   if (r.isInteger() || r.isLong() || r.isAddress()) {
     return INT_REG;
   } else if (r.isFloatingPoint()) {
     return DOUBLE_REG;
   } else {
     throw new OptimizingCompilerException("getPhysicalRegisterType " + " unexpected " + r);
   }
 }
コード例 #2
0
ファイル: StackManager.java プロジェクト: JikesRVM/JikesRVM
  @Override
  public boolean needScratch(Register r, Instruction s) {
    // We never need a scratch register for a floating point value in an
    // FMOV instruction.
    if (r.isFloatingPoint() && s.operator() == IA32_FMOV) return false;

    // never need a scratch register for a YIELDPOINT_OSR
    if (s.operator() == YIELDPOINT_OSR) return false;

    // Some MOVEs never need scratch registers
    if (isScratchFreeMove(s)) return false;

    // If s already has a memory operand, it is illegal to introduce
    // another.
    if (s.hasMemoryOperand()) return true;

    // If r appears more than once in the instruction, we can't
    // use a memory operand for all occurrences, so we will need a scratch
    int count = 0;
    for (Enumeration<Operand> ops = s.getOperands(); ops.hasMoreElements(); ) {
      Operand op = ops.nextElement();
      if (op.isRegister()) {
        RegisterOperand rop = op.asRegister();
        if (rop.getRegister() == r) {
          count++;
        }
      }
    }
    if (count > 1) return true;

    // Check the architecture restrictions.
    if (RegisterRestrictions.mustBeInRegister(r, s)) return true;

    // Otherwise, everything is OK.
    return false;
  }