[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Chris Lattner
sabre at nondot.org
Thu Sep 28 16:34:41 PDT 2006
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.162 -> 1.163
---
Log message:
Eliminate ConstantBool::True and ConstantBool::False. Instead, provide
ConstantBool::getTrue() and ConstantBool::getFalse().
---
Diffs of the changes: (+18 -8)
Constants.cpp | 26 ++++++++++++++++++--------
1 files changed, 18 insertions(+), 8 deletions(-)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.162 llvm/lib/VMCore/Constants.cpp:1.163
--- llvm/lib/VMCore/Constants.cpp:1.162 Wed Sep 27 19:38:19 2006
+++ llvm/lib/VMCore/Constants.cpp Thu Sep 28 18:34:27 2006
@@ -26,10 +26,6 @@
#include <iostream>
using namespace llvm;
-ConstantBool *ConstantBool::True = new ConstantBool(true);
-ConstantBool *ConstantBool::False = new ConstantBool(false);
-
-
//===----------------------------------------------------------------------===//
// Constant Class
//===----------------------------------------------------------------------===//
@@ -128,7 +124,7 @@
// Static constructor to create the maximum constant of an integral type...
ConstantIntegral *ConstantIntegral::getMaxValue(const Type *Ty) {
switch (Ty->getTypeID()) {
- case Type::BoolTyID: return ConstantBool::True;
+ case Type::BoolTyID: return ConstantBool::getTrue();
case Type::SByteTyID:
case Type::ShortTyID:
case Type::IntTyID:
@@ -152,7 +148,7 @@
// Static constructor to create the minimum constant for an integral type...
ConstantIntegral *ConstantIntegral::getMinValue(const Type *Ty) {
switch (Ty->getTypeID()) {
- case Type::BoolTyID: return ConstantBool::False;
+ case Type::BoolTyID: return ConstantBool::getFalse();
case Type::SByteTyID:
case Type::ShortTyID:
case Type::IntTyID:
@@ -176,7 +172,7 @@
// Static constructor to create an integral constant with all bits set
ConstantIntegral *ConstantIntegral::getAllOnesValue(const Type *Ty) {
switch (Ty->getTypeID()) {
- case Type::BoolTyID: return ConstantBool::True;
+ case Type::BoolTyID: return ConstantBool::getTrue();
case Type::SByteTyID:
case Type::ShortTyID:
case Type::IntTyID:
@@ -877,6 +873,20 @@
};
}
+
+//---- ConstantBool::get*() implementation.
+
+ConstantBool *ConstantBool::getTrue() {
+ static ConstantBool *T = 0;
+ if (T) return T;
+ return T = new ConstantBool(true);
+}
+ConstantBool *ConstantBool::getFalse() {
+ static ConstantBool *F = 0;
+ if (F) return F;
+ return F = new ConstantBool(false);
+}
+
//---- ConstantUInt::get() and ConstantSInt::get() implementations...
//
static ManagedStatic<ValueMap< int64_t, Type, ConstantSInt> > SIntConstants;
@@ -1380,7 +1390,7 @@
C = ConstantExpr::getCast(C, C->getType()->getSignedVersion());
return ConstantExpr::getCast(C, Ty);
} else {
- if (C == ConstantBool::True)
+ if (C == ConstantBool::getTrue())
return ConstantIntegral::getAllOnesValue(Ty);
else
return ConstantIntegral::getNullValue(Ty);
More information about the llvm-commits
mailing list