Skip to content

Commit

Permalink
backend: Replace C pointer syntax with D (#20726)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorpel authored Jan 18, 2025
1 parent 971a1d6 commit 670a6c1
Show file tree
Hide file tree
Showing 66 changed files with 2,371 additions and 2,371 deletions.
12 changes: 6 additions & 6 deletions compiler/src/dmd/backend/aarray.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ nothrow:
*/
private struct aaA
{
aaA *next;
aaA* next;
hash_t hash; // hash of the key
/* key */ // key value goes here
/* value */ // value value goes here
Expand Down Expand Up @@ -144,11 +144,11 @@ nothrow:

// Not found, create new elem
//printf("create new one\n");
e = cast(aaA *) malloc(aaA.sizeof + aligned_keysize + Value.sizeof);
e = cast(aaA*) malloc(aaA.sizeof + aligned_keysize + Value.sizeof);
if (!e)
err_nomem();
memcpy(e + 1, &pkey, Key.sizeof);
memset(cast(void *)(e + 1) + aligned_keysize, 0, Value.sizeof);
memset(cast(void*)(e + 1) + aligned_keysize, 0, Value.sizeof);
e.hash = key_hash;
e.next = null;
*pe = e;
Expand Down Expand Up @@ -248,7 +248,7 @@ nothrow:

if (nodes >= size_t.max / Key.sizeof)
err_nomem();
auto p = cast(Key *)malloc(nodes * Key.sizeof);
auto p = cast(Key*)malloc(nodes * Key.sizeof);
if (!p)
err_nomem();
auto q = p;
Expand Down Expand Up @@ -279,7 +279,7 @@ nothrow:
const aligned_keysize = aligntsize(Key.sizeof);
if (nodes >= size_t.max / Key.sizeof)
err_nomem();
auto p = cast(Value *)malloc(nodes * Value.sizeof);
auto p = cast(Value*)malloc(nodes * Value.sizeof);
if (!p)
err_nomem();
auto q = p;
Expand Down Expand Up @@ -510,7 +510,7 @@ public alias AApair2 = AArray!(TinfoPair, Pair);
aa.del(k);
bool v = true;
assert(!aa.isIn(k));
bool *pv = aa.get(k);
bool* pv = aa.get(k);
*pv = true;
int j = 9;
pv = aa.get(j);
Expand Down
40 changes: 20 additions & 20 deletions compiler/src/dmd/backend/arm/cod1.d
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void storeToEA(ref code cs, reg_t reg, uint sz)
*/

@trusted
int isscaledindex(tym_t ty, elem *e)
int isscaledindex(tym_t ty, elem* e)
{
const size = tysize(ty); // size of load
if (size != 4 && size != 8)
Expand Down Expand Up @@ -228,7 +228,7 @@ int isscaledindex(tym_t ty, elem *e)
*/

@trusted
void logexp(ref CodeBuilder cdb, elem *e, uint jcond, FL fltarg, code *targ)
void logexp(ref CodeBuilder cdb, elem* e, uint jcond, FL fltarg, code* targ)
{
//printf("logexp(e = %p, jcond = %d)\n", e, jcond); elem_print(e);
if (tybasic(e.Ety) == TYnoreturn)
Expand Down Expand Up @@ -260,7 +260,7 @@ void logexp(ref CodeBuilder cdb, elem *e, uint jcond, FL fltarg, code *targ)
}
else
{
code *cnop = gen1(null, INSTR.nop);
code* cnop = gen1(null, INSTR.nop);
logexp(cdb, e.E1, jcond | 1, FL.code, cnop);
regconsave = cgstate.regcon;
logexp(cdb, e.E2, jcond, fltarg, targ);
Expand All @@ -277,7 +277,7 @@ void logexp(ref CodeBuilder cdb, elem *e, uint jcond, FL fltarg, code *targ)
con_t regconsave;
if (jcond & 1)
{
code *cnop = gen1(null, INSTR.nop); // a dummy target address
code* cnop = gen1(null, INSTR.nop); // a dummy target address
logexp(cdb, e.E1, jcond & ~1, FL.code, cnop);
regconsave = cgstate.regcon;
logexp(cdb, e.E2, jcond, fltarg, targ);
Expand Down Expand Up @@ -315,12 +315,12 @@ void logexp(ref CodeBuilder cdb, elem *e, uint jcond, FL fltarg, code *targ)

case OPcond:
{
code *cnop2 = gen1(null, INSTR.nop); // addresses of start of leaves
code *cnop = gen1(null, INSTR.nop);
code* cnop2 = gen1(null, INSTR.nop); // addresses of start of leaves
code* cnop = gen1(null, INSTR.nop);
logexp(cdb, e.E1, false, FL.code, cnop2); // eval condition
con_t regconold = cgstate.regcon;
logexp(cdb, e.E2.E1, jcond, fltarg, targ);
genBranch(cdb, COND.al, FL.code, cast(block *) cnop); // skip second leaf
genBranch(cdb, COND.al, FL.code, cast(block*) cnop); // skip second leaf

con_t regconsave = cgstate.regcon;
cgstate.regcon = regconold;
Expand Down Expand Up @@ -363,7 +363,7 @@ void logexp(ref CodeBuilder cdb, elem *e, uint jcond, FL fltarg, code *targ)
codelem(cgstate,cdb, e, retregs, true); // evaluate elem
if (no87)
cse_flush(cdb,no87); // flush CSE's to memory
genBranch(cdb, cond, fltarg, cast(block *) targ); // generate jmp instruction
genBranch(cdb, cond, fltarg, cast(block*) targ); // generate jmp instruction
cgstate.stackclean--;
}

Expand All @@ -384,7 +384,7 @@ void logexp(ref CodeBuilder cdb, elem *e, uint jcond, FL fltarg, code *targ)
*/

@trusted
void loadea(ref CodeBuilder cdb,elem *e,ref code cs,uint op,reg_t reg,targ_size_t offset,
void loadea(ref CodeBuilder cdb,elem* e,ref code cs,uint op,reg_t reg,targ_size_t offset,
regm_t keepmsk,regm_t desmsk, RM rmx = RM.rw)
{
code* c, cg, cd;
Expand Down Expand Up @@ -465,7 +465,7 @@ void loadea(ref CodeBuilder cdb,elem *e,ref code cs,uint op,reg_t reg,targ_size_
*/

@trusted
void getlvalue(ref CodeBuilder cdb,ref code pcs,elem *e,regm_t keepmsk,RM rm = RM.rw)
void getlvalue(ref CodeBuilder cdb,ref code pcs,elem* e,regm_t keepmsk,RM rm = RM.rw)
{
FL fl;
uint opsave;
Expand Down Expand Up @@ -861,7 +861,7 @@ void getlvalue(ref CodeBuilder cdb,ref code pcs,elem *e,regm_t keepmsk,RM rm = R
return Lptr();
}

/* give up and replace *e1 with
/* give up and replace* e1 with
* MOV idxreg,e
* EA = 0[idxreg]
* pinholeopt() will usually correct the 0, we need it in case
Expand Down Expand Up @@ -1151,9 +1151,9 @@ static if (0)
cdb.gen2(op | XORPS, modregrm(3, xreg-XMM0, xreg-XMM0)); // XORPS xreg,xreg
cdb.gen2(op | UCOMISS, modregrm(3, xreg-XMM0, reg-XMM0)); // UCOMISS xreg,reg
if (tym == TYcfloat || tym == TYcdouble)
{ code *cnop = gennop(null);
genjmp(cdb, JNE, FL.code, cast(block *) cnop); // JNE L1
genjmp(cdb, JP, FL.code, cast(block *) cnop); // JP L1
{ code* cnop = gennop(null);
genjmp(cdb, JNE, FL.code, cast(block*) cnop); // JNE L1
genjmp(cdb, JP, FL.code, cast(block*) cnop); // JP L1
reg = findreg(regm & ~mask(reg));
cdb.gen2(op | UCOMISS, modregrm(3, xreg-XMM0, reg-XMM0)); // UCOMISS xreg,reg
cdb.append(cnop);
Expand Down Expand Up @@ -1265,7 +1265,7 @@ static if (0)
* generate necessary code to return result in outretregs.
*/
@trusted
void fixresult(ref CodeBuilder cdb, elem *e, regm_t retregs, ref regm_t outretregs)
void fixresult(ref CodeBuilder cdb, elem* e, regm_t retregs, ref regm_t outretregs)
{
//printf("arm.fixresult(e = %p, retregs = %s, outretregs = %s)\n",e,regm_str(retregs),regm_str(outretregs));
if (outretregs == 0) return; // if don't want result
Expand Down Expand Up @@ -1398,7 +1398,7 @@ printf("stackpushsave: %d\n", stackpushsave);

// Easier to deal with parameters as an array: parameters[0..np]
int np = OTbinary(e.Eoper) ? el_nparams(e.E2) : 0;
Parameter *parameters = cast(Parameter *)alloca(np * Parameter.sizeof);
Parameter* parameters = cast(Parameter*)alloca(np * Parameter.sizeof);

if (np)
{
Expand All @@ -1407,7 +1407,7 @@ printf("stackpushsave: %d\n", stackpushsave);
assert(n == np);
}

Symbol *sf = null; // symbol of the function being called
Symbol* sf = null; // symbol of the function being called
if (e.E1.Eoper == OPvar)
sf = e.E1.Vsym;

Expand Down Expand Up @@ -1435,7 +1435,7 @@ printf("stackpushsave: %d\n", stackpushsave);
FuncParamRegs fpr = FuncParamRegs_create(tyf);
for (int i = np; --i >= 0;)
{
elem *ep = parameters[i].e;
elem* ep = parameters[i].e;
uint psize = cast(uint)_align(stackalign, paramsize(ep, tyf)); // align on stack boundary
if (config.exe == EX_WIN64)
{
Expand Down Expand Up @@ -1947,7 +1947,7 @@ private void funccall(ref CodeBuilder cdb, elem* e, uint numpara, uint numalign,

if (e1.Eoper != OPind) { printf("e1.fl: %s, e1.Eoper: %s\n", fl_str(el_fl(e1)), oper_str(e1.Eoper)); }
assert(e1.Eoper == OPind);
elem *e11 = e1.E1;
elem* e11 = e1.E1;
tym_t e11ty = tybasic(e11.Ety);
load_localgot(cdb);
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS)) // 32 bit only
Expand Down Expand Up @@ -2415,7 +2415,7 @@ static if (1)
opcode_t opmv = xmmload(tym, xmmIsAligned(e));
if (e.Eoper == OPvar)
{
Symbol *s = e.Vsym;
Symbol* s = e.Vsym;
if (s.Sfl == FL.reg && !(mask(s.Sreglsw) & XMMREGS))
{ //opmv = LODD; // MOVD/MOVQ
/* getlvalue() will unwind this and unregister s; could use a better solution */
Expand Down
Loading

0 comments on commit 670a6c1

Please sign in to comment.