[llvm-commits] [llvm] r125453 - /llvm/trunk/include/llvm/ADT/APInt.h

Chris Lattner sabre at nondot.org
Sun Feb 13 00:04:17 PST 2011


Author: lattner
Date: Sun Feb 13 02:04:16 2011
New Revision: 125453

URL: http://llvm.org/viewvc/llvm-project?rev=125453&view=rev
Log:
add a helper method.

Modified:
    llvm/trunk/include/llvm/ADT/APInt.h

Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=125453&r1=125452&r2=125453&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Sun Feb 13 02:04:16 2011
@@ -431,6 +431,13 @@
   /// @returns the low "numBits" bits of this APInt.
   APInt getLoBits(unsigned numBits) const;
 
+  /// getOneBitSet - Return an APInt with exactly one bit set in the result.
+  static APInt getOneBitSet(unsigned numBits, unsigned BitNo) {
+    APInt Res(numBits, 0);
+    Res.setBit(BitNo);
+    return Res;
+  }
+  
   /// Constructs an APInt value that has a contiguous range of bits set. The
   /// bits from loBit (inclusive) to hiBit (exclusive) will be set. All other
   /// bits will be zero. For example, with parameters(32, 0, 16) you would get





More information about the llvm-commits mailing list