FileDocCategorySizeDatePackage
InterferenceRegisterMapper.javaAPI DocAndroid 1.5 API5716Wed May 06 22:41:02 BST 2009com.android.dx.ssa

InterferenceRegisterMapper

public class InterferenceRegisterMapper extends BasicRegisterMapper
A register mapper that keeps track of the accumulated interference information for the registers in the new namespace. Please note that this mapper requires that the old namespace does not have variable register widths/categories, and the new namespace does.

Fields Summary
private final ArrayList
newRegInterference
Array of interference sets. ArrayList is indexed by new namespace and BitIntSet's are indexed by old namespace. The list expands as needed and missing items are assumed to interfere with nothing. Bit sets are always used here, unlike elsewhere, because the max size of this matrix will be (countSsaRegs * countRopRegs), which may grow to hundreds of K but not megabytes.
private final com.android.dx.ssa.back.InterferenceGraph
oldRegInterference
The interference graph for the old namespace
Constructors Summary
public InterferenceRegisterMapper(com.android.dx.ssa.back.InterferenceGraph oldRegInterference, int countOldRegisters)

param
countOldRegisters number of registers in old namespace.

        super(countOldRegisters);

        newRegInterference = new ArrayList<BitIntSet>();
        this.oldRegInterference = oldRegInterference;
    
Methods Summary
private voidaddInterfence(int newReg, int oldReg)
Adds a register's interference set to the interference list, growing it if necessary.

param
newReg register in new namespace
param
oldReg register in old namespace

        newRegInterference.ensureCapacity(newReg + 1);

        while (newReg >= newRegInterference.size()) {
            newRegInterference.add(new BitIntSet(newReg +1));
        }

        oldRegInterference.mergeInterferenceSet(
                oldReg, newRegInterference.get(newReg));
    
public voidaddMapping(int oldReg, int newReg, int category)
{@inheritDoc}

        super.addMapping(oldReg, newReg, category);

        addInterfence(newReg, oldReg);

        if (category == 2) {
            addInterfence(newReg + 1, oldReg);
        }
    
public booleanareAnyPinned(com.android.dx.rop.code.RegisterSpecList oldSpecs, int newReg, int targetCategory)
Checks to see if any of a set of old-namespace registers are pinned to the specified new-namespace reg + category. Takes into account the category of the old-namespace registers.

param
oldSpecs non-null; set of old-namespace regs
param
newReg >= 0 new-namespace register
param
targetCategory 1 or 2; the number of adjacent new-namespace registers (starting at ropReg) to consider
return
true if any of the old-namespace register have been mapped to the new-namespace register + category


        int sz = oldSpecs.size();
        for (int i = 0; i < sz; i++) {
            RegisterSpec oldSpec = oldSpecs.get(i);
            int r = oldToNew(oldSpec.getReg());

            /*
             * If oldSpec is a category-2 register, then check both newReg
             * and newReg - 1.
             */
            if (r == newReg
                || (oldSpec.getCategory() == 2 && (r + 1) == newReg)
                || (targetCategory == 2 && (r == newReg + 1))) {
                return true;
            }
        }
        return false;
    
public booleaninterferes(int oldReg, int newReg, int category)
Checks to see if old namespace reg oldReg interferes with what currently maps to newReg.

param
oldReg old namespace register
param
newReg new namespace register
param
category category of old namespace register
return
true if oldReg will interfere with newReg

        if (newReg >= newRegInterference.size()) {
            return false;
        } else {
            IntSet existing = newRegInterference.get(newReg);

            if (existing == null) {
                return false;
            } else if (category == 1) {
                return existing.has(oldReg);
            } else {
                return existing.has(oldReg)
                        || (interferes(oldReg, newReg+1, category-1));
            }
        }
    
public booleaninterferes(com.android.dx.rop.code.RegisterSpec oldSpec, int newReg)
Checks to see if old namespace reg oldReg interferes with what currently maps to newReg.

param
oldSpec non-null; old namespace register
param
newReg new namespace register
return
true if oldReg will interfere with newReg

        return interferes(oldSpec.getReg(), newReg, oldSpec.getCategory());