aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-08-09 22:51:36 +0000
committerDale Johannesen <dalej@apple.com>2007-08-09 22:51:36 +0000
commitbdad80977b40ce9a833b2373323a5949dd2e5332 (patch)
tree1a4c53daa15fad81fe1923181c7e3143c12b4714 /llvm/lib/Bitcode
parentf855b626e8ae931866dbf1e300840fcb01792dfc (diff)
downloadllvm-bdad80977b40ce9a833b2373323a5949dd2e5332.zip
llvm-bdad80977b40ce9a833b2373323a5949dd2e5332.tar.gz
llvm-bdad80977b40ce9a833b2373323a5949dd2e5332.tar.bz2
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. llvm-svn: 40974
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp4
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp12
2 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 07a4279..eb18e31 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -629,6 +629,10 @@ bool BitcodeReader::ParseConstants() {
V = ConstantFP::get(CurTy, BitsToFloat(Record[0]));
else if (CurTy == Type::DoubleTy)
V = ConstantFP::get(CurTy, BitsToDouble(Record[0]));
+ // FIXME: Make long double constants work.
+ else if (CurTy == Type::X86_FP80Ty ||
+ CurTy == Type::FP128Ty || CurTy == Type::PPC_FP128Ty)
+ assert(0 && "Long double constants not handled yet.");
else
V = UndefValue::get(CurTy);
break;
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index c5be80f..17c14f0 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -525,11 +525,17 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
}
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
Code = bitc::CST_CODE_FLOAT;
- if (CFP->getType() == Type::FloatTy) {
+ const Type *Ty = CFP->getType();
+ if (Ty == Type::FloatTy) {
Record.push_back(FloatToBits((float)CFP->getValue()));
- } else {
- assert (CFP->getType() == Type::DoubleTy && "Unknown FP type!");
+ } else if (Ty == Type::DoubleTy) {
Record.push_back(DoubleToBits((double)CFP->getValue()));
+ // FIXME: make long double constants work.
+ } else if (Ty == Type::X86_FP80Ty ||
+ Ty == Type::FP128Ty || Ty == Type::PPC_FP128Ty) {
+ assert (0 && "Long double constants not handled yet.");
+ } else {
+ assert (0 && "Unknown FP type!");
}
} else if (isa<ConstantArray>(C) && cast<ConstantArray>(C)->isString()) {
// Emit constant strings specially.