blob: 137acb40d480983132ebf37faa8ecdf9ce62b41b [file] [log] [blame]
Johnny Chen4baf2e32011-01-24 18:24:53 +00001//===-- 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
15namespace 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.
19static inline bool BadReg(uint32_t n) { return n == 13 || n == 15; }
20
Johnny Chen7dc60e12011-01-24 19:46:32 +000021// Returns an integer result equal to the number of bits of x that are ones.
22static 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 Chen4baf2e32011-01-24 18:24:53 +000033} // namespace lldb_private
34
35#endif // lldb_ARMUtils_h_