Johnny Chen | 4baf2e3 | 2011-01-24 18:24:53 +0000 | [diff] [blame] | 1 | //===-- lldb_ARMUtils.h -----------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef lldb_ARMUtils_h_ |
| 11 | #define lldb_ARMUtils_h_ |
| 12 | |
| 13 | // Utility functions for the ARM/Thumb Instruction Set Architecture. |
| 14 | |
| 15 | namespace lldb_private { |
| 16 | |
| 17 | // This function performs the check for the register numbers 13 and 15 that are |
| 18 | // not permitted for many Thumb register specifiers. |
| 19 | static inline bool BadReg(uint32_t n) { return n == 13 || n == 15; } |
| 20 | |
Johnny Chen | 7dc60e1 | 2011-01-24 19:46:32 +0000 | [diff] [blame^] | 21 | // Returns an integer result equal to the number of bits of x that are ones. |
| 22 | static inline uint32_t BitCount(uint32_t x) |
| 23 | { |
| 24 | // c accumulates the total bits set in x |
| 25 | uint32_t c; |
| 26 | for (c = 0; x; ++c) |
| 27 | { |
| 28 | x &= x - 1; // clear the least significant bit set |
| 29 | } |
| 30 | return c; |
| 31 | } |
| 32 | |
Johnny Chen | 4baf2e3 | 2011-01-24 18:24:53 +0000 | [diff] [blame] | 33 | } // namespace lldb_private |
| 34 | |
| 35 | #endif // lldb_ARMUtils_h_ |