aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-03-23 21:16:53 +0000
committerDale Johannesen <dalej@apple.com>2009-03-23 21:16:53 +0000
commit1b25cb2416c46a6cebf2a6c52235e9fe46a10d11 (patch)
tree70fbe0beb7dc9d7c44f2216bcc8cb4822f7460e5 /lib/Bitcode
parentad20778705d7568eb5db8c5214d7e01ebc28dd8b (diff)
downloadexternal_llvm-1b25cb2416c46a6cebf2a6c52235e9fe46a10d11.zip
external_llvm-1b25cb2416c46a6cebf2a6c52235e9fe46a10d11.tar.gz
external_llvm-1b25cb2416c46a6cebf2a6c52235e9fe46a10d11.tar.bz2
Fix internal representation of fp80 to be the
same as a normal i80 {low64, high16} rather than its own {high64, low16}. A depressing number of places know about this; I think I got them all. Bitcode readers and writers convert back to the old form to avoid breaking compatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67562 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp10
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp5
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 299ce0b..69eadd9 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -801,9 +801,13 @@ bool BitcodeReader::ParseConstants() {
V = ConstantFP::get(APFloat(APInt(32, (uint32_t)Record[0])));
else if (CurTy == Type::DoubleTy)
V = ConstantFP::get(APFloat(APInt(64, Record[0])));
- else if (CurTy == Type::X86_FP80Ty)
- V = ConstantFP::get(APFloat(APInt(80, 2, &Record[0])));
- else if (CurTy == Type::FP128Ty)
+ else if (CurTy == Type::X86_FP80Ty) {
+ // Bits are not stored the same way as a normal i80 APInt, compensate.
+ uint64_t Rearrange[2];
+ Rearrange[0] = (Record[1] & 0xffffLL) | (Record[0] << 16);
+ Rearrange[1] = Record[0] >> 48;
+ V = ConstantFP::get(APFloat(APInt(80, 2, Rearrange)));
+ } else if (CurTy == Type::FP128Ty)
V = ConstantFP::get(APFloat(APInt(128, 2, &Record[0]), true));
else if (CurTy == Type::PPC_FP128Ty)
V = ConstantFP::get(APFloat(APInt(128, 2, &Record[0])));
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 1055564..d4d3443 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -559,10 +559,11 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
} else if (Ty == Type::X86_FP80Ty) {
// api needed to prevent premature destruction
+ // bits are not in the same order as a normal i80 APInt, compensate.
APInt api = CFP->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();
- Record.push_back(p[0]);
- Record.push_back((uint16_t)p[1]);
+ Record.push_back((p[1] << 48) | (p[0] >> 16));
+ Record.push_back(p[0] & 0xffffLL);
} else if (Ty == Type::FP128Ty || Ty == Type::PPC_FP128Ty) {
APInt api = CFP->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();