View source code
Display the source code in dmd/backend/cod1.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.cod1

Code generation 1

Handles function calls: putting arguments in registers / on the stack, and jumping to the function.

Compiler implementation of the D programming language.



argtypes(t, arg1type, arg2type) Finds replacement types for register passing of aggregates.
buildEA(c, base, index, scale, disp) Build an EA of the form disp[base][index*scale].
buildModregrm(mod, reg, rm) Build REX, modregrm and sib bytes
callclib(cdb, e, clib, pretregs, keepmask) Generate code sequence to call C runtime library support routine. clib = CLIB.xxxx keepmask = mask of registers not to destroy. Currently can handle only 1. Should use a temporary rather than push/pop for speed.
cdfunc(cdb, e, pretregs) Generate code sequence for function call.
cdisscaledindex(cdb, e, pidxregs, keepmsk) Generate code for which isscaledindex(e) returned a non-zero result.
cdstrthis(cdb, e, pretregs)
fixresult(cdb, e, retregs, pretregs) Given the result of an expression is in retregs, generate necessary code to return result in *pretregs.
fltregs(cdb, pcs, tym) Given an opcode and EA in cs, generate code for each floating register in turn.
genEEcode() Generate code for eecontext
gensaverestore(regm, cdbsave, cdbrestore) Gen a save/restore sequence for mask of registers.
genstackclean(cdb, numpara, keepmsk) Clean parameters off stack.
getaddrmode(idxregs) Get addressing mode.
getlvalue(cdb, pcs, e, keepmsk) Compute addressing mode. Generate & return sequence of code (if any). Return in cs the info on it.
isscaledindex(e) Determine if e is a 32 bit scaled index addressing mode.
loaddata(cdb, e, pretregs) Generate code to load data into registers.
loadea(cdb, e, cs, op, reg, offset, keepmsk, desmsk) Routine to aid in setting things up for gen(). Look for common subexpression. Can handle indirection operators, but not if they're common subs.
logexp(cdb, e, jcond, fltarg, targ) Generate code for a logical expression.
offsetinreg(cdb, e, pretregs) Get offset portion of e, and store it in an index register. Return mask of index register in *pretregs.
paramsize(e, tyf) Determine size of argument e that will be pushed.
pushParams(cdb, e, stackalign, tyf) Generate code to push argument e on the stack. stackpush is incremented by stackalign for each PUSH.
regParamInPreg(s) Determine if we should leave parameter s in the register it came in, or allocate a register it using the register allocator.
tstresult(cdb, regm, tym, saveflag) Given a result in registers, test it for true or false. Will fail if TYfptr and the reg is ES! If saveflag is true, preserve the contents of the registers.


Parameter Helper function for converting OPparam's into array of Parameters.

Manifest constants

INF32 if 32 bit only
INF64 if 64 bit only
INFfloat if this is floating point
INFpusheabcdx pass EAX/EBX/ECX/EDX on stack, callee does ret 16
INFpushebx push EBX before load_localgot()
INFwkdone if weak extern is already done
SSFLlea can do it in one LEA
SSFLnobase no base register
SSFLnobase1 no base register for first LEA
SSFLnobp can't have EBP in relconst


Walter Bright


Boost License 1.0