summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Utility/InstructionUtils.h
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2011-02-11 23:29:14 +0000
committerJohnny Chen <johnny.chen@apple.com>2011-02-11 23:29:14 +0000
commit722d4e4aa0a5cebd584f076fdfdfedbddf4bee8e (patch)
tree5cab1e710fb044a540c6ffb6199eac7096982d6a /lldb/source/Plugins/Process/Utility/InstructionUtils.h
parent9865d7f0e64762497363f48e38b0b000d6c57716 (diff)
downloadbcm5719-llvm-722d4e4aa0a5cebd584f076fdfdfedbddf4bee8e.tar.gz
bcm5719-llvm-722d4e4aa0a5cebd584f076fdfdfedbddf4bee8e.zip
Add a couple of utility functions plus some comments.
llvm-svn: 125416
Diffstat (limited to 'lldb/source/Plugins/Process/Utility/InstructionUtils.h')
-rw-r--r--lldb/source/Plugins/Process/Utility/InstructionUtils.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Utility/InstructionUtils.h b/lldb/source/Plugins/Process/Utility/InstructionUtils.h
index 4f59a52e3e9..e7b1446a5c5 100644
--- a/lldb/source/Plugins/Process/Utility/InstructionUtils.h
+++ b/lldb/source/Plugins/Process/Utility/InstructionUtils.h
@@ -14,6 +14,9 @@
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)
{
@@ -21,12 +24,17 @@ Bits32 (const uint32_t bits, const uint32_t msbit, const uint32_t lsbit)
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)
{
@@ -36,12 +44,32 @@ SetBits32(uint32_t &bits, const uint32_t msbit, const uint32_t lsbit, const uint
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)
OpenPOWER on IntegriCloud