Merge commit '16a2cf3873e00fa08e587d1b05c9132d98c24f50' into back-to-imgui
This commit is contained in:
16
external/capstone/MathExtras.h
vendored
16
external/capstone/MathExtras.h
vendored
@@ -482,15 +482,31 @@ static inline unsigned int countLeadingZeros(int x)
|
||||
}
|
||||
|
||||
/// \brief Get specified field from 32-bit instruction. Returns bits from the segment [from, to]
|
||||
/// The right most bit of insn is bit 31.
|
||||
static inline uint32_t get_insn_field(uint32_t insn, uint8_t from, uint8_t to)
|
||||
{
|
||||
return insn >> (31 - to) & ((1 << (to - from + 1)) - 1);
|
||||
}
|
||||
|
||||
/// \brief Get specified field from 32-bit instruction. Returns bits from the segment [from, to]
|
||||
/// The right most bit of insn is bit 0.
|
||||
static inline uint32_t get_insn_field_r(uint32_t insn, uint8_t from, uint8_t to)
|
||||
{
|
||||
return insn >> from & ((1 << (to - from + 1)) - 1);
|
||||
}
|
||||
|
||||
/// \brief Get specified bit from 32-bit instruction
|
||||
static inline uint32_t get_insn_bit(uint32_t insn, uint8_t bit)
|
||||
{
|
||||
return get_insn_field(insn, bit, bit);
|
||||
}
|
||||
|
||||
/// \brief Create a bitmask with the N right-most bits set to 1, and all other
|
||||
/// bits set to 0. Only unsigned types are allowed.
|
||||
static inline uint32_t maskTrailingOnes32(uint32_t N)
|
||||
{
|
||||
const unsigned Bits = CHAR_BIT * sizeof(uint32_t);
|
||||
return N == 0 ? 0 : (((uint32_t) -1) >> (Bits - N));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user