diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Plugins/Process/Utility/InstructionUtils.h | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2 |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/source/Plugins/Process/Utility/InstructionUtils.h')
-rw-r--r-- | lldb/source/Plugins/Process/Utility/InstructionUtils.h | 138 |
1 files changed, 57 insertions, 81 deletions
diff --git a/lldb/source/Plugins/Process/Utility/InstructionUtils.h b/lldb/source/Plugins/Process/Utility/InstructionUtils.h index 6226fbc..e422a96 100644 --- a/lldb/source/Plugins/Process/Utility/InstructionUtils.h +++ b/lldb/source/Plugins/Process/Utility/InstructionUtils.h @@ -16,123 +16,99 @@ namespace lldb_private { // Return the bit field(s) from the most significant bit (msbit) to the // least significant bit (lsbit) of a 64-bit unsigned value. -static inline uint64_t -Bits64 (const uint64_t bits, const uint32_t msbit, const uint32_t lsbit) -{ - assert(msbit < 64 && lsbit <= msbit); - return (bits >> lsbit) & ((1ull << (msbit - lsbit + 1)) - 1); +static inline uint64_t Bits64(const uint64_t bits, const uint32_t msbit, + const uint32_t lsbit) { + assert(msbit < 64 && lsbit <= msbit); + return (bits >> lsbit) & ((1ull << (msbit - lsbit + 1)) - 1); } // 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); +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); } // Return the bit value from the 'bit' position of a 32-bit unsigned value. -static inline uint32_t -Bit32 (const uint32_t bits, const uint32_t bit) -{ - return (bits >> bit) & 1u; +static inline uint32_t Bit32(const uint32_t bits, const uint32_t bit) { + return (bits >> bit) & 1u; } -static inline uint64_t -Bit64 (const uint64_t bits, const uint32_t bit) -{ - return (bits >> bit) & 1ull; +static inline uint64_t Bit64(const uint64_t bits, const uint32_t bit) { + return (bits >> bit) & 1ull; } // Set the bit field(s) from the most significant bit (msbit) to the // least significant bit (lsbit) of a 32-bit unsigned value to '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; +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; } // Set the 'bit' position of a 32-bit unsigned value to 'val'. -static inline void -SetBit32(uint32_t &bits, const uint32_t bit, const uint32_t val) -{ - SetBits32(bits, bit, bit, val); +static inline void SetBit32(uint32_t &bits, const uint32_t bit, + const uint32_t val) { + SetBits32(bits, bit, bit, val); } // 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)); +static inline uint32_t Rotr32(uint32_t bits, uint32_t amt) { + assert(amt < 32 && "Invalid rotate amount"); + return (bits >> amt) | (bits << ((32 - amt) & 31)); } // 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)); +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) -{ - if (bit >= 63) - return -1ll; - return (1ull << (bit + 1ull)) - 1ull; +static inline uint64_t MaskUpToBit(const uint64_t bit) { + if (bit >= 63) + return -1ll; + return (1ull << (bit + 1ull)) - 1ull; } // Return an integer result equal to the number of bits of x that are ones. -static inline uint32_t -BitCount (uint64_t x) -{ - // c accumulates the total bits set in x - uint32_t c; - for (c = 0; x; ++c) - { - x &= x - 1; // clear the least significant bit set - } - return c; +static inline uint32_t BitCount(uint64_t x) { + // c accumulates the total bits set in x + uint32_t c; + for (c = 0; x; ++c) { + x &= x - 1; // clear the least significant bit set + } + return c; } -static inline bool -BitIsSet (const uint64_t value, const uint64_t bit) -{ - return (value & (1ull << bit)) != 0; +static inline bool BitIsSet(const uint64_t value, const uint64_t bit) { + return (value & (1ull << bit)) != 0; } -static inline bool -BitIsClear (const uint64_t value, const uint64_t bit) -{ - return (value & (1ull << bit)) == 0; +static inline bool BitIsClear(const uint64_t value, const uint64_t bit) { + return (value & (1ull << bit)) == 0; } -static inline uint64_t -UnsignedBits (const uint64_t value, const uint64_t msbit, const uint64_t lsbit) -{ - uint64_t result = value >> lsbit; - result &= MaskUpToBit (msbit - lsbit); - return result; +static inline uint64_t UnsignedBits(const uint64_t value, const uint64_t msbit, + const uint64_t lsbit) { + uint64_t result = value >> lsbit; + result &= MaskUpToBit(msbit - lsbit); + return result; } -static inline int64_t -SignedBits (const uint64_t value, const uint64_t msbit, const uint64_t lsbit) -{ - uint64_t result = UnsignedBits (value, msbit, lsbit); - if (BitIsSet(value, msbit)) - { - // Sign extend - result |= ~MaskUpToBit (msbit - lsbit); - } - return result; +static inline int64_t SignedBits(const uint64_t value, const uint64_t msbit, + const uint64_t lsbit) { + uint64_t result = UnsignedBits(value, msbit, lsbit); + if (BitIsSet(value, msbit)) { + // Sign extend + result |= ~MaskUpToBit(msbit - lsbit); + } + return result; } -} // namespace lldb_private +} // namespace lldb_private -#endif // lldb_InstructionUtils_h_ +#endif // lldb_InstructionUtils_h_ |