coins.backend.gen
Class CodeGenerator_x86_64

java.lang.Object
  extended bycoins.backend.gen.CodeGenerator
      extended bycoins.backend.gen.CodeGenerator_x86_64

public class CodeGenerator_x86_64
extends CodeGenerator


Nested Class Summary
(package private)  class CodeGenerator_x86_64.RewrState
          State label for rewriting engine.
(package private)  class CodeGenerator_x86_64.State
          State label for instruction selection engine.
(package private) static class CodeGenerator_x86_64.X86_64Attr
          X86_64's function attribute
 
Nested classes inherited from class coins.backend.gen.CodeGenerator
CodeGenerator.FunctionAttr, CodeGenerator.LexpToString, CodeGenerator.Match
 
Field Summary
(package private) static int INT_CLASS
           
(package private) static java.lang.String[][] IREGPARAM
           
(package private) static int MAX_F_REGPARAM
           
(package private) static int MAX_I_REGPARAM
           
(package private)  int maxStackOffset
           
(package private) static int MEMORY
           
(package private) static int NO_CLASS
           
(package private)  int numberOfCALLs
           
(package private)  boolean rbpUsed
           
(package private)  ImList regCallClobbers
           
(package private)  LirNode retAggrAddr
           
(package private)  int[] retAggrClass
           
(package private) static java.lang.String[][] RETURN_I_REG
           
(package private) static int SSE
           
(package private)  CodeGenerator_x86_64.State[] stateVec
          State vector for labeling LIR nodes.
(package private) static java.lang.String[] STORE_F_REG
           
(package private) static java.lang.String[] STORE_I_REG
           
(package private)  SymRoot symRoot
           
(package private)  LocalTransformer TailRecursionTrig
           
 
Fields inherited from class coins.backend.gen.CodeGenerator
addrType, asmWriter, convention, debOut, disableRewrite, F128, F32, F64, func, funcAttrTbl, I16, I32, I64, I8, INLINECOPYUNIT, lexpConv, lir, localEarlyRewritingTrig, localLateRewritingTrig, machineName, machineParams, module, optSpeed, ProcessFramesTrig, root, typeParamWord
 
Constructor Summary
CodeGenerator_x86_64()
          Create code generator engine.
 
Method Summary
 int alignForType(int type)
          Return alignment for type.
(package private)  void checkLastArg(CodeGenerator_x86_64.X86_64Attr attr)
           
(package private)  int[] classify(Type aggrType)
           
(package private)  java.lang.String defaultRegsetForType(int type)
          Return default register set for type.
 Transformer[] earlyRewritingSequence()
          Return early time pre-rewriting sequence.
(package private)  java.lang.String emitAfter(java.lang.String x, java.lang.String y)
           
(package private)  void emitBeginningOfSegment(java.io.PrintWriter out, java.lang.String segment)
          Emit beginning of segment
