calling compiler helper functions now works (#21276)

This commit is contained in:
Walter Bright 2025-04-20 09:35:50 -07:00 committed by GitHub
parent 4c2d438f75
commit 283547e3af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 24 additions and 12 deletions

View file

@ -1318,7 +1318,6 @@ void fixresult(ref CodeBuilder cdb, elem* e, regm_t retregs, ref regm_t outretre
* Extra information about each CLIB_A runtime library function.
*/
private
enum CLIB_A
{
realToDouble,

View file

@ -1094,6 +1094,8 @@ void loadFloatRegConst(ref CodeBuilder cdb, reg_t vreg, double value, uint sz)
ubyte imm8;
if (encodeHFD(value, imm8))
{
assert(sz == 2 || sz == 4 || sz == 8);
assert(imm8 <= 0xFF);
uint ftype = INSTR.szToFtype(sz);
cdb.gen1(INSTR.fmov_float_imm(ftype,imm8,vreg)); // FMOV <Vd>,#<imm8>
}
@ -1550,12 +1552,16 @@ void assignaddrc(code* c)
}
else if (op24 == 1)
{
//printf("shift: %d opc: %d\n", shift, opc);
if (opc & 2 && shift == 0)
shift = 4;
assert(field(ins,29,27) == 7);
uint imm12 = field(ins,21,10); // unsigned 12 bits
//printf("shift: %d offset: x%llx imm12: x%x\n", shift, offset, imm12);
offset += imm12 << shift; // add in imm
//printf("shift: %d offset: %llx imm12: %x\n", shift, offset, imm12);
assert((offset & ((1 << shift) - 1)) == 0); // no misaligned access
imm12 = cast(uint)(offset >> shift);
//printf("imm12: x%x\n", imm12);
assert(imm12 < 0x1000);
ins = setField(ins,21,10,imm12);
}

View file

@ -1476,7 +1476,11 @@ void cdcnvt(ref CGstate cg, ref CodeBuilder cdb,elem* e, ref regm_t pretregs)
case OPd_ld: // call __extenddftf2
case OPld_d: // call __trunctfdf2
cdb.gen1(INSTR.udf); // TODO AArch64
regm_t retregs1 = mask(32);
codelem(cgstate,cdb,e.E1,retregs1,false);
import dmd.backend.arm.cod1 : CLIB_A, callclib;
CLIB_A clib = e.Eoper == OPd_ld ? CLIB_A.doubleToReal : CLIB_A.realToDouble;
callclib(cdb,e,clib,pretregs,0);
break;
default:

View file

@ -2162,10 +2162,7 @@ void disassemble(uint c) @trusted
p1 = "fmov";
p2 = fregString(rbuf[0..4],"sd h"[ftype],Rd);
uint sz = ftype == 0 ? 32 : ftype == 1 ? 64 : 16;
float f = decodeImm8ToFloat(imm8);
if (sz == 16)
p1 = ""; // no support half-float literals
p3 = doubletostring(f);
}
else

View file

@ -1030,7 +1030,7 @@ struct INSTR
assert(imm12 < 0x1000);
assert(size < 4);
assert(opc < 4);
return ldst_pos(size,1,opc,imm12,Rn,Vt);
return ldst_pos(size,1,opc | 1,imm12,Rn,Vt);
}
/* https://www.scs.stanford.edu/~zyedidia/arm64/ldrsw_imm.html

View file

@ -35,7 +35,7 @@ struct CodeBuilder
code** pTail;
enum BADINS = 0x1234_5678;
//enum BADINS = 0xBD00_07A0;
//enum BADINS = 0x3D80_03E0;
nothrow:
public:
@ -119,6 +119,7 @@ struct CodeBuilder
{
/* this is a high usage routine */
debug assert(cs);
//debug printf("gen(%08x)\n", cs.Iop);
assert(cs.Iop != BADINS);
assert(I64 || cs.Irex == 0);
code* ce = code_malloc();

View file

@ -1123,7 +1123,7 @@ void stackoffsets(ref CGstate cg, ref symtab_t symtab, bool estimate)
{
case SC.fastpar:
if (!(funcsym_p.Sfunc.Fflags3 & Ffakeeh))
goto Ldefault; // don't need consistent stack frame
goto default; // don't need consistent stack frame
break;
case SC.parameter:
@ -1139,7 +1139,6 @@ void stackoffsets(ref CGstate cg, ref symtab_t symtab, bool estimate)
break; // allocate even if it's dead
default:
Ldefault:
if (Symbol_Sisdead(*s, cg.anyiasm))
continue; // don't allocate space
break;

View file

@ -3050,7 +3050,7 @@ FuncParamRegs FuncParamRegs_create(tym_t tyf)
@trusted
bool FuncParamRegs_alloc(ref FuncParamRegs fpr, type* t, tym_t ty, out reg_t preg1, out reg_t preg2)
{
//printf("FuncParamRegs::alloc(ty: TY%sm t: %p)\n", tystring[tybasic(ty)], t);
//printf("FuncParamRegs::alloc(ty: %s t: %p)\n", tym_str(ty), t);
//if (t) type_print(t);
preg1 = NOREG;
@ -3204,7 +3204,13 @@ bool FuncParamRegs_alloc(ref FuncParamRegs fpr, type* t, tym_t ty, out reg_t pre
}
if (fpr.xmmcnt < fpr.numfloatregs)
{
if (tyxmmreg(ty))
if (tyfloating(ty) && cgstate.AArch64)
{
*preg = fpr.floatregs[fpr.xmmcnt];
++fpr.xmmcnt;
goto Lnext;
}
else if (tyxmmreg(ty))
{
*preg = fpr.floatregs[fpr.xmmcnt];
if (config.exe == EX_WIN64)