X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FAsmWriter.cpp;h=4a7fde190553312aaeb7b452e7cac769e3226a56;hb=fa7494306bc6fbe16cc82a67b93e762241b26777;hp=e6576c5bf7efb0e1c5d3a351aa070c9bc35f5372;hpb=24473120a253a05f3601cd3373403b47e6d03d41;p=oota-llvm.git diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index e6576c5bf7e..4a7fde19055 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -708,8 +708,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, } if (const ConstantFP *CFP = dyn_cast(CV)) { - if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEhalf || - &CFP->getValueAPF().getSemantics() == &APFloat::IEEEsingle || + if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEsingle || &CFP->getValueAPF().getSemantics() == &APFloat::IEEEdouble) { // We would like to output the FP constant value in exponential notation, // but we cannot do this if doing so will lose precision. Check here to @@ -719,7 +718,9 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, bool ignored; bool isHalf = &CFP->getValueAPF().getSemantics()==&APFloat::IEEEhalf; bool isDouble = &CFP->getValueAPF().getSemantics()==&APFloat::IEEEdouble; - if (!isHalf) { + bool isInf = CFP->getValueAPF().isInfinity(); + bool isNaN = CFP->getValueAPF().isNaN(); + if (!isHalf && !isInf && !isNaN) { double Val = isDouble ? CFP->getValueAPF().convertToDouble() : CFP->getValueAPF().convertToFloat(); SmallString<128> StrVal; @@ -733,7 +734,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, ((StrVal[0] == '-' || StrVal[0] == '+') && (StrVal[1] >= '0' && StrVal[1] <= '9'))) { // Reparse stringized version! - if (atof(StrVal.c_str()) == Val) { + if (APFloat(APFloat::IEEEdouble, StrVal).convertToDouble() == Val) { Out << StrVal.str(); return; } @@ -757,16 +758,20 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, return; } - // Some form of long double. These appear as a magic letter identifying - // the type, then a fixed number of hex digits. + // Either half, or some form of long double. + // These appear as a magic letter identifying the type, then a + // fixed number of hex digits. Out << "0x"; + // Bit position, in the current word, of the next nibble to print. + int shiftcount; + if (&CFP->getValueAPF().getSemantics() == &APFloat::x87DoubleExtended) { Out << 'K'; // api needed to prevent premature destruction APInt api = CFP->getValueAPF().bitcastToAPInt(); const uint64_t* p = api.getRawData(); uint64_t word = p[1]; - int shiftcount=12; + shiftcount = 12; int width = api.getBitWidth(); for (int j=0; j>shiftcount) & 15; @@ -782,17 +787,21 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, } } return; - } else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEquad) + } else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEquad) { + shiftcount = 60; Out << 'L'; - else if (&CFP->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) + } else if (&CFP->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) { + shiftcount = 60; Out << 'M'; - else + } else if (&CFP->getValueAPF().getSemantics() == &APFloat::IEEEhalf) { + shiftcount = 12; + Out << 'H'; + } else llvm_unreachable("Unsupported floating point type"); // api needed to prevent premature destruction APInt api = CFP->getValueAPF().bitcastToAPInt(); const uint64_t* p = api.getRawData(); uint64_t word = *p; - int shiftcount=60; int width = api.getBitWidth(); for (int j=0; j>shiftcount) & 15; @@ -827,30 +836,21 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, } if (const ConstantArray *CA = dyn_cast(CV)) { - // As a special case, print the array as a string if it is an array of - // i8 with ConstantInt values. - // Type *ETy = CA->getType()->getElementType(); - if (CA->isString()) { - Out << "c\""; - PrintEscapedString(CA->getAsString(), Out); - Out << '"'; - } else { // Cannot output in string format... - Out << '['; + Out << '['; + TypePrinter.print(ETy, Out); + Out << ' '; + WriteAsOperandInternal(Out, CA->getOperand(0), + &TypePrinter, Machine, + Context); + for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) { + Out << ", "; TypePrinter.print(ETy, Out); Out << ' '; - WriteAsOperandInternal(Out, CA->getOperand(0), - &TypePrinter, Machine, + WriteAsOperandInternal(Out, CA->getOperand(i), &TypePrinter, Machine, Context); - for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) { - Out << ", "; - TypePrinter.print(ETy, Out); - Out << ' '; - WriteAsOperandInternal(Out, CA->getOperand(i), &TypePrinter, Machine, - Context); - } - Out << ']'; } + Out << ']'; return; } @@ -1738,12 +1738,12 @@ void AssemblyWriter::printInstruction(const Instruction &I) { Out << ", "; writeOperand(SI.getDefaultDest(), true); Out << " ["; - unsigned NumCases = SI.getNumCases(); - for (unsigned i = 0; i < NumCases; ++i) { + for (SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); + i != e; ++i) { Out << "\n "; - writeOperand(SI.getCaseValue(i), true); + writeOperand(i.getCaseValue(), true); Out << ", "; - writeOperand(SI.getCaseSuccessor(i), true); + writeOperand(i.getCaseSuccessor(), true); } Out << "\n ]"; } else if (isa(I)) { @@ -2015,7 +2015,7 @@ static void WriteMDNodeComment(const MDNode *Node, if (!CI) return; APInt Val = CI->getValue(); APInt Tag = Val & ~APInt(Val.getBitWidth(), LLVMDebugVersionMask); - if (Val.ult(LLVMDebugVersion)) + if (Val.ult(LLVMDebugVersion11)) return; Out.PadToColumn(50);