Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 1138:4c8bb03e4fbc
Update DtoConstFP() to be correct after LLVM r67562, which changed the way the
APFloat constructor expects its i80 APInts to be formatted. (They're now
actually consistent with the x87 format)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Tue, 24 Mar 2009 15:24:59 +0100 |
parents | f0b6549055ab |
children | 71479f6e2a01 |
comparison
equal
deleted
inserted
replaced
1137:45d73f0a9b43 | 1138:4c8bb03e4fbc |
---|---|
18 #include "gen/classes.h" | 18 #include "gen/classes.h" |
19 #include "gen/typeinf.h" | 19 #include "gen/typeinf.h" |
20 #include "gen/complex.h" | 20 #include "gen/complex.h" |
21 #include "gen/llvmhelpers.h" | 21 #include "gen/llvmhelpers.h" |
22 #include "gen/linkage.h" | 22 #include "gen/linkage.h" |
23 #include "gen/llvm-version.h" | |
23 | 24 |
24 bool DtoIsPassedByRef(Type* type) | 25 bool DtoIsPassedByRef(Type* type) |
25 { | 26 { |
26 Type* typ = type->toBasetype(); | 27 Type* typ = type->toBasetype(); |
27 TY t = typ->ty; | 28 TY t = typ->ty; |
519 | 520 |
520 if(llty == LLType::FloatTy || llty == LLType::DoubleTy) | 521 if(llty == LLType::FloatTy || llty == LLType::DoubleTy) |
521 return LLConstantFP::get(llty, value); | 522 return LLConstantFP::get(llty, value); |
522 else if(llty == LLType::X86_FP80Ty) { | 523 else if(llty == LLType::X86_FP80Ty) { |
523 uint64_t bits[] = {0, 0}; | 524 uint64_t bits[] = {0, 0}; |
525 #if LLVM_REV < 67562 | |
526 // Prior to r67562, the i80 APInt format expected by the APFloat | |
527 // constructor was different than the memory layout on the actual | |
528 // processor. | |
524 bits[1] = *(uint16_t*)&value; | 529 bits[1] = *(uint16_t*)&value; |
525 bits[0] = *(uint64_t*)((uint16_t*)&value + 1); | 530 bits[0] = *(uint64_t*)((uint16_t*)&value + 1); |
531 #else | |
532 bits[0] = *(uint64_t*)&value; | |
533 bits[1] = *(uint16_t*)((uint64_t*)&value + 1); | |
534 #endif | |
526 return LLConstantFP::get(APFloat(APInt(80, 2, bits))); | 535 return LLConstantFP::get(APFloat(APInt(80, 2, bits))); |
527 } else { | 536 } else { |
528 assert(0 && "Unknown floating point type encountered"); | 537 assert(0 && "Unknown floating point type encountered"); |
529 } | 538 } |
530 } | 539 } |