<commit_before>//===-- lldb_InstructionUtils.h ---------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef lldb_InstructionUtils_h_
#define lldb_InstructionUtils_h_

// Common utilities for manipulating instruction bit fields.

namespace lldb_private {

static inline uint32_t
Bits32 (const uint32_t bits, const uint32_t msbit, const uint32_t lsbit)
{
    assert(msbit < 32 && lsbit <= msbit);
    return (bits >> lsbit) & ((1u << (msbit - lsbit + 1)) - 1);
}

static inline uint32_t
Bit32 (const uint32_t bits, const uint32_t bit)
{
    return Bits32(bits, bit, bit);
}

static inline void
SetBits32(uint32_t &bits, const uint32_t msbit, const uint32_t lsbit, const uint32_t val)
{
    assert(msbit < 32 && lsbit < 32 && msbit >= lsbit);
    uint32_t mask = ((1u << (msbit - lsbit + 1)) - 1);
    bits &= ~(mask << lsbit);
    bits |= (val & mask) << lsbit;
}

static inline void
SetBit32(uint32_t &bits, const uint32_t bit, const uint32_t val)
{
    SetBits32(bits, bit, bit, val);
}

// Create a mask that starts at bit zero and includes "bit"
static inline uint64_t
MaskUpToBit (const uint64_t bit)
{
    return (1ull << (bit + 1ull)) - 1ull;
}

// Returns an integer result equal to the number of bits of x that are ones.
static inline uint32_t
BitCount (uint64_t x)<commit_msg>Add a couple of utility functions plus some comments.<commit_after>//===-- lldb_InstructionUtils.h ---------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef lldb_InstructionUtils_h_
#define lldb_InstructionUtils_h_

// Common utilities for manipulating instruction bit fields.

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)
{
    assert(msbit < 32 && lsbit <= msbit);
    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)
{
    assert(msbit < 32 && lsbit < 32 && msbit >= lsbit);
    uint32_t mask = ((1u << (msbit - lsbit + 1)) - 1);
    bits &= ~(mask << lsbit);
    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)
{
    return (1ull << (bit + 1ull)) - 1ull;
}

// Returns an integer result equal to the number of bits of x that are ones.
static inline uint32_t
BitCount (uint64_t x)
{'fraction_non_alphanumeric': 0.1690452755905512, 'fraction_numerical': 0.04478346456692913, 'mean_word_length': 2.7191216834400733, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3394731', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1311, 'n_words': 472}