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.

Members

Enums

INF32
anonymousenum INF32

Extra information about each CLIB runtime library function.

SSFLnobp
anonymousenum SSFLnobp

Determine index if we can do two LEA instructions as a multiply.

Functions

FuncParamRegs_create
FuncParamRegs FuncParamRegs_create(tym_t tyf)

tyf: type of the function

argtypes
void argtypes(type* t, type* arg1type, type* arg2type)

Finds replacement types for register passing of aggregates.

buildEA
void buildEA(code* c, int base, int index, int scale, targ_size_t disp)

Build an EA of the form dispbase[index*scale]. Input: c struct to fill in base base register (-1 if none) index index register (-1 if none) scale scale factor - 1,2,4,8 disp displacement

buildModregrm
uint buildModregrm(int mod, int reg, int rm)

Build REX, modregrm and sib bytes

callclib
void callclib(CodeBuilder cdb, elem* e, uint clib, regm_t* pretregs, regm_t 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
void cdfunc(CodeBuilder cdb, elem* e, regm_t* pretregs)

Generate code sequence for function call.

cdisscaledindex
void cdisscaledindex(CodeBuilder cdb, elem* e, regm_t* pidxregs, regm_t keepmsk)

Generate code for which isscaledindex(e) returned a non-zero result.

cdstrthis
void cdstrthis(CodeBuilder cdb, elem* e, regm_t* pretregs)
fixresult
void fixresult(CodeBuilder cdb, elem* e, regm_t retregs, regm_t* pretregs)

Given the result of an expression is in retregs, generate necessary code to return result in *pretregs.

fltregs
void fltregs(CodeBuilder cdb, code* pcs, tym_t tym)

Given an opcode and EA in cs, generate code for each floating register in turn. Input: tym either TYdouble or TYfloat

genEEcode
void genEEcode()

Generate code for eecontext

gensaverestore
uint gensaverestore(regm_t regm, CodeBuilder cdbsave, CodeBuilder cdbrestore)

Gen a save/restore sequence for mask of registers.

genstackclean
void genstackclean(CodeBuilder cdb, uint numpara, regm_t keepmsk)

Clean parameters off stack. Input: numpara amount to adjust stack pointer keepmsk mask of registers to not destroy

getaddrmode
uint getaddrmode(regm_t idxregs)

Get addressing mode.

getlvalue
void getlvalue(CodeBuilder cdb, code* pcs, elem* e, regm_t keepmsk)

Compute addressing mode. Generate & return sequence of code (if any). Return in cs the info on it. Input: pcs -> where to store data about addressing mode e -> the lvalue elem keepmsk mask of registers we must not destroy or use if (keepmsk & RMstore), this will be only a store operation into the lvalue if (keepmsk & RMload), this will be a read operation only

getlvalue_lsw
void getlvalue_lsw(code* c)
getlvalue_msw
void getlvalue_msw(code* c)
isscaledindex
int isscaledindex(elem* e)

Determine if e is a 32 bit scaled index addressing mode.

loaddata
void loaddata(CodeBuilder cdb, elem* e, regm_t* pretregs)

Generate code to load data into registers.

loadea
void loadea(CodeBuilder cdb, elem* e, code* cs, uint op, uint reg, targ_size_t offset, regm_t keepmsk, regm_t 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. Input: e -> elem where we get some of the data from cs -> partially filled code to add op = opcode reg = reg field of (mod reg r/m) offset = data to be added to Voffset field keepmsk = mask of registers we must not destroy desmsk = mask of registers destroyed by executing the instruction

logexp
void logexp(CodeBuilder cdb, elem* e, int jcond, uint fltarg, code* targ)

Generate code for a logical expression. Input: e elem jcond bit 1 if true then goto jump address if e if false then goto jump address if !e 2 don't call save87() fltarg FLcode or FLblock, flavor of target if e evaluates to jcond targ either code or block pointer to destination

offsetinreg
void offsetinreg(CodeBuilder cdb, elem* e, regm_t* pretregs)

Get offset portion of e, and store it in an index register. Return mask of index register in *pretregs.

paramsize
targ_size_t paramsize(elem* e, tym_t tyf)

Determine size of argument e that will be pushed.

pushParams
void pushParams(CodeBuilder cdb, elem* e, uint stackalign, tym_t tyf)

Generate code to push argument e on the stack. stackpush is incremented by stackalign for each PUSH.

regParamInPreg
bool regParamInPreg(Symbol* s)

Determine if we should leave parameter s in the register it came in, or allocate a register it using the register allocator.

tstresult
void tstresult(CodeBuilder cdb, regm_t regm, tym_t tym, uint 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.

Structs

ClibInfo
struct ClibInfo
Undocumented in source but is binding to C++. You might be able to learn more by searching the web for its name.
Parameter
struct Parameter

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

Ssindex
struct Ssindex
Undocumented in source but is binding to C++. You might be able to learn more by searching the web for its name.

Meta