On 21/12/25 12:11, Philippe Mathieu-Daudé wrote:
On 19/12/25 17:36, Philippe Mathieu-Daudé wrote:
Do not open-code address_space_{ld,st}n(), use it passing
the access size as argument. Directly expand to the big-endian
variant (with the '_be' suffix) since we only build the SPARC
targets as big-endian.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
target/sparc/ldst_helper.c | 42 ++++----------------------------------
1 file changed, 4 insertions(+), 38 deletions(-)
diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index a87a0b3eee0..e9139814c26 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -701,25 +701,8 @@ uint64_t helper_ld_asi(CPUSPARCState *env,
target_ulong addr,
MemTxResult result;
hwaddr access_addr = (hwaddr)addr | ((hwaddr)(asi & 0xf) <<
32);
- switch (size) {
- case 1:
- ret = address_space_ldub(cs->as, access_addr,
- MEMTXATTRS_UNSPECIFIED, &result);
- break;
- case 2:
- ret = address_space_lduw(cs->as, access_addr,
- MEMTXATTRS_UNSPECIFIED, &result);
- break;
- default:
Unfortunately I missed this 'default' case (which I don't understand),
so this patch is not a faithful API conversion, thus incorrect.
- case 4:
- ret = address_space_ldl(cs->as, access_addr,
- MEMTXATTRS_UNSPECIFIED, &result);
- break;
- case 8:
- ret = address_space_ldq(cs->as, access_addr,
- MEMTXATTRS_UNSPECIFIED, &result);
- break;
- }
+ ret = address_space_ldn_be(cs->as, access_addr, size,
+ MEMTXATTRS_UNSPECIFIED, &result);
I just inverted size <-> access_addr :) The default case shouldn't be
reachable IMHO.