aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Constants.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-21 12:12:12 +0000
committerChris Lattner <sabre@nondot.org>2004-06-21 12:12:12 +0000
commitc2dfb8bb909b0ba08733be94821513aef9467fa0 (patch)
tree6a24c80fe25469cf253dd42d0c973a73655f28ee /include/llvm/Constants.h
parent1a580bea99e109895f24369399c563877b3fad19 (diff)
downloadexternal_llvm-c2dfb8bb909b0ba08733be94821513aef9467fa0.tar.gz
external_llvm-c2dfb8bb909b0ba08733be94821513aef9467fa0.tar.bz2
external_llvm-c2dfb8bb909b0ba08733be94821513aef9467fa0.zip
Make ConstantBool act like a 1 bit ConstantInt, in order to simplify client
code. Patch contributed by Vladimir Prus. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14280 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r--include/llvm/Constants.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 9016f1a611..fbb7a42f5d 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -37,9 +37,18 @@ struct ConvertConstantType;
///
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 @@ public:
/// 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 @@ public:
/// 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 @@ public:
///
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 @@ public:
///
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; }