FileDocCategorySizeDatePackage
InterferenceGraph.javaAPI DocAndroid 1.5 API3263Wed May 06 22:41:02 BST 2009com.android.dx.ssa.back

InterferenceGraph

public class InterferenceGraph extends Object
A register interference graph

Fields Summary
private final ArrayList
interference
interference graph, indexed by register in both dimensions
Constructors Summary
public InterferenceGraph(int countRegs)
Creates a new graph.

param
countRegs >=0 the start count of registers in the namespace. New registers can be added subsequently.

        interference = new ArrayList<IntSet>(countRegs);

        for (int i = 0; i < countRegs; i++) {
            interference.add(SetFactory.makeInterferenceSet(countRegs));
        }
    
Methods Summary
public voidadd(int regV, int regW)
Adds a register pair to the interference/liveness graph. Parameter order is insignificant.

param
regV one register index
param
regW another register index

        ensureCapacity(Math.max(regV, regW) + 1);

        interference.get(regV).add(regW);
        interference.get(regW).add(regV);
    
public voiddumpToStdout()
Dumps interference graph to stdout for debugging.

        int oldRegCount = interference.size();

        for (int i = 0; i < oldRegCount; i++) {
            StringBuilder sb = new StringBuilder();

            sb.append("Reg " + i + ":" + interference.get(i).toString());

            System.out.println(sb.toString());
        }
    
private voidensureCapacity(int size)
Ensures that the interference graph is appropriately sized.

param
size requested minumum size

        int countRegs = interference.size();
        interference.ensureCapacity(size);
        for (int i = countRegs ; i < size; i++) {
            interference.add(SetFactory.makeInterferenceSet(size));
        }
    
public voidmergeInterferenceSet(int reg, com.android.dx.util.IntSet set)
Merges the interference set for a register into a given bit set

param
reg >=0 register
param
set non-null; interference set; will be merged with set for given register

        if (reg < interference.size()) {
            set.merge(interference.get(reg));
        }