add target.isAArch64 to e2ir.d (#21074)

This commit is contained in:
Walter Bright 2025-03-23 23:42:27 -07:00 committed by GitHub
parent 63152e453c
commit f4da0efbd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2016,9 +2016,10 @@ elem* toElem(Expression e, ref IRState irs)
elem* esiz1, esiz2; // Data size, to pass to memcmp elem* esiz1, esiz2; // Data size, to pass to memcmp
const sz = telement.size(); // Size of one element const sz = telement.size(); // Size of one element
bool is64 = target.isX86_64 || target.isAArch64;
if (t1.ty == Tarray) if (t1.ty == Tarray)
{ {
elen1 = el_una(target.isX86_64 ? OP128_64 : OP64_32, TYsize_t, el_same(earr1)); elen1 = el_una(is64 ? OP128_64 : OP64_32, TYsize_t, el_same(earr1));
esiz1 = el_bin(OPmul, TYsize_t, el_same(elen1), el_long(TYsize_t, sz)); esiz1 = el_bin(OPmul, TYsize_t, el_same(elen1), el_long(TYsize_t, sz));
eptr1 = array_toPtr(t1, el_same(earr1)); eptr1 = array_toPtr(t1, el_same(earr1));
} }
@ -2032,7 +2033,7 @@ elem* toElem(Expression e, ref IRState irs)
if (t2.ty == Tarray) if (t2.ty == Tarray)
{ {
elen2 = el_una(target.isX86_64 ? OP128_64 : OP64_32, TYsize_t, el_same(earr2)); elen2 = el_una(is64 ? OP128_64 : OP64_32, TYsize_t, el_same(earr2));
esiz2 = el_bin(OPmul, TYsize_t, el_same(elen2), el_long(TYsize_t, sz)); esiz2 = el_bin(OPmul, TYsize_t, el_same(elen2), el_long(TYsize_t, sz));
eptr2 = array_toPtr(t2, el_same(earr2)); eptr2 = array_toPtr(t2, el_same(earr2));
} }
@ -2290,7 +2291,7 @@ elem* toElem(Expression e, ref IRState irs)
einit = resolveLengthVar(are.lengthVar, &n1, ta); einit = resolveLengthVar(are.lengthVar, &n1, ta);
enbytes = el_copytree(n1); enbytes = el_copytree(n1);
n1 = array_toPtr(ta, n1); n1 = array_toPtr(ta, n1);
enbytes = el_una(target.isX86_64 ? OP128_64 : OP64_32, TYsize_t, enbytes); enbytes = el_una((target.isX86_64 || target.isAArch64) ? OP128_64 : OP64_32, TYsize_t, enbytes);
} }
else if (ta.ty == Tpointer) else if (ta.ty == Tpointer)
{ {
@ -2404,7 +2405,7 @@ elem* toElem(Expression e, ref IRState irs)
else else
{ {
// It's not a constant, so pull it from the dynamic array // It's not a constant, so pull it from the dynamic array
return el_una(target.isX86_64 ? OP128_64 : OP64_32, TYsize_t, el_copytree(ex)); return el_una((target.isX86_64 || target.isAArch64) ? OP128_64 : OP64_32, TYsize_t, el_copytree(ex));
} }
} }
@ -3751,7 +3752,7 @@ elem* toElem(Expression e, ref IRState irs)
elem* visitArrayLength(ArrayLengthExp ale) elem* visitArrayLength(ArrayLengthExp ale)
{ {
elem* e = toElem(ale.e1, irs); elem* e = toElem(ale.e1, irs);
e = el_una(target.isX86_64 ? OP128_64 : OP64_32, totym(ale.type), e); e = el_una((target.isX86_64 || target.isAArch64) ? OP128_64 : OP64_32, totym(ale.type), e);
elem_setLoc(e, ale.loc); elem_setLoc(e, ale.loc);
return e; return e;
} }
@ -3773,7 +3774,7 @@ elem* toElem(Expression e, ref IRState irs)
elem* e = toElem(dfpe.e1, irs); elem* e = toElem(dfpe.e1, irs);
Type tb1 = dfpe.e1.type.toBasetype(); Type tb1 = dfpe.e1.type.toBasetype();
e = addressElem(e, tb1); e = addressElem(e, tb1);
e = el_bin(OPadd, TYnptr, e, el_long(TYsize_t, target.isX86_64 ? 8 : 4)); e = el_bin(OPadd, TYnptr, e, el_long(TYsize_t, (target.isX86_64 || target.isAArch64) ? 8 : 4));
e = el_una(OPind, totym(dfpe.type), e); e = el_una(OPind, totym(dfpe.type), e);
elem_setLoc(e, dfpe.loc); elem_setLoc(e, dfpe.loc);
return e; return e;
@ -3833,7 +3834,7 @@ elem* toElem(Expression e, ref IRState irs)
{ {
elen = e; elen = e;
e = el_same(elen); e = el_same(elen);
elen = el_una(target.isX86_64 ? OP128_64 : OP64_32, TYsize_t, elen); elen = el_una((target.isX86_64 || target.isAArch64) ? OP128_64 : OP64_32, TYsize_t, elen);
} }
} }
@ -3993,7 +3994,7 @@ elem* toElem(Expression e, ref IRState irs)
{ {
elength = n1; elength = n1;
n1 = el_same(elength); n1 = el_same(elength);
elength = el_una(target.isX86_64 ? OP128_64 : OP64_32, TYsize_t, elength); elength = el_una((target.isX86_64 || target.isAArch64) ? OP128_64 : OP64_32, TYsize_t, elength);
L1: L1:
elem* n2x = n2; elem* n2x = n2;
n2 = el_same(n2x); n2 = el_same(n2x);
@ -4550,7 +4551,7 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
else else
{ {
// e1 . (uint)(e1 >> 32) // e1 . (uint)(e1 >> 32)
if (target.isX86_64) if (target.isX86_64 || target.isAArch64)
{ {
e = el_bin(OPshr, TYucent, e, el_long(TYint, 64)); e = el_bin(OPshr, TYucent, e, el_long(TYint, 64));
e = el_una(OP128_64, totym(t), e); e = el_una(OP128_64, totym(t), e);
@ -4594,7 +4595,7 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
elem* es = el_same(e); elem* es = el_same(e);
elem* eptr = el_una(OPmsw, TYnptr, es); elem* eptr = el_una(OPmsw, TYnptr, es);
elem* elen = el_una(target.isX86_64 ? OP128_64 : OP64_32, TYsize_t, e); elem* elen = el_una(target.isX86_64 || target.isAArch64 ? OP128_64 : OP64_32, TYsize_t, e);
elem* elen2 = el_bin(OPmul, TYsize_t, elen, el_long(TYsize_t, fsize / tsize)); elem* elen2 = el_bin(OPmul, TYsize_t, elen, el_long(TYsize_t, fsize / tsize));
e = el_pair(totym(ce.type), elen2, eptr); e = el_pair(totym(ce.type), elen2, eptr);
} }
@ -4758,7 +4759,7 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
case Tpointer: case Tpointer:
if (fty == Tdelegate) if (fty == Tdelegate)
return Lpaint(ce, e, ttym); return Lpaint(ce, e, ttym);
tty = target.isX86_64 ? Tuns64 : Tuns32; tty = target.isX86_64 || target.isAArch64 ? Tuns64 : Tuns32;
break; break;
case Tchar: tty = Tuns8; break; case Tchar: tty = Tuns8; break;
@ -4783,7 +4784,7 @@ elem* toElemCast(CastExp ce, elem* e, bool isLvalue, ref IRState irs)
// typeof(null) is same with void* in binary level. // typeof(null) is same with void* in binary level.
return Lzero(ce, e, ttym); return Lzero(ce, e, ttym);
} }
case Tpointer: fty = target.isX86_64 ? Tuns64 : Tuns32; break; case Tpointer: fty = (target.isX86_64 || target.isAArch64) ? Tuns64 : Tuns32; break;
case Tchar: fty = Tuns8; break; case Tchar: fty = Tuns8; break;
case Twchar: fty = Tuns16; break; case Twchar: fty = Tuns16; break;
case Tdchar: fty = Tuns32; break; case Tdchar: fty = Tuns32; break;
@ -5459,7 +5460,7 @@ elem* callfunc(Loc loc,
assert(tf); assert(tf);
ethis = ec; ethis = ec;
ec = el_same(ethis); ec = el_same(ethis);
ethis = el_una(target.isX86_64 ? OP128_64 : OP64_32, TYnptr, ethis); // get this ethis = el_una(target.isX86_64 || target.isAArch64 ? OP128_64 : OP64_32, TYnptr, ethis); // get this
ec = array_toPtr(t, ec); // get funcptr ec = array_toPtr(t, ec); // get funcptr
tym_t tym; tym_t tym;
/* Delegates use the same calling convention as member functions. /* Delegates use the same calling convention as member functions.
@ -6328,7 +6329,7 @@ Lagain:
case 2: r = RTLSYM.MEMSET16; break; case 2: r = RTLSYM.MEMSET16; break;
case 4: r = RTLSYM.MEMSET32; break; case 4: r = RTLSYM.MEMSET32; break;
case 8: r = RTLSYM.MEMSET64; break; case 8: r = RTLSYM.MEMSET64; break;
case 16: r = target.isX86_64 ? RTLSYM.MEMSET128ii : RTLSYM.MEMSET128; break; case 16: r = (target.isX86_64 || target.isAArch64) ? RTLSYM.MEMSET128ii : RTLSYM.MEMSET128; break;
default: r = RTLSYM.MEMSETN; break; default: r = RTLSYM.MEMSETN; break;
} }
@ -6345,7 +6346,7 @@ Lagain:
} }
} }
if (target.isX86_64 && tybasic(evalue.Ety) == TYstruct && r != RTLSYM.MEMSETN) if ((target.isX86_64 || target.isAArch64) && tybasic(evalue.Ety) == TYstruct && r != RTLSYM.MEMSETN)
{ {
/* If this struct is in-memory only, i.e. cannot necessarily be passed as /* If this struct is in-memory only, i.e. cannot necessarily be passed as
* a gp register parameter. * a gp register parameter.
@ -6388,7 +6389,7 @@ Lagain:
edim = el_bin(OPmul, TYsize_t, edim, el_long(TYsize_t, sz)); edim = el_bin(OPmul, TYsize_t, edim, el_long(TYsize_t, sz));
} }
if (irs.target.os == Target.OS.Windows && irs.target.isX86_64 && sz > registerSize) if (irs.target.os == Target.OS.Windows && (irs.target.isX86_64 || irs.target.isAArch64) && sz > registerSize)
{ {
evalue = addressElem(evalue, tb); evalue = addressElem(evalue, tb);
} }