Skip to content
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

AArch64 OPd_f and OPf_d conversions #20815

Merged
merged 1 commit into from
Feb 3, 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
37 changes: 37 additions & 0 deletions compiler/src/dmd/backend/arm/cod4.d
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,43 @@
fixresult(cdb,e,retregs,pretregs);
break;

case OPd_f: // fcvt d31,s31
case OPf_d: // fcvt s31,d31
regm_t retregs1 = ALLREGS; //INSTR.FLOATREGS;

Check warning on line 1367 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod4.d#L1365-L1367

Added lines #L1365 - L1367 were not covered by tests
static if (1)
retregs1 = mCX; // hack because no floating support in rest of code

Check warning on line 1369 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1369 was not covered by tests
else
codelem(cgstate,cdb,e.E1,retregs1,false);
const reg_t V1 = findreg(retregs1); // source floating point register

Check warning on line 1372 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1372 was not covered by tests

static if (1)
{
regm_t retregs = mDX;

Check warning on line 1376 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1376 was not covered by tests
}
else
{
regm_t retregs = pretregs & INSTR.FLOATREGS;
if (retregs == 0)
retregs = INSTR.FLOATREGS & cgstate.allregs;
}
const tym = tybasic(e.Ety);
reg_t Vd = allocreg(cdb,retregs,tym); // destination integer register

Check warning on line 1385 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod4.d#L1384-L1385

Added lines #L1384 - L1385 were not covered by tests

switch (e.Eoper)

Check warning on line 1387 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1387 was not covered by tests
{
case OPd_f: // fcvt s31,d31
cdb.gen1(INSTR.fcvt_float(1,4,V1,Vd));
break;
case OPf_d: // fcvt d31,s31
cdb.gen1(INSTR.fcvt_float(0,5,V1,Vd));
break;

Check warning on line 1394 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod4.d#L1389-L1394

Added lines #L1389 - L1394 were not covered by tests
default:
assert(0);
}

fixresult(cdb,e,retregs,pretregs);
break;

Check warning on line 1400 in compiler/src/dmd/backend/arm/cod4.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod4.d#L1399-L1400

Added lines #L1399 - L1400 were not covered by tests

default:
assert(0);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/backend/arm/disasmarm.d
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,7 @@ void disassemble(uint c) @trusted
field(ins,21,21) == 1 &&
field(ins,14,10) == 0x10)
{
url = "floatdpl";
url = "floatdp1";

uint M = field(ins,31,31);
uint S = field(ins,29,29);
Expand Down
6 changes: 5 additions & 1 deletion compiler/src/dmd/backend/arm/instr.d
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,13 @@
static uint floatdp1(uint M, uint S, uint ftype, uint opcode, uint Rn, uint Rd)
{
assert(Rn < 32 && Rd < 32); // remember to convert R32-63 to 0-31
return (M << 31) | (S << 29) | (0x1E << 24) | (ftype << 22) | (1 << 21) | (0x10 << 10) | (Rn << 5) | Rd;
return (M << 31) | (S << 29) | (0x1E << 24) | (ftype << 22) | (1 << 21) | (opcode << 15) | (0x10 << 10) | (Rn << 5) | Rd;

Check warning on line 721 in compiler/src/dmd/backend/arm/instr.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L721 was not covered by tests
}

/* FCVT fpreg,fpreg https://www.scs.stanford.edu/~zyedidia/arm64/fcvt_float.html
*/
static uint fcvt_float(uint ftype, uint opcode, reg_t Rn, reg_t Rd) { return floatdp1(0,0,ftype,opcode,Rn,Rd); }

Check warning on line 726 in compiler/src/dmd/backend/arm/instr.d

View check run for this annotation

Codecov / codecov/patch

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

Added line #L726 was not covered by tests

/* Floating-point compare
* Floating-point immediate
* Floating-point condistional compare
Expand Down
Loading