diff options
author | Dale Johannesen <dalej@apple.com> | 2007-09-12 03:30:33 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2007-09-12 03:30:33 +0000 |
commit | 9d5f45607793052bf5b4436d1b43013fab9999ac (patch) | |
tree | da064f263b6242adf84ced2a98439707a6114ddd /lib/CodeGen | |
parent | 257500db0437b6089f46ccf58bcdf04ad8dae9d9 (diff) |
Revise previous patch per review comments.
Next round of x87 long double stuff.
Getting close now, basically works.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter.cpp | 45 | ||||
-rw-r--r-- | lib/CodeGen/MachOWriter.cpp | 8 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 10 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 15 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 12 |
5 files changed, 62 insertions, 28 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index 49bcba7814..b55310661e 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -831,7 +831,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { // precision... if (CFP->getType() == Type::DoubleTy) { double Val = CFP->getValueAPF().convertToDouble(); // for comment only - uint64_t i = *CFP->getValueAPF().convertToAPInt().getRawData(); + uint64_t i = CFP->getValueAPF().convertToAPInt().getZExtValue(); if (TAI->getData64bitsDirective()) O << TAI->getData64bitsDirective() << i << "\t" << TAI->getCommentString() << " double value: " << Val << "\n"; @@ -851,13 +851,50 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { << " double most significant word " << Val << "\n"; } return; - } else { + } else if (CFP->getType() == Type::FloatTy) { float Val = CFP->getValueAPF().convertToFloat(); // for comment only O << TAI->getData32bitsDirective() - << (uint32_t)*CFP->getValueAPF().convertToAPInt().getRawData() + << CFP->getValueAPF().convertToAPInt().getZExtValue() << "\t" << TAI->getCommentString() << " float " << Val << "\n"; return; - } + } else if (CFP->getType() == Type::X86_FP80Ty) { + // all long double variants are printed as hex + const uint64_t *p = CFP->getValueAPF().convertToAPInt().getRawData(); + if (TD->isBigEndian()) { + O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48) + << "\t" << TAI->getCommentString() + << " long double most significant halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32) + << "\t" << TAI->getCommentString() + << " long double next halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 16) + << "\t" << TAI->getCommentString() + << " long double next halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[0]) + << "\t" << TAI->getCommentString() + << " long double next halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[1]) + << "\t" << TAI->getCommentString() + << " long double least significant halfword\n"; + } else { + O << TAI->getData16bitsDirective() << uint16_t(p[1]) + << "\t" << TAI->getCommentString() + << " long double least significant halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[0]) + << "\t" << TAI->getCommentString() + << " long double next halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 16) + << "\t" << TAI->getCommentString() + << " long double next halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32) + << "\t" << TAI->getCommentString() + << " long double next halfword\n"; + O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48) + << "\t" << TAI->getCommentString() + << " long double most significant halfword\n"; + } + return; + } else assert(0 && "Floating point constant type not handled"); } else if (CV->getType() == Type::Int64Ty) { if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { uint64_t Val = CI->getZExtValue(); diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index 1c9b0feff5..0c743759da 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -861,8 +861,8 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, break; } case Type::FloatTyID: { - uint32_t val = (uint32_t)*cast<ConstantFP>(PC)-> - getValueAPF().convertToAPInt().getRawData(); + uint32_t val = cast<ConstantFP>(PC)->getValueAPF().convertToAPInt(). + getZExtValue(); if (TD->isBigEndian()) val = ByteSwap_32(val); ptr[0] = val; @@ -872,8 +872,8 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, break; } case Type::DoubleTyID: { - uint64_t val = *cast<ConstantFP>(PC)->getValueAPF().convertToAPInt(). - getRawData(); + uint64_t val = cast<ConstantFP>(PC)->getValueAPF().convertToAPInt(). + getZExtValue(); if (TD->isBigEndian()) val = ByteSwap_64(val); ptr[0] = val; diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 2050d23ad7..68158be167 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3800,8 +3800,8 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) { default: assert(0 && "Unknown FP type"); case MVT::f32: if (!AfterLegalize || TLI.isTypeLegal(MVT::i32)) { - Tmp = DAG.getConstant((uint32_t)*CFP->getValueAPF(). - convertToAPInt().getRawData(), MVT::i32); + Tmp = DAG.getConstant((uint32_t)CFP->getValueAPF(). + convertToAPInt().getZExtValue(), MVT::i32); return DAG.getStore(Chain, Tmp, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), ST->isVolatile(), ST->getAlignment()); @@ -3809,8 +3809,8 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) { break; case MVT::f64: if (!AfterLegalize || TLI.isTypeLegal(MVT::i64)) { - Tmp = DAG.getConstant(*CFP->getValueAPF().convertToAPInt(). - getRawData(), MVT::i64); + Tmp = DAG.getConstant(CFP->getValueAPF().convertToAPInt(). + getZExtValue(), MVT::i64); return DAG.getStore(Chain, Tmp, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), ST->isVolatile(), ST->getAlignment()); @@ -3818,7 +3818,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) { // Many FP stores are not make apparent until after legalize, e.g. for // argument passing. Since this is so common, custom legalize the // 64-bit integer store into two 32-bit stores. - uint64_t Val = *CFP->getValueAPF().convertToAPInt().getRawData(); + uint64_t Val = CFP->getValueAPF().convertToAPInt().getZExtValue(); SDOperand Lo = DAG.getConstant(Val & 0xFFFFFFFF, MVT::i32); SDOperand Hi = DAG.getConstant(Val >> 32, MVT::i32); if (!TLI.isLittleEndian()) std::swap(Lo, Hi); diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index d7eb85bd8f..da55eafdb2 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -489,11 +489,8 @@ static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP, ConstantFP *LLVMC = ConstantFP::get(isDouble ? Type::DoubleTy : Type::FloatTy, CFP->getValueAPF()); if (!UseCP) { - const APFloat& Val = LLVMC->getValueAPF(); - return isDouble - ? DAG.getConstant(*Val.convertToAPInt().getRawData(), MVT::i64) - : DAG.getConstant((uint32_t )*Val.convertToAPInt().getRawData(), - MVT::i32); + return DAG.getConstant(LLVMC->getValueAPF().convertToAPInt().getZExtValue(), + isDouble ? MVT::i64 : MVT::i32); } if (isDouble && CFP->isValueValidForType(MVT::f32, CFP->getValueAPF()) && @@ -1981,13 +1978,13 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { // together. if (ConstantFPSDNode *CFP = dyn_cast<ConstantFPSDNode>(ST->getValue())) { if (CFP->getValueType(0) == MVT::f32) { - Tmp3 = DAG.getConstant((uint32_t)*CFP->getValueAPF(). - convertToAPInt().getRawData(), + Tmp3 = DAG.getConstant((uint32_t)CFP->getValueAPF(). + convertToAPInt().getZExtValue(), MVT::i32); } else { assert(CFP->getValueType(0) == MVT::f64 && "Unknown FP type!"); - Tmp3 = DAG.getConstant(*CFP->getValueAPF().convertToAPInt(). - getRawData(), MVT::i64); + Tmp3 = DAG.getConstant(CFP->getValueAPF().convertToAPInt(). + getZExtValue(), MVT::i64); } Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(), SVOffset, isVolatile, Alignment); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 85a76f436b..ed1777e34a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -109,12 +109,12 @@ bool ISD::isBuildVectorAllOnes(const SDNode *N) { } else if (isa<ConstantFPSDNode>(NotZero)) { MVT::ValueType VT = NotZero.getValueType(); if (VT== MVT::f64) { - if (*((cast<ConstantFPSDNode>(NotZero)->getValueAPF(). - convertToAPInt().getRawData())) != (uint64_t)-1) + if (((cast<ConstantFPSDNode>(NotZero)->getValueAPF(). + convertToAPInt().getZExtValue())) != (uint64_t)-1) return false; } else { - if ((uint32_t)*cast<ConstantFPSDNode>(NotZero)-> - getValueAPF().convertToAPInt().getRawData() != + if ((uint32_t)cast<ConstantFPSDNode>(NotZero)-> + getValueAPF().convertToAPInt().getZExtValue() != (uint32_t)-1) return false; } @@ -1697,9 +1697,9 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, } case ISD::BIT_CONVERT: if (VT == MVT::i32 && C->getValueType(0) == MVT::f32) - return getConstant((uint32_t)*V.convertToAPInt().getRawData(), VT); + return getConstant((uint32_t)V.convertToAPInt().getZExtValue(), VT); else if (VT == MVT::i64 && C->getValueType(0) == MVT::f64) - return getConstant(*V.convertToAPInt().getRawData(), VT); + return getConstant(V.convertToAPInt().getZExtValue(), VT); break; } } |