Lines Matching +full:32 +full:- +full:bit
1 //===-- InstructionUtils.h --------------------------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
15 // Common utilities for manipulating instruction bit fields.
19 // Return the bit field(s) from the most significant bit (msbit) to the
20 // least significant bit (lsbit) of a 64-bit unsigned value.
24 return (bits >> lsbit) & ((1ull << (msbit - lsbit + 1)) - 1); in Bits64()
27 // Return the bit field(s) from the most significant bit (msbit) to the
28 // least significant bit (lsbit) of a 32-bit unsigned value.
31 assert(msbit < 32 && lsbit <= msbit); in Bits32()
32 return (bits >> lsbit) & ((1u << (msbit - lsbit + 1)) - 1); in Bits32()
35 // Return the bit value from the 'bit' position of a 32-bit unsigned value.
36 static inline uint32_t Bit32(const uint32_t bits, const uint32_t bit) { in Bit32() argument
37 return (bits >> bit) & 1u; in Bit32()
40 static inline uint64_t Bit64(const uint64_t bits, const uint32_t bit) { in Bit64() argument
41 return (bits >> bit) & 1ull; in Bit64()
44 // Set the bit field(s) from the most significant bit (msbit) to the
45 // least significant bit (lsbit) of a 32-bit unsigned value to 'val'.
48 assert(msbit < 32 && lsbit < 32 && msbit >= lsbit); in SetBits32()
49 uint32_t mask = ((1u << (msbit - lsbit + 1)) - 1); in SetBits32()
54 // Set the 'bit' position of a 32-bit unsigned value to 'val'.
55 static inline void SetBit32(uint32_t &bits, const uint32_t bit, in SetBit32() argument
57 SetBits32(bits, bit, bit, val); in SetBit32()
60 // Rotate a 32-bit unsigned value right by the specified amount.
62 assert(amt < 32 && "Invalid rotate amount"); in Rotr32()
63 return (bits >> amt) | (bits << ((32 - amt) & 31)); in Rotr32()
66 // Rotate a 32-bit unsigned value left by the specified amount.
68 assert(amt < 32 && "Invalid rotate amount"); in Rotl32()
69 return (bits << amt) | (bits >> ((32 - amt) & 31)); in Rotl32()
72 // Create a mask that starts at bit zero and includes "bit"
73 static inline uint64_t MaskUpToBit(const uint64_t bit) { in MaskUpToBit() argument
74 if (bit >= 63) in MaskUpToBit()
75 return -1ll; in MaskUpToBit()
76 return (1ull << (bit + 1ull)) - 1ull; in MaskUpToBit()
84 x &= x - 1; // clear the least significant bit set in BitCount()
89 static inline bool BitIsSet(const uint64_t value, const uint64_t bit) { in BitIsSet() argument
90 return (value & (1ull << bit)) != 0; in BitIsSet()
93 static inline bool BitIsClear(const uint64_t value, const uint64_t bit) { in BitIsClear() argument
94 return (value & (1ull << bit)) == 0; in BitIsClear()
100 result &= MaskUpToBit(msbit - lsbit); in UnsignedBits()
109 result |= ~MaskUpToBit(msbit - lsbit); in SignedBits()