harpoon.Backend.Generic
Class InstrBuilder

java.lang.Object
  |
  +--harpoon.Backend.Generic.InstrBuilder
Direct Known Subclasses:
InstrBuilder, InstrBuilder, InstrBuilder

public abstract class InstrBuilder
extends Object

InstrBuilder defines an interface that general program transformations can call to generate needed assembly code blocks for arbitrary target architectures.

Many of the Instr optimizations need to insert new code to support the transformations that they make on the code. This class provides a set of generic Instr creation routines that each backend wil implement, to be used in creating the support code.

Version:
$Id: InstrBuilder.java,v 1.3 2002/02/26 22:43:45 cananian Exp $
Author:
Felix S. Klock II <pnkfelix@mit.edu>
See Also:
harpoon.Analysis.Instr

Constructor Summary
InstrBuilder()
          Creates a InstrBuilder.
 
Method Summary
 int getSize(Temp temp)
          Returns the size of temp on the stack.
 InstrLABEL makeLabel(Label l, Instr template)
          Returns a new InstrLABEL for generating new arbitrary code blocks to branch to.
 List makeLoad(List regs, int startingOffset, Instr template)
          Generates a new set of Instrs for memory traffic from RAM to multiple registers in the register file.
protected abstract  List makeLoad(Temp reg, int offset, Instr template)
          Generates a new set of Instrs for memory traffic from RAM to one register in the register file.
 List makeStore(List regs, int startingOffset, Instr template)
          Generates a new set of Instrs for memory traffic from multiple registers in the register file to RAM.
protected abstract  List makeStore(Temp reg, int offset, Instr template)
          Generates a new set of Instrs for memory traffic from the register file to RAM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstrBuilder

public InstrBuilder()
Creates a InstrBuilder.

Method Detail

makeLoad

public List makeLoad(List regs,
                     int startingOffset,
                     Instr template)
Generates a new set of Instrs for memory traffic from RAM to multiple registers in the register file. This method's default implementation simply calls makeLoad(Temp,int,Instr) for each element of regs and concatenates the returned Lists of Instrs, so architectures with more efficient memory-to-multiple-register operations should override this implementation with a better one.

See Also:
makeLoad(Temp, int, Instr), getSize(harpoon.Temp.Temp)

makeStore

public List makeStore(List regs,
                      int startingOffset,
                      Instr template)
Generates a new set of Instrs for memory traffic from multiple registers in the register file to RAM. This method's default implementation simply calls makeStore(Temp,int,Instr) for each element of regs and concatenates the returned Lists of Instrs, so architectures with more efficient multiple-register-to-memory operations should override this implementation with a better one.

See Also:
makeStore(Temp, int, Instr), getSize(harpoon.Temp.Temp)

makeLoad

protected abstract List makeLoad(Temp reg,
                                 int offset,
                                 Instr template)
Generates a new set of Instrs for memory traffic from RAM to one register in the register file.

See Also:
getSize(harpoon.Temp.Temp)

makeStore

protected abstract List makeStore(Temp reg,
                                  int offset,
                                  Instr template)
Generates a new set of Instrs for memory traffic from the register file to RAM.

See Also:
getSize(harpoon.Temp.Temp)

getSize

public int getSize(Temp temp)
Returns the size of temp on the stack.
effects: Calculates the size that a value of the type of temp would have on the stack (in terms of the abstract number used for calculating stack offsets in makeLoad() and makeStore()).
When constructing loads and stores, the register allocator should ensure that live values do not overlap on the stack. Thus, given two temps t1 and t2, either ( offset(t2) is greater than or equal to offset(t1) + getSize(t1) ) OR ( offset(t1) is greater than or equal to offset(t2) + getSize(t2) ).
The default implementation simply returns 1; subclasses should override this and check for double word temps, etc.

See Also:
makeLoad(java.util.List, int, harpoon.IR.Assem.Instr), makeStore(java.util.List, int, harpoon.IR.Assem.Instr)

makeLabel

public InstrLABEL makeLabel(Label l,
                            Instr template)
Returns a new InstrLABEL for generating new arbitrary code blocks to branch to.

Parameters:
template - An Instr to base the generated InstrLABEL. template should be part of the instruction stream that the returned InstrLABEL is intended for.