Skip to content

Commit

Permalink
refactor out ISXREF
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Feb 3, 2024
1 parent da20db5 commit 442605e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
25 changes: 9 additions & 16 deletions compiler/src/dmd/e2ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,12 @@ import dmd.backend.util2 : mem_malloc2;

private int registerSize() { return _tysize[TYnptr]; }

/* If variable var is a reference
*/
bool ISREF(Declaration var)
{
if (var.isReference())
{
return true;
}

return ISX64REF(var);
}

/* If variable var of type typ is a reference due to x64 calling conventions
/*****
* If variable var is a reference due to target calling conventions
* Params:
* var = parameter variable
* Returns:
* true if actually implicitly passed by reference
*/
bool ISX64REF(Declaration var)
{
Expand Down Expand Up @@ -706,7 +699,7 @@ elem* toElem(Expression e, ref IRState irs)
e = el_bin(OPadd, TYnptr, ethis, el_long(TYnptr, soffset));
if (se.op == EXP.variable)
e = el_una(OPind, TYnptr, e);
if (ISREF(se.var) && !(ISX64REF(se.var) && v && v.offset && !forceStackAccess))
if (se.var.isReference() && v && v.offset && !forceStackAccess)
e = el_una(OPind, s.Stype.Tty, e);
else if (se.op == EXP.symbolOffset && nrvo)
{
Expand All @@ -731,7 +724,7 @@ elem* toElem(Expression e, ref IRState irs)
e.ET = Type_toCtype(se.type);
elem_setLoc(e, se.loc);
}
if (ISREF(se.var) && !ISX64REF(se.var))
if (se.var.isReference())
{
e.Ety = TYnptr;
e = el_una(OPind, s.Stype.Tty, e);
Expand Down Expand Up @@ -767,7 +760,7 @@ elem* toElem(Expression e, ref IRState irs)
e = el_una(OPind,s.Stype.Tty,e);
}
}
else if (ISREF(se.var))
else if (se.var.isReference() || ISX64REF(se.var))
{
// Out parameters are really references
e = el_var(s);
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/toir.d
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void buildClosure(FuncDeclaration fd, ref IRState irs)
if (v.storage_class & STC.lazy_)
tym = TYdelegate;
}
else if (ISREF(v) && !x64ref)
else if (v.isReference())
tym = TYnptr; // reference parameters are just pointers
else if (v.storage_class & STC.lazy_)
tym = TYdelegate;
Expand Down

0 comments on commit 442605e

Please sign in to comment.