Skip to content

Commit 57fb2fa

Browse files
committed
Fix Q extension on big-endian targets
The previous routines always stored the low-order bits into the low-order doubleword, which is only correct on little-endian targets.
1 parent e04e7f9 commit 57fb2fa

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

riscv/insns/flq.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
require_extension('Q');
22
require_fp;
3-
WRITE_FRD(MMU.load_float128(RS1 + insn.i_imm()));
3+
uint128_t v = MMU.load<uint128_t>(RS1 + insn.i_imm());
4+
float128_t f = { uint64_t(v), uint64_t(v >> 64) };
5+
WRITE_FRD(f);

riscv/insns/fsq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
require_extension('Q');
22
require_fp;
3-
MMU.store_float128(RS1 + insn.s_imm(), FRS2);
3+
uint128_t v = FRS2.v[0] | (uint128_t(FRS2.v[1]) << 64);
4+
MMU.store<uint128_t>(RS1 + insn.s_imm(), v);

riscv/mmu.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -211,28 +211,6 @@ class mmu_t
211211
})
212212
}
213213

214-
void store_float128(reg_t addr, float128_t val)
215-
{
216-
if (unlikely(addr & (sizeof(float128_t)-1)) && !is_misaligned_enabled()) {
217-
throw trap_store_address_misaligned((proc) ? proc->state.v : false, addr, 0, 0);
218-
}
219-
220-
store<uint64_t>(addr, val.v[0]);
221-
store<uint64_t>(addr + 8, val.v[1]);
222-
}
223-
224-
float128_t load_float128(reg_t addr)
225-
{
226-
if (unlikely(addr & (sizeof(float128_t)-1)) && !is_misaligned_enabled()) {
227-
throw trap_load_address_misaligned((proc) ? proc->state.v : false, addr, 0, 0);
228-
}
229-
230-
float128_t res;
231-
res.v[0] = load<uint64_t>(addr);
232-
res.v[1] = load<uint64_t>(addr + 8);
233-
return res;
234-
}
235-
236214
void cbo_zero(reg_t addr) {
237215
auto access_info = generate_access_info(addr, STORE, {});
238216
reg_t transformed_addr = access_info.transformed_vaddr;

0 commit comments

Comments
 (0)