diff options
Diffstat (limited to 'lldb/source/Plugins/Process/Utility/InstructionUtils.h')
-rw-r--r-- | lldb/source/Plugins/Process/Utility/InstructionUtils.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Utility/InstructionUtils.h b/lldb/source/Plugins/Process/Utility/InstructionUtils.h index 4f59a52e3e9..e7b1446a5c5 100644 --- a/lldb/source/Plugins/Process/Utility/InstructionUtils.h +++ b/lldb/source/Plugins/Process/Utility/InstructionUtils.h @@ -14,6 +14,9 @@ namespace lldb_private { +// Bits32 - Return the bit field(s) from the most significant bit (msbit) to the +// least significant bit (lsbit) of a 32-bit unsigned value. +// static inline uint32_t Bits32 (const uint32_t bits, const uint32_t msbit, const uint32_t lsbit) { @@ -21,12 +24,17 @@ Bits32 (const uint32_t bits, const uint32_t msbit, const uint32_t lsbit) return (bits >> lsbit) & ((1u << (msbit - lsbit + 1)) - 1); } +// Bit32 - Return the bit from the 'bit' position of a 32-bit unsigned value. +// static inline uint32_t Bit32 (const uint32_t bits, const uint32_t bit) { return Bits32(bits, bit, bit); } +// SetBits32 - Set the bit field(s) from the most significant bit (msbit) to the +// least significant bit (lsbit) of a 32-bit unsigned value as 'val'. +// static inline void SetBits32(uint32_t &bits, const uint32_t msbit, const uint32_t lsbit, const uint32_t val) { @@ -36,12 +44,32 @@ SetBits32(uint32_t &bits, const uint32_t msbit, const uint32_t lsbit, const uint bits |= (val & mask) << lsbit; } +// SetBit32 - Set the 'bit' position of a 32-bit unsigned value as 'val'. +// static inline void SetBit32(uint32_t &bits, const uint32_t bit, const uint32_t val) { SetBits32(bits, bit, bit, val); } +// Rotr32 - Rotate a 32-bit unsigned value right by the specified amount. +// +static inline uint32_t +Rotr32 (uint32_t bits, uint32_t amt) +{ + assert(amt < 32 && "Invalid rotate amount"); + return (bits >> amt) | (bits << ((32-amt)&31)); +} + +// Rotl32 - Rotate a 32-bit unsigned value left by the specified amount. +// +static inline uint32_t +Rotl32 (uint32_t bits, uint32_t amt) +{ + assert(amt < 32 && "Invalid rotate amount"); + return (bits << amt) | (bits >> ((32-amt)&31)); +} + // Create a mask that starts at bit zero and includes "bit" static inline uint64_t MaskUpToBit (const uint64_t bit) |