mirror of
https://gitlab.com/qemu-project/capstone.git
synced 2025-09-17 02:01:15 +08:00
replace if-s in AArch64_AM_decodeAdvSIMDModImmType10 with lookup table (#552)
* replace if-s in AArch64_AM_decodeAdvSIMDModImmType10 with lookup table Lookup table is much faster than bunch of if-s. If you don't like lookup tables, I have another proposal. See http://goo.gl/RjW1lr and compare generated machine code * Smaller lookup table and shifting and bit mask used * Update AArch64AddressingModes.h
This commit is contained in:
@ -213,16 +213,13 @@ static inline float AArch64_AM_getFPImmFloat(unsigned Imm)
|
||||
|
||||
static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType10(uint8_t Imm)
|
||||
{
|
||||
uint64_t EncVal = 0;
|
||||
if (Imm & 0x80) EncVal |= 0xff00000000000000ULL;
|
||||
if (Imm & 0x40) EncVal |= 0x00ff000000000000ULL;
|
||||
if (Imm & 0x20) EncVal |= 0x0000ff0000000000ULL;
|
||||
if (Imm & 0x10) EncVal |= 0x000000ff00000000ULL;
|
||||
if (Imm & 0x08) EncVal |= 0x00000000ff000000ULL;
|
||||
if (Imm & 0x04) EncVal |= 0x0000000000ff0000ULL;
|
||||
if (Imm & 0x02) EncVal |= 0x000000000000ff00ULL;
|
||||
if (Imm & 0x01) EncVal |= 0x00000000000000ffULL;
|
||||
return EncVal;
|
||||
static const uint32_t lookup[16] = {
|
||||
0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
|
||||
0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
|
||||
0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
|
||||
0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff
|
||||
};
|
||||
return lookup[Imm & 0x0f] | ((uint64_t)lookup[Imm >> 4] << 32);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user