> Patch 10 for long double. Doing constants right needs expanding > ConstantFP > to handle values bigger than double. If we assume host==target and > host > long double works correctly, this is not too bad, but we don't want to > have that limitation longterm. I could implement accepting double > constants as long double or something like that, which would lead to > incorrect codegen with no errors; the more I think about that the > worse > it seems. Rather than do such a hack that would be backed out later, > I'm settling for giving reasonable error messages, for now.
Using host long double is an acceptable hack for now. Alternatively: > ====================================================================== > ======== > --- llvm/trunk/lib/VMCore/Constants.cpp (original) > +++ llvm/trunk/lib/VMCore/Constants.cpp Thu Aug 9 17:51:36 2007 > @@ -288,12 +291,17 @@ > ConstantFP *&Slot = (*FloatConstants)[std::make_pair(IntVal, > Ty)]; > if (Slot) return Slot; > return Slot = new ConstantFP(Ty, (float)V); > + } else if (Ty == Type::DoubleTy) { > uint64_t IntVal = DoubleToBits(V); > ConstantFP *&Slot = (*DoubleConstants)[std::make_pair(IntVal, > Ty)]; > if (Slot) return Slot; > return Slot = new ConstantFP(Ty, V); > + // FIXME: Make long double constants work. > + } else if (Ty == Type::X86_FP80Ty || > + Ty == Type::PPC_FP128Ty || Ty == Type::FP128Ty) { > + assert(0 && "Long double constants not handled yet."); You could just treat these like doubles for now: > uint64_t IntVal = DoubleToBits(V); > ConstantFP *&Slot = (*DoubleConstants)[std::make_pair(IntVal, > Ty)]; > if (Slot) return Slot; > return Slot = new ConstantFP(Ty, V); This gives you the correct value, but loses the long double precision. Seems a better short term hack than just asserting :) -Chris _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits