|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectharpoon.ClassFile.HCode<Instr>
harpoon.IR.Assem.Code
harpoon.Backend.Generic.Code
public abstract class Code
Generic.Code
is an abstract superclass of codeviews
which use Instr
s.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class harpoon.ClassFile.HCode |
---|
HCode.PrintCallback<HCE extends HCodeElement> |
Nested classes/interfaces inherited from interface harpoon.Util.Collections.Graph |
---|
Graph.Edge<N extends Graph.Node<N,E>,E extends Graph.Edge<N,E>>, Graph.Node<N extends Graph.Node<N,E>,E extends Graph.Edge<N,E>> |
Field Summary | |
---|---|
static boolean |
PEEPHOLE_OPTIMIZATIONS
|
Fields inherited from class harpoon.IR.Assem.Code |
---|
frame, inf, instrs, parent |
Constructor Summary | |
---|---|
protected |
Code(Code treeCode)
|
protected |
Code(Code code,
Instr i,
Derivation d,
String codeName)
Generates a new Generic.Code from
another Generic.Code , code , with
i as the root instruction (instead of whatever
root was used in code , and codeName
as the value that would be returned by a call
getName() . |
Method Summary | |
---|---|
abstract void |
assignRegister(Instr i,
Temp pseudoReg,
List regs)
Assigns a register to a Temp in i . |
Derivation |
getDerivation()
Returns the Derivation associated with
this . |
abstract String |
getName()
Return the name of this code view. |
abstract List |
getRegisters(Instr i,
Temp val)
Returns all of the Register Temp s that
val maps to in i . |
boolean |
isSafeToRemove(Instr instr)
Returns false if instr cannot be safely deleted. |
void |
printPreallocatedCode()
|
void |
printPreallocatedCode(HCode.PrintCallback callback)
|
abstract boolean |
registerAssigned(Instr i,
Temp pseudoReg)
Checks if pseudoReg has been assigned to some
registers in i . |
void |
removeAssignment(Instr i,
Temp pseudoReg)
|
String |
toAssem(Instr instr)
Overrides superclass implementation of toAssem to return an empty string if instr
can be safely eliminated from output. |
Methods inherited from class harpoon.IR.Assem.Code |
---|
elementArrayFactory, formatCommentedInstr, getElementsI, getFrame, getInstrFactory, getLeafElements, getMethod, getRegisterName, getRootElement, myPrint, myPrint, myPrint, nodes, print, print |
Methods inherited from class harpoon.ClassFile.HCode |
---|
clone, clone, elementIndexer, getElements, getElementsL, print, toString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static boolean PEEPHOLE_OPTIMIZATIONS
Constructor Detail |
---|
protected Code(Code code, Instr i, Derivation d, String codeName)
Generic.Code
from
another Generic.Code
, code
, with
i
as the root instruction (instead of whatever
root was used in code
, and codeName
as the value that would be returned by a call
getName()
. (the codeName argument is a hack to
get around a dependency problem in the constructor for
Assem.Code
.
protected Code(Code treeCode)
Method Detail |
---|
public void printPreallocatedCode()
public void printPreallocatedCode(HCode.PrintCallback callback)
public Derivation getDerivation()
Code
Derivation
associated with
this
. Returns null
if
Derivation
information is not available.
getDerivation
in class Code
public boolean isSafeToRemove(Instr instr)
instr
cannot be safely deleted.
instr
from this
stream of
instructions without changing the semantic meaning of the
program, then this might return true.
Otherwise, returns false.
public String toAssem(Instr instr)
instr
can be safely eliminated from output.
toAssem
in class Code
public abstract String getName()
HCode
"bytecode"
.
It is suggested that additional views be named in a similarly
human-friendly fashion.
getName
in class HCode<Instr>
public abstract List getRegisters(Instr i, Temp val)
Temp
s that
val
maps to in i
.
val
must be a Temp
that
is an element of i.defC()
or
i.useC()
registerAssigned(i, val)
is true
Collection
of the
Register Temp
s that are assigned to
val
in i
. Every member of the
Collection
returned will be a valid Register
for this architecture.
public abstract void assignRegister(Instr i, Temp pseudoReg, List regs)
Temp
in i
.
i
(FSK: potentially at least)
FSK: Flaw 1 -- if there are multiple references to
pseudoReg
in i
, like a := a + 1,
then this method is too general; it does not allow us to put
a's def in a different register from its use. Now, since
we're using SSI form at a high level, I don't know if we'll
ever encounter code like that (depends on how Tree->Instr form
is performed), but
(1.) I don't like relying on SSI to catch
undocumented problems like this implicitly,
(2.) we could, in theory, try to use this backend with a
non-SSI front end
The other issue here is I don't know when allowing the
flexibility of having different registers for a's def and use
will buy us anything...
UPDATE: it does buy us something:
since it allows for smaller webs w/o move instructions. we
can get around this problem relatively cheaply by maintaining
not just a Instr x Temp -> List<Reg> mapping, but instead two
mappings:
Instr x Use -> List<Reg>
Instr x Def -> List<Reg>.
i will implement this after preliminary Global Register
Allocation is working.
public abstract boolean registerAssigned(Instr i, Temp pseudoReg)
pseudoReg
has been assigned to some
registers in i
.
val
must be a Temp
that
is an element of i.defC()
or
i.useC()
pseudoReg
has been assigned
to some List
of registers in i
and removeAssignment(i, pseudoReg)
has not
been called since, returns true
.
Else returns false
.
public void removeAssignment(Instr i, Temp pseudoReg)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |