View source code
Display the source code in dmd/backend/cgcod.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module dmd.backend.cgcod

Top level code for the code generator.




alignsection(base, alignment, 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
allocreg(cdb, pretregs, preg, tym) Allocate some registers.
allocScratchReg(cdb, regm) Allocate a scratch register.
andregcon(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(ps1, ps2) Predicate for sorting auto symbols for qsort().
callcdxxx(cdb, e, pretregs, op) Generate code sequence for an elem.
codgen(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(cdb, do87) Flush all CSE's out of registers and into memory.
cssave(e, regm, opsflag) Common subexpressions exist in registers. Note this in regcon.cse.mval.
docommas(cdb, pe) Scan down comma-expressions.
evalinregister(e) Determine if a computation should be done into a register.
findreg(regm) Given a register mask, find and return the number of the first register that fits.
freenode(e) Free element (but not it's 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(cdb, r) We are going to use the registers in mask r. Generate any code necessary to save any regs.
getregs_imm(cdb, r) Getregs without marking immediate register values as gone.
getregsNoSave(r) We are going to use the registers in mask r. Same as getregs(), but assert if code is needed to be generated.
getscratch() Return mask of scratch registers.
isregvar(e, pregm, preg) Determine if elem e is a register variable. If so: *pregm = mask of registers that make up the variable *preg = the least significant register returns true Else returns false
lpadregs() Determine registers that should be destroyed upon arrival to code entry point for exception handling.
numbitsset(regm) Count the number of bits set in a register mask.
prolog(cdb) Generate code for a function start.
regm_str(rm) Turn register mask into a string suitable for printing.
scodelem(cdb, e, pretregs, keepmsk, constflag) Same as codelem(), but do not destroy the registers in keepmsk. Use scratch registers as much as possible, then use stack.
stackoffsets(flags) Compute offsets for remaining tmp, automatic and register variables that did not make it into registers.
useregs(regm) Mark registers as used.

Global variables

msavereg uint Register masks.
stackpush uint # of bytes that SP is beyond BP.


Walter Bright


Boost License 1.0