[llvm-commits] CVS: llvm/include/llvm/Constants.h DerivedTypes.h Type.h
Reid Spencer
reid at x10sys.com
Fri Jan 19 13:14:33 PST 2007
Changes in directory llvm/include/llvm:
Constants.h updated: 1.119 -> 1.120
DerivedTypes.h updated: 1.80 -> 1.81
Type.h updated: 1.101 -> 1.102
---
Log message:
For PR1043: http://llvm.org/PR1043 :
This is the final patch for this PR. It implements some minor cleanup
in the use of IntegerType, to wit:
1. Type::getIntegerTypeMask -> IntegerType::getBitMask
2. Type::Int*Ty changed to IntegerType* from Type*
3. ConstantInt::getType() returns IntegerType* now, not Type*
This also fixes PR1120: http://llvm.org/PR1120 .
Patch by Sheng Zhou.
---
Diffs of the changes: (+20 -20)
Constants.h | 13 ++++++++++---
DerivedTypes.h | 7 +++++++
Type.h | 20 +++-----------------
3 files changed, 20 insertions(+), 20 deletions(-)
Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.119 llvm/include/llvm/Constants.h:1.120
--- llvm/include/llvm/Constants.h:1.119 Fri Jan 12 17:39:50 2007
+++ llvm/include/llvm/Constants.h Fri Jan 19 15:13:56 2007
@@ -60,7 +60,7 @@
/// sign extended as appropriate for the type of this constant.
/// @brief Return the sign extended value.
inline int64_t getSExtValue() const {
- unsigned Size = getType()->getPrimitiveSizeInBits();
+ unsigned Size = Value::getType()->getPrimitiveSizeInBits();
return (int64_t(Val) << (64-Size)) >> (64-Size);
}
/// A helper method that can be used to determine if the constant contained
@@ -92,6 +92,13 @@
/// @brief Get a ConstantInt for a specific value.
static ConstantInt *get(const Type *Ty, int64_t V);
+ /// getType - Specialize the getType() method to always return an IntegerType,
+ /// which reduces the amount of casting needed in parts of the compiler.
+ ///
+ inline const IntegerType *getType() const {
+ return reinterpret_cast<const IntegerType*>(Value::getType());
+ }
+
/// This static method returns true if the type Ty is big enough to
/// represent the value V. This can be used to avoid having the get method
/// assert when V is larger than Ty can represent. Note that there are two
@@ -130,7 +137,7 @@
int64_t V = getSExtValue();
if (V < 0) return false; // Be careful about wrap-around on 'long's
++V;
- return !isValueValidForType(getType(), V) || V < 0;
+ return !isValueValidForType(Value::getType(), V) || V < 0;
}
return isAllOnesValue();
}
@@ -145,7 +152,7 @@
int64_t V = getSExtValue();
if (V > 0) return false; // Be careful about wrap-around on 'long's
--V;
- return !isValueValidForType(getType(), V) || V > 0;
+ return !isValueValidForType(Value::getType(), V) || V > 0;
}
return getZExtValue() == 0;
}
Index: llvm/include/llvm/DerivedTypes.h
diff -u llvm/include/llvm/DerivedTypes.h:1.80 llvm/include/llvm/DerivedTypes.h:1.81
--- llvm/include/llvm/DerivedTypes.h:1.80 Wed Jan 17 20:59:54 2007
+++ llvm/include/llvm/DerivedTypes.h Fri Jan 19 15:13:56 2007
@@ -101,6 +101,13 @@
/// @brief Get the number of bits in this IntegerType
unsigned getBitWidth() const { return getSubclassData(); }
+ /// getBitMask - Return a bitmask with ones set for all of the bits
+ /// that can be set by an unsigned version of this type. This is 0xFF for
+ /// sbyte/ubyte, 0xFFFF for shorts, etc.
+ uint64_t getBitMask() const {
+ return ~uint64_t(0UL) >> (64-getPrimitiveSizeInBits());
+ }
+
/// This method determines if the width of this IntegerType is a power-of-2
/// in terms of 8 bit bytes.
/// @returns true if this is a power-of-2 byte width.
Index: llvm/include/llvm/Type.h
diff -u llvm/include/llvm/Type.h:1.101 llvm/include/llvm/Type.h:1.102
--- llvm/include/llvm/Type.h:1.101 Tue Jan 16 19:49:59 2007
+++ llvm/include/llvm/Type.h Fri Jan 19 15:13:56 2007
@@ -24,6 +24,7 @@
class DerivedType;
class PointerType;
+class IntegerType;
class TypeMapBase;
/// This file contains the declaration of the Type class. For more "Type" type
@@ -217,14 +218,6 @@
///
unsigned getPrimitiveSizeInBits() const;
- /// getIntegerTypeMask - Return a bitmask with ones set for all of the bits
- /// that can be set by an unsigned version of this type. This is 0xFF for
- /// sbyte/ubyte, 0xFFFF for shorts, etc.
- uint64_t getIntegerTypeMask() const {
- assert(isInteger() && "This only works for integer types!");
- return ~uint64_t(0UL) >> (64-getPrimitiveSizeInBits());
- }
-
/// getForwaredType - Return the type that this type has been resolved to if
/// it has been resolved to anything. This is used to implement the
/// union-find algorithm for type resolution, and shouldn't be used by general
@@ -237,14 +230,7 @@
/// getVAArgsPromotedType - Return the type an argument of this type
/// will be promoted to if passed through a variable argument
/// function.
- const Type *getVAArgsPromotedType() const {
- if (ID == IntegerTyID && getSubclassData() < 32)
- return Type::Int32Ty;
- else if (ID == FloatTyID)
- return Type::DoubleTy;
- else
- return this;
- }
+ const Type *getVAArgsPromotedType() const;
//===--------------------------------------------------------------------===//
// Type Iteration support
@@ -279,7 +265,7 @@
// These are the builtin types that are always available...
//
static const Type *VoidTy, *LabelTy, *FloatTy, *DoubleTy;
- static const Type *Int1Ty, *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
+ static const IntegerType *Int1Ty, *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Type *T) { return true; }
More information about the llvm-commits
mailing list