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

Chris Lattner lattner at cs.uiuc.edu
Mon Jun 21 07:19:01 PDT 2004


Changes in directory llvm/include/llvm:

Constants.h updated: 1.47 -> 1.48

---
Log message:

Make ConstantBool act like a 1 bit ConstantInt, in order to simplify client 
code.  Patch contributed by Vladimir Prus.


---
Diffs of the changes:  (+11 -12)

Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.47 llvm/include/llvm/Constants.h:1.48
--- llvm/include/llvm/Constants.h:1.47	Tue May 25 00:32:13 2004
+++ llvm/include/llvm/Constants.h	Mon Jun 21 07:11:01 2004
@@ -37,9 +37,18 @@
 ///
 class ConstantIntegral : public Constant {
 protected:
-  ConstantIntegral(const Type *Ty) : Constant(Ty) {}
+  union {
+    int64_t  Signed;
+    uint64_t Unsigned;
+  } Val;
+  ConstantIntegral(const Type *Ty, uint64_t V);
 public:
 
+  /// getRawValue - return the underlying value of this constant as a 64-bit
+  /// unsigned integer value.
+  ///
+  inline uint64_t getRawValue() const { return Val.Unsigned; }
+
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
   ///
@@ -79,7 +88,6 @@
 /// ConstantBool - Boolean Values
 ///
 class ConstantBool : public ConstantIntegral {
-  bool Val;
   ConstantBool(bool V);
 public:
   static ConstantBool *True, *False;  // The True & False values
@@ -93,7 +101,7 @@
 
   /// getValue - return the boolean value of this constant.
   ///
-  inline bool getValue() const { return Val; }
+  inline bool getValue() const { return static_cast<bool>(getRawValue()); }
 
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
@@ -120,10 +128,6 @@
 ///
 class ConstantInt : public ConstantIntegral {
 protected:
-  union {
-    int64_t  Signed;
-    uint64_t Unsigned;
-  } Val;
   ConstantInt(const ConstantInt &);      // DO NOT IMPLEMENT
   ConstantInt(const Type *Ty, uint64_t V);
 public:
@@ -143,11 +147,6 @@
   ///
   static ConstantInt *get(const Type *Ty, unsigned char V);
 
-  /// getRawValue - return the underlying value of this constant as a 64-bit
-  /// unsigned integer value.
-  ///
-  inline uint64_t getRawValue() const { return Val.Unsigned; }
-
   /// isNullValue - Return true if this is the value that would be returned by
   /// getNullValue.
   virtual bool isNullValue() const { return Val.Unsigned == 0; }





More information about the llvm-commits mailing list