mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Privatize the ConstantFP table. I'm on a roll!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76097 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -222,76 +222,6 @@ bool ConstantFP::isExactlyValue(const APFloat& V) const {
|
||||
return Val.bitwiseIsEqual(V);
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct DenseMapAPFloatKeyInfo {
|
||||
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 KeyTy getTombstoneKey() {
|
||||
return KeyTy(APFloat(APFloat::Bogus,2));
|
||||
}
|
||||
static unsigned getHashValue(const KeyTy &Key) {
|
||||
return Key.val.getHashValue();
|
||||
}
|
||||
static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {
|
||||
return LHS == RHS;
|
||||
}
|
||||
static bool isPod() { return false; }
|
||||
};
|
||||
}
|
||||
|
||||
//---- ConstantFP::get() implementation...
|
||||
//
|
||||
typedef DenseMap<DenseMapAPFloatKeyInfo::KeyTy, ConstantFP*,
|
||||
DenseMapAPFloatKeyInfo> FPMapTy;
|
||||
|
||||
static ManagedStatic<FPMapTy> FPConstants;
|
||||
|
||||
ConstantFP *ConstantFP::get(const APFloat &V) {
|
||||
DenseMapAPFloatKeyInfo::KeyTy Key(V);
|
||||
|
||||
ConstantsLock->reader_acquire();
|
||||
ConstantFP *&Slot = (*FPConstants)[Key];
|
||||
ConstantsLock->reader_release();
|
||||
|
||||
if (!Slot) {
|
||||
sys::SmartScopedWriter<true> Writer(*ConstantsLock);
|
||||
ConstantFP *&NewSlot = (*FPConstants)[Key];
|
||||
if (!NewSlot) {
|
||||
const Type *Ty;
|
||||
if (&V.getSemantics() == &APFloat::IEEEsingle)
|
||||
Ty = Type::FloatTy;
|
||||
else if (&V.getSemantics() == &APFloat::IEEEdouble)
|
||||
Ty = Type::DoubleTy;
|
||||
else if (&V.getSemantics() == &APFloat::x87DoubleExtended)
|
||||
Ty = Type::X86_FP80Ty;
|
||||
else if (&V.getSemantics() == &APFloat::IEEEquad)
|
||||
Ty = Type::FP128Ty;
|
||||
else {
|
||||
assert(&V.getSemantics() == &APFloat::PPCDoubleDouble &&
|
||||
"Unknown FP format");
|
||||
Ty = Type::PPC_FP128Ty;
|
||||
}
|
||||
NewSlot = new ConstantFP(Ty, V);
|
||||
}
|
||||
|
||||
return NewSlot;
|
||||
}
|
||||
|
||||
return Slot;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ConstantXXX Classes
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user