optionrom: do not rely on compiler's bswap optimization
Recent compilers can detect and inline manually-written bswap code, but GCC 4.2.1 (the last GPLv2 version) cannot and generates really awful code. Depending on how the compiler is configured, it might also not want to generate bswap because it was not in i386. Using asm is fine because TCG knows about bswap and all processors with virtualization extensions also do. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
0cebabd5e8
commit
0342454f8a
Binary file not shown.
@ -122,24 +122,14 @@ static inline void writel_es(uint16_t offset, uint32_t val)
|
|||||||
|
|
||||||
static inline uint32_t bswap32(uint32_t x)
|
static inline uint32_t bswap32(uint32_t x)
|
||||||
{
|
{
|
||||||
return
|
asm("bswapl %0" : "=r" (x) : "0" (x));
|
||||||
((x & 0x000000ffU) << 24) |
|
return x;
|
||||||
((x & 0x0000ff00U) << 8) |
|
|
||||||
((x & 0x00ff0000U) >> 8) |
|
|
||||||
((x & 0xff000000U) >> 24);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t bswap64(uint64_t x)
|
static inline uint64_t bswap64(uint64_t x)
|
||||||
{
|
{
|
||||||
return
|
asm("bswapl %%eax; bswapl %%edx; xchg %%eax, %%edx" : "=A" (x) : "0" (x));
|
||||||
((x & 0x00000000000000ffULL) << 56) |
|
return x;
|
||||||
((x & 0x000000000000ff00ULL) << 40) |
|
|
||||||
((x & 0x0000000000ff0000ULL) << 24) |
|
|
||||||
((x & 0x00000000ff000000ULL) << 8) |
|
|
||||||
((x & 0x000000ff00000000ULL) >> 8) |
|
|
||||||
((x & 0x0000ff0000000000ULL) >> 24) |
|
|
||||||
((x & 0x00ff000000000000ULL) >> 40) |
|
|
||||||
((x & 0xff00000000000000ULL) >> 56);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t cpu_to_be64(uint64_t x)
|
static inline uint64_t cpu_to_be64(uint64_t x)
|
||||||
|
Loading…
Reference in New Issue
Block a user