Skip to content

Commit

Permalink
[RISC-V] Simulate long vector load and store operations with builtin …
Browse files Browse the repository at this point in the history
…memcpy.

This commit adds a call to __builtin_memcpy when the data to be
loaded or stored exceeds 64 bits.
The __builtin_memcpy intrinsic will move the data from the memory address
of the simulated vector register to the destination memory address
or vice versa.
  • Loading branch information
PaoloS02 committed Oct 2, 2024
1 parent 4ce1730 commit 9669f1a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion target/riscv/vector_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,22 @@ vext_group_ldst_host(CPURISCVState *env, void *vd, uint32_t byte_end,
}

fn = fns[is_load][group_size];
fn(vd, byte_offset, host + byte_offset);

if (byte_offset + 32 < byte_end) {
group_size = MO_256;
if (is_load)
__builtin_memcpy((uint8_t *)(vd + byte_offset), (uint8_t *)(host + byte_offset), 32);
else
__builtin_memcpy((uint8_t *)(host + byte_offset), (uint8_t *)(vd + byte_offset), 32);
} else if (byte_offset + 16 < byte_end) {
group_size = MO_128;
if (is_load)
__builtin_memcpy((uint8_t *)(vd + byte_offset), (uint8_t *)(host + byte_offset), 16);
else
__builtin_memcpy((uint8_t *)(host + byte_offset), (uint8_t *)(vd + byte_offset), 16);
} else {
fn(vd, byte_offset, host + byte_offset);
}

return 1 << group_size;
}
Expand Down

0 comments on commit 9669f1a

Please sign in to comment.