Skip to content

add 128 bit float support to cdorth() #21293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions compiler/src/dmd/backend/arm/cod1.d
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,10 @@
{
realToDouble,
doubleToReal,
add,
min,
mul,
div,
netf2,
}

Expand Down Expand Up @@ -1398,6 +1402,38 @@
break;
}

case CLIB_A.add:

Check warning on line 1405 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1405 was not covered by tests
{
string name = "__addtf3";
s = symboly(name, mask(32) | mask(33));
cinfo.retregs = mask(32);
break;

Check warning on line 1410 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L1407-L1410

Added lines #L1407 - L1410 were not covered by tests
}

case CLIB_A.min:

Check warning on line 1413 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1413 was not covered by tests
{
string name = "__subtf3";
s = symboly(name, mask(32) | mask(33));
cinfo.retregs = mask(32);
break;

Check warning on line 1418 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L1415-L1418

Added lines #L1415 - L1418 were not covered by tests
}

case CLIB_A.mul:

Check warning on line 1421 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1421 was not covered by tests
{
string name = "__multf3";
s = symboly(name, mask(32) | mask(33));
cinfo.retregs = mask(32);
break;

Check warning on line 1426 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L1423-L1426

Added lines #L1423 - L1426 were not covered by tests
}

case CLIB_A.div:

Check warning on line 1429 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1429 was not covered by tests
{
string name = "__divtf3";
s = symboly(name, mask(32) | mask(33));
cinfo.retregs = mask(32);
break;

Check warning on line 1434 in compiler/src/dmd/backend/arm/cod1.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L1431-L1434

Added lines #L1431 - L1434 were not covered by tests
}

case CLIB_A.netf2:
{
string name = "__netf2";
Expand Down
63 changes: 40 additions & 23 deletions compiler/src/dmd/backend/arm/cod2.d
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import dmd.backend.ty;
import dmd.backend.type;
import dmd.backend.x86.xmm;
import dmd.backend.arm.cod1 : loadFromEA, storeToEA, getlvalue;
import dmd.backend.arm.cod1 : loadFromEA, storeToEA, getlvalue, CLIB_A, callclib;
import dmd.backend.arm.cod3 : conditionCode, genBranch, gentstreg, movregconst, COND, loadFloatRegConst;
import dmd.backend.arm.instr;

Expand Down Expand Up @@ -96,30 +96,47 @@

if (tyfloating(ty1))
{
uint ftype = sz == 2 ? 3 :
sz == 4 ? 0 : 1;
switch (e.Eoper)
if (sz == 16) // 128 bit float

Check warning on line 99 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L99

Added line #L99 was not covered by tests
{
// FADD/FSUB (extended register)
// http://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#addsub_ext
case OPadd:
cdb.gen1(INSTR.fadd_float(ftype,Rm,Rn,Rd)); // FADD Rd,Rn,Rm
break;

case OPmin:
cdb.gen1(INSTR.fsub_float(ftype,Rm,Rn,Rd)); // FSUB Rd,Rn,Rm
break;

case OPmul:
cdb.gen1(INSTR.fmul_float(ftype,Rm,Rn,Rd)); // FMUL Rd,Rn,Rm
break;

case OPdiv:
cdb.gen1(INSTR.fdiv_float(ftype,Rm,Rn,Rd)); // FDIV Rd,Rn,Rm
break;
uint clib;
switch (e.Eoper)

Check warning on line 102 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L101-L102

Added lines #L101 - L102 were not covered by tests
{
case OPadd: clib = CLIB_A.add; break;
case OPmin: clib = CLIB_A.min; break;
case OPmul: clib = CLIB_A.mul; break;
case OPdiv: clib = CLIB_A.div; break;

Check warning on line 107 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L104-L107

Added lines #L104 - L107 were not covered by tests

default:
assert(0);
default:
assert(0);
}
callclib(cdb,e,clib,pretregs,0);

Check warning on line 112 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L112

Added line #L112 was not covered by tests
}
else
{
const ftype = INSTR.szToFtype(sz);
switch (e.Eoper)

Check warning on line 117 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L116-L117

Added lines #L116 - L117 were not covered by tests
{
// FADD/FSUB (extended register)
// http://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#addsub_ext
case OPadd:
cdb.gen1(INSTR.fadd_float(ftype,Rm,Rn,Rd)); // FADD Rd,Rn,Rm
break;

Check warning on line 123 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L121-L123

Added lines #L121 - L123 were not covered by tests

case OPmin:
cdb.gen1(INSTR.fsub_float(ftype,Rm,Rn,Rd)); // FSUB Rd,Rn,Rm
break;

Check warning on line 127 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L125-L127

Added lines #L125 - L127 were not covered by tests

case OPmul:
cdb.gen1(INSTR.fmul_float(ftype,Rm,Rn,Rd)); // FMUL Rd,Rn,Rm
break;

Check warning on line 131 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L129-L131

Added lines #L129 - L131 were not covered by tests

case OPdiv:
cdb.gen1(INSTR.fdiv_float(ftype,Rm,Rn,Rd)); // FDIV Rd,Rn,Rm
break;

Check warning on line 135 in compiler/src/dmd/backend/arm/cod2.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod2.d#L133-L135

Added lines #L133 - L135 were not covered by tests

default:
assert(0);
}
}
pretregs = retregs | PSW;
fixresult(cdb,e,mask(Rd),pretregs);
Expand Down
Loading