harpoon.Backend.MIPS
Class StackInfo

java.lang.Object
  extended by harpoon.Backend.MIPS.StackInfo

public class StackInfo
extends Object

This class encapsulates information about a given stack frame, e.g., does it grow up or down, where is the return address stored, that sort of thing.

INPUT

callInfo is called up front for every call made by this frame. This information is necessary for construction of the MIPS stack frame, but it is not necessary for conventions that use a non-virtual frame pointer. regAllocUsedRegs is called after register allocation to give the stackinfo object knowledge of which callee saved registers were used. regAllocLocalWords is called after the register allocation to give the stackinfo object knowledge of how many temps the spill code needs. It would be nice to give the types of the temps to the stackinfo object and let it map temp index to registers and stack offset, but that is not the current interface to the spill information.

OUTPUT

Lots of useful offsets. The multi-word (or multi-stack slot) temp support is currently limited to two word temps. It is ugly, but its not clear that generalizing the solution is a good thing at this stage.


Field Summary
static int BYTEALIGNMENT
           
static int REGISTER
           
static int REGSTACKSPLIT
           
static int STACK
           
 
Constructor Summary
StackInfo(RegFileInfo _regfile)
          Each new frame should create a new stack info object.
 
Method Summary
 int argOffset(Object inv, int arg_idx)
          Argument build are is the lowest region on the mips stack, starting at 0(sp)
 Temp argReg(Object inv, int arg_idx)
          Return which argument register this argument goes in
 int argSecondOffset(Object inv, int arg_idx)
          Give a higher offset.
 Temp argSecondReg(Object inv, int arg_idx)
          Return the second argument register for a two word temporary.
 int argWhere(Object inv, int arg_idx)
          Call this to find out if a given argument is to be passed in a register, on the stack, or (for multi-word temporaries) split between register and stack.
 Temp calleeReg(int callee_idx)
          Return the register for this callee saved register index
 int calleeSaveOffset(int callee_idx)
          Return the offset for a given callee saved register index.
 int calleeSaveTotal()
          Return how many callee saved registers there are for this frame
 void callInfo(INVOCATION inv)
          Call callInfo with the destination label and argument list for all calls made by this activation frame.
 void callInfo(METHOD meth)
          For callee argument information call callInfo with METHOD object, and we will interpret the parameter list.
 int frameSize()
           
 int getFPOffset()
           
 int getRAOffset()
           
 int localSaveOffset(int local_idx)
          Return the offset for a given local index
 void regAllocLocalWords(int w)
          On top (highest address) of the MIPS stack frame are the locals/temporaries This isn't a great interface, but it is the info we get from RegAlloc.
 void regAllocUsedRegs(ArrayList used)
          Give the stack frame model the array of used callee saved registers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGISTER

public static final int REGISTER
See Also:
Constant Field Values

STACK

public static final int STACK
See Also:
Constant Field Values

REGSTACKSPLIT

public static final int REGSTACKSPLIT
See Also:
Constant Field Values

BYTEALIGNMENT

public static final int BYTEALIGNMENT
See Also:
Constant Field Values
Constructor Detail

StackInfo

public StackInfo(RegFileInfo _regfile)
Each new frame should create a new stack info object.

Method Detail

argOffset

public int argOffset(Object inv,
                     int arg_idx)
Argument build are is the lowest region on the mips stack, starting at 0(sp)


argSecondOffset

public int argSecondOffset(Object inv,
                           int arg_idx)
Give a higher offset. If you are big endian, this is the least signifigant word.


argWhere

public int argWhere(Object inv,
                    int arg_idx)
Call this to find out if a given argument is to be passed in a register, on the stack, or (for multi-word temporaries) split between register and stack.


argReg

public Temp argReg(Object inv,
                   int arg_idx)
Return which argument register this argument goes in


argSecondReg

public Temp argSecondReg(Object inv,
                         int arg_idx)
Return the second argument register for a two word temporary.


regAllocUsedRegs

public void regAllocUsedRegs(ArrayList used)
Give the stack frame model the array of used callee saved registers. There should be no duplicates, and you probably want to sort the list (it probably should be a LinearSet)


calleeSaveTotal

public int calleeSaveTotal()
Return how many callee saved registers there are for this frame


calleeReg

public Temp calleeReg(int callee_idx)
Return the register for this callee saved register index


calleeSaveOffset

public int calleeSaveOffset(int callee_idx)
Return the offset for a given callee saved register index.


regAllocLocalWords

public void regAllocLocalWords(int w)
On top (highest address) of the MIPS stack frame are the locals/temporaries This isn't a great interface, but it is the info we get from RegAlloc. I would have expected somethine like an ExpList, just like arguments.


localSaveOffset

public int localSaveOffset(int local_idx)
Return the offset for a given local index


getFPOffset

public int getFPOffset()

getRAOffset

public int getRAOffset()

frameSize

public int frameSize()

callInfo

public void callInfo(INVOCATION inv)
Call callInfo with the destination label and argument list for all calls made by this activation frame. The stack then knows about every function it has to call.


callInfo

public void callInfo(METHOD meth)
For callee argument information call callInfo with METHOD object, and we will interpret the parameter list.