[llvm-commits] [SignlessTypes] CVS: llvm/include/llvm/Constants.h
Reid Spencer
reid at x10sys.com
Fri Oct 20 00:34:10 PDT 2006
Changes in directory llvm/include/llvm:
Constants.h updated: 1.88.2.2 -> 1.88.2.3
---
Log message:
The forgotten patches. These should have been committed and tagged with the
ST_iter_1 tag, but they weren't, so we're commiting them now.
---
Diffs of the changes: (+6 -22)
Constants.h | 28 ++++++----------------------
1 files changed, 6 insertions(+), 22 deletions(-)
Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.88.2.2 llvm/include/llvm/Constants.h:1.88.2.3
--- llvm/include/llvm/Constants.h:1.88.2.2 Thu Oct 19 23:27:17 2006
+++ llvm/include/llvm/Constants.h Fri Oct 20 02:33:52 2006
@@ -41,23 +41,15 @@
/// @brief An abstract class for integer constants.
class ConstantIntegral : public Constant {
protected:
- union {
- int64_t Signed;
- uint64_t Unsigned;
- } Val;
+ uint64_t Val;
ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V);
- ConstantIntegral(const Type *Ty, ValueTy VT, int64_t V);
public:
- /// @brief Return the raw value of the constant as a 64-bit integer value.
- inline uint64_t getRawValue() const { return Val.Unsigned; }
-
/// Return the constant as a 64-bit unsigned integer value after it
/// has been zero extended as appropriate for the type of this constant.
/// @brief Return the zero extended value.
inline uint64_t getZExtValue() const {
- unsigned Size = getType()->getPrimitiveSizeInBits();
- return Val.Unsigned & (~uint64_t(0UL) >> (64-Size));
+ return Val;
}
/// Return the constant as a 64-bit integer value after it has been sign
@@ -65,7 +57,7 @@
/// @brief Return the sign extended value.
inline int64_t getSExtValue() const {
unsigned Size = getType()->getPrimitiveSizeInBits();
- return (Val.Signed << (64-Size)) >> (64-Size);
+ return (int64_t(Val) << (64-Size)) >> (64-Size);
}
/// This function is implemented by subclasses and will return true iff this
@@ -147,7 +139,7 @@
/// @returns the value of this ConstantBool
/// @brief return the boolean value of this constant.
- inline bool getValue() const { return static_cast<bool>(getRawValue()); }
+ inline bool getValue() const { return static_cast<bool>(getZExtValue()); }
/// @see ConstantIntegral for details
/// @brief Implement overrides
@@ -182,7 +174,7 @@
bool equalsInt(unsigned char V) const {
assert(V <= 127 &&
"equalsInt: Can only be used with very small positive constants!");
- return Val.Unsigned == V;
+ return Val == V;
}
/// Return a ConstantInt with the specified value for the specified type.
@@ -190,13 +182,6 @@
/// conversions don't bite us and to get around compiler errors where the
/// compiler can't find a suitable overload for a given integer value.
/// @brief Get a ConstantInt for a specific value.
- static ConstantInt *get(const Type *Ty, int8_t V);
- static ConstantInt *get(const Type *Ty, uint8_t V);
- static ConstantInt *get(const Type *Ty, int16_t V);
- static ConstantInt *get(const Type *Ty, uint16_t V);
- static ConstantInt *get(const Type *Ty, int32_t V);
- static ConstantInt *get(const Type *Ty, uint32_t V);
- static ConstantInt *get(const Type *Ty, uint64_t V);
static ConstantInt *get(const Type *Ty, int64_t V);
/// This static method returns true if the type Ty is big enough to
@@ -205,12 +190,11 @@
/// @returns true if V is a valid value for type Ty
/// @brief Determine if the value is in range for the given type.
static bool isValueValidForType(const Type *Ty, int64_t V);
- static bool isValueValidForType(const Type *Ty, uint64_t V);
/// @returns true if this is the null integer value.
/// @see ConstantIntegral for details
/// @brief Implement override.
- virtual bool isNullValue() const { return Val.Unsigned == 0; }
+ virtual bool isNullValue() const { return Val == 0; }
/// @returns true iff this constant's bits are all set to true.
/// @see ConstantIntegral
More information about the llvm-commits
mailing list