if ((r.isFloatingPoint() && s.operator == IA32_FMOV) || (!isScratchFreeMove(s) && (s.hasMemoryOperand()))) {
boolean maybeNeedsScratch = !(r.isFloatingPoint() && s.operator==IA32_FMOV); if (maybeNeedsScratch && (!isScratchFreeMove(s) && (s.hasMemoryOperand()))) {
  void insertSpillCode() {    if (verboseDebug) {      System.out.println("INSERT SPILL CODE:");    }    // walk over each instruction in the IR    for (Enumeration e = ir.forwardInstrEnumerator(); e.hasMoreElements();) {      OPT_Instruction s = (OPT_Instruction)e.nextElement();      if (verboseDebug) {       System.out.println(s);      }      // If any scratch registers are currently in use, but use physical      // registers that appear in s, then free the scratch register.      restoreScratchRegistersBefore(s);        // we must spill all scratch registers before leaving this basic block      if (s.operator == BBEND || s.isPEI() || s.isBranch() ||           s.isReturn()) {        restoreAllScratchRegistersBefore(s);      }      // Walk over each operand and insert the appropriate spill code.      // for the operand.      for (Enumeration ops = s.getOperands(); ops.hasMoreElements(); ) {        OPT_Operand op = (OPT_Operand)ops.nextElement();        if (op != null && op.isRegister()) {          OPT_Register r = op.asRegister().register;          if (!r.isPhysical()) {            // Is r currently assigned to a scratch register?            ScratchRegister scratch = findScratchHome(r);            if (verboseDebug) {              System.out.println(r + " SCRATCH " + scratch);            }            if (scratch != null) {              // r is currently assigned to a scratch register.  Continue to              // use the same scratch register.              boolean defined = definedIn(r,s) || definesSpillLocation(r,s);              if (defined) {                scratch.setDirty(true);              }              replaceRegisterWithScratch(s,r,scratch.scratch);            } else {              // r is currently NOT assigned to a scratch register.              // Do we need to create a new scratch register to hold r?              // Note that we never need scratch floating point register              // for FMOVs, since we already have a scratch stack location              // reserved.              if ((r.isFloatingPoint() && s.operator == IA32_FMOV) ||                 (!isScratchFreeMove(s) && (s.hasMemoryOperand()))) {                // We must create a new scratch register.                boolean used = usedIn(r,s) || usesSpillLocation(r,s);                boolean defined = definedIn(r,s) || definesSpillLocation(r,s);                if (used) {                  if (!usedIn(r,s)) {                    OPT_Register r2 = spillLocationUse(r,s);                    scratch = moveToScratchBefore(s,r2);                    if (verboseDebug) {                      System.out.println("MOVED TO SCRATCH BEFORE " + r2 +                                          " " + scratch);                    }                  } else {                    scratch = moveToScratchBefore(s,r);                    if (verboseDebug) {                      System.out.println("MOVED TO SCRATCH BEFORE " + r +                                          " " + scratch);                    }                  }                }                   if (defined) {                  scratch = holdInScratchAfter(s,r);                  scratch.setDirty(true);                  if (verboseDebug) {                    System.out.println("HELD IN SCRATCH AFTER" + r +                                        " " + scratch);                  }                }                // replace the register in the target instruction.                replaceRegisterWithScratch(s,r,scratch.scratch);              } else {                // No need to use a scratch register here.                replaceOperandWithSpillLocation(s,op.asRegister());              }            }          }        }      }      // deal with sys calls that may bash non-volatiles      if (s.operator == IA32_SYSCALL) {        OPT_CallingConvention.saveNonvolatilesAroundSysCall(s,ir);      }          }  }