diff --git a/compiler/src/dmd/backend/arm/cod1.d b/compiler/src/dmd/backend/arm/cod1.d index 70a23197c3..acf4c77b81 100644 --- a/compiler/src/dmd/backend/arm/cod1.d +++ b/compiler/src/dmd/backend/arm/cod1.d @@ -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, diff --git a/compiler/src/dmd/backend/arm/cod3.d b/compiler/src/dmd/backend/arm/cod3.d index 7b2bbf55a8..e92451ca04 100644 --- a/compiler/src/dmd/backend/arm/cod3.d +++ b/compiler/src/dmd/backend/arm/cod3.d @@ -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 ,# } @@ -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); } diff --git a/compiler/src/dmd/backend/arm/cod4.d b/compiler/src/dmd/backend/arm/cod4.d index 6b6d14051e..ca8291d2c0 100644 --- a/compiler/src/dmd/backend/arm/cod4.d +++ b/compiler/src/dmd/backend/arm/cod4.d @@ -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: diff --git a/compiler/src/dmd/backend/arm/disasmarm.d b/compiler/src/dmd/backend/arm/disasmarm.d index bbb7986f4e..a4bb4f16f3 100644 --- a/compiler/src/dmd/backend/arm/disasmarm.d +++ b/compiler/src/dmd/backend/arm/disasmarm.d @@ -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 diff --git a/compiler/src/dmd/backend/arm/instr.d b/compiler/src/dmd/backend/arm/instr.d index f17d64873f..b8dc957ff5 100644 --- a/compiler/src/dmd/backend/arm/instr.d +++ b/compiler/src/dmd/backend/arm/instr.d @@ -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 diff --git a/compiler/src/dmd/backend/codebuilder.d b/compiler/src/dmd/backend/codebuilder.d index 8c2ea83b54..49154e934e 100644 --- a/compiler/src/dmd/backend/codebuilder.d +++ b/compiler/src/dmd/backend/codebuilder.d @@ -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(); diff --git a/compiler/src/dmd/backend/x86/cgcod.d b/compiler/src/dmd/backend/x86/cgcod.d index 456e12cdeb..5445fb434b 100644 --- a/compiler/src/dmd/backend/x86/cgcod.d +++ b/compiler/src/dmd/backend/x86/cgcod.d @@ -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; diff --git a/compiler/src/dmd/backend/x86/cod1.d b/compiler/src/dmd/backend/x86/cod1.d index 51c20d5c18..393641fc3c 100644 --- a/compiler/src/dmd/backend/x86/cod1.d +++ b/compiler/src/dmd/backend/x86/cod1.d @@ -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)