aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-08-24 22:09:56 +0000
committerDale Johannesen <dalej@apple.com>2007-08-24 22:09:56 +0000
commit12595d7b165bf460b18f4ddd395dd29e6e6e68bc (patch)
treefaf1eb03b939699d0d02ccffedb56e8ebf9b7230 /lib/VMCore
parent8bb369b8072c919ef5802f639a52b17620201190 (diff)
downloadexternal_llvm-12595d7b165bf460b18f4ddd395dd29e6e6e68bc.zip
external_llvm-12595d7b165bf460b18f4ddd395dd29e6e6e68bc.tar.gz
external_llvm-12595d7b165bf460b18f4ddd395dd29e6e6e68bc.tar.bz2
Poison APFloat::operator==. Replace existing uses with bitwiseIsEqual.
This means backing out the preceding change to Constants.cpp, alas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41378 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Constants.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 36ba7c0..04689e4 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -248,19 +248,30 @@ bool ConstantFP::isNullValue() const {
}
bool ConstantFP::isExactlyValue(double V) const {
- return Val == APFloat(V);
+ return Val.bitwiseIsEqual(APFloat(V));
}
namespace {
struct DenseMapAPFloatKeyInfo {
- static inline APFloat getEmptyKey() {
- return APFloat(APFloat::Bogus,1);
+ struct KeyTy {
+ APFloat val;
+ KeyTy(const APFloat& V) : val(V){}
+ KeyTy(const KeyTy& that) : val(that.val) {}
+ bool operator==(const KeyTy& that) const {
+ return this->val.bitwiseIsEqual(that.val);
+ }
+ bool operator!=(const KeyTy& that) const {
+ return !this->operator==(that);
+ }
+ };
+ static inline KeyTy getEmptyKey() {
+ return KeyTy(APFloat(APFloat::Bogus,1));
}
- static inline APFloat getTombstoneKey() {
- return APFloat(APFloat::Bogus,2);
+ static inline KeyTy getTombstoneKey() {
+ return KeyTy(APFloat(APFloat::Bogus,2));
}
- static unsigned getHashValue(const APFloat &Key) {
- return Key.getHashValue();
+ static unsigned getHashValue(const KeyTy &Key) {
+ return Key.val.getHashValue();
}
static bool isPod() { return false; }
};
@@ -268,21 +279,21 @@ namespace {
//---- ConstantFP::get() implementation...
//
-typedef DenseMap<APFloat, ConstantFP*,
+typedef DenseMap<DenseMapAPFloatKeyInfo::KeyTy, ConstantFP*,
DenseMapAPFloatKeyInfo> FPMapTy;
static ManagedStatic<FPMapTy> FPConstants;
ConstantFP *ConstantFP::get(const Type *Ty, double V) {
if (Ty == Type::FloatTy) {
- APFloat Key(APFloat((float)V));
+ DenseMapAPFloatKeyInfo::KeyTy Key(APFloat((float)V));
ConstantFP *&Slot = (*FPConstants)[Key];
if (Slot) return Slot;
return Slot = new ConstantFP(Ty, (float)V);
} else if (Ty == Type::DoubleTy) {
// Without the redundant cast, the following is taken to be
// a function declaration. What a language.
- APFloat Key(APFloat((double)V));
+ DenseMapAPFloatKeyInfo::KeyTy Key(APFloat((double)V));
ConstantFP *&Slot = (*FPConstants)[Key];
if (Slot) return Slot;
return Slot = new ConstantFP(Ty, V);