Package EDU.purdue.cs.bloat.codegen
Class RegisterAllocator
- java.lang.Object
-
- EDU.purdue.cs.bloat.codegen.RegisterAllocator
-
public class RegisterAllocator extends java.lang.ObjectRegisterAllocator performs analysis on a control flow graph and determines the minimum amount of local variables needed in a method.- See Also:
LocalVariable
-
-
Constructor Summary
Constructors Constructor Description RegisterAllocator(FlowGraph cfg, Liveness liveness)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intmaxLocals()Returns the maximum number of local variables used by the cfg after its "registers" (local variables) have been allocated.LocalVariablenewLocal(Type type)Creates a new local variable in this method (as modeled by the cfg).
-
-
-
Constructor Detail
-
RegisterAllocator
public RegisterAllocator(FlowGraph cfg, Liveness liveness)
Constructor. Builds an interference graph based on the expression nodes found in liveness. Traverses the graph and determines which nodes needs to be precolored and which nodes can be coalesced (move statements). Nodes are coalesced and local variables are assigned to expressions.- See Also:
FlowGraph,LocalVariable
-
-
Method Detail
-
maxLocals
public int maxLocals()
Returns the maximum number of local variables used by the cfg after its "registers" (local variables) have been allocated.
-
newLocal
public LocalVariable newLocal(Type type)
Creates a new local variable in this method (as modeled by the cfg). Updates the number of local variables appropriately.
-
-