Skip to content

Commit 283547e

Browse files
authored
calling compiler helper functions now works (dlang#21276)
1 parent 4c2d438 commit 283547e

8 files changed

Lines changed: 24 additions & 12 deletions

File tree

compiler/src/dmd/backend/arm/cod1.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,6 @@ void fixresult(ref CodeBuilder cdb, elem* e, regm_t retregs, ref regm_t outretre
13181318
* Extra information about each CLIB_A runtime library function.
13191319
*/
13201320

1321-
private
13221321
enum CLIB_A
13231322
{
13241323
realToDouble,

compiler/src/dmd/backend/arm/cod3.d

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,8 @@ void loadFloatRegConst(ref CodeBuilder cdb, reg_t vreg, double value, uint sz)
10941094
ubyte imm8;
10951095
if (encodeHFD(value, imm8))
10961096
{
1097+
assert(sz == 2 || sz == 4 || sz == 8);
1098+
assert(imm8 <= 0xFF);
10971099
uint ftype = INSTR.szToFtype(sz);
10981100
cdb.gen1(INSTR.fmov_float_imm(ftype,imm8,vreg)); // FMOV <Vd>,#<imm8>
10991101
}
@@ -1550,12 +1552,16 @@ void assignaddrc(code* c)
15501552
}
15511553
else if (op24 == 1)
15521554
{
1555+
//printf("shift: %d opc: %d\n", shift, opc);
1556+
if (opc & 2 && shift == 0)
1557+
shift = 4;
15531558
assert(field(ins,29,27) == 7);
15541559
uint imm12 = field(ins,21,10); // unsigned 12 bits
1560+
//printf("shift: %d offset: x%llx imm12: x%x\n", shift, offset, imm12);
15551561
offset += imm12 << shift; // add in imm
1556-
//printf("shift: %d offset: %llx imm12: %x\n", shift, offset, imm12);
15571562
assert((offset & ((1 << shift) - 1)) == 0); // no misaligned access
15581563
imm12 = cast(uint)(offset >> shift);
1564+
//printf("imm12: x%x\n", imm12);
15591565
assert(imm12 < 0x1000);
15601566
ins = setField(ins,21,10,imm12);
15611567
}

compiler/src/dmd/backend/arm/cod4.d

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,11 @@ void cdcnvt(ref CGstate cg, ref CodeBuilder cdb,elem* e, ref regm_t pretregs)
14761476

14771477
case OPd_ld: // call __extenddftf2
14781478
case OPld_d: // call __trunctfdf2
1479-
cdb.gen1(INSTR.udf); // TODO AArch64
1479+
regm_t retregs1 = mask(32);
1480+
codelem(cgstate,cdb,e.E1,retregs1,false);
1481+
import dmd.backend.arm.cod1 : CLIB_A, callclib;
1482+
CLIB_A clib = e.Eoper == OPd_ld ? CLIB_A.doubleToReal : CLIB_A.realToDouble;
1483+
callclib(cdb,e,clib,pretregs,0);
14801484
break;
14811485

14821486
default:

compiler/src/dmd/backend/arm/disasmarm.d

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,10 +2162,7 @@ void disassemble(uint c) @trusted
21622162

21632163
p1 = "fmov";
21642164
p2 = fregString(rbuf[0..4],"sd h"[ftype],Rd);
2165-
uint sz = ftype == 0 ? 32 : ftype == 1 ? 64 : 16;
21662165
float f = decodeImm8ToFloat(imm8);
2167-
if (sz == 16)
2168-
p1 = ""; // no support half-float literals
21692166
p3 = doubletostring(f);
21702167
}
21712168
else

compiler/src/dmd/backend/arm/instr.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ struct INSTR
10301030
assert(imm12 < 0x1000);
10311031
assert(size < 4);
10321032
assert(opc < 4);
1033-
return ldst_pos(size,1,opc,imm12,Rn,Vt);
1033+
return ldst_pos(size,1,opc | 1,imm12,Rn,Vt);
10341034
}
10351035

10361036
/* https://www.scs.stanford.edu/~zyedidia/arm64/ldrsw_imm.html

compiler/src/dmd/backend/codebuilder.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct CodeBuilder
3535
code** pTail;
3636

3737
enum BADINS = 0x1234_5678;
38-
//enum BADINS = 0xBD00_07A0;
38+
//enum BADINS = 0x3D80_03E0;
3939

4040
nothrow:
4141
public:
@@ -119,6 +119,7 @@ struct CodeBuilder
119119
{
120120
/* this is a high usage routine */
121121
debug assert(cs);
122+
//debug printf("gen(%08x)\n", cs.Iop);
122123
assert(cs.Iop != BADINS);
123124
assert(I64 || cs.Irex == 0);
124125
code* ce = code_malloc();

compiler/src/dmd/backend/x86/cgcod.d

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ void stackoffsets(ref CGstate cg, ref symtab_t symtab, bool estimate)
11231123
{
11241124
case SC.fastpar:
11251125
if (!(funcsym_p.Sfunc.Fflags3 & Ffakeeh))
1126-
goto Ldefault; // don't need consistent stack frame
1126+
goto default; // don't need consistent stack frame
11271127
break;
11281128

11291129
case SC.parameter:
@@ -1139,7 +1139,6 @@ void stackoffsets(ref CGstate cg, ref symtab_t symtab, bool estimate)
11391139
break; // allocate even if it's dead
11401140

11411141
default:
1142-
Ldefault:
11431142
if (Symbol_Sisdead(*s, cg.anyiasm))
11441143
continue; // don't allocate space
11451144
break;

compiler/src/dmd/backend/x86/cod1.d

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,7 @@ FuncParamRegs FuncParamRegs_create(tym_t tyf)
30503050
@trusted
30513051
bool FuncParamRegs_alloc(ref FuncParamRegs fpr, type* t, tym_t ty, out reg_t preg1, out reg_t preg2)
30523052
{
3053-
//printf("FuncParamRegs::alloc(ty: TY%sm t: %p)\n", tystring[tybasic(ty)], t);
3053+
//printf("FuncParamRegs::alloc(ty: %s t: %p)\n", tym_str(ty), t);
30543054
//if (t) type_print(t);
30553055

30563056
preg1 = NOREG;
@@ -3204,7 +3204,13 @@ bool FuncParamRegs_alloc(ref FuncParamRegs fpr, type* t, tym_t ty, out reg_t pre
32043204
}
32053205
if (fpr.xmmcnt < fpr.numfloatregs)
32063206
{
3207-
if (tyxmmreg(ty))
3207+
if (tyfloating(ty) && cgstate.AArch64)
3208+
{
3209+
*preg = fpr.floatregs[fpr.xmmcnt];
3210+
++fpr.xmmcnt;
3211+
goto Lnext;
3212+
}
3213+
else if (tyxmmreg(ty))
32083214
{
32093215
*preg = fpr.floatregs[fpr.xmmcnt];
32103216
if (config.exe == EX_WIN64)

0 commit comments

Comments
 (0)