comparison gen/tollvm.cpp @ 653:5812d6fac0f0

Fix x86_fp80 constants.
author Christian Kamm <kamm incasoftware de>
date Mon, 06 Oct 2008 09:07:35 +0200
parents aa6a0b7968f7
children 99f32e967746
comparison
equal deleted inserted replaced
652:c8fcde3337b0 653:5812d6fac0f0
527 527
528 llvm::ConstantFP* DtoConstFP(Type* t, long double value) 528 llvm::ConstantFP* DtoConstFP(Type* t, long double value)
529 { 529 {
530 const LLType* llty = DtoType(t); 530 const LLType* llty = DtoType(t);
531 assert(llty->isFloatingPoint()); 531 assert(llty->isFloatingPoint());
532 return LLConstantFP::get(llty, value); 532
533 if(llty == LLType::FloatTy || llty == LLType::DoubleTy)
534 return LLConstantFP::get(llty, value);
535 else if(llty == LLType::X86_FP80Ty) {
536 uint64_t bits[] = {0, 0};
537 bits[1] = *(uint16_t*)&value;
538 bits[0] = *((uint16_t*)&value + 4);
539 bits[0] <<= 16;
540 bits[0] += *((uint16_t*)&value + 3);
541 bits[0] <<= 16;
542 bits[0] += *((uint16_t*)&value + 2);
543 bits[0] <<= 16;
544 bits[0] += *((uint16_t*)&value + 1);
545 return LLConstantFP::get(APFloat(APInt(80, 2, bits)));
546 } else {
547 assert(0 && "Unknown floating point type encountered");
548 }
533 } 549 }
534 550
535 ////////////////////////////////////////////////////////////////////////////////////////// 551 //////////////////////////////////////////////////////////////////////////////////////////
536 552
537 LLConstant* DtoConstString(const char* str) 553 LLConstant* DtoConstString(const char* str)