Class RegisterAllocator

java.lang.Object
EDU.purdue.cs.bloat.codegen.RegisterAllocator

public class RegisterAllocator extends Object
RegisterAllocator performs analysis on a control flow graph and determines the minimum amount of local variables needed in a method.
See Also:
  • Constructor Details

    • 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:
  • Method Details

    • 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.