2016-06-29 Jim Wilson <jim.wilson@linaro.org>
sim/aarch64/
* cpustate.h: Include config.h.
(union GRegisterValue): Add WORDS_BIGENDIAN check. For big endian code
use anonymous structs to align members.
* simulator.c (aarch64_step): Use sim_core_read_buffer and
endian_le2h_4 to read instruction from pc.
@@ -22,6 +22,7 @@
#ifndef _CPU_STATE_H
#define _CPU_STATE_H
+#include "config.h"
#include <sys/types.h>
#include <stdint.h>
#include <inttypes.h>
@@ -133,6 +134,7 @@ typedef enum VReg
an explicit extend. */
typedef union GRegisterValue
{
+#if !WORDS_BIGENDIAN
int8_t s8;
int16_t s16;
int32_t s32;
@@ -141,6 +143,16 @@ typedef union GRegisterValue
uint16_t u16;
uint32_t u32;
uint64_t u64;
+#else
+ struct { int64_t :56; int8_t s8; };
+ struct { int64_t :48; int16_t s16; };
+ struct { int64_t :32; int32_t s32; };
+ int64_t s64;
+ struct { uint64_t :56; uint8_t u8; };
+ struct { uint64_t :48; uint16_t u16; };
+ struct { uint64_t :32; uint32_t u32; };
+ uint64_t u64;
+#endif
} GRegister;
/* Float registers provide for storage of a single, double or quad
@@ -14083,7 +14083,11 @@ aarch64_step (sim_cpu *cpu)
return FALSE;
aarch64_set_next_PC (cpu, pc + 4);
- aarch64_get_instr (cpu) = aarch64_get_mem_u32 (cpu, pc);
+
+ /* Code is always little-endian. */
+ sim_core_read_buffer (CPU_STATE (cpu), cpu, read_map,
+ &aarch64_get_instr (cpu), pc, 4);
+ aarch64_get_instr (cpu) = endian_le2h_4 (aarch64_get_instr (cpu));
TRACE_INSN (cpu, " pc = %" PRIx64 " instr = %08x", pc,
aarch64_get_instr (cpu));