Skip to content

Commit

Permalink
add fpregs to loadFromEA() and storeToEA()
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Feb 7, 2025
1 parent e6d09ab commit 69579f9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
51 changes: 51 additions & 0 deletions compiler/src/dmd/backend/arm/cod1.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ nothrow:
*/
void loadFromEA(ref code cs, reg_t reg, uint szw, uint szr)
{
if (reg & 32) // if floating point register

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L58 was not covered by tests
{
if (cs.reg != NOREG)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L60 was not covered by tests
{
if (cs.reg != reg) // do not mov onto itself

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L62 was not covered by tests
{
assert(cs.reg & 32);
cs.Iop = INSTR.fmov(szw == 8,cs.reg,reg); // FMOV reg,cs.reg

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

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L64-L65

Added lines #L64 - L65 were not covered by tests
}
}
else if (cs.base != NOREG)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L68 was not covered by tests
{
// LDR reg,[cs.base, #offset]
assert(cs.index == NOREG);
uint imm12 = cs.Sextend;
if (szw == 4) imm12 >>= 2;
else if (szw == 8) imm12 >>= 3;

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

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L71-L74

Added lines #L71 - L74 were not covered by tests
else assert(0);
cs.Iop = INSTR.ldr_imm_fpsimd(szw == 8 ? 3 : 2,1,imm12,cs.base,reg);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L76 was not covered by tests
}
else
assert(0);
return;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L80 was not covered by tests
}

if (cs.reg != NOREG)
{
if (cs.reg != reg) // do not mov onto itself
Expand Down Expand Up @@ -94,6 +119,32 @@ void loadFromEA(ref code cs, reg_t reg, uint szw, uint szr)
*/
void storeToEA(ref code cs, reg_t reg, uint sz)
{
if (reg & 32) // if floating point store

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L122 was not covered by tests
{
if (cs.reg != NOREG)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L124 was not covered by tests
{
if (cs.reg != reg) // do not mov onto itself

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L126 was not covered by tests
{
assert(cs.reg & 32);
cs.Iop = INSTR.fmov(sz == 8,reg,cs.reg); // FMOV cs.reg,reg

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

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L128-L129

Added lines #L128 - L129 were not covered by tests
}
cs.IFL1 = FL.unde;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L131 was not covered by tests
}
else if (cs.base != NOREG)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L133 was not covered by tests
{
// STR reg,[cs.base, #offset]
assert(cs.index == NOREG);
uint imm12 = cs.Sextend;
if (sz == 4) imm12 >>= 4;
else if (sz == 8) imm12 >>= 8;

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

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/arm/cod1.d#L136-L139

Added lines #L136 - L139 were not covered by tests
else assert(0);
cs.Iop = INSTR.str_imm_fpsimd(sz == 8 ? 3 : 2,0,imm12,cs.base,reg);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L141 was not covered by tests
}
else
assert(0);
return;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L145 was not covered by tests
}

if (cs.reg != NOREG)
{
if (cs.reg != reg) // do not mov onto itself
Expand Down
5 changes: 5 additions & 0 deletions compiler/src/dmd/backend/arm/instr.d
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,11 @@ struct INSTR
*/
static uint str_imm_fpsimd(uint size, uint opc, uint imm12, reg_t Rn, reg_t Vt) { return ldst_pos(size,1,opc,imm12,Rn,Vt); }

/* https://www.scs.stanford.edu/~zyedidia/arm64/ldr_imm_fpsimd.html
* LDR <Vt>,[<Xn|SP>,#<simm>] Unsigned offset
*/
static uint ldr_imm_fpsimd(uint size, uint opc, uint imm12, reg_t Rn, reg_t Vt) { return ldst_pos(size,1,opc,imm12,Rn,Vt); }

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L932 was not covered by tests

/* } */

/* { ************************** Data Processing -- Register **********************************/
Expand Down
11 changes: 9 additions & 2 deletions compiler/src/dmd/backend/x86/cod3.d
Original file line number Diff line number Diff line change
Expand Up @@ -4299,12 +4299,19 @@ void prolog_loadparams(ref CodeBuilder cdb, tym_t tyf, bool pushalloc)
{
if (AArch64)
{
uint imm = cast(uint)(offset + localsize + 16);

Check warning on line 4302 in compiler/src/dmd/backend/x86/cod3.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/x86/cod3.d#L4302

Added line #L4302 was not covered by tests
if (tyfloating(t.Tty))
{
// STR preg,[bp,#offset]
cdb.gen1(INSTR.str_imm_fpsimd(2 + (sz == 8),0,cast(uint)(offset + localsize + 16) >> 3,29,preg));
if (sz == 8)
imm >>= 3;
else if (sz == 4)
imm >>= 2;
cdb.gen1(INSTR.str_imm_fpsimd(2 + (sz == 8),0,imm,29,preg));

Check warning on line 4310 in compiler/src/dmd/backend/x86/cod3.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/x86/cod3.d#L4306-L4310

Added lines #L4306 - L4310 were not covered by tests
}
else
// STR preg,bp,#offset
cdb.gen1(INSTR.str_imm_gen(sz > 4, preg, 29, offset + localsize + 16));
cdb.gen1(INSTR.str_imm_gen(sz > 4, preg, 29, imm));

Check warning on line 4314 in compiler/src/dmd/backend/x86/cod3.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/x86/cod3.d#L4314

Added line #L4314 was not covered by tests
}
else
{
Expand Down

0 comments on commit 69579f9

Please sign in to comment.