dmd.backend.cgcod

Top level code for the code generator.

Members

Functions

alignsection
targ_size_t alignsection(targ_size_t base, uint alignment, int bias)

Align sections on the stack. base negative offset of section from frame pointer alignment alignment to use bias difference between where frame pointer points and the STACKALIGNed part of the stack

allocScratchReg
reg_t allocScratchReg(CodeBuilder cdb, regm_t regm)

Allocate a scratch register.

allocreg
void allocreg(CodeBuilder cdb, regm_t* pretregs, reg_t* preg, tym_t tym)

Allocate some registers. Input: pretregs Pointer to mask of registers to make selection from. tym Mask of type we will store in registers. Output: *pretregs Mask of allocated registers. *preg Register number of first allocated register. msavereg,mfuncreg retregs bits are cleared. regcon.cse.mval,regcon.cse.mops updated

andregcon
void andregcon(con_t pregconsave)

For elems in regcon that don't match regconsave, clear the corresponding bit in regcon.cse.mval. Do same for regcon.immed.

autosort_cmp
int autosort_cmp(void* ps1, void* ps2)

Predicate for sorting auto symbols for qsort().

callcdxxx
void callcdxxx(CodeBuilder cdb, elem* e, regm_t* pretregs, OPER op)

Generate code sequence for an elem. Input: pretregs = mask of possible registers to return result in Note: longs are in AX,BX or CX,DX or SI,DI doubles are AX,BX,CX,DX only constflag = 1 for user of result will not modify the registers returned in *pretregs. 2 for freenode() not called. Output: *pretregs mask of registers result is returned in

codgen
void codgen(Symbol* sfunc)

Generate code for a function. Note at the end of this routine mfuncreg will contain the mask of registers not affected by the function. Some minor optimization possibilities are here.

cse_flush
void cse_flush(CodeBuilder cdb, int do87)

Flush all CSE's out of registers and into memory. Input: do87 !=0 means save 87 registers too

cssave
bool cssave(elem* e, regm_t regm, uint opsflag)

Common subexpressions exist in registers. Note this in regcon.cse.mval. Input: e the subexpression regm mask of registers holding it opsflag if != 0 then regcon.cse.mops gets set too

docommas
void docommas(CodeBuilder cdb, elem* pe)

Scan down comma-expressions. Output: pe = first elem down right side that is not an OPcomma

evalinregister
bool evalinregister(elem* e)

Determine if a computation should be done into a register.

findreg
reg_t findreg(regm_t regm)

Given a register mask, find and return the number of the first register that fits.

freenode
void freenode(elem* e)

Free element (but not its leaves! (assume they are already freed)) Don't decrement Ecount! This is so we can detect if the common subexp has already been evaluated. If common subexpression is not required anymore, eliminate references to it.

getregs
void getregs(CodeBuilder cdb, regm_t r)

We are going to use the registers in mask r. Generate any code necessary to save any regs.

getregsNoSave
void getregsNoSave(regm_t r)

We are going to use the registers in mask r. Same as getregs(), but assert if code is needed to be generated.

getregs_imm
void getregs_imm(CodeBuilder cdb, regm_t r)

Getregs without marking immediate register values as gone.

getscratch
regm_t getscratch()

Return mask of scratch registers.

isregvar
bool isregvar(elem* e, regm_t pregm, reg_t preg)

Determine if elem e is a register variable.

lpadregs
regm_t lpadregs()

Determine registers that should be destroyed upon arrival to code entry point for exception handling.

prolog
void prolog(CodeBuilder cdb)

Generate code for a function start. Input: Offset(cseg) address of start of code Auto.alignment Output: Offset(cseg) adjusted for size of code generated EBPtoESP hasframe BPoff

regm_str
const(char)* regm_str(regm_t rm)

Turn register mask into a string suitable for printing.

scodelem
void scodelem(CodeBuilder cdb, elem* e, regm_t* pretregs, regm_t keepmsk, bool constflag)

Same as codelem(), but do not destroy the registers in keepmsk. Use scratch registers as much as possible, then use stack. Input: constflag true if user of result will not modify the registers returned in *pretregs.

stackoffsets
void stackoffsets(symtab_t symtab, bool estimate)

Compute stack frame offsets for local variables. that did not make it into registers.

useregs
void useregs(regm_t regm)

Mark registers as used.

Static variables

msavereg
regm_t msavereg;

Register masks.

stackpush
uint stackpush;
of bytes that SP is beyond BP.

Meta