(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
(package private)  void emitLinkage(java.io.PrintWriter out, SymStatic symbol)
          Emit linkage information of symbol
(package private)  java.lang.String emitLir(LirNode node)
          Expand emit-macro for LirNode.
(package private)  java.lang.String emitList(ImList form, boolean topLevel)
          Expand emit-macro for list form.
(package private)  void emitZeros(java.io.PrintWriter out, int bytes)
          Emit data zeros
(package private)  java.lang.Object expandBuildMacro(ImList form)
          Expand building-macro.
(package private)  java.lang.String floatSizeSuffix(java.lang.Object arg)
          Return floating point memory's size.
(package private)  int getCost1(LirNode t, int goal)
          Return the cost for LIR node t and goal nonterminal goal.
(package private)  int getCost2(LirNode t, int goal)
           
(package private)  Rule getRule(LirNode t, int goal)
          Return the chosen rule for LIR node t and goal nonterminal goal.
(package private)  SymRoot getSymRoot()
           
(package private)  Type hirType(LirNode arg)
           
(package private)  void initLabeling(LirFactory lir)
          Initialize for labeling.
(package private)  void initRewriteLabeling()
          Initialization for rewriting.
(package private)  boolean isInRegister(int[] aggrClass, int[] index_disp, int nextSize, int nextDisp, Type nextType)
           
(package private)  boolean isVarArgs(LirNode calledFunc)
           
(package private)  java.lang.Object jmac1(LirNode x)
          Decode SUBREG node.
(package private)  java.lang.String jmac10(java.lang.String base)
           
(package private)  java.lang.String jmac11(java.lang.String base, java.lang.String index)
           
(package private)  java.lang.String jmac12(java.lang.String con, java.lang.String reg)
           
(package private)  java.lang.String jmac13(java.lang.String reg, java.lang.String scale)
           
(package private)  java.lang.String jmac14(java.lang.String x)
          Return lower half register name.
(package private)  java.lang.String jmac15(java.lang.String x)
          Return lowest byte register name.
(package private)  java.lang.String jmac16(java.lang.String x)
          Return lower 32bit of memory/register/constant operand.
(package private)  java.lang.String jmac17(java.lang.String x)
           
(package private)  java.lang.String jmac18(java.lang.String x)
           
(package private)  java.lang.String jmac19(java.lang.String x)
           
(package private)  java.lang.String jmac2(java.lang.String x, java.lang.String y)
           
(package private)  java.lang.String jmac20(java.lang.String x)
          Return upper 32bit of memory/register/constant operand.
(package private)  java.lang.String jmac21(java.lang.String x)
          Return expanded 32bit register name.(w to l)
(package private)  java.lang.String jmac22(java.lang.String x)
          Return expanded 32bit register name.(b to l)
(package private)  java.lang.String jmac23(java.lang.String x)
          Return expanded 64bit register name.(l to q)
(package private)  java.lang.String jmac24(java.lang.String x)
          Return full register name.
(package private)  java.lang.String jmac25(java.lang.Object f)
          Generate prologue sequence.
(package private)  java.lang.String jmac26(java.lang.Object f, java.lang.String rettype)
          Generate epilogue sequence.
(package private)  java.lang.String jmac27(java.lang.String con)
           
(package private)  java.lang.String jmac28(java.lang.String x)
           
(package private)  java.lang.String jmac29(java.lang.String x)
           
(package private)  java.lang.String jmac3(java.lang.String x, java.lang.String y)
           
(package private)  java.lang.String jmac30(java.lang.String format, java.lang.Object args)
           
(package private)  java.lang.String jmac4(java.lang.String x, java.lang.String y)
           
(package private)  java.lang.String jmac5(java.lang.String x)
           
(package private)  java.lang.String jmac6(java.lang.String x)
           
(package private)  java.lang.String jmac7(java.lang.String x)
           
(package private)  java.lang.String jmac8(java.lang.String type, java.lang.String x)
           
(package private)  java.lang.String jmac9(java.lang.String base)
           
(package private)  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)
          Convert symbol to assembler form.
(package private)  CodeGenerator.FunctionAttr newFunctionAttr(Function func)
          Prepare new function attribute information.
(package private)  LirNode paramCount(LirNode node)
          count number of parameters in PROLOGUE
(package private)  void peepHoleOpt(BiList list)
          Postprocess list-form assembler source.
(package private)  java.lang.Object quiltLir(LirNode node)
          Expand building-macro, for LirNode
(package private)  LirNode returnReg(int type)
          Return the register for value returned.
(package private)  LirNode rewriteCall(LirNode node, BiList pre, BiList post)
          Rewrite CALL node.
(package private)  LirNode rewriteDIVMOD(LirNode node, BiList pre, int opCode)
           
(package private)  LirNode rewriteDIVMODby1(LirNode node, BiList pre, int opCode)
           
(package private)  LirNode rewriteDIVMODtoShift(LirNode node, BiList pre, int opCode)
           
(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 rewriteMULtoShift(LirNode node, BiList pre)
           
(package private)  LirNode rewritePrologue(LirNode node, BiList post)
          Rewrite PROLOGUE
(package private)  LirNode rewriteTree(LirNode tree, java.lang.String phase, BiList pre, BiList post)
          Rewrite L-expression.
(package private)  LirNode rewriteVaArg(LirNode node, BiList pre)
           
(package private)  java.lang.String segmentForConst()
          Return segment for read-only constant.
(package private)  void setAllocaCalled()
          Set alloca called.
(package private)  void setFuncAttr(int numberOfCALLs, int maxStackOffset)
           
(package private)  void setParamCount(int paramIcount, int paramFcount, LirNode lastArg)
           
(package private)  void setStackParams(int stackParams)
           
(package private)  LirNode setVaStartCalled(LirNode callNode)
           
(package private)  LirNode setVaStartCalledLate(LirNode callNode, BiList pre)
           
(package private)  java.lang.String showLabel(LirNode t)
          Return label state
(package private)  int startNT()
          Return start nonterminal symbol.
(package private)  LirNode stripConv(LirNode tree)
           
 
Methods inherited from class coins.backend.gen.CodeGenerator
buildCode, clcvnClobbers, clcvnParamMem, clcvnParamOffset, clcvnParamReg, clcvnParamWord, clcvnPartialWord, clcvnPassFloatRegMem, clcvnRegLimit, clcvnReturnValue, clcvnSetPartialWord, clcvnStructReturnAsFirst, clcvnStructReturnPtr, close, codeInfo, convToAsm, dropRegToFrame, emitAlign, emitAsmCode, emitBeginningOfModule, emitCode, emitCodeLabel, emitComment, emitDataLabel, emitEndOfModule, emitEndOfSegment, emitIdent, emitLirDefault, emitListDefault, emitNamedConst, emitObject, emitObjectX, emitSegment, emitTop, equalArg, frameIsEmpty, frameSize, genHeader, genTrailer, getFunctionAttr, getMachineParams, initialize, initializeMachineDep, insertPostProcessor, instructionSelection, isComplex, isSimple, makeLabelDef, mapRegToFrame, nActualOperands, noRescan, notifyEndToPostProcessor, paramOffset, paramToBeSaved, phyReg, prepareCodeInfo, prerewrite, printLabel, quiltLirDefault, reduce, reserveFrame, rewriteAggregateCopy, rewriteAsm, rewriteCONVFU, rewriteCONVUF, rewriteJumpn, setAsmStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stateVec

CodeGenerator_x86_64.State[] stateVec
State vector for labeling LIR nodes. Suffix is a LirNode's id.


regCallClobbers

ImList regCallClobbers

TailRecursionTrig

final LocalTransformer TailRecursionTrig

MAX_I_REGPARAM

static final int MAX_I_REGPARAM
See Also:
Constant Field Values

IREGPARAM

static final java.lang.String[][] IREGPARAM

MAX_F_REGPARAM

static final int MAX_F_REGPARAM
See Also:
Constant Field Values

STORE_F_REG

static final java.lang.String[] STORE_F_REG

STORE_I_REG

static final java.lang.String[] STORE_I_REG

RETURN_I_REG

static final java.lang.String[][] RETURN_I_REG

NO_CLASS

static final int NO_CLASS
See Also:
Constant Field Values

MEMORY

static final int MEMORY
See Also:
Constant Field Values

INT_CLASS

static final int INT_CLASS
See Also:
Constant Field Values

SSE

static final int SSE
See Also:
Constant Field Values

maxStackOffset

int maxStackOffset

numberOfCALLs

int numberOfCALLs

rbpUsed

boolean rbpUsed

retAggrClass

int[] retAggrClass

retAggrAddr

LirNode retAggrAddr

symRoot

SymRoot symRoot
Constructor Detail

CodeGenerator_x86_64

public CodeGenerator_x86_64()
Create code generator engine.

Method Detail

initRewriteLabeling

void initRewriteLabeling()
Description copied from class: CodeGenerator
Initialization for rewriting.

Specified by:
initRewriteLabeling in class CodeGenerator

rewriteTree

LirNode rewriteTree(LirNode tree,
                    java.lang.String phase,
                    BiList pre,
                    BiList post)
Rewrite L-expression.

Specified by:
rewriteTree in class CodeGenerator

defaultRegsetForType

java.lang.String defaultRegsetForType(int type)
Return default register set for type.

Specified by:
defaultRegsetForType in class CodeGenerator

initLabeling

void initLabeling(LirFactory lir)
Description copied from class: CodeGenerator
Initialize for labeling.

Specified by:
initLabeling in class CodeGenerator

showLabel

java.lang.String showLabel(LirNode t)
Description copied from class: CodeGenerator
Return label state

Specified by:
showLabel in class CodeGenerator

labelTree

void labelTree(LirNode t)
Description copied from class: CodeGenerator
Label LIR tree t.

Specified by:
labelTree in class CodeGenerator

getRule

Rule getRule(LirNode t,
             int goal)
Description copied from class: CodeGenerator
Return the chosen rule for LIR node t and goal nonterminal goal.

Specified by:
getRule in class CodeGenerator

getCost1

int getCost1(LirNode t,
             int goal)
Description copied from class: CodeGenerator
Return the cost for LIR node t and goal nonterminal goal.

Specified by:
getCost1 in class CodeGenerator

getCost2

int getCost2(LirNode t,
             int goal)
Specified by:
getCost2 in class CodeGenerator

startNT

int startNT()
Description copied from class: CodeGenerator
Return start nonterminal symbol.

Specified by:
startNT in class CodeGenerator

expandBuildMacro

java.lang.Object expandBuildMacro(ImList form)
Expand building-macro.

Specified by:
expandBuildMacro in class CodeGenerator

quiltLir

java.lang.Object quiltLir(LirNode node)
Expand building-macro, for LirNode

Specified by:
quiltLir in class CodeGenerator

emitList

java.lang.String emitList(ImList form,
                          boolean topLevel)
Expand emit-macro for list form.

Specified by:
emitList in class CodeGenerator

emitLir

java.lang.String emitLir(LirNode node)
Expand emit-macro for LirNode.

Specified by:
emitLir in class CodeGenerator

newFunctionAttr

CodeGenerator.FunctionAttr newFunctionAttr(Function func)
Description copied from class: CodeGenerator
Prepare new function attribute information.

Overrides:
newFunctionAttr in class CodeGenerator

setAllocaCalled

void setAllocaCalled()
Set alloca called.


setVaStartCalled

LirNode setVaStartCalled(LirNode callNode)

checkLastArg

void checkLastArg(CodeGenerator_x86_64.X86_64Attr attr)

setVaStartCalledLate

LirNode setVaStartCalledLate(LirNode callNode,
                             BiList pre)

rewriteVaArg

LirNode rewriteVaArg(LirNode node,
                     BiList pre)

setFuncAttr

void setFuncAttr(int numberOfCALLs,
                 int maxStackOffset)

setStackParams

void setStackParams(int stackParams)

setParamCount

void setParamCount(int paramIcount,
                   int paramFcount,
                   LirNode lastArg)

stripConv

LirNode stripConv(LirNode tree)

rewriteFrame

LirNode rewriteFrame(LirNode node)
Rewrite FRAME node to target machine form.

Overrides:
rewriteFrame in class CodeGenerator

earlyRewritingSequence

public Transformer[] earlyRewritingSequence()
Return early time pre-rewriting sequence.

Overrides:
earlyRewritingSequence in class CodeGenerator

lateRewritingSequence

public Transformer[] lateRewritingSequence()
Return late time pre-rewriting sequence.

Overrides:
lateRewritingSequence in class CodeGenerator

rewriteDIVMODby1

LirNode rewriteDIVMODby1(LirNode node,
                         BiList pre,
                         int opCode)

rewriteDIVMOD

LirNode rewriteDIVMOD(LirNode node,
                      BiList pre,
                      int opCode)

rewriteDIVMODtoShift

LirNode rewriteDIVMODtoShift(LirNode node,
                             BiList pre,
                             int opCode)

rewriteMULtoShift

LirNode rewriteMULtoShift(LirNode node,
                          BiList pre)

getSymRoot

SymRoot getSymRoot()

paramCount

LirNode paramCount(LirNode node)
count number of parameters in PROLOGUE


rewritePrologue

LirNode rewritePrologue(LirNode node,
                        BiList post)
Rewrite PROLOGUE

Overrides:
rewritePrologue in class CodeGenerator

returnReg

LirNode returnReg(int type)
Return the register for value returned.


rewriteEpilogue

LirNode rewriteEpilogue(LirNode node,
                        BiList pre)
Rewrite EPILOGUE

Overrides:
rewriteEpilogue in class CodeGenerator

isVarArgs

boolean isVarArgs(LirNode calledFunc)

hirType

Type hirType(LirNode arg)

classify

int[] classify(Type aggrType)

isInRegister

boolean isInRegister(int[] aggrClass,
                     int[] index_disp,
                     int nextSize,
                     int nextDisp,
                     Type nextType)

rewriteCall

LirNode rewriteCall(LirNode node,
                    BiList pre,
                    BiList post)
Rewrite CALL node.

Overrides:
rewriteCall in class CodeGenerator

peepHoleOpt

void peepHoleOpt(BiList list)
Postprocess list-form assembler source.

Overrides:
peepHoleOpt in class CodeGenerator
Parameters:
list - assembler source in list form.

floatSizeSuffix

java.lang.String floatSizeSuffix(java.lang.Object arg)
Return floating point memory's size.

Parameters:
arg - memory operand list.
Returns:
"s" for float, "d" for double.

jmac1

java.lang.Object jmac1(LirNode x)
Decode SUBREG node.


jmac2

java.lang.String jmac2(java.lang.String x,
                       java.lang.String y)

emitAfter

java.lang.String emitAfter(java.lang.String x,
                           java.lang.String y)

jmac3

java.lang.String jmac3(java.lang.String x,
                       java.lang.String y)

jmac4

java.lang.String jmac4(java.lang.String x,
                       java.lang.String y)

jmac5

java.lang.String jmac5(java.lang.String x)

jmac6

java.lang.String jmac6(java.lang.String x)

jmac7

java.lang.String jmac7(java.lang.String x)

jmac8

java.lang.String jmac8(java.lang.String type,
                       java.lang.String x)

jmac9

java.lang.String jmac9(java.lang.String base)

jmac10

java.lang.String jmac10(java.lang.String base)

jmac11

java.lang.String jmac11(java.lang.String base,
                        java.lang.String index)

jmac12

java.lang.String jmac12(java.lang.String con,
                        java.lang.String reg)

jmac13

java.lang.String jmac13(java.lang.String reg,
                        java.lang.String scale)

jmac14

java.lang.String jmac14(java.lang.String x)
Return lower half register name.


jmac15

java.lang.String jmac15(java.lang.String x)
Return lowest byte register name.


jmac16

java.lang.String jmac16(java.lang.String x)
Return lower 32bit of memory/register/constant operand.


jmac17

java.lang.String jmac17(java.lang.String x)

jmac18

java.lang.String jmac18(java.lang.String x)

jmac19

java.lang.String jmac19(java.lang.String x)

jmac20

java.lang.String jmac20(java.lang.String x)
Return upper 32bit of memory/register/constant operand.


jmac21

java.lang.String jmac21(java.lang.String x)
Return expanded 32bit register name.(w to l)


jmac22

java.lang.String jmac22(java.lang.String x)
Return expanded 32bit register name.(b to l)


jmac23

java.lang.String jmac23(java.lang.String x)
Return expanded 64bit register name.(l to q)


jmac24

java.lang.String jmac24(java.lang.String x)
Return full register name.


jmac25

java.lang.String jmac25(java.lang.Object f)
Generate prologue sequence.


jmac26

java.lang.String jmac26(java.lang.Object f,
                        java.lang.String rettype)
Generate epilogue sequence.


jmac27

java.lang.String jmac27(java.lang.String con)

jmac28

java.lang.String jmac28(java.lang.String x)

jmac29

java.lang.String jmac29(java.lang.String x)

jmac30

java.lang.String jmac30(java.lang.String format,
                        java.lang.Object args)

emitBeginningOfSegment

void emitBeginningOfSegment(java.io.PrintWriter out,
                            java.lang.String segment)
Emit beginning of segment

Overrides:
emitBeginningOfSegment in class CodeGenerator

emitLinkage

void emitLinkage(java.io.PrintWriter out,
                 SymStatic symbol)
Description copied from class: CodeGenerator
Emit linkage information of symbol

Overrides:
emitLinkage in class CodeGenerator

makeAsmSymbol

java.lang.String makeAsmSymbol(java.lang.String symbol)
Convert symbol to assembler form. Prepend "_" when mac or cygwin (COFF), untouched otherwise (ELF).

Overrides:
makeAsmSymbol in class CodeGenerator

alignForType

public int alignForType(int type)
Description copied from class: CodeGenerator
Return alignment for type.

Overrides:
alignForType in class CodeGenerator

segmentForConst

java.lang.String segmentForConst()
Description copied from class: CodeGenerator
Return segment for read-only constant.

Overrides:
segmentForConst in class CodeGenerator

emitData

void emitData(java.io.PrintWriter out,
              int type,
              LirNode node)
Emit data

Overrides:
emitData in class CodeGenerator

emitCommon

void emitCommon(java.io.PrintWriter out,
                SymStatic symbol,
                int bytes)
Emit data common

Overrides:
emitCommon in class CodeGenerator

emitZeros

void emitZeros(java.io.PrintWriter out,
               int bytes)
Emit data zeros

Overrides:
emitZeros in class CodeGenerator