[Lldb-commits] [lldb] r125416 - /lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h

Johnny Chen johnny.chen at apple.com
Fri Feb 11 15:29:14 PST 2011


Author: johnny
Date: Fri Feb 11 17:29:14 2011
New Revision: 125416

URL: http://llvm.org/viewvc/llvm-project?rev=125416&view=rev
Log:
Add a couple of utility functions plus some comments.

Modified:
    lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h

Modified: lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h?rev=125416&r1=125415&r2=125416&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h Fri Feb 11 17:29:14 2011
@@ -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 @@
     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 @@
     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)





More information about the lldb-commits mailing list