[llvm-commits] CVS: llvm/include/llvm/Constants.h

Chris Lattner lattner at cs.uiuc.edu
Sat Sep 24 15:57:40 PDT 2005



Changes in directory llvm/include/llvm:

Constants.h updated: 1.72 -> 1.73
---
Log message:

Add long-overdue helpers for getting constants with known upper bits


---
Diffs of the changes:  (+14 -0)

 Constants.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.72 llvm/include/llvm/Constants.h:1.73
--- llvm/include/llvm/Constants.h:1.72	Wed Aug 17 15:06:22 2005
+++ llvm/include/llvm/Constants.h	Sat Sep 24 17:57:28 2005
@@ -54,7 +54,21 @@
   /// unsigned integer value.
   ///
   inline uint64_t getRawValue() const { return Val.Unsigned; }
+  
+  /// getZExtValue - Return the constant zero extended as appropriate for this
+  /// type.
+  inline uint64_t getZExtValue() const {
+    unsigned Size = getType()->getPrimitiveSizeInBits();
+    return Val.Unsigned & (~0ULL >> (64-Size));
+  }
 
+  /// getSExtValue - Return the constant sign extended as appropriate for this
+  /// type.
+  inline int64_t getSExtValue() const {
+    unsigned Size = getType()->getPrimitiveSizeInBits();
+    return (Val.Signed << (64-Size)) >> (64-Size);
+  }
+  
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
   ///






More information about the llvm-commits mailing list