|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcoins.backend.gen.CodeGenerator
Abstract code generator. Generators for specific machines are defined as subclasses of this class.
| Nested Class Summary | |
(package private) static class |
CodeGenerator.FunctionAttr
Keeps track of function's attributes. |
(package private) class |
CodeGenerator.LexpToString
Convert address expression to external form. |
(package private) class |
CodeGenerator.Match
Node of matching tree (or DAG) |
| Field Summary | |
(package private) int |
addrType
Address type |
(package private) java.io.PrintWriter |
asmWriter
Output Writer |
(package private) java.lang.String |
convention
OS convention |
(package private) java.io.PrintWriter |
debOut
Debugging message |
(package private) NumberSet |
disableRewrite
Flags for disabling rescanning. |
(package private) static int |
F128
|
(package private) static int |
F32
|
(package private) static int |
F64
|
(package private) Function |
func
Current function |
(package private) java.util.Map |
funcAttrTbl
Function attribute tables. |
(package private) static int |
I16
|
(package private) static int |
I32
|
(package private) static int |
I64
Commonly used type constants. |
(package private) static int |
I8
|
(package private) static int |
INLINECOPYUNIT
|
(package private) CodeGenerator.LexpToString |
lexpConv
|
(package private) LirFactory |
lir
LIR factory |
(package private) LocalTransformer |
localEarlyRewritingTrig
Early time pre-rewriting of LIR, function by function. |
(package private) LocalTransformer |
localLateRewritingTrig
Late time pre-rewriting of LIR, function by function. |
(package private) java.lang.String |
machineName
CPU name |
(package private) MachineParams |
machineParams
Feature of Machine |
(package private) Module |
module
L-Module |
(package private) boolean |
optSpeed
Flag speed/space tradeoff. |
(package private) LocalTransformer |
ProcessFramesTrig
|
(package private) Root |
root
Global variables |
(package private) int |
typeParamWord
Type of parameter words on stack |
| Constructor Summary | |
CodeGenerator()
Creator |
|
| Method Summary | |
int |
alignForType(int type)
Return alignment for type. |
(package private) BiList |
buildCode(Function f)
Convert FUNCTION to S-expression assembly code. |
(package private) ImList |
clcvnClobbers()
Return clobber list |
(package private) LirNode |
clcvnParamMem(int type,
int location,
boolean caller)
Return parameter memory |
(package private) int |
clcvnParamOffset(int location)
Return offset of parameter |
(package private) LirNode |
clcvnParamReg(int type,
int location,
boolean caller)
Return parameter register |
(package private) LirNode |
clcvnParamWord(int type,
int location,
boolean caller)
Return parameter word - either register or memory. |
(package private) LirNode |
clcvnPartialWord(LirNode exp,
int part)
Return partial word of object |
(package private) void |
clcvnPassFloatRegMem(int location,
LirNode arg,
BiLink memp,
BiLink regp,
BiList alist)
Pass floating point number to register/ register and memory. |
(package private) int |
clcvnRegLimit()
Return number of registers multiply word-size. |
(package private) LirNode |
clcvnReturnValue(int type)
Return return register |
(package private) LirNode |
clcvnSetPartialWord(LirNode lhs,
int part,
LirNode rhs)
Set partial word of object |
(package private) boolean |
clcvnStructReturnAsFirst()
Return true if struct return address |
(package private) LirNode |
clcvnStructReturnPtr(boolean caller)
Create code that sets address of struct to hidden parameter. |
void |
close()
Close output stream. |
ImList |
codeInfo(LirNode ins)
Return cost and misc. |
LocalTransformer |
convToAsm()
|
(package private) abstract java.lang.String |
defaultRegsetForType(int type)
Return default register set for type. |
(package private) LirNode |
dropRegToFrame(LirNode node)
Convert (REG t ...) node to (MEM t (FRAME I32 ...)). |
Transformer[] |
earlyRewritingSequence()
Return early time pre-rewriting sequence. |
(package private) void |
emitAlign(java.io.PrintWriter out,
int align)
Emit align (Bytesize) |
(package private) java.lang.String |
emitAsmCode(java.lang.String format,
ImList args)
Emit asm instruction. |
(package private) void |
emitBeginningOfModule(Module mod,
java.io.PrintWriter out)
Emit beginning of module |
(package private) void |
emitBeginningOfSegment(java.io.PrintWriter out,
java.lang.String segment)
Emit beginning of segment |
(package private) void |
emitCode(BiList asmList,
java.io.PrintWriter file)
Emit S-expression assembly code to file. |
(package private) void |
emitCodeLabel(java.io.PrintWriter out,
java.lang.String label)
Emit label for code |
(package private) void |
emitComment(java.io.PrintWriter out,
java.lang.String comment)
print comment in assembly language. |
(package private) void |
emitCommon(java.io.PrintWriter out,
SymStatic symbol,
int bytes)
Emit data common |
(package private) void |
emitData(java.io.PrintWriter out,
int type,
LirNode node)
Emit data for big endian machine. |
(package private) void |
emitDataLabel(java.io.PrintWriter out,
java.lang.String label)
Emit label for data |
(package private) void |
emitEndOfModule(Module mod,
java.io.PrintWriter out)
Emit ending of module |
(package private) void |
emitEndOfSegment(java.io.PrintWriter out,
java.lang.String segment)
Emit end of segment |
(package private) void |
emitIdent(java.io.PrintWriter out,
java.lang.String ident)
Print .ident in assembly language. |
(package private) void |
emitLinkage(java.io.PrintWriter out,
SymStatic symbol)
Emit linkage information of symbol |
(package private) abstract java.lang.String |
emitLir(LirNode node)
Expand emit-macro for LirNode. |
(package private) java.lang.String |
emitLirDefault(LirNode node)
Default expansion action for LirNode. |
(package private) abstract java.lang.String |
emitList(ImList form,
boolean topLevel)
Expand emit-macro for list form. |
(package private) java.lang.String |
emitListDefault(ImList form,
boolean topLevel)
Default expansion action for S-expression. |
void |
emitNamedConst(java.lang.String name,
LirNode value)
Emit named constant. |
(package private) java.lang.String |
emitObject(java.lang.Object x)
Convert S-expression assembly code to string. |
(package private) java.lang.String |
emitObjectX(java.lang.Object x,
boolean top)
Convert S-expression assembly code to string. |
(package private) void |
emitSegment(java.io.PrintWriter file,
java.lang.String segment)
Change default segment to segment. |
(package private) java.lang.String |
emitTop(java.lang.Object x)
Convert toplevel S-expression assembly code to string. |
(package private) void |
emitZeros(java.io.PrintWriter out,
int bytes)
Emit data zeros |
(package private) boolean |
equalArg(LirNode x,
LirNode y)
Return true if variable x and y are same. |
(package private) abstract java.lang.Object |
expandBuildMacro(ImList form)
Expand building macro for list form. |
(package private) boolean |
frameIsEmpty(Function f)
|
(package private) int |
frameSize(Function f)
Return frame size (in positive) of function. |
void |
genHeader(Module mod)
Generate header on assembly file. |
void |
genTrailer(Module mod)
Generate trailer on assembly file. |
(package private) abstract int |
getCost1(LirNode t,
int goal)
Return the cost for LIR node t and goal nonterminal goal. |
(package private) abstract int |
getCost2(LirNode t,
int goal)
|
(package private) CodeGenerator.FunctionAttr |
getFunctionAttr(Function func)
Return function attributes. |
MachineParams |
getMachineParams()
Return machineParams |
(package private) abstract Rule |
getRule(LirNode t,
int goal)
Return the chosen rule for LIR node t and goal nonterminal goal. |
void |
initialize(Root root,
Module module,
TargetMachine target,
java.lang.String machine,
java.lang.String convention)
Set root pointer etc. |
(package private) void |
initializeMachineDep()
Do Machine-dependent initialization (subclass may override this). |
(package private) abstract void |
initLabeling(LirFactory lir)
Initialize for labeling. |
(package private) abstract void |
initRewriteLabeling()
Initialization for rewriting. |
(package private) java.io.OutputStream |
insertPostProcessor(java.io.OutputStream stream)
Insert post-processor filter pass. |
void |
instructionSelection(Function f)
Rewrite a function so that each LIR tree corresponds to single machine instruction. |
(package private) boolean |
isComplex(LirNode node)
Return true if node is a complex one. |
(package private) boolean |
isSimple(LirNode node)
Return true if node is a simple variable. |
(package private) abstract void |
labelTree(LirNode t)
Label LIR tree t. |
Transformer[] |
lateRewritingSequence()
Return late time pre-rewriting sequence. |
(package private) java.lang.String |
makeAsmSymbol(java.lang.String symbol)
Make symbol in assembly language form. |
(package private) java.lang.String |
makeLabelDef(java.lang.String label)
Return label definition |
(package private) Symbol |
mapRegToFrame(Symbol reg)
Return FRAME variable symbol entry which corresponds to REG variable. |
(package private) int |
nActualOperands(LirNode node)
Return the number of operands excluding CLOBBER and USE. |
(package private) CodeGenerator.FunctionAttr |
newFunctionAttr(Function f)
Prepare new function attribute information. |
(package private) LirNode |
noRescan(LirNode node)
Disable rewriting of LIR node. |
(package private) void |
notifyEndToPostProcessor()
Notify end of assembly to post-processor. |
(package private) int |
paramOffset(LirNode arg)
Return offset of the formal parameter (used by va_start). |
(package private) int |
paramToBeSaved()
Return the location of parameter which should be reside on memory. |
(package private) void |
peepHoleOpt(BiList list)
Peep-hole optimizer. |
(package private) LirNode |
phyReg(java.lang.String name)
Return physical register node. |
void |
prepareCodeInfo(Function f)
|
void |
prerewrite(Function f,
java.lang.String phase)
Pre-rewrite of L-Function. |
(package private) void |
printLabel(LirNode t,
java.lang.String indent)
Print label of tree t. |
(package private) abstract java.lang.Object |
quiltLir(LirNode node)
Expand building macro for LirNode. |
(package private) java.lang.Object |
quiltLirDefault(LirNode node)
Expand LirNode |
(package private) CodeGenerator.Match |
reduce(LirNode t,
int goal)
Reduce labeled tree t
with goal nonterminal goal. |
(package private) SymAuto |
reserveFrame(java.lang.String name,
int type)
Reserve frame variable. |
(package private) LirNode |
rewriteAggregateCopy(LirNode node,
BiList pre)
Rewrite aggregate copy. |
(package private) LirNode |
rewriteAsm(LirNode node,
BiList pre,
BiList post)
Rewrite ASM |
(package private) LirNode |
rewriteCall(LirNode node,
BiList pre,
BiList post)
Rewrite CALL. |
(package private) LirNode |
rewriteCONVFU(LirNode node,
BiList pre)
Rewrite CONVFU(x) to: if (x < 2147483648) CONVFS(x) else CONVFS(x - 2147483648) + 214748648 |
(package private) LirNode |
rewriteCONVUF(LirNode node,
BiList pre)
Rewrite CONVUF |
(package private) LirNode |
rewriteEpilogue(LirNode node,
BiList pre)
Rewrite EPILOGUE |
(package private) LirNode |
rewriteFrame(LirNode node)
Rewrite FRAME node to target machine form. |
(package private) LirNode |
rewriteJumpn(LirNode node,
BiList pre)
Rewrite JUMPN. |
(package private) LirNode |
rewritePrologue(LirNode node,
BiList post)
Rewrite PROLOGUE |
(package private) abstract LirNode |
rewriteTree(LirNode tree,
java.lang.String phase,
BiList pre,
BiList post)
Rewrite L-expression. |
(package private) java.lang.String |
segmentForConst()
Return segment for read-only constant. |
void |
setAsmStream(java.io.OutputStream stream)
Set assembler output stream. |
(package private) abstract java.lang.String |
showLabel(LirNode t)
Return label state |
(package private) abstract int |
startNT()
Return start nonterminal symbol. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
static final int I64
static final int I32
static final int I16
static final int I8
static final int F128
static final int F64
static final int F32
Root root
Module module
java.io.PrintWriter debOut
MachineParams machineParams
int addrType
int typeParamWord
java.lang.String machineName
java.lang.String convention
java.util.Map funcAttrTbl
boolean optSpeed
Function func
LirFactory lir
java.io.PrintWriter asmWriter
NumberSet disableRewrite
final LocalTransformer localEarlyRewritingTrig
final LocalTransformer localLateRewritingTrig
final LocalTransformer ProcessFramesTrig
static final int INLINECOPYUNIT
CodeGenerator.LexpToString lexpConv
| Constructor Detail |
public CodeGenerator()
| Method Detail |
public void initialize(Root root,
Module module,
TargetMachine target,
java.lang.String machine,
java.lang.String convention)
public void setAsmStream(java.io.OutputStream stream)
java.io.OutputStream insertPostProcessor(java.io.OutputStream stream)
void notifyEndToPostProcessor()
void initializeMachineDep()
CodeGenerator.FunctionAttr getFunctionAttr(Function func)
LirNode noRescan(LirNode node)
public void prerewrite(Function f,
java.lang.String phase)
abstract void initRewriteLabeling()
abstract LirNode rewriteTree(LirNode tree,
java.lang.String phase,
BiList pre,
BiList post)
public Transformer[] earlyRewritingSequence()
public Transformer[] lateRewritingSequence()
int frameSize(Function f)
boolean frameIsEmpty(Function f)
LirNode dropRegToFrame(LirNode node)
Symbol mapRegToFrame(Symbol reg)
SymAuto reserveFrame(java.lang.String name,
int type)
LirNode rewriteAggregateCopy(LirNode node,
BiList pre)
int paramToBeSaved()
int paramOffset(LirNode arg)
boolean equalArg(LirNode x,
LirNode y)
LirNode rewritePrologue(LirNode node,
BiList post)
LirNode rewriteEpilogue(LirNode node,
BiList pre)
boolean isComplex(LirNode node)
LirNode phyReg(java.lang.String name)
LirNode rewriteCall(LirNode node,
BiList pre,
BiList post)
int clcvnRegLimit()
LirNode clcvnParamWord(int type,
int location,
boolean caller)
LirNode clcvnParamReg(int type,
int location,
boolean caller)
LirNode clcvnParamMem(int type,
int location,
boolean caller)
void clcvnPassFloatRegMem(int location,
LirNode arg,
BiLink memp,
BiLink regp,
BiList alist)
int clcvnParamOffset(int location)
LirNode clcvnReturnValue(int type)
LirNode clcvnSetPartialWord(LirNode lhs,
int part,
LirNode rhs)
LirNode clcvnPartialWord(LirNode exp,
int part)
ImList clcvnClobbers()
boolean clcvnStructReturnAsFirst()
LirNode clcvnStructReturnPtr(boolean caller)
LirNode rewriteJumpn(LirNode node,
BiList pre)
LirNode rewriteAsm(LirNode node,
BiList pre,
BiList post)
int nActualOperands(LirNode node)
public void instructionSelection(Function f)
public void genHeader(Module mod)
public LocalTransformer convToAsm()
public void emitNamedConst(java.lang.String name,
LirNode value)
BiList buildCode(Function f)
public void prepareCodeInfo(Function f)
public ImList codeInfo(LirNode ins)
ins - instruction L-expression tree which are alpready reduced.
java.lang.Object quiltLirDefault(LirNode node)
void peepHoleOpt(BiList list)
void emitCode(BiList asmList,
java.io.PrintWriter file)
java.lang.String emitTop(java.lang.Object x)
java.lang.String emitObject(java.lang.Object x)
java.lang.String emitObjectX(java.lang.Object x,
boolean top)
top - true if this is a top-level.
java.lang.String emitListDefault(ImList form,
boolean topLevel)
java.lang.String emitLirDefault(LirNode node)
public void genTrailer(Module mod)
public void close()
void emitSegment(java.io.PrintWriter file,
java.lang.String segment)
segment.
void printLabel(LirNode t,
java.lang.String indent)
t.
CodeGenerator.Match reduce(LirNode t,
int goal)
throws NoMatchException
t
with goal nonterminal goal.
NoMatchExceptionboolean isSimple(LirNode node)
LirNode rewriteCONVUF(LirNode node,
BiList pre)
LirNode rewriteCONVFU(LirNode node,
BiList pre)
abstract void initLabeling(LirFactory lir)
abstract java.lang.String showLabel(LirNode t)
abstract void labelTree(LirNode t)
abstract Rule getRule(LirNode t,
int goal)
abstract int getCost1(LirNode t,
int goal)
abstract int getCost2(LirNode t,
int goal)
abstract int startNT()
abstract java.lang.String defaultRegsetForType(int type)
abstract java.lang.String emitList(ImList form,
boolean topLevel)
abstract java.lang.String emitLir(LirNode node)
abstract java.lang.Object expandBuildMacro(ImList form)
abstract java.lang.Object quiltLir(LirNode node)
LirNode rewriteFrame(LirNode node)
void emitIdent(java.io.PrintWriter out,
java.lang.String ident)
void emitComment(java.io.PrintWriter out,
java.lang.String comment)
void emitBeginningOfModule(Module mod,
java.io.PrintWriter out)
void emitEndOfModule(Module mod,
java.io.PrintWriter out)
void emitBeginningOfSegment(java.io.PrintWriter out,
java.lang.String segment)
void emitEndOfSegment(java.io.PrintWriter out,
java.lang.String segment)
void emitLinkage(java.io.PrintWriter out,
SymStatic symbol)
void emitDataLabel(java.io.PrintWriter out,
java.lang.String label)
void emitCodeLabel(java.io.PrintWriter out,
java.lang.String label)
void emitAlign(java.io.PrintWriter out,
int align)
void emitCommon(java.io.PrintWriter out,
SymStatic symbol,
int bytes)
void emitZeros(java.io.PrintWriter out,
int bytes)
java.lang.String emitAsmCode(java.lang.String format,
ImList args)
void emitData(java.io.PrintWriter out,
int type,
LirNode node)
CodeGenerator.FunctionAttr newFunctionAttr(Function f)
public int alignForType(int type)
java.lang.String segmentForConst()
java.lang.String makeAsmSymbol(java.lang.String symbol)
java.lang.String makeLabelDef(java.lang.String label)
public MachineParams getMachineParams()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||