summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-27 06:09:08 +0000
committerChris Lattner <sabre@nondot.org>2005-09-27 06:09:08 +0000
commite7e139e8e8f700bb85c9efc884efa63a2e411270 (patch)
tree4efa7f5ef6f3e50f1cffb1eda4812fd188afc53e /llvm/lib
parent555fb9c98424360b6b64461ab3d5e1f975c74bf0 (diff)
downloadbcm5719-llvm-e7e139e8e8f700bb85c9efc884efa63a2e411270.tar.gz
bcm5719-llvm-e7e139e8e8f700bb85c9efc884efa63a2e411270.zip
Split SimpleConstantVal up into its components, so each Constant subclass getsa different enum value. This allows 'classof' for these to be really simple,not needing to call getType() anymore.
This speeds up isa/dyncast/etc for constants, and also makes them smaller. For example, the text section of a release build of InstCombine.cpp shrinks from 230037 bytes to 216363 bytes, a 6% reduction. llvm-svn: 23467
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Constants.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index d2500024414..1a2b7748567 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -209,38 +209,42 @@ bool ConstantUInt::isAllOnesValue() const {
//===----------------------------------------------------------------------===//
// Normal Constructors
-ConstantIntegral::ConstantIntegral(const Type *Ty, uint64_t V)
- : Constant(Ty, SimpleConstantVal, 0, 0) {
+ConstantIntegral::ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V)
+ : Constant(Ty, VT, 0, 0) {
Val.Unsigned = V;
}
-ConstantBool::ConstantBool(bool V) : ConstantIntegral(Type::BoolTy, V) {
+ConstantBool::ConstantBool(bool V)
+ : ConstantIntegral(Type::BoolTy, ConstantBoolVal, V) {
}
-ConstantInt::ConstantInt(const Type *Ty, uint64_t V) : ConstantIntegral(Ty, V) {
+ConstantInt::ConstantInt(const Type *Ty, ValueTy VT, uint64_t V)
+ : ConstantIntegral(Ty, VT, V) {
}
-ConstantSInt::ConstantSInt(const Type *Ty, int64_t V) : ConstantInt(Ty, V) {
+ConstantSInt::ConstantSInt(const Type *Ty, int64_t V)
+ : ConstantInt(Ty, ConstantSIntVal, V) {
assert(Ty->isInteger() && Ty->isSigned() &&
"Illegal type for signed integer constant!");
assert(isValueValidForType(Ty, V) && "Value too large for type!");
}
-ConstantUInt::ConstantUInt(const Type *Ty, uint64_t V) : ConstantInt(Ty, V) {
+ConstantUInt::ConstantUInt(const Type *Ty, uint64_t V)
+ : ConstantInt(Ty, ConstantUIntVal, V) {
assert(Ty->isInteger() && Ty->isUnsigned() &&
"Illegal type for unsigned integer constant!");
assert(isValueValidForType(Ty, V) && "Value too large for type!");
}
ConstantFP::ConstantFP(const Type *Ty, double V)
- : Constant(Ty, SimpleConstantVal, 0, 0) {
+ : Constant(Ty, ConstantFPVal, 0, 0) {
assert(isValueValidForType(Ty, V) && "Value too large for type!");
Val = V;
}
ConstantArray::ConstantArray(const ArrayType *T,
const std::vector<Constant*> &V)
- : Constant(T, SimpleConstantVal, new Use[V.size()], V.size()) {
+ : Constant(T, ConstantArrayVal, new Use[V.size()], V.size()) {
assert(V.size() == T->getNumElements() &&
"Invalid initializer vector for constant array");
Use *OL = OperandList;
@@ -259,7 +263,7 @@ ConstantArray::~ConstantArray() {
ConstantStruct::ConstantStruct(const StructType *T,
const std::vector<Constant*> &V)
- : Constant(T, SimpleConstantVal, new Use[V.size()], V.size()) {
+ : Constant(T, ConstantStructVal, new Use[V.size()], V.size()) {
assert(V.size() == T->getNumElements() &&
"Invalid initializer vector for constant structure");
Use *OL = OperandList;
@@ -280,7 +284,7 @@ ConstantStruct::~ConstantStruct() {
ConstantPacked::ConstantPacked(const PackedType *T,
const std::vector<Constant*> &V)
- : Constant(T, SimpleConstantVal, new Use[V.size()], V.size()) {
+ : Constant(T, ConstantPackedVal, new Use[V.size()], V.size()) {
Use *OL = OperandList;
for (unsigned i = 0, e = V.size(); i != e; ++i) {
assert((V[i]->getType() == T->getElementType() ||
OpenPOWER on IntegriCloud