@Test
 public void getBasicIntervalRegAllocStateReturnsNullIfNoMatchingIntervalIsFound() {
   CompoundInterval ci = createCompoundIntervalWithoutRegister();
   RegisterAllocatorState regAllocState = new RegisterAllocatorState(1);
   regAllocState.initializeDepthFirstNumbering(20);
   Instruction writeFloor = Empty.create(WRITE_FLOOR);
   regAllocState.setDFN(writeFloor, DEFAULT_BEGIN);
   ci.getBasicInterval(regAllocState, writeFloor);
   assertNull(ci.getBasicInterval(10));
 }
Пример #2
0
 /**
  * Attempt to rewrite a move instruction to a NOP.
  *
  * @param s the instruction to rewrite
  * @return {@code true} if and only if the transformation applies
  */
 private boolean mutateMoveToNop(Instruction s) {
   Operand result = MIR_Move.getResult(s);
   Operand val = MIR_Move.getValue(s);
   if (result.isStackLocation() && val.isStackLocation()) {
     if (result.similar(val)) {
       Empty.mutate(s, NOP);
       return true;
     }
   }
   return false;
 }
 @Test
 public void addRangeChangesEndOfLastIntervalWhenRangesDirectlyFollowEachOther_DefUse() {
   Register reg = new Register(3);
   CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, reg);
   assertThat(ci.last().getEnd(), is(DEFAULT_END));
   RegisterAllocatorState regAllocState = new RegisterAllocatorState(1);
   Instruction def = Empty.create(WRITE_FLOOR);
   Instruction lastUse = Empty.create(WRITE_FLOOR);
   LiveIntervalElement live = new LiveIntervalElement(reg, def, lastUse);
   ControlFlowGraph emptyCfg = new ControlFlowGraph(0);
   BasicBlock bb = new BasicBlock(1, null, emptyCfg);
   bb.appendInstruction(def);
   bb.appendInstruction(lastUse);
   regAllocState.initializeDepthFirstNumbering(10);
   regAllocState.setDFN(def, DEFAULT_END);
   regAllocState.setDFN(lastUse, DEFAULT_END + 1);
   BasicInterval bi = ci.addRange(regAllocState, live, bb);
   assertNull(bi);
   assertThat(ci.last().getEnd(), is(DEFAULT_END + 1));
 }
 @Test
 public void getBasicIntervalRegAllocStateReturnsAnIntervalIfOneMatches() {
   CompoundInterval ci = createCompoundIntervalWithoutRegister();
   RegisterAllocatorState regAllocState = new RegisterAllocatorState(1);
   regAllocState.initializeDepthFirstNumbering(20);
   Instruction writeFloor = Empty.create(WRITE_FLOOR);
   regAllocState.setDFN(writeFloor, DEFAULT_END);
   BasicInterval bi = ci.getBasicInterval(regAllocState, writeFloor);
   assertThat(bi.getBegin(), is(DEFAULT_BEGIN));
   assertThat(bi.getEnd(), is(DEFAULT_END));
 }
 @Test
 public void getBasicIntervalRegAllocStateReturnsIntervalWithGreatestStartIfMultipleMatch() {
   CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, null);
   ci.add(new BasicInterval(DEFAULT_BEGIN, DEFAULT_END + 1));
   RegisterAllocatorState regAllocState = new RegisterAllocatorState(1);
   regAllocState.initializeDepthFirstNumbering(20);
   Instruction writeFloor = Empty.create(WRITE_FLOOR);
   regAllocState.setDFN(writeFloor, DEFAULT_END);
   BasicInterval bi = ci.getBasicInterval(regAllocState, writeFloor);
   assertThat(bi.getBegin(), is(DEFAULT_BEGIN));
   assertThat(bi.getEnd(), is(DEFAULT_END + 1));
 }
Пример #6
0
 /**
  * Mutate FMOVs that end live ranges
  *
  * @param live The live interval for a basic block/reg pair
  * @param register The register for this live interval
  * @param dfnbegin The (adjusted) begin for this interval
  * @param dfnend The (adjusted) end for this interval
  */
 @Override
 public boolean mutateFMOVs(
     OPT_LiveIntervalElement live, OPT_Register register, int dfnbegin, int dfnend) {
   OPT_Instruction end = live.getEnd();
   if (end != null && end.operator == IA32_FMOV) {
     if (dfnend == dfnbegin) {
       // if end, an FMOV, both begins and ends the live range,
       // then end is dead.  Change it to a NOP and return null.
       Empty.mutate(end, NOP);
       return false;
     } else {
       if (!end.isPEI()) {
         if (VM.VerifyAssertions) {
           OPT_Operand value = MIR_Move.getValue(end);
           VM._assert(value.isRegister());
           VM._assert(MIR_Move.getValue(end).asRegister().getRegister() == register);
         }
         end.operator = IA32_FMOV_ENDING_LIVE_RANGE;
       }
     }
   }
   return true;
 }