|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectharpoon.Backend.Generic.InstrBuilder
public abstract class InstrBuilder
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.
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 Instr s 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 Instr s 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 Instr s 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 Instr s 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 |
---|
public InstrBuilder()
InstrBuilder
.
Method Detail |
---|
public List makeLoad(List regs, int startingOffset, Instr template)
Instr
s 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
List
s of Instr
s, so architectures
with more efficient memory-to-multiple-register operations
should override this implementation with a better one.
regs
- The target register Temp
s
to hold the values that will be loaded from
startingOffset
in memory.startingOffset
- The stack offset
(zero-indexed). This is
an ordinal number, it is NOT meant to be a multiple of
some byte size. Note that this method will load values
starting at startingOffset
and go up to
startingOffset
+
regs.size()-1
(with the first register in
regs
corresponding to
startingOffset
+ 0, the second to
startingOffset
+ 1, and so on), so code
planning to reference the locations corresponding to
the sources for the data in the register file should
account for any additional offsets.template
- An Instr
to derive
the generated List
from.
template
gives this
the
ability to incorporate additional information into the
produced List
of Instr
s.makeLoad(Temp, int, Instr)
,
getSize(harpoon.Temp.Temp)
public List makeStore(List regs, int startingOffset, Instr template)
Instr
s 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
List
s of Instr
s, so architectures
with more efficient multiple-register-to-memory operations
should override this implementation with a better one.
regs
- The register Temp
s
holding the values that will be stored starting at
startingOffset
in memory.startingOffset
- The stack offset
(zero-indexed). This is
an ordinal number, it is NOT meant to be a multiple of
some byte size. Note that this method will store values
starting at startingOffset
and go up to
startingOffset
+
regs.size()-1
(with the first register in
regs
corresponding to
startingOffset
+ 0, the second to
startingOffset
+ 1, and so on), so code
planning to reference the locations corresponding to
the targets for the data in the register file should
account for any additional offsets.template
- An Instr
to derive
the generated List
from.
template
gives this
the
ability to incorporate additional information into the
produced List
of Instr
s.makeStore(Temp, int, Instr)
,
getSize(harpoon.Temp.Temp)
protected abstract List makeLoad(Temp reg, int offset, Instr template)
Instr
s for memory traffic
from RAM to one register in the register file.
reg
- The target register Temp
to hold the value that will be loaded from
offset
in memory.offset
- The stack offset (zero-indexed).
This is an
ordinal number, it is NOT meant to be a multiple of
some byte size. This frame should perform the
necessary magic to turn the number into an appropriate
stack offset.template
- An Instr
to derive
the generated List
from.
template
gives this
the
ability to incorporate additional information into the
produced List
of Instr
s.getSize(harpoon.Temp.Temp)
protected abstract List makeStore(Temp reg, int offset, Instr template)
Instr
s for memory traffic
from the register file to RAM.
reg
- The register Temp
holding
the value that will be stored at offset
in
memory.offset
- The stack offset (zero-indexed).
This is an
abstract number, it is NOT necessarily a multiple of
some byte size. This frame should perform the
necessary magic to turn the number into an appropriate
stack offset.template
- An Instr
to derive
the generated List
from
template
gives this
the
ability to incorporate additional information into the
produced List
of Instr
s.getSize(harpoon.Temp.Temp)
public int getSize(Temp temp)
temp
on the stack.
temp
would have on the stack (in
terms of the abstract number used for calculating stack
offsets in makeLoad()
and
makeStore()
).
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)
).
makeLoad(java.util.List, int, harpoon.IR.Assem.Instr)
,
makeStore(java.util.List, int, harpoon.IR.Assem.Instr)
public InstrLABEL makeLabel(Label l, Instr template)
InstrLABEL
for generating new
arbitrary code blocks to branch to.
template
- An Instr
to base the generated
InstrLABEL
.
template
should be part of the
instruction stream that the returned
InstrLABEL
is intended for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |