mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
calling compiler helper functions now works (#21276)
This commit is contained in:
parent
4c2d438f75
commit
283547e3af
8 changed files with 24 additions and 12 deletions
|
@ -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.
|
* Extra information about each CLIB_A runtime library function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private
|
|
||||||
enum CLIB_A
|
enum CLIB_A
|
||||||
{
|
{
|
||||||
realToDouble,
|
realToDouble,
|
||||||
|
|
|
@ -1094,6 +1094,8 @@ void loadFloatRegConst(ref CodeBuilder cdb, reg_t vreg, double value, uint sz)
|
||||||
ubyte imm8;
|
ubyte imm8;
|
||||||
if (encodeHFD(value, imm8))
|
if (encodeHFD(value, imm8))
|
||||||
{
|
{
|
||||||
|
assert(sz == 2 || sz == 4 || sz == 8);
|
||||||
|
assert(imm8 <= 0xFF);
|
||||||
uint ftype = INSTR.szToFtype(sz);
|
uint ftype = INSTR.szToFtype(sz);
|
||||||
cdb.gen1(INSTR.fmov_float_imm(ftype,imm8,vreg)); // FMOV <Vd>,#<imm8>
|
cdb.gen1(INSTR.fmov_float_imm(ftype,imm8,vreg)); // FMOV <Vd>,#<imm8>
|
||||||
}
|
}
|
||||||
|
@ -1550,12 +1552,16 @@ void assignaddrc(code* c)
|
||||||
}
|
}
|
||||||
else if (op24 == 1)
|
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);
|
assert(field(ins,29,27) == 7);
|
||||||
uint imm12 = field(ins,21,10); // unsigned 12 bits
|
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
|
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
|
assert((offset & ((1 << shift) - 1)) == 0); // no misaligned access
|
||||||
imm12 = cast(uint)(offset >> shift);
|
imm12 = cast(uint)(offset >> shift);
|
||||||
|
//printf("imm12: x%x\n", imm12);
|
||||||
assert(imm12 < 0x1000);
|
assert(imm12 < 0x1000);
|
||||||
ins = setField(ins,21,10,imm12);
|
ins = setField(ins,21,10,imm12);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1476,7 +1476,11 @@ void cdcnvt(ref CGstate cg, ref CodeBuilder cdb,elem* e, ref regm_t pretregs)
|
||||||
|
|
||||||
case OPd_ld: // call __extenddftf2
|
case OPd_ld: // call __extenddftf2
|
||||||
case OPld_d: // call __trunctfdf2
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2162,10 +2162,7 @@ void disassemble(uint c) @trusted
|
||||||
|
|
||||||
p1 = "fmov";
|
p1 = "fmov";
|
||||||
p2 = fregString(rbuf[0..4],"sd h"[ftype],Rd);
|
p2 = fregString(rbuf[0..4],"sd h"[ftype],Rd);
|
||||||
uint sz = ftype == 0 ? 32 : ftype == 1 ? 64 : 16;
|
|
||||||
float f = decodeImm8ToFloat(imm8);
|
float f = decodeImm8ToFloat(imm8);
|
||||||
if (sz == 16)
|
|
||||||
p1 = ""; // no support half-float literals
|
|
||||||
p3 = doubletostring(f);
|
p3 = doubletostring(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1030,7 +1030,7 @@ struct INSTR
|
||||||
assert(imm12 < 0x1000);
|
assert(imm12 < 0x1000);
|
||||||
assert(size < 4);
|
assert(size < 4);
|
||||||
assert(opc < 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
|
/* https://www.scs.stanford.edu/~zyedidia/arm64/ldrsw_imm.html
|
||||||
|
|
|
@ -35,7 +35,7 @@ struct CodeBuilder
|
||||||
code** pTail;
|
code** pTail;
|
||||||
|
|
||||||
enum BADINS = 0x1234_5678;
|
enum BADINS = 0x1234_5678;
|
||||||
//enum BADINS = 0xBD00_07A0;
|
//enum BADINS = 0x3D80_03E0;
|
||||||
|
|
||||||
nothrow:
|
nothrow:
|
||||||
public:
|
public:
|
||||||
|
@ -119,6 +119,7 @@ struct CodeBuilder
|
||||||
{
|
{
|
||||||
/* this is a high usage routine */
|
/* this is a high usage routine */
|
||||||
debug assert(cs);
|
debug assert(cs);
|
||||||
|
//debug printf("gen(%08x)\n", cs.Iop);
|
||||||
assert(cs.Iop != BADINS);
|
assert(cs.Iop != BADINS);
|
||||||
assert(I64 || cs.Irex == 0);
|
assert(I64 || cs.Irex == 0);
|
||||||
code* ce = code_malloc();
|
code* ce = code_malloc();
|
||||||
|
|
|
@ -1123,7 +1123,7 @@ void stackoffsets(ref CGstate cg, ref symtab_t symtab, bool estimate)
|
||||||
{
|
{
|
||||||
case SC.fastpar:
|
case SC.fastpar:
|
||||||
if (!(funcsym_p.Sfunc.Fflags3 & Ffakeeh))
|
if (!(funcsym_p.Sfunc.Fflags3 & Ffakeeh))
|
||||||
goto Ldefault; // don't need consistent stack frame
|
goto default; // don't need consistent stack frame
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SC.parameter:
|
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
|
break; // allocate even if it's dead
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Ldefault:
|
|
||||||
if (Symbol_Sisdead(*s, cg.anyiasm))
|
if (Symbol_Sisdead(*s, cg.anyiasm))
|
||||||
continue; // don't allocate space
|
continue; // don't allocate space
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3050,7 +3050,7 @@ FuncParamRegs FuncParamRegs_create(tym_t tyf)
|
||||||
@trusted
|
@trusted
|
||||||
bool FuncParamRegs_alloc(ref FuncParamRegs fpr, type* t, tym_t ty, out reg_t preg1, out reg_t preg2)
|
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);
|
//if (t) type_print(t);
|
||||||
|
|
||||||
preg1 = NOREG;
|
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 (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];
|
*preg = fpr.floatregs[fpr.xmmcnt];
|
||||||
if (config.exe == EX_WIN64)
|
if (config.exe == EX_WIN64)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue