[PATCH 22/57][Arm][GAS] Add support for MVE instructions: vmlaldav, vmlalv, vmlsldav...
[binutils-gdb.git] / sim / d10v / endian.c
blobdbc3db2003405fd5b31aef0a29e605f23fcff771
1 /* If we're being compiled as a .c file, rather than being included in
2 d10v_sim.h, then ENDIAN_INLINE won't be defined yet. */
4 #ifndef ENDIAN_INLINE
5 #define NO_ENDIAN_INLINE
6 #include "sim-main.h"
7 #define ENDIAN_INLINE
8 #endif
10 ENDIAN_INLINE uint16
11 get_word (uint8 *x)
13 return ((uint16)x[0]<<8) + x[1];
16 ENDIAN_INLINE uint32
17 get_longword (uint8 *x)
19 return ((uint32)x[0]<<24) + ((uint32)x[1]<<16) + ((uint32)x[2]<<8) + ((uint32)x[3]);
22 ENDIAN_INLINE int64
23 get_longlong (uint8 *x)
25 uint32 top = get_longword (x);
26 uint32 bottom = get_longword (x+4);
27 return (((int64)top)<<32) | (int64)bottom;
30 ENDIAN_INLINE void
31 write_word (uint8 *addr, uint16 data)
33 addr[0] = (data >> 8) & 0xff;
34 addr[1] = data & 0xff;
37 ENDIAN_INLINE void
38 write_longword (uint8 *addr, uint32 data)
40 addr[0] = (data >> 24) & 0xff;
41 addr[1] = (data >> 16) & 0xff;
42 addr[2] = (data >> 8) & 0xff;
43 addr[3] = data & 0xff;
46 ENDIAN_INLINE void
47 write_longlong (uint8 *addr, int64 data)
49 write_longword (addr, (uint32)(data >> 32));
50 write_longword (addr+4, (uint32)data);