9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INSTRUCTIONUTILS_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INSTRUCTIONUTILS_H
21static inline uint64_t
Bits64(
const uint64_t
bits,
const uint32_t msbit,
22 const uint32_t lsbit) {
23 assert(msbit < 64 && lsbit <= msbit);
24 return (
bits >> lsbit) & ((1ull << (msbit - lsbit + 1)) - 1);
29static inline uint32_t
Bits32(
const uint32_t
bits,
const uint32_t msbit,
30 const uint32_t lsbit) {
31 assert(msbit < 32 && lsbit <= msbit);
32 return (
bits >> lsbit) & ((1u << (msbit - lsbit + 1)) - 1);
36static inline uint32_t
Bit32(
const uint32_t
bits,
const uint32_t
bit) {
40static inline uint64_t
Bit64(
const uint64_t
bits,
const uint32_t
bit) {
47 const uint32_t lsbit,
const uint32_t val) {
48 assert(msbit < 32 && lsbit < 32 && msbit >= lsbit);
49 uint32_t mask = ((1u << (msbit - lsbit + 1)) - 1);
50 bits &= ~(mask << lsbit);
51 bits |= (val & mask) << lsbit;
61static inline uint32_t
Rotr32(uint32_t
bits, uint32_t amt) {
62 assert(amt < 32 &&
"Invalid rotate amount");
63 return (
bits >> amt) | (
bits << ((32 - amt) & 31));
67static inline uint32_t
Rotl32(uint32_t
bits, uint32_t amt) {
68 assert(amt < 32 &&
"Invalid rotate amount");
69 return (
bits << amt) | (
bits >> ((32 - amt) & 31));
76 return (1ull << (
bit + 1ull)) - 1ull;
89static inline bool BitIsSet(
const uint64_t value,
const uint64_t
bit) {
90 return (value & (1ull <<
bit)) != 0;
93static inline bool BitIsClear(
const uint64_t value,
const uint64_t
bit) {
94 return (value & (1ull <<
bit)) == 0;
97static inline uint64_t
UnsignedBits(
const uint64_t value,
const uint64_t msbit,
98 const uint64_t lsbit) {
99 uint64_t result = value >> lsbit;
104static inline int64_t
SignedBits(
const uint64_t value,
const uint64_t msbit,
105 const uint64_t lsbit) {
109 result |= ~MaskUpToBit(msbit - lsbit);
A class that represents a running process on the host machine.
static void SetBit32(uint32_t &bits, const uint32_t bit, const uint32_t val)
static uint64_t Bits64(const uint64_t bits, const uint32_t msbit, const uint32_t lsbit)
static void SetBits32(uint32_t &bits, const uint32_t msbit, const uint32_t lsbit, const uint32_t val)
static uint32_t Rotl32(uint32_t bits, uint32_t amt)
static bool BitIsSet(const uint64_t value, const uint64_t bit)
static uint32_t Rotr32(uint32_t bits, uint32_t amt)
static uint32_t BitCount(uint64_t x)
static uint64_t UnsignedBits(const uint64_t value, const uint64_t msbit, const uint64_t lsbit)
static uint32_t Bits32(const uint32_t bits, const uint32_t msbit, const uint32_t lsbit)
static uint64_t Bit64(const uint64_t bits, const uint32_t bit)
static uint64_t MaskUpToBit(const uint64_t bit)
static int64_t SignedBits(const uint64_t value, const uint64_t msbit, const uint64_t lsbit)
static bool BitIsClear(const uint64_t value, const uint64_t bit)
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
static uint32_t Bit32(const uint32_t bits, const uint32_t bit)