From 43421b3dd70af5b70e71816521f37502c397cc65 Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Thu, 6 Sep 2007 18:13:44 +0000 Subject: [PATCH] Next round of APFloat changes. Use APFloat in UpgradeParser and AsmParser. Change all references to ConstantFP to use the APFloat interface rather than double. Remove the ConstantFP double interfaces. Use APFloat functions for constant folding arithmetic and comparisons. (There are still way too many places APFloat is just a wrapper around host float/double, but we're getting there.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41747 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Constants.h | 21 +- lib/Analysis/ConstantFolding.cpp | 55 ++- lib/Analysis/ScalarEvolution.cpp | 3 +- lib/AsmParser/Lexer.cpp.cvs | 18 +- lib/AsmParser/Lexer.l | 6 +- lib/AsmParser/Lexer.l.cvs | 6 +- lib/AsmParser/ParserInternals.h | 16 +- lib/AsmParser/llvmAsmParser.h.cvs | 2 +- lib/AsmParser/llvmAsmParser.y | 18 +- lib/AsmParser/llvmAsmParser.y.cvs | 18 +- lib/Bitcode/Reader/BitcodeReader.cpp | 15 +- lib/Bitcode/Writer/BitcodeWriter.cpp | 5 +- lib/CodeGen/AsmPrinter.cpp | 3 +- lib/CodeGen/MachOWriter.cpp | 6 +- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 5 +- lib/ExecutionEngine/ExecutionEngine.cpp | 4 +- lib/ExecutionEngine/JIT/JIT.cpp | 6 +- lib/Target/CBackend/CBackend.cpp | 34 +- lib/Target/MSIL/MSILWriter.cpp | 10 +- lib/Target/X86/X86ISelLowering.cpp | 33 +- lib/Transforms/IPO/SimplifyLibCalls.cpp | 27 +- .../Scalar/InstructionCombining.cpp | 2 +- lib/VMCore/AsmWriter.cpp | 9 +- lib/VMCore/ConstantFold.cpp | 163 ++++---- lib/VMCore/Constants.cpp | 37 +- tools/llvm-upgrade/UpgradeInternals.h | 9 +- tools/llvm-upgrade/UpgradeLexer.cpp.cvs | 371 +++++++++--------- tools/llvm-upgrade/UpgradeLexer.l | 6 +- tools/llvm-upgrade/UpgradeLexer.l.cvs | 6 +- tools/llvm-upgrade/UpgradeParser.y | 18 +- tools/llvm-upgrade/UpgradeParser.y.cvs | 18 +- tools/llvm2cpp/CppWriter.cpp | 27 +- 32 files changed, 540 insertions(+), 437 deletions(-) diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 86b4daadad1..b6b3f6346f6 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -217,29 +217,13 @@ class ConstantFP : public Constant { APFloat Val; ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT protected: - ConstantFP(const Type *Ty, double V); ConstantFP(const Type *Ty, const APFloat& V); public: /// get() - Static factory methods - Return objects of the specified value - static ConstantFP *get(const Type *Ty, double V); static ConstantFP *get(const Type *Ty, const APFloat& V); /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); - static bool isValueValidForType(const Type *Ty, double V) { - if (Ty == Type::FloatTy) - return isValueValidForType(Ty, APFloat((float)V)); - else - return isValueValidForType(Ty, APFloat(V)); - } - inline double getValue() const { - if (&Val.getSemantics() == &APFloat::IEEEdouble) - return Val.convertToDouble(); - else if (&Val.getSemantics() == &APFloat::IEEEsingle) - return (double)Val.convertToFloat(); - else - assert(0); - } inline const APFloat& getValueAPF() const { return Val; } /// isNullValue - Return true if this is the value that would be returned by @@ -250,8 +234,11 @@ public: /// isExactlyValue - We don't rely on operator== working on double values, as /// it returns true for things that are clearly not equal, like -0.0 and 0.0. /// As such, this method can be used to do an exact bit-for-bit comparison of - /// two floating point values. + /// two floating point values. The version with a double operand is retained + /// because it's so convenient to write isExactlyValue(2.0), but please use + /// it only for constants. bool isExactlyValue(const APFloat& V) const; + bool isExactlyValue(double V) const { if (&Val.getSemantics() == &APFloat::IEEEdouble) return isExactlyValue(APFloat(V)); diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 70ce34969c9..6c828fa0042 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -407,8 +407,14 @@ static Constant *ConstantFoldFP(double (*NativeFP)(double), double V, const Type *Ty) { errno = 0; V = NativeFP(V); - if (errno == 0) - return ConstantFP::get(Ty, V); + if (errno == 0) { + if (Ty==Type::FloatTy) + return ConstantFP::get(Ty, APFloat((float)V)); + else if (Ty==Type::DoubleTy) + return ConstantFP::get(Ty, APFloat(V)); + else + assert(0); + } errno = 0; return 0; } @@ -418,14 +424,21 @@ static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double), const Type *Ty) { errno = 0; V = NativeFP(V, W); - if (errno == 0) - return ConstantFP::get(Ty, V); + if (errno == 0) { + if (Ty==Type::FloatTy) + return ConstantFP::get(Ty, APFloat((float)V)); + else if (Ty==Type::DoubleTy) + return ConstantFP::get(Ty, APFloat(V)); + else + assert(0); + } errno = 0; return 0; } /// ConstantFoldCall - Attempt to constant fold a call to the specified function /// with the specified arguments, returning null if unsuccessful. + Constant * llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) { const ValueName *NameVal = F->getValueName(); @@ -436,7 +449,14 @@ llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) { const Type *Ty = F->getReturnType(); if (NumOperands == 1) { if (ConstantFP *Op = dyn_cast(Operands[0])) { - double V = Op->getValue(); + if (Ty!=Type::FloatTy && Ty!=Type::DoubleTy) + return 0; + /// Currently APFloat versions of these functions do not exist, so we use + /// the host native double versions. Float versions are not called + /// directly but for all these it is true (float)(f((double)arg)) == + /// f(arg). Long double not supported yet. + double V = Ty==Type::FloatTy ? (double)Op->getValueAPF().convertToFloat(): + Op->getValueAPF().convertToDouble(); switch (Str[0]) { case 'a': if (Len == 4 && !strcmp(Str, "acos")) @@ -460,7 +480,7 @@ llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) { break; case 'f': if (Len == 4 && !strcmp(Str, "fabs")) - return ConstantFP::get(Ty, fabs(V)); + return ConstantFoldFP(fabs, V, Ty); else if (Len == 5 && !strcmp(Str, "floor")) return ConstantFoldFP(floor, V, Ty); break; @@ -472,9 +492,10 @@ llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) { else if (!strcmp(Str, "llvm.sqrt.f32") || !strcmp(Str, "llvm.sqrt.f64")) { if (V >= -0.0) - return ConstantFP::get(Ty, sqrt(V)); + return ConstantFoldFP(sqrt, V, Ty); else // Undefined - return ConstantFP::get(Ty, 0.0); + return ConstantFP::get(Ty, Ty==Type::FloatTy ? APFloat(0.0f) : + APFloat(0.0)); } break; case 's': @@ -512,9 +533,15 @@ llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) { } } else if (NumOperands == 2) { if (ConstantFP *Op1 = dyn_cast(Operands[0])) { - double Op1V = Op1->getValue(); + double Op1V = Ty==Type::FloatTy ? + (double)Op1->getValueAPF().convertToFloat(): + Op1->getValueAPF().convertToDouble(); if (ConstantFP *Op2 = dyn_cast(Operands[1])) { - double Op2V = Op2->getValue(); + if (Ty!=Type::FloatTy && Ty!=Type::DoubleTy) + return 0; + double Op2V = Ty==Type::FloatTy ? + (double)Op2->getValueAPF().convertToFloat(): + Op2->getValueAPF().convertToDouble(); if (Len == 3 && !strcmp(Str, "pow")) { return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty); @@ -525,11 +552,11 @@ llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) { } } else if (ConstantInt *Op2C = dyn_cast(Operands[1])) { if (!strcmp(Str, "llvm.powi.f32")) { - return ConstantFP::get(Ty, std::pow((float)Op1V, - (int)Op2C->getZExtValue())); + return ConstantFP::get(Ty, APFloat((float)std::pow((float)Op1V, + (int)Op2C->getZExtValue()))); } else if (!strcmp(Str, "llvm.powi.f64")) { - return ConstantFP::get(Ty, std::pow((double)Op1V, - (int)Op2C->getZExtValue())); + return ConstantFP::get(Ty, APFloat((double)std::pow((double)Op1V, + (int)Op2C->getZExtValue()))); } } } diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 5bae18cc4c3..aaba49eacd9 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -485,7 +485,8 @@ SCEVHandle SCEVUnknown::getIntegerSCEV(int Val, const Type *Ty) { if (Val == 0) C = Constant::getNullValue(Ty); else if (Ty->isFloatingPoint()) - C = ConstantFP::get(Ty, Val); + C = ConstantFP::get(Ty, APFloat(Ty==Type::FloatTy ? APFloat::IEEEsingle : + APFloat::IEEEdouble, Val)); else C = ConstantInt::get(Ty, Val); return SCEVUnknown::get(C); diff --git a/lib/AsmParser/Lexer.cpp.cvs b/lib/AsmParser/Lexer.cpp.cvs index 30ddb8fa0f0..326bdf0ac79 100644 --- a/lib/AsmParser/Lexer.cpp.cvs +++ b/lib/AsmParser/Lexer.cpp.cvs @@ -2129,15 +2129,17 @@ YY_RULE_SETUP case 145: YY_RULE_SETUP #line 440 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" -{ llvmAsmlval.FPVal = atof(yytext); return FPVAL; } +{ llvmAsmlval.FPVal = new APFloat(atof(yytext)); return FPVAL; } YY_BREAK case 146: YY_RULE_SETUP #line 441 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" -{ llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; } +{ llvmAsmlval.FPVal = new APFloat(HexToFP(yytext)); + return FPVAL; + } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 443 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" +#line 445 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" { /* Make sure to free the internal buffers for flex when we are * done reading our input! @@ -2148,20 +2150,20 @@ case YY_STATE_EOF(INITIAL): YY_BREAK case 147: YY_RULE_SETUP -#line 451 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" +#line 453 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" { /* Ignore whitespace */ } YY_BREAK case 148: YY_RULE_SETUP -#line 452 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" +#line 454 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" { return yytext[0]; } YY_BREAK case 149: YY_RULE_SETUP -#line 454 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" +#line 456 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2165 "Lexer.cpp" +#line 2167 "Lexer.cpp" case YY_END_OF_BUFFER: { @@ -3043,5 +3045,5 @@ int main() return 0; } #endif -#line 454 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" +#line 456 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/Lexer.l" diff --git a/lib/AsmParser/Lexer.l b/lib/AsmParser/Lexer.l index 64e6d16eda8..390544d8c3d 100644 --- a/lib/AsmParser/Lexer.l +++ b/lib/AsmParser/Lexer.l @@ -437,8 +437,10 @@ shufflevector { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); } return GLOBALVAL_ID; } -{FPConstant} { llvmAsmlval.FPVal = atof(yytext); return FPVAL; } -{HexFPConstant} { llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; } +{FPConstant} { llvmAsmlval.FPVal = new APFloat(atof(yytext)); return FPVAL; } +{HexFPConstant} { llvmAsmlval.FPVal = new APFloat(HexToFP(yytext)); + return FPVAL; + } <> { /* Make sure to free the internal buffers for flex when we are diff --git a/lib/AsmParser/Lexer.l.cvs b/lib/AsmParser/Lexer.l.cvs index 64e6d16eda8..390544d8c3d 100644 --- a/lib/AsmParser/Lexer.l.cvs +++ b/lib/AsmParser/Lexer.l.cvs @@ -437,8 +437,10 @@ shufflevector { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); } return GLOBALVAL_ID; } -{FPConstant} { llvmAsmlval.FPVal = atof(yytext); return FPVAL; } -{HexFPConstant} { llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; } +{FPConstant} { llvmAsmlval.FPVal = new APFloat(atof(yytext)); return FPVAL; } +{HexFPConstant} { llvmAsmlval.FPVal = new APFloat(HexToFP(yytext)); + return FPVAL; + } <> { /* Make sure to free the internal buffers for flex when we are diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index e315902c31f..61de652c516 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -22,7 +22,7 @@ #include "llvm/Instructions.h" #include "llvm/Assembly/Parser.h" #include "llvm/ADT/StringExtras.h" - +#include "llvm/ADT/APFloat.h" // Global variables exported from the lexer... @@ -93,10 +93,10 @@ struct ValID { std::string *Name; // If it's a named reference. Memory must be deleted. int64_t ConstPool64; // Constant pool reference. This is the value uint64_t UConstPool64;// Unsigned constant pool reference. - double ConstPoolFP; // Floating point constant pool reference + APFloat *ConstPoolFP; // Floating point constant pool reference Constant *ConstantValue; // Fully resolved constant for ConstantVal case. InlineAsmDescriptor *IAD; - }; + }; static ValID createLocalID(unsigned Num) { ValID D; D.Type = LocalID; D.Num = Num; return D; @@ -119,7 +119,7 @@ struct ValID { ValID D; D.Type = ConstUIntVal; D.UConstPool64 = Val; return D; } - static ValID create(double Val) { + static ValID create(APFloat *Val) { ValID D; D.Type = ConstFPVal; D.ConstPoolFP = Val; return D; } @@ -168,7 +168,7 @@ struct ValID { case GlobalID : return '@' + utostr(Num); case LocalName : return *Name; case GlobalName : return *Name; - case ConstFPVal : return ftostr(ConstPoolFP); + case ConstFPVal : return ftostr(*ConstPoolFP); case ConstNullVal : return "null"; case ConstUndefVal : return "undef"; case ConstZeroVal : return "zeroinitializer"; @@ -194,7 +194,8 @@ struct ValID { case GlobalName: return *Name < *V.Name; case ConstSIntVal: return ConstPool64 < V.ConstPool64; case ConstUIntVal: return UConstPool64 < V.UConstPool64; - case ConstFPVal: return ConstPoolFP < V.ConstPoolFP; + case ConstFPVal: return ConstPoolFP->compare(*V.ConstPoolFP) == + APFloat::cmpLessThan; case ConstNullVal: return false; case ConstUndefVal: return false; case ConstZeroVal: return false; @@ -212,7 +213,8 @@ struct ValID { case GlobalName: return *Name == *(V.Name); case ConstSIntVal: return ConstPool64 == V.ConstPool64; case ConstUIntVal: return UConstPool64 == V.UConstPool64; - case ConstFPVal: return ConstPoolFP == V.ConstPoolFP; + case ConstFPVal: return ConstPoolFP->compare(*V.ConstPoolFP) == + APFloat::cmpEqual; case ConstantVal: return ConstantValue == V.ConstantValue; case ConstNullVal: return true; case ConstUndefVal: return true; diff --git a/lib/AsmParser/llvmAsmParser.h.cvs b/lib/AsmParser/llvmAsmParser.h.cvs index 353388b01ae..feb3ff6d30c 100644 --- a/lib/AsmParser/llvmAsmParser.h.cvs +++ b/lib/AsmParser/llvmAsmParser.h.cvs @@ -355,7 +355,7 @@ typedef union YYSTYPE { uint64_t UInt64Val; int SIntVal; unsigned UIntVal; - double FPVal; + llvm::APFloat *FPVal; bool BoolVal; std::string *StrVal; // This memory must be deleted diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 93f7a085bc6..83dfa31f03a 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -412,11 +412,15 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) { } case ValID::ConstFPVal: // Is it a floating point const pool reference? - if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { + if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) { GenerateError("FP constant invalid for type"); return 0; } - return ConstantFP::get(Ty, D.ConstPoolFP); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if (Ty==Type::FloatTy) + D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + return ConstantFP::get(Ty, *D.ConstPoolFP); case ValID::ConstNullVal: // Is it a null value? if (!isa(Ty)) { @@ -992,7 +996,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { uint64_t UInt64Val; int SIntVal; unsigned UIntVal; - double FPVal; + llvm::APFloat *FPVal; bool BoolVal; std::string *StrVal; // This memory must be deleted @@ -1862,9 +1866,13 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr CHECK_FOR_ERROR } | FPType FPVAL { // Float & Double constants - if (!ConstantFP::isValueValidForType($1, $2)) + if (!ConstantFP::isValueValidForType($1, *$2)) GEN_ERROR("Floating point constant invalid for type"); - $$ = ConstantFP::get($1, $2); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if ($1==Type::FloatTy) + $2->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + $$ = ConstantFP::get($1, *$2); CHECK_FOR_ERROR }; diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs index 93f7a085bc6..83dfa31f03a 100644 --- a/lib/AsmParser/llvmAsmParser.y.cvs +++ b/lib/AsmParser/llvmAsmParser.y.cvs @@ -412,11 +412,15 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) { } case ValID::ConstFPVal: // Is it a floating point const pool reference? - if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { + if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) { GenerateError("FP constant invalid for type"); return 0; } - return ConstantFP::get(Ty, D.ConstPoolFP); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if (Ty==Type::FloatTy) + D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + return ConstantFP::get(Ty, *D.ConstPoolFP); case ValID::ConstNullVal: // Is it a null value? if (!isa(Ty)) { @@ -992,7 +996,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { uint64_t UInt64Val; int SIntVal; unsigned UIntVal; - double FPVal; + llvm::APFloat *FPVal; bool BoolVal; std::string *StrVal; // This memory must be deleted @@ -1862,9 +1866,13 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr CHECK_FOR_ERROR } | FPType FPVAL { // Float & Double constants - if (!ConstantFP::isValueValidForType($1, $2)) + if (!ConstantFP::isValueValidForType($1, *$2)) GEN_ERROR("Floating point constant invalid for type"); - $$ = ConstantFP::get($1, $2); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if ($1==Type::FloatTy) + $2->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + $$ = ConstantFP::get($1, *$2); CHECK_FOR_ERROR }; diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 6ad1fd595b7..fcf2e510f9b 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -626,13 +626,16 @@ bool BitcodeReader::ParseConstants() { if (Record.empty()) return Error("Invalid FLOAT record"); if (CurTy == Type::FloatTy) - V = ConstantFP::get(CurTy, BitsToFloat(Record[0])); + V = ConstantFP::get(CurTy, APFloat((float)BitsToDouble(Record[0]))); else if (CurTy == Type::DoubleTy) - V = ConstantFP::get(CurTy, BitsToDouble(Record[0])); - // FIXME: Make long double constants work. - else if (CurTy == Type::X86_FP80Ty || - CurTy == Type::FP128Ty || CurTy == Type::PPC_FP128Ty) - assert(0 && "Long double constants not handled yet."); + V = ConstantFP::get(CurTy, APFloat(BitsToDouble(Record[0]))); + // FIXME: Make long double constants work. BitsToDouble does not make it. + else if (CurTy == Type::X86_FP80Ty) + V = ConstantFP::get(CurTy, APFloat(BitsToDouble(Record[0]))); + else if (CurTy == Type::FP128Ty) + V = ConstantFP::get(CurTy, APFloat(BitsToDouble(Record[0]))); + else if (CurTy == Type::PPC_FP128Ty) + assert(0 && "PowerPC long double constants not handled yet."); else V = UndefValue::get(CurTy); break; diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 17c14f0a0d1..ab3d9834d16 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -527,9 +527,10 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, Code = bitc::CST_CODE_FLOAT; const Type *Ty = CFP->getType(); if (Ty == Type::FloatTy) { - Record.push_back(FloatToBits((float)CFP->getValue())); + Record.push_back(DoubleToBits((double)CFP->getValueAPF(). + convertToFloat())); } else if (Ty == Type::DoubleTy) { - Record.push_back(DoubleToBits((double)CFP->getValue())); + Record.push_back(DoubleToBits(CFP->getValueAPF().convertToDouble())); // FIXME: make long double constants work. } else if (Ty == Type::X86_FP80Ty || Ty == Type::FP128Ty || Ty == Type::PPC_FP128Ty) { diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index fa6f5691fc3..e80afd40eed 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -829,8 +829,8 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { } else if (const ConstantFP *CFP = dyn_cast(CV)) { // FP Constants are printed as integer constants to avoid losing // precision... - double Val = CFP->getValue(); if (CFP->getType() == Type::DoubleTy) { + double Val = CFP->getValueAPF().convertToDouble(); if (TAI->getData64bitsDirective()) O << TAI->getData64bitsDirective() << DoubleToBits(Val) << "\t" << TAI->getCommentString() << " double value: " << Val << "\n"; @@ -851,6 +851,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { } return; } else { + float Val = CFP->getValueAPF().convertToFloat(); O << TAI->getData32bitsDirective() << FloatToBits(Val) << "\t" << TAI->getCommentString() << " float " << Val << "\n"; return; diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index 36060e150ea..af2555d3eed 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -861,7 +861,8 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, break; } case Type::FloatTyID: { - uint64_t val = FloatToBits(cast(PC)->getValue()); + uint64_t val = FloatToBits(cast(PC)-> + getValueAPF().convertToFloat()); if (TD->isBigEndian()) val = ByteSwap_32(val); ptr[0] = val; @@ -871,7 +872,8 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, break; } case Type::DoubleTyID: { - uint64_t val = DoubleToBits(cast(PC)->getValue()); + uint64_t val = DoubleToBits(cast(PC)-> + getValueAPF().convertToDouble()); if (TD->isBigEndian()) val = ByteSwap_64(val); ptr[0] = val; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index a695048a5ad..d1e9365274a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -840,7 +840,7 @@ SDOperand SelectionDAGLowering::getValue(const Value *V) { return N = DAG.getNode(ISD::BUILD_VECTOR, VT, &Ops[0], Ops.size()); } else if (ConstantFP *CFP = dyn_cast(C)) { - return N = DAG.getConstantFP(CFP->getValue(), VT); + return N = DAG.getConstantFP(CFP->getValueAPF(), VT); } else if (const VectorType *PTy = dyn_cast(VTy)) { unsigned NumElements = PTy->getNumElements(); MVT::ValueType PVT = TLI.getValueType(PTy->getElementType()); @@ -2003,7 +2003,8 @@ void SelectionDAGLowering::visitSub(User &I) { const Type *ElTy = DestTy->getElementType(); if (ElTy->isFloatingPoint()) { unsigned VL = DestTy->getNumElements(); - std::vector NZ(VL, ConstantFP::get(ElTy, -0.0)); + std::vector NZ(VL, ConstantFP::get(ElTy, + ElTy==Type::FloatTy ? APFloat(-0.0f) : APFloat(-0.0))); Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size()); if (CV == CNZ) { SDOperand Op2 = getValue(I.getOperand(1)); diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 325ab8af527..fb9ff371d50 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -525,10 +525,10 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { GenericValue Result; switch (C->getType()->getTypeID()) { case Type::FloatTyID: - Result.FloatVal = (float)cast(C)->getValue(); + Result.FloatVal = cast(C)->getValueAPF().convertToFloat(); break; case Type::DoubleTyID: - Result.DoubleVal = (double)cast(C)->getValue(); + Result.DoubleVal = cast(C)->getValueAPF().convertToDouble(); break; case Type::IntegerTyID: Result.IntVal = cast(C)->getValue(); diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 766d62ce194..848786f3148 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -206,8 +206,10 @@ GenericValue JIT::runFunction(Function *F, switch (ArgTy->getTypeID()) { default: assert(0 && "Unknown argument type for function call!"); case Type::IntegerTyID: C = ConstantInt::get(AV.IntVal); break; - case Type::FloatTyID: C = ConstantFP ::get(ArgTy, AV.FloatVal); break; - case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, AV.DoubleVal); break; + case Type::FloatTyID: C = ConstantFP ::get(ArgTy, APFloat(AV.FloatVal)); + break; + case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, APFloat(AV.DoubleVal)); + break; case Type::PointerTyID: void *ArgPtr = GVTOP(AV); if (sizeof(void*) == 4) { diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index b0c76c8e8e7..ff95e90dc72 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -604,17 +604,19 @@ void CWriter::printConstantVector(ConstantVector *CP) { // only deal in IEEE FP). // static bool isFPCSafeToPrint(const ConstantFP *CFP) { + APFloat APF = APFloat(CFP->getValueAPF()); // copy + if (CFP->getType()==Type::FloatTy) + APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven); #if HAVE_PRINTF_A && ENABLE_CBE_PRINTF_A char Buffer[100]; - sprintf(Buffer, "%a", CFP->getValue()); - + sprintf(Buffer, "%a", APF.convertToDouble()); if (!strncmp(Buffer, "0x", 2) || !strncmp(Buffer, "-0x", 3) || !strncmp(Buffer, "+0x", 3)) - return atof(Buffer) == CFP->getValue(); + return APF.bitwiseIsEqual(APFloat(atof(Buffer))); return false; #else - std::string StrVal = ftostr(CFP->getValue()); + std::string StrVal = ftostr(APF); while (StrVal[0] == ' ') StrVal.erase(StrVal.begin()); @@ -625,7 +627,7 @@ static bool isFPCSafeToPrint(const ConstantFP *CFP) { ((StrVal[0] == '-' || StrVal[0] == '+') && (StrVal[1] >= '0' && StrVal[1] <= '9'))) // Reparse stringized version! - return atof(StrVal.c_str()) == CFP->getValue(); + return APF.bitwiseIsEqual(APFloat(atof(StrVal.c_str()))); return false; #endif } @@ -882,9 +884,13 @@ void CWriter::printConstant(Constant *CPV) { Out << "(*(" << (FPC->getType() == Type::FloatTy ? "float" : "double") << "*)&FPConstant" << I->second << ')'; } else { - if (IsNAN(FPC->getValue())) { + double V = FPC->getType() == Type::FloatTy ? + FPC->getValueAPF().convertToFloat() : + FPC->getValueAPF().convertToDouble(); + if (IsNAN(V)) { // The value is NaN + // FIXME the actual NaN bits should be emitted. // The prefix for a quiet NaN is 0x7FF8. For a signalling NaN, // it's 0x7ff4. const unsigned long QuietNaN = 0x7ff8UL; @@ -893,7 +899,7 @@ void CWriter::printConstant(Constant *CPV) { // We need to grab the first part of the FP # char Buffer[100]; - uint64_t ll = DoubleToBits(FPC->getValue()); + uint64_t ll = DoubleToBits(V); sprintf(Buffer, "0x%llx", static_cast(ll)); std::string Num(&Buffer[0], &Buffer[6]); @@ -905,9 +911,9 @@ void CWriter::printConstant(Constant *CPV) { else Out << "LLVM_NAN" << (Val == QuietNaN ? "" : "S") << "(\"" << Buffer << "\") /*nan*/ "; - } else if (IsInf(FPC->getValue())) { + } else if (IsInf(V)) { // The value is Inf - if (FPC->getValue() < 0) Out << '-'; + if (V < 0) Out << '-'; Out << "LLVM_INF" << (FPC->getType() == Type::FloatTy ? "F" : "") << " /*inf*/ "; } else { @@ -915,12 +921,12 @@ void CWriter::printConstant(Constant *CPV) { #if HAVE_PRINTF_A && ENABLE_CBE_PRINTF_A // Print out the constant as a floating point number. char Buffer[100]; - sprintf(Buffer, "%a", FPC->getValue()); + sprintf(Buffer, "%a", V); Num = Buffer; #else - Num = ftostr(FPC->getValue()); + Num = ftostr(FPC->getValueAPF()); #endif - Out << Num; + Out << Num; } } break; @@ -1715,15 +1721,15 @@ void CWriter::printFloatingPointConstants(Function &F) { if (const ConstantFP *FPC = dyn_cast(*I)) if (!isFPCSafeToPrint(FPC) && // Do not put in FPConstantMap if safe. !FPConstantMap.count(FPC)) { - double Val = FPC->getValue(); - FPConstantMap[FPC] = FPCounter; // Number the FP constants if (FPC->getType() == Type::DoubleTy) { + double Val = FPC->getValueAPF().convertToDouble(); Out << "static const ConstantDoubleTy FPConstant" << FPCounter++ << " = 0x" << std::hex << DoubleToBits(Val) << std::dec << "ULL; /* " << Val << " */\n"; } else if (FPC->getType() == Type::FloatTy) { + float Val = FPC->getValueAPF().convertToFloat(); Out << "static const ConstantFloatTy FPConstant" << FPCounter++ << " = 0x" << std::hex << FloatToBits(Val) << std::dec << "U; /* " << Val << " */\n"; diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp index 5859adf87af..71789703ff3 100644 --- a/lib/Target/MSIL/MSILWriter.cpp +++ b/lib/Target/MSIL/MSILWriter.cpp @@ -428,10 +428,10 @@ void MSILWriter::printConstLoad(const Constant* C) { uint64_t X; unsigned Size; if (FP->getType()->getTypeID()==Type::FloatTyID) { - X = FloatToBits(FP->getValue()); + X = FloatToBits(FP->getValueAPF().convertToFloat()); Size = 4; } else { - X = DoubleToBits(FP->getValue()); + X = DoubleToBits(FP->getValueAPF().convertToDouble()); Size = 8; } Out << "\tldc.r" << Size << "\t( " << utohexstr(X) << ')'; @@ -1472,9 +1472,11 @@ void MSILWriter::printStaticConstant(const Constant* C, uint64_t& Offset) { TySize = TD->getTypeSize(Ty); const ConstantFP* FP = cast(C); if (Ty->getTypeID() == Type::FloatTyID) - Out << "int32 (" << FloatToBits(FP->getValue()) << ')'; + Out << "int32 (" << + FloatToBits(FP->getValueAPF().convertToFloat()) << ')'; else - Out << "int64 (" << DoubleToBits(FP->getValue()) << ')'; + Out << "int64 (" << + DoubleToBits(FP->getValueAPF().convertToDouble()) << ')'; break; } case Type::ArrayTyID: diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 8cfd5f9a3c4..22b282bd5f7 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -3412,11 +3412,11 @@ SDOperand X86TargetLowering::LowerFABS(SDOperand Op, SelectionDAG &DAG) { const Type *OpNTy = MVT::getTypeForValueType(EltVT); std::vector CV; if (EltVT == MVT::f64) { - Constant *C = ConstantFP::get(OpNTy, BitsToDouble(~(1ULL << 63))); + Constant *C = ConstantFP::get(OpNTy, APFloat(BitsToDouble(~(1ULL << 63)))); CV.push_back(C); CV.push_back(C); } else { - Constant *C = ConstantFP::get(OpNTy, BitsToFloat(~(1U << 31))); + Constant *C = ConstantFP::get(OpNTy, APFloat(BitsToFloat(~(1U << 31)))); CV.push_back(C); CV.push_back(C); CV.push_back(C); @@ -3440,11 +3440,11 @@ SDOperand X86TargetLowering::LowerFNEG(SDOperand Op, SelectionDAG &DAG) { const Type *OpNTy = MVT::getTypeForValueType(EltVT); std::vector CV; if (EltVT == MVT::f64) { - Constant *C = ConstantFP::get(OpNTy, BitsToDouble(1ULL << 63)); + Constant *C = ConstantFP::get(OpNTy, APFloat(BitsToDouble(1ULL << 63))); CV.push_back(C); CV.push_back(C); } else { - Constant *C = ConstantFP::get(OpNTy, BitsToFloat(1U << 31)); + Constant *C = ConstantFP::get(OpNTy, APFloat(BitsToFloat(1U << 31))); CV.push_back(C); CV.push_back(C); CV.push_back(C); @@ -3475,18 +3475,19 @@ SDOperand X86TargetLowering::LowerFCOPYSIGN(SDOperand Op, SelectionDAG &DAG) { if (MVT::getSizeInBits(SrcVT) < MVT::getSizeInBits(VT)) { Op1 = DAG.getNode(ISD::FP_EXTEND, VT, Op1); SrcVT = VT; + SrcTy = MVT::getTypeForValueType(SrcVT); } // First get the sign bit of second operand. std::vector CV; if (SrcVT == MVT::f64) { - CV.push_back(ConstantFP::get(SrcTy, BitsToDouble(1ULL << 63))); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); + CV.push_back(ConstantFP::get(SrcTy, APFloat(BitsToDouble(1ULL << 63)))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0))); } else { - CV.push_back(ConstantFP::get(SrcTy, BitsToFloat(1U << 31))); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); + CV.push_back(ConstantFP::get(SrcTy, APFloat(BitsToFloat(1U << 31)))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0f))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0f))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0f))); } Constant *C = ConstantVector::get(CV); SDOperand CPIdx = DAG.getConstantPool(C, getPointerTy(), 4); @@ -3508,13 +3509,13 @@ SDOperand X86TargetLowering::LowerFCOPYSIGN(SDOperand Op, SelectionDAG &DAG) { // Clear first operand sign bit. CV.clear(); if (VT == MVT::f64) { - CV.push_back(ConstantFP::get(SrcTy, BitsToDouble(~(1ULL << 63)))); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); + CV.push_back(ConstantFP::get(SrcTy, APFloat(BitsToDouble(~(1ULL << 63))))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0))); } else { - CV.push_back(ConstantFP::get(SrcTy, BitsToFloat(~(1U << 31)))); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); - CV.push_back(ConstantFP::get(SrcTy, 0.0)); + CV.push_back(ConstantFP::get(SrcTy, APFloat(BitsToFloat(~(1U << 31))))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0f))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0f))); + CV.push_back(ConstantFP::get(SrcTy, APFloat(0.0f))); } C = ConstantVector::get(CV); CPIdx = DAG.getConstantPool(C, getPointerTy(), 4); diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp index 5925f582ad4..01d3c9ff2ec 100644 --- a/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -1118,27 +1118,32 @@ public: Value* base = ci->getOperand(1); Value* expn = ci->getOperand(2); if (ConstantFP *Op1 = dyn_cast(base)) { - double Op1V = Op1->getValue(); - if (Op1V == 1.0) // pow(1.0,x) -> 1.0 - return ReplaceCallWith(ci, ConstantFP::get(Ty, 1.0)); + if (Ty!=Type::FloatTy && Ty!=Type::DoubleTy) + return false; // FIXME long double not yet supported + if (Op1->isExactlyValue(1.0)) // pow(1.0,x) -> 1.0 + return ReplaceCallWith(ci, ConstantFP::get(Ty, + Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0))); } else if (ConstantFP* Op2 = dyn_cast(expn)) { - double Op2V = Op2->getValue(); - if (Op2V == 0.0) { + if (Ty!=Type::FloatTy && Ty!=Type::DoubleTy) + return false; // FIXME long double not yet supported + if (Op2->getValueAPF().isZero()) { // pow(x,0.0) -> 1.0 - return ReplaceCallWith(ci, ConstantFP::get(Ty,1.0)); - } else if (Op2V == 0.5) { + return ReplaceCallWith(ci, ConstantFP::get(Ty, + Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0))); + } else if (Op2->isExactlyValue(0.5)) { // pow(x,0.5) -> sqrt(x) CallInst* sqrt_inst = new CallInst(SLC.get_sqrt(), base, ci->getName()+".pow",ci); return ReplaceCallWith(ci, sqrt_inst); - } else if (Op2V == 1.0) { + } else if (Op2->isExactlyValue(1.0)) { // pow(x,1.0) -> x return ReplaceCallWith(ci, base); - } else if (Op2V == -1.0) { + } else if (Op2->isExactlyValue(-1.0)) { // pow(x,-1.0) -> 1.0/x Value *div_inst = - BinaryOperator::createFDiv(ConstantFP::get(Ty, 1.0), base, - ci->getName()+".pow", ci); + BinaryOperator::createFDiv(ConstantFP::get(Ty, + Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0)), + base, ci->getName()+".pow", ci); return ReplaceCallWith(ci, div_inst); } } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 4902fb710ad..26df55531a8 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2348,7 +2348,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { // "In IEEE floating point, x*1 is not equivalent to x for nans. However, // ANSI says we can drop signals, so we can do this anyway." (from GCC) - if (Op1F->getValue() == 1.0) + if (Op1F->isExactlyValue(1.0)) return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0' } diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 9286e15d6cd..a7b1239bcf8 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -486,7 +486,10 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, // make sure that we only output it in exponential format if we can parse // the value back and get the same value. // - std::string StrVal = ftostr(CFP->getValue()); + bool isDouble = &CFP->getValueAPF().getSemantics() == &APFloat::IEEEdouble; + double Val = (isDouble) ? CFP->getValueAPF().convertToDouble() : + CFP->getValueAPF().convertToFloat(); + std::string StrVal = ftostr(CFP->getValueAPF()); // Check to make sure that the stringized number is not some string like // "Inf" or NaN, that atof will accept, but the lexer will not. Check that @@ -496,7 +499,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, ((StrVal[0] == '-' || StrVal[0] == '+') && (StrVal[1] >= '0' && StrVal[1] <= '9'))) // Reparse stringized version! - if (atof(StrVal.c_str()) == CFP->getValue()) { + if (atof(StrVal.c_str()) == Val) { Out << StrVal; return; } @@ -505,7 +508,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, // output the string in hexadecimal format! assert(sizeof(double) == sizeof(uint64_t) && "assuming that double is 64 bits!"); - Out << "0x" << utohexstr(DoubleToBits(CFP->getValue())); + Out << "0x" << utohexstr(DoubleToBits(Val)); } else if (isa(CV)) { Out << "zeroinitializer"; diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index fb2e65f6ba6..5686a0e35fa 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -68,7 +68,7 @@ static Constant *CastConstantVector(ConstantVector *CV, for (unsigned i = 0; i != SrcNumElts; ++i) { ConstantInt *CI = cast(CV->getOperand(i)); double V = CI->getValue().bitsToDouble(); - Result.push_back(ConstantFP::get(Type::DoubleTy, V)); + Result.push_back(ConstantFP::get(Type::DoubleTy, APFloat(V))); } return ConstantVector::get(Result); } @@ -76,7 +76,7 @@ static Constant *CastConstantVector(ConstantVector *CV, for (unsigned i = 0; i != SrcNumElts; ++i) { ConstantInt *CI = cast(CV->getOperand(i)); float V = CI->getValue().bitsToFloat(); - Result.push_back(ConstantFP::get(Type::FloatTy, V)); + Result.push_back(ConstantFP::get(Type::FloatTy, APFloat(V))); } return ConstantVector::get(Result); } @@ -87,7 +87,8 @@ static Constant *CastConstantVector(ConstantVector *CV, if (SrcEltTy->getTypeID() == Type::DoubleTyID) { for (unsigned i = 0; i != SrcNumElts; ++i) { uint64_t V = - DoubleToBits(cast(CV->getOperand(i))->getValue()); + DoubleToBits(cast(CV->getOperand(i))-> + getValueAPF().convertToDouble()); Constant *C = ConstantInt::get(Type::Int64Ty, V); Result.push_back(ConstantExpr::getBitCast(C, DstEltTy )); } @@ -96,7 +97,8 @@ static Constant *CastConstantVector(ConstantVector *CV, assert(SrcEltTy->getTypeID() == Type::FloatTyID); for (unsigned i = 0; i != SrcNumElts; ++i) { - uint32_t V = FloatToBits(cast(CV->getOperand(i))->getValue()); + uint32_t V = FloatToBits(cast(CV->getOperand(i))-> + getValueAPF().convertToFloat()); Constant *C = ConstantInt::get(Type::Int32Ty, V); Result.push_back(ConstantExpr::getBitCast(C, DstEltTy)); } @@ -175,20 +177,31 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, switch (opc) { case Instruction::FPTrunc: case Instruction::FPExt: - if (const ConstantFP *FPC = dyn_cast(V)) - return ConstantFP::get(DestTy, FPC->getValue()); + if (const ConstantFP *FPC = dyn_cast(V)) { + APFloat Val = FPC->getValueAPF(); + Val.convert(DestTy==Type::FloatTy ? APFloat::IEEEsingle : + APFloat::IEEEdouble, + APFloat::rmNearestTiesToEven); + return ConstantFP::get(DestTy, Val); + } return 0; // Can't fold. case Instruction::FPToUI: if (const ConstantFP *FPC = dyn_cast(V)) { + APFloat V = FPC->getValueAPF(); + bool isDouble = &V.getSemantics()==&APFloat::IEEEdouble; uint32_t DestBitWidth = cast(DestTy)->getBitWidth(); - APInt Val(APIntOps::RoundDoubleToAPInt(FPC->getValue(), DestBitWidth)); + APInt Val(APIntOps::RoundDoubleToAPInt(isDouble ? V.convertToDouble() : + (double)V.convertToFloat(), DestBitWidth)); return ConstantInt::get(Val); } return 0; // Can't fold. case Instruction::FPToSI: if (const ConstantFP *FPC = dyn_cast(V)) { + APFloat V = FPC->getValueAPF(); + bool isDouble = &V.getSemantics()==&APFloat::IEEEdouble; uint32_t DestBitWidth = cast(DestTy)->getBitWidth(); - APInt Val(APIntOps::RoundDoubleToAPInt(FPC->getValue(), DestBitWidth)); + APInt Val(APIntOps::RoundDoubleToAPInt(isDouble ? V.convertToDouble() : + (double)V.convertToFloat(), DestBitWidth)); return ConstantInt::get(Val); } return 0; // Can't fold. @@ -201,12 +214,22 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, return ConstantInt::get(DestTy, 0); return 0; // Other pointer types cannot be casted case Instruction::UIToFP: - if (const ConstantInt *CI = dyn_cast(V)) - return ConstantFP::get(DestTy, CI->getValue().roundToDouble()); + if (const ConstantInt *CI = dyn_cast(V)) { + if (DestTy==Type::FloatTy) + return ConstantFP::get(DestTy, + APFloat((float)CI->getValue().roundToDouble())); + else + return ConstantFP::get(DestTy, APFloat(CI->getValue().roundToDouble())); + } return 0; case Instruction::SIToFP: - if (const ConstantInt *CI = dyn_cast(V)) - return ConstantFP::get(DestTy, CI->getValue().signedRoundToDouble()); + if (const ConstantInt *CI = dyn_cast(V)) { + double d = CI->getValue().signedRoundToDouble(); + if (DestTy==Type::FloatTy) + return ConstantFP::get(DestTy, APFloat((float)d)); + else + return ConstantFP::get(DestTy, APFloat(d)); + } return 0; case Instruction::ZExt: if (const ConstantInt *CI = dyn_cast(V)) { @@ -309,9 +332,9 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, if (DestTy->isFloatingPoint()) { if (DestTy == Type::FloatTy) - return ConstantFP::get(DestTy, CI->getValue().bitsToFloat()); + return ConstantFP::get(DestTy, APFloat(CI->getValue().bitsToFloat())); assert(DestTy == Type::DoubleTy && "Unknown FP type!"); - return ConstantFP::get(DestTy, CI->getValue().bitsToDouble()); + return ConstantFP::get(DestTy, APFloat(CI->getValue().bitsToDouble())); } // Otherwise, can't fold this (vector?) return 0; @@ -322,11 +345,13 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, // FP -> Integral. if (DestTy == Type::Int32Ty) { APInt Val(32, 0); - return ConstantInt::get(Val.floatToBits(FP->getValue())); + return ConstantInt::get(Val.floatToBits(FP-> + getValueAPF().convertToFloat())); } else { assert(DestTy == Type::Int64Ty && "only support f32/f64 for now!"); APInt Val(64, 0); - return ConstantInt::get(Val.doubleToBits(FP->getValue())); + return ConstantInt::get(Val.doubleToBits(FP-> + getValueAPF().convertToDouble())); } } return 0; @@ -660,39 +685,50 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, } } else if (const ConstantFP *CFP1 = dyn_cast(C1)) { if (const ConstantFP *CFP2 = dyn_cast(C2)) { - double C1Val = CFP1->getValue(); - double C2Val = CFP2->getValue(); + APFloat C1V = CFP1->getValueAPF(); + APFloat C2V = CFP2->getValueAPF(); + APFloat C3V = C1V; // copy for modification + bool isDouble = CFP1->getType()==Type::DoubleTy; switch (Opcode) { default: break; - case Instruction::Add: - return ConstantFP::get(CFP1->getType(), C1Val + C2Val); + case Instruction::Add: + (void)C3V.add(C2V, APFloat::rmNearestTiesToEven); + return ConstantFP::get(CFP1->getType(), C3V); case Instruction::Sub: - return ConstantFP::get(CFP1->getType(), C1Val - C2Val); - case Instruction::Mul: - return ConstantFP::get(CFP1->getType(), C1Val * C2Val); + (void)C3V.subtract(C2V, APFloat::rmNearestTiesToEven); + return ConstantFP::get(CFP1->getType(), C3V); + case Instruction::Mul: + (void)C3V.multiply(C2V, APFloat::rmNearestTiesToEven); + return ConstantFP::get(CFP1->getType(), C3V); case Instruction::FDiv: - if (CFP2->isExactlyValue(0.0) || CFP2->isExactlyValue(-0.0)) - if (CFP1->isExactlyValue(0.0) || CFP1->isExactlyValue(-0.0)) + // FIXME better to look at the return code + if (C2V.isZero()) + if (C1V.isZero()) // IEEE 754, Section 7.1, #4 - return ConstantFP::get(CFP1->getType(), - std::numeric_limits::quiet_NaN()); - else if (CFP2->isExactlyValue(-0.0) || C1Val < 0.0) + return ConstantFP::get(CFP1->getType(), isDouble ? + APFloat(std::numeric_limits::quiet_NaN()) : + APFloat(std::numeric_limits::quiet_NaN())); + else if (C2V.isNegZero() || C1V.isNegative()) // IEEE 754, Section 7.2, negative infinity case - return ConstantFP::get(CFP1->getType(), - -std::numeric_limits::infinity()); + return ConstantFP::get(CFP1->getType(), isDouble ? + APFloat(-std::numeric_limits::infinity()) : + APFloat(-std::numeric_limits::infinity())); else // IEEE 754, Section 7.2, positive infinity case - return ConstantFP::get(CFP1->getType(), - std::numeric_limits::infinity()); - return ConstantFP::get(CFP1->getType(), C1Val / C2Val); + return ConstantFP::get(CFP1->getType(), isDouble ? + APFloat(std::numeric_limits::infinity()) : + APFloat(std::numeric_limits::infinity())); + (void)C3V.divide(C2V, APFloat::rmNearestTiesToEven); + return ConstantFP::get(CFP1->getType(), C3V); case Instruction::FRem: - if (CFP2->isExactlyValue(0.0) || CFP2->isExactlyValue(-0.0)) + if (C2V.isZero()) // IEEE 754, Section 7.1, #5 - return ConstantFP::get(CFP1->getType(), - std::numeric_limits::quiet_NaN()); - return ConstantFP::get(CFP1->getType(), std::fmod(C1Val, C2Val)); - + return ConstantFP::get(CFP1->getType(), isDouble ? + APFloat(std::numeric_limits::quiet_NaN()) : + APFloat(std::numeric_limits::quiet_NaN())); + (void)C3V.mod(C2V, APFloat::rmNearestTiesToEven); + return ConstantFP::get(CFP1->getType(), C3V); } } } else if (const ConstantVector *CP1 = dyn_cast(C1)) { @@ -1123,52 +1159,47 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, case ICmpInst::ICMP_UGE:return ConstantInt::get(Type::Int1Ty, V1.uge(V2)); } } else if (isa(C1) && isa(C2)) { - double C1Val = cast(C1)->getValue(); - double C2Val = cast(C2)->getValue(); + APFloat C1V = cast(C1)->getValueAPF(); + APFloat C2V = cast(C2)->getValueAPF(); + APFloat::cmpResult R = C1V.compare(C2V); switch (pred) { default: assert(0 && "Invalid FCmp Predicate"); return 0; case FCmpInst::FCMP_FALSE: return ConstantInt::getFalse(); case FCmpInst::FCMP_TRUE: return ConstantInt::getTrue(); case FCmpInst::FCMP_UNO: - return ConstantInt::get(Type::Int1Ty, C1Val != C1Val || C2Val != C2Val); + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered); case FCmpInst::FCMP_ORD: - return ConstantInt::get(Type::Int1Ty, C1Val == C1Val && C2Val == C2Val); + return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpUnordered); case FCmpInst::FCMP_UEQ: - if (C1Val != C1Val || C2Val != C2Val) - return ConstantInt::getTrue(); - /* FALL THROUGH */ + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered || + R==APFloat::cmpEqual); case FCmpInst::FCMP_OEQ: - return ConstantInt::get(Type::Int1Ty, C1Val == C2Val); + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpEqual); case FCmpInst::FCMP_UNE: - if (C1Val != C1Val || C2Val != C2Val) - return ConstantInt::getTrue(); - /* FALL THROUGH */ + return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpEqual); case FCmpInst::FCMP_ONE: - return ConstantInt::get(Type::Int1Ty, C1Val != C2Val); + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpLessThan || + R==APFloat::cmpGreaterThan); case FCmpInst::FCMP_ULT: - if (C1Val != C1Val || C2Val != C2Val) - return ConstantInt::getTrue(); - /* FALL THROUGH */ + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered || + R==APFloat::cmpLessThan); case FCmpInst::FCMP_OLT: - return ConstantInt::get(Type::Int1Ty, C1Val < C2Val); + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpLessThan); case FCmpInst::FCMP_UGT: - if (C1Val != C1Val || C2Val != C2Val) - return ConstantInt::getTrue(); - /* FALL THROUGH */ + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered || + R==APFloat::cmpGreaterThan); case FCmpInst::FCMP_OGT: - return ConstantInt::get(Type::Int1Ty, C1Val > C2Val); + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpGreaterThan); case FCmpInst::FCMP_ULE: - if (C1Val != C1Val || C2Val != C2Val) - return ConstantInt::getTrue(); - /* FALL THROUGH */ + return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpGreaterThan); case FCmpInst::FCMP_OLE: - return ConstantInt::get(Type::Int1Ty, C1Val <= C2Val); + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpLessThan || + R==APFloat::cmpEqual); case FCmpInst::FCMP_UGE: - if (C1Val != C1Val || C2Val != C2Val) - return ConstantInt::getTrue(); - /* FALL THROUGH */ + return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpLessThan); case FCmpInst::FCMP_OGE: - return ConstantInt::get(Type::Int1Ty, C1Val >= C2Val); + return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpGreaterThan || + R==APFloat::cmpEqual); } } else if (const ConstantVector *CP1 = dyn_cast(C1)) { if (const ConstantVector *CP2 = dyn_cast(C2)) { diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index f7cbe82e72a..1708e460795 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -107,11 +107,13 @@ Constant *Constant::getNullValue(const Type *Ty) { case Type::IntegerTyID: return ConstantInt::get(Ty, 0); case Type::FloatTyID: + return ConstantFP::get(Ty, APFloat(0.0f)); case Type::DoubleTyID: + return ConstantFP::get(Ty, APFloat(0.0)); case Type::X86_FP80TyID: case Type::PPC_FP128TyID: case Type::FP128TyID: - return ConstantFP::get(Ty, 0.0); + return ConstantFP::get(Ty, APFloat(0.0)); //FIXME case Type::PointerTyID: return ConstantPointerNull::get(cast(Ty)); case Type::StructTyID: @@ -238,11 +240,6 @@ ConstantInt *ConstantInt::get(const APInt& V) { // ConstantFP //===----------------------------------------------------------------------===// - -ConstantFP::ConstantFP(const Type *Ty, double V) - : Constant(Ty, ConstantFPVal, 0, 0), - Val(Ty==Type::FloatTy ? APFloat((float)V) : APFloat(V)) { -} ConstantFP::ConstantFP(const Type *Ty, const APFloat& V) : Constant(Ty, ConstantFPVal, 0, 0), Val(V) { // temporary @@ -293,27 +290,6 @@ typedef DenseMap FPConstants; -ConstantFP *ConstantFP::get(const Type *Ty, double V) { - if (Ty == Type::FloatTy) { - DenseMapAPFloatKeyInfo::KeyTy Key(APFloat((float)V)); - ConstantFP *&Slot = (*FPConstants)[Key]; - if (Slot) return Slot; - return Slot = new ConstantFP(Ty, APFloat((float)V)); - } else if (Ty == Type::DoubleTy) { - // Without the redundant cast, the following is taken to be - // a function declaration. What a language. - DenseMapAPFloatKeyInfo::KeyTy Key(APFloat((double)V)); - ConstantFP *&Slot = (*FPConstants)[Key]; - if (Slot) return Slot; - return Slot = new ConstantFP(Ty, APFloat(V)); - } else if (Ty == Type::X86_FP80Ty || - Ty == Type::PPC_FP128Ty || Ty == Type::FP128Ty) { - assert(0 && "Long double constants not handled yet."); - } else { - assert(0 && "Unknown FP Type!"); - } -} - ConstantFP *ConstantFP::get(const Type *Ty, const APFloat& V) { // temporary if (Ty==Type::FloatTy) @@ -1934,12 +1910,15 @@ Constant *ConstantExpr::getZeroValueForNegationExpr(const Type *Ty) { if (const VectorType *PTy = dyn_cast(Ty)) if (PTy->getElementType()->isFloatingPoint()) { std::vector zeros(PTy->getNumElements(), - ConstantFP::get(PTy->getElementType(),-0.0)); + ConstantFP::get(PTy->getElementType(), + PTy->getElementType()==Type::FloatTy ? + APFloat(-0.0f) : APFloat(0.0))); return ConstantVector::get(PTy, zeros); } if (Ty->isFloatingPoint()) - return ConstantFP::get(Ty, -0.0); + return ConstantFP::get(Ty, Ty==Type::FloatTy ? APFloat(-0.0f) : + APFloat(-0.0)); return Constant::getNullValue(Ty); } diff --git a/tools/llvm-upgrade/UpgradeInternals.h b/tools/llvm-upgrade/UpgradeInternals.h index 0e004007960..756a86a4a92 100644 --- a/tools/llvm-upgrade/UpgradeInternals.h +++ b/tools/llvm-upgrade/UpgradeInternals.h @@ -159,7 +159,7 @@ struct ValID { char *Name; // If it's a named reference. Memory must be free'd. int64_t ConstPool64; // Constant pool reference. This is the value uint64_t UConstPool64;// Unsigned constant pool reference. - double ConstPoolFP; // Floating point constant pool reference + APFloat *ConstPoolFP; // Floating point constant pool reference Constant *ConstantValue; // Fully resolved constant for ConstantVal case. InlineAsmDescriptor *IAD; }; @@ -187,7 +187,7 @@ struct ValID { return D; } - static ValID create(double Val) { + static ValID create(APFloat* Val) { ValID D; D.Type = ConstFPVal; D.ConstPoolFP = Val; D.S.makeSignless(); return D; @@ -245,7 +245,7 @@ struct ValID { switch (Type) { case NumberVal : return std::string("#") + itostr(Num); case NameVal : return Name; - case ConstFPVal : return ftostr(ConstPoolFP); + case ConstFPVal : return ftostr(*ConstPoolFP); case ConstNullVal : return "null"; case ConstUndefVal : return "undef"; case ConstZeroVal : return "zeroinitializer"; @@ -271,7 +271,8 @@ struct ValID { case NameVal: return strcmp(Name, V.Name) < 0; case ConstSIntVal: return ConstPool64 < V.ConstPool64; case ConstUIntVal: return UConstPool64 < V.UConstPool64; - case ConstFPVal: return ConstPoolFP < V.ConstPoolFP; + case ConstFPVal: return ConstPoolFP->compare(*V.ConstPoolFP) == + APFloat::cmpLessThan; case ConstNullVal: return false; case ConstUndefVal: return false; case ConstZeroVal: return false; diff --git a/tools/llvm-upgrade/UpgradeLexer.cpp.cvs b/tools/llvm-upgrade/UpgradeLexer.cpp.cvs index 68ae9a47c5a..7756bbc08e9 100644 --- a/tools/llvm-upgrade/UpgradeLexer.cpp.cvs +++ b/tools/llvm-upgrade/UpgradeLexer.cpp.cvs @@ -17,10 +17,10 @@ #define yylineno Upgradelineno #line 20 "UpgradeLexer.cpp" -/* A lexical scanner generated by flex*/ +/* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header$ + * $Header: /cvs/root/flex/flex/skel.c,v 1.2 2004/05/07 00:28:17 jkh Exp $ */ #define FLEX_SCANNER @@ -28,7 +28,6 @@ #define YY_FLEX_MINOR_VERSION 5 #include -#include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ @@ -42,6 +41,7 @@ #ifdef __cplusplus #include +#include /* Use prototypes in function declarations. */ #define YY_USE_PROTOS @@ -153,15 +153,6 @@ extern FILE *yyin, *yyout; #define unput(c) yyunput( c, yytext_ptr ) -/* Some routines like yy_flex_realloc() are emitted as static but are - not called by all lexers. This generates warnings in some compilers, - notably GCC. Arrange to suppress these. */ -#ifdef __GNUC__ -#define YY_MAY_BE_UNUSED __attribute__((unused)) -#else -#define YY_MAY_BE_UNUSED -#endif - /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). @@ -268,7 +259,7 @@ YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static inline void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )) YY_MAY_BE_UNUSED; +static inline void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer @@ -934,7 +925,7 @@ goto find_rule; \ #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 1 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" #define INITIAL 0 /*===-- UpgradeLexer.l - Scanner for 1.9 assembly files --------*- C++ -*--===// // @@ -949,7 +940,7 @@ char *yytext; // //===----------------------------------------------------------------------===*/ #define YY_NEVER_INTERACTIVE 1 -#line 28 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 28 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" #include "UpgradeInternals.h" #include "llvm/Module.h" #include @@ -1090,7 +1081,7 @@ using namespace llvm; /* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing * it to deal with 64 bit numbers. */ -#line 1094 "UpgradeLexer.cpp" +#line 1085 "UpgradeLexer.cpp" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1238,13 +1229,13 @@ YY_MALLOC_DECL YY_DECL { register yy_state_type yy_current_state; - register char *yy_cp = NULL, *yy_bp = NULL; + register char *yy_cp, *yy_bp; register int yy_act; -#line 194 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 194 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" -#line 1248 "UpgradeLexer.cpp" +#line 1239 "UpgradeLexer.cpp" if ( yy_init ) { @@ -1337,742 +1328,742 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 1: YY_RULE_SETUP -#line 196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 196 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { /* Ignore comments for now */ } YY_BREAK case 2: YY_RULE_SETUP -#line 198 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 198 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return BEGINTOK; } YY_BREAK case 3: YY_RULE_SETUP -#line 199 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 199 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ENDTOK; } YY_BREAK case 4: YY_RULE_SETUP -#line 200 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 200 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return TRUETOK; } YY_BREAK case 5: YY_RULE_SETUP -#line 201 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 201 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return FALSETOK; } YY_BREAK case 6: YY_RULE_SETUP -#line 202 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 202 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return DECLARE; } YY_BREAK case 7: YY_RULE_SETUP -#line 203 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 203 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return GLOBAL; } YY_BREAK case 8: YY_RULE_SETUP -#line 204 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 204 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return CONSTANT; } YY_BREAK case 9: YY_RULE_SETUP -#line 205 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 205 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return INTERNAL; } YY_BREAK case 10: YY_RULE_SETUP -#line 206 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 206 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return LINKONCE; } YY_BREAK case 11: YY_RULE_SETUP -#line 207 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 207 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return WEAK; } YY_BREAK case 12: YY_RULE_SETUP -#line 208 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 208 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return APPENDING; } YY_BREAK case 13: YY_RULE_SETUP -#line 209 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 209 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return DLLIMPORT; } YY_BREAK case 14: YY_RULE_SETUP -#line 210 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 210 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return DLLEXPORT; } YY_BREAK case 15: YY_RULE_SETUP -#line 211 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 211 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return EXTERN_WEAK; } YY_BREAK case 16: YY_RULE_SETUP -#line 212 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 212 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return EXTERNAL; } /* Deprecated, turn into external */ YY_BREAK case 17: YY_RULE_SETUP -#line 213 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 213 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return EXTERNAL; } YY_BREAK case 18: YY_RULE_SETUP -#line 214 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 214 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return IMPLEMENTATION; } YY_BREAK case 19: YY_RULE_SETUP -#line 215 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 215 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ZEROINITIALIZER; } YY_BREAK case 20: YY_RULE_SETUP -#line 216 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 216 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return DOTDOTDOT; } YY_BREAK case 21: YY_RULE_SETUP -#line 217 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 217 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return UNDEF; } YY_BREAK case 22: YY_RULE_SETUP -#line 218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 218 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return NULL_TOK; } YY_BREAK case 23: YY_RULE_SETUP -#line 219 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 219 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return TO; } YY_BREAK case 24: YY_RULE_SETUP -#line 220 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 220 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return EXCEPT; } YY_BREAK case 25: YY_RULE_SETUP -#line 221 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 221 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return NOT; } /* Deprecated, turned into XOR */ YY_BREAK case 26: YY_RULE_SETUP -#line 222 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 222 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return TAIL; } YY_BREAK case 27: YY_RULE_SETUP -#line 223 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 223 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return TARGET; } YY_BREAK case 28: YY_RULE_SETUP -#line 224 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 224 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return TRIPLE; } YY_BREAK case 29: YY_RULE_SETUP -#line 225 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 225 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return DEPLIBS; } YY_BREAK case 30: YY_RULE_SETUP -#line 226 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 226 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ENDIAN; } YY_BREAK case 31: YY_RULE_SETUP -#line 227 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 227 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return POINTERSIZE; } YY_BREAK case 32: YY_RULE_SETUP -#line 228 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 228 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return DATALAYOUT; } YY_BREAK case 33: YY_RULE_SETUP -#line 229 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 229 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return LITTLE; } YY_BREAK case 34: YY_RULE_SETUP -#line 230 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 230 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return BIG; } YY_BREAK case 35: YY_RULE_SETUP -#line 231 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 231 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return VOLATILE; } YY_BREAK case 36: YY_RULE_SETUP -#line 232 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 232 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ALIGN; } YY_BREAK case 37: YY_RULE_SETUP -#line 233 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 233 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return SECTION; } YY_BREAK case 38: YY_RULE_SETUP -#line 234 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 234 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return MODULE; } YY_BREAK case 39: YY_RULE_SETUP -#line 235 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 235 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ASM_TOK; } YY_BREAK case 40: YY_RULE_SETUP -#line 236 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 236 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return SIDEEFFECT; } YY_BREAK case 41: YY_RULE_SETUP -#line 238 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 238 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return CC_TOK; } YY_BREAK case 42: YY_RULE_SETUP -#line 239 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 239 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return CCC_TOK; } YY_BREAK case 43: YY_RULE_SETUP -#line 240 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 240 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return CSRETCC_TOK; } YY_BREAK case 44: YY_RULE_SETUP -#line 241 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 241 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return FASTCC_TOK; } YY_BREAK case 45: YY_RULE_SETUP -#line 242 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 242 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return COLDCC_TOK; } YY_BREAK case 46: YY_RULE_SETUP -#line 243 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 243 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return X86_STDCALLCC_TOK; } YY_BREAK case 47: YY_RULE_SETUP -#line 244 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 244 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return X86_FASTCALLCC_TOK; } YY_BREAK case 48: YY_RULE_SETUP -#line 246 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 246 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(SBYTE, Type::Int8Ty, 2); } YY_BREAK case 49: YY_RULE_SETUP -#line 247 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 247 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(UBYTE, Type::Int8Ty, 1); } YY_BREAK case 50: YY_RULE_SETUP -#line 248 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 248 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(UBYTE, Type::Int8Ty, 1); } YY_BREAK case 51: YY_RULE_SETUP -#line 249 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 249 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(SHORT, Type::Int16Ty, 2); } YY_BREAK case 52: YY_RULE_SETUP -#line 250 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 250 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(USHORT, Type::Int16Ty, 1); } YY_BREAK case 53: YY_RULE_SETUP -#line 251 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 251 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(USHORT, Type::Int16Ty, 1); } YY_BREAK case 54: YY_RULE_SETUP -#line 252 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 252 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(INT, Type::Int32Ty, 2); } YY_BREAK case 55: YY_RULE_SETUP -#line 253 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 253 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(UINT, Type::Int32Ty, 1); } YY_BREAK case 56: YY_RULE_SETUP -#line 254 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 254 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(UINT, Type::Int32Ty, 1); } YY_BREAK case 57: YY_RULE_SETUP -#line 255 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 255 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(LONG, Type::Int64Ty, 2); } YY_BREAK case 58: YY_RULE_SETUP -#line 256 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 256 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(ULONG, Type::Int64Ty, 1); } YY_BREAK case 59: YY_RULE_SETUP -#line 257 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 257 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(ULONG, Type::Int64Ty, 1); } YY_BREAK case 60: YY_RULE_SETUP -#line 258 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 258 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(VOID, Type::VoidTy, 0); } YY_BREAK case 61: YY_RULE_SETUP -#line 259 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 259 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(BOOL, Type::Int1Ty, 1); } YY_BREAK case 62: YY_RULE_SETUP -#line 260 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 260 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(BOOL, Type::Int1Ty, 1); } YY_BREAK case 63: YY_RULE_SETUP -#line 261 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 261 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(FLOAT, Type::FloatTy, 0); } YY_BREAK case 64: YY_RULE_SETUP -#line 262 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 262 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(DOUBLE, Type::DoubleTy,0); } YY_BREAK case 65: YY_RULE_SETUP -#line 263 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 263 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TY(LABEL, Type::LabelTy, 0); } YY_BREAK case 66: YY_RULE_SETUP -#line 264 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 264 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return TYPE; } YY_BREAK case 67: YY_RULE_SETUP -#line 265 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 265 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return OPAQUE; } YY_BREAK case 68: YY_RULE_SETUP -#line 267 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 267 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, AddOp, ADD); } YY_BREAK case 69: YY_RULE_SETUP -#line 268 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 268 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SubOp, SUB); } YY_BREAK case 70: YY_RULE_SETUP -#line 269 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 269 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, MulOp, MUL); } YY_BREAK case 71: YY_RULE_SETUP -#line 270 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 270 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, DivOp, DIV); } YY_BREAK case 72: YY_RULE_SETUP -#line 271 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 271 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, UDivOp, UDIV); } YY_BREAK case 73: YY_RULE_SETUP -#line 272 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 272 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SDivOp, SDIV); } YY_BREAK case 74: YY_RULE_SETUP -#line 273 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 273 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, FDivOp, FDIV); } YY_BREAK case 75: YY_RULE_SETUP -#line 274 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 274 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, RemOp, REM); } YY_BREAK case 76: YY_RULE_SETUP -#line 275 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 275 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, URemOp, UREM); } YY_BREAK case 77: YY_RULE_SETUP -#line 276 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 276 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SRemOp, SREM); } YY_BREAK case 78: YY_RULE_SETUP -#line 277 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 277 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, FRemOp, FREM); } YY_BREAK case 79: YY_RULE_SETUP -#line 278 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 278 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, AndOp, AND); } YY_BREAK case 80: YY_RULE_SETUP -#line 279 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 279 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, OrOp , OR ); } YY_BREAK case 81: YY_RULE_SETUP -#line 280 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 280 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, XorOp, XOR); } YY_BREAK case 82: YY_RULE_SETUP -#line 281 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 281 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SetNE, SETNE); } YY_BREAK case 83: YY_RULE_SETUP -#line 282 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 282 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SetEQ, SETEQ); } YY_BREAK case 84: YY_RULE_SETUP -#line 283 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 283 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SetLT, SETLT); } YY_BREAK case 85: YY_RULE_SETUP -#line 284 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 284 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SetGT, SETGT); } YY_BREAK case 86: YY_RULE_SETUP -#line 285 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 285 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SetLE, SETLE); } YY_BREAK case 87: YY_RULE_SETUP -#line 286 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 286 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, SetGE, SETGE); } YY_BREAK case 88: YY_RULE_SETUP -#line 287 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 287 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, ShlOp, SHL); } YY_BREAK case 89: YY_RULE_SETUP -#line 288 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 288 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, ShrOp, SHR); } YY_BREAK case 90: YY_RULE_SETUP -#line 289 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 289 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, LShrOp, LSHR); } YY_BREAK case 91: YY_RULE_SETUP -#line 290 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 290 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(BinaryOpVal, AShrOp, ASHR); } YY_BREAK case 92: YY_RULE_SETUP -#line 292 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 292 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, ICmpOp, ICMP); } YY_BREAK case 93: YY_RULE_SETUP -#line 293 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 293 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, FCmpOp, FCMP); } YY_BREAK case 94: YY_RULE_SETUP -#line 295 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 295 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return EQ; } YY_BREAK case 95: YY_RULE_SETUP -#line 296 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 296 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return NE; } YY_BREAK case 96: YY_RULE_SETUP -#line 297 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 297 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return SLT; } YY_BREAK case 97: YY_RULE_SETUP -#line 298 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 298 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return SGT; } YY_BREAK case 98: YY_RULE_SETUP -#line 299 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 299 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return SLE; } YY_BREAK case 99: YY_RULE_SETUP -#line 300 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 300 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return SGE; } YY_BREAK case 100: YY_RULE_SETUP -#line 301 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 301 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ULT; } YY_BREAK case 101: YY_RULE_SETUP -#line 302 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 302 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return UGT; } YY_BREAK case 102: YY_RULE_SETUP -#line 303 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 303 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ULE; } YY_BREAK case 103: YY_RULE_SETUP -#line 304 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 304 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return UGE; } YY_BREAK case 104: YY_RULE_SETUP -#line 305 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 305 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return OEQ; } YY_BREAK case 105: YY_RULE_SETUP -#line 306 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 306 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ONE; } YY_BREAK case 106: YY_RULE_SETUP -#line 307 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 307 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return OLT; } YY_BREAK case 107: YY_RULE_SETUP -#line 308 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 308 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return OGT; } YY_BREAK case 108: YY_RULE_SETUP -#line 309 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 309 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return OLE; } YY_BREAK case 109: YY_RULE_SETUP -#line 310 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 310 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return OGE; } YY_BREAK case 110: YY_RULE_SETUP -#line 311 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 311 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return ORD; } YY_BREAK case 111: YY_RULE_SETUP -#line 312 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 312 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return UNO; } YY_BREAK case 112: YY_RULE_SETUP -#line 313 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 313 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return UEQ; } YY_BREAK case 113: YY_RULE_SETUP -#line 314 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 314 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return UNE; } YY_BREAK case 114: YY_RULE_SETUP -#line 316 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 316 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, PHIOp, PHI_TOK); } YY_BREAK case 115: YY_RULE_SETUP -#line 317 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 317 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, CallOp, CALL); } YY_BREAK case 116: YY_RULE_SETUP -#line 318 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 318 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, CastOp, CAST); } YY_BREAK case 117: YY_RULE_SETUP -#line 319 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 319 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, TruncOp, TRUNC); } YY_BREAK case 118: YY_RULE_SETUP -#line 320 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 320 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, ZExtOp , ZEXT); } YY_BREAK case 119: YY_RULE_SETUP -#line 321 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 321 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, SExtOp, SEXT); } YY_BREAK case 120: YY_RULE_SETUP -#line 322 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 322 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, FPTruncOp, FPTRUNC); } YY_BREAK case 121: YY_RULE_SETUP -#line 323 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 323 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, FPExtOp, FPEXT); } YY_BREAK case 122: YY_RULE_SETUP -#line 324 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 324 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, FPToUIOp, FPTOUI); } YY_BREAK case 123: YY_RULE_SETUP -#line 325 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 325 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, FPToSIOp, FPTOSI); } YY_BREAK case 124: YY_RULE_SETUP -#line 326 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 326 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, UIToFPOp, UITOFP); } YY_BREAK case 125: YY_RULE_SETUP -#line 327 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 327 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, SIToFPOp, SITOFP); } YY_BREAK case 126: YY_RULE_SETUP -#line 328 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 328 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, PtrToIntOp, PTRTOINT); } YY_BREAK case 127: YY_RULE_SETUP -#line 329 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 329 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, IntToPtrOp, INTTOPTR); } YY_BREAK case 128: YY_RULE_SETUP -#line 330 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 330 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(CastOpVal, BitCastOp, BITCAST); } YY_BREAK case 129: YY_RULE_SETUP -#line 331 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 331 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, SelectOp, SELECT); } YY_BREAK case 130: YY_RULE_SETUP -#line 332 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 332 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return VANEXT_old; } YY_BREAK case 131: YY_RULE_SETUP -#line 333 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 333 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return VAARG_old; } YY_BREAK case 132: YY_RULE_SETUP -#line 334 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 334 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, VAArg , VAARG); } YY_BREAK case 133: YY_RULE_SETUP -#line 335 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 335 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(TermOpVal, RetOp, RET); } YY_BREAK case 134: YY_RULE_SETUP -#line 336 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 336 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(TermOpVal, BrOp, BR); } YY_BREAK case 135: YY_RULE_SETUP -#line 337 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 337 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(TermOpVal, SwitchOp, SWITCH); } YY_BREAK case 136: YY_RULE_SETUP -#line 338 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 338 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(TermOpVal, InvokeOp, INVOKE); } YY_BREAK case 137: YY_RULE_SETUP -#line 339 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 339 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return UNWIND; } YY_BREAK case 138: YY_RULE_SETUP -#line 340 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 340 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(TermOpVal, UnreachableOp, UNREACHABLE); } YY_BREAK case 139: YY_RULE_SETUP -#line 342 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 342 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(MemOpVal, MallocOp, MALLOC); } YY_BREAK case 140: YY_RULE_SETUP -#line 343 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 343 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(MemOpVal, AllocaOp, ALLOCA); } YY_BREAK case 141: YY_RULE_SETUP -#line 344 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 344 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(MemOpVal, FreeOp, FREE); } YY_BREAK case 142: YY_RULE_SETUP -#line 345 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 345 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(MemOpVal, LoadOp, LOAD); } YY_BREAK case 143: YY_RULE_SETUP -#line 346 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 346 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(MemOpVal, StoreOp, STORE); } YY_BREAK case 144: YY_RULE_SETUP -#line 347 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 347 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(MemOpVal, GetElementPtrOp, GETELEMENTPTR); } YY_BREAK case 145: YY_RULE_SETUP -#line 349 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 349 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, ExtractElementOp, EXTRACTELEMENT); } YY_BREAK case 146: YY_RULE_SETUP -#line 350 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 350 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, InsertElementOp, INSERTELEMENT); } YY_BREAK case 147: YY_RULE_SETUP -#line 351 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 351 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { RET_TOK(OtherOpVal, ShuffleVectorOp, SHUFFLEVECTOR); } YY_BREAK case 148: YY_RULE_SETUP -#line 354 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 354 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { UnEscapeLexed(yytext+1); Upgradelval.StrVal = strdup(yytext+1); // Skip % @@ -2081,7 +2072,7 @@ YY_RULE_SETUP YY_BREAK case 149: YY_RULE_SETUP -#line 359 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 359 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { yytext[strlen(yytext)-1] = 0; // nuke colon UnEscapeLexed(yytext); @@ -2091,7 +2082,7 @@ YY_RULE_SETUP YY_BREAK case 150: YY_RULE_SETUP -#line 365 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 365 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { yytext[strlen(yytext)-2] = 0; // nuke colon, end quote UnEscapeLexed(yytext+1); @@ -2101,7 +2092,7 @@ YY_RULE_SETUP YY_BREAK case 151: YY_RULE_SETUP -#line 372 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 372 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { // Note that we cannot unescape a string constant here! The // string constant might contain a \00 which would not be // understood by the string stuff. It is valid to make a @@ -2114,12 +2105,12 @@ YY_RULE_SETUP YY_BREAK case 152: YY_RULE_SETUP -#line 383 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 383 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { Upgradelval.UInt64Val = atoull(yytext); return EUINT64VAL; } YY_BREAK case 153: YY_RULE_SETUP -#line 384 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 384 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { uint64_t Val = atoull(yytext+1); // +1: we have bigger negative range @@ -2131,7 +2122,7 @@ YY_RULE_SETUP YY_BREAK case 154: YY_RULE_SETUP -#line 392 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 392 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { Upgradelval.UInt64Val = HexIntToVal(yytext+3); return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL; @@ -2139,7 +2130,7 @@ YY_RULE_SETUP YY_BREAK case 155: YY_RULE_SETUP -#line 397 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 397 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { uint64_t Val = atoull(yytext+1); if ((unsigned)Val != Val) @@ -2150,7 +2141,7 @@ YY_RULE_SETUP YY_BREAK case 156: YY_RULE_SETUP -#line 404 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 404 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { uint64_t Val = atoull(yytext+2); // +1: we have bigger negative range @@ -2162,16 +2153,18 @@ YY_RULE_SETUP YY_BREAK case 157: YY_RULE_SETUP -#line 413 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" -{ Upgradelval.FPVal = atof(yytext); return FPVAL; } +#line 413 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" +{ Upgradelval.FPVal = new APFloat(atof(yytext)); return FPVAL; } YY_BREAK case 158: YY_RULE_SETUP -#line 414 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" -{ Upgradelval.FPVal = HexToFP(yytext); return FPVAL; } +#line 414 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" +{ Upgradelval.FPVal = new APFloat(HexToFP(yytext)); + return FPVAL; + } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 416 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 418 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { /* Make sure to free the internal buffers for flex when we are * done reading our input! @@ -2182,20 +2175,20 @@ case YY_STATE_EOF(INITIAL): YY_BREAK case 159: YY_RULE_SETUP -#line 424 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 426 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { /* Ignore whitespace */ } YY_BREAK case 160: YY_RULE_SETUP -#line 425 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 427 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" { return yytext[0]; } YY_BREAK case 161: YY_RULE_SETUP -#line 427 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 429 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2199 "UpgradeLexer.cpp" +#line 2192 "UpgradeLexer.cpp" case YY_END_OF_BUFFER: { @@ -2571,7 +2564,6 @@ register char *yy_bp; #endif /* ifndef YY_NO_UNPUT */ -#ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput() #else @@ -2645,7 +2637,7 @@ static int input() return c; } -#endif /* YY_NO_INPUT */ + #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) @@ -2756,6 +2748,11 @@ YY_BUFFER_STATE b; } +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) @@ -3073,5 +3070,5 @@ int main() return 0; } #endif -#line 427 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeLexer.l" +#line 429 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeLexer.l" diff --git a/tools/llvm-upgrade/UpgradeLexer.l b/tools/llvm-upgrade/UpgradeLexer.l index 300cf5cc1aa..5318736bc4f 100644 --- a/tools/llvm-upgrade/UpgradeLexer.l +++ b/tools/llvm-upgrade/UpgradeLexer.l @@ -410,8 +410,10 @@ shufflevector { RET_TOK(OtherOpVal, ShuffleVectorOp, SHUFFLEVECTOR); } return SINTVAL; } -{FPConstant} { Upgradelval.FPVal = atof(yytext); return FPVAL; } -{HexFPConstant} { Upgradelval.FPVal = HexToFP(yytext); return FPVAL; } +{FPConstant} { Upgradelval.FPVal = new APFloat(atof(yytext)); return FPVAL; } +{HexFPConstant} { Upgradelval.FPVal = new APFloat(HexToFP(yytext)); + return FPVAL; + } <> { /* Make sure to free the internal buffers for flex when we are diff --git a/tools/llvm-upgrade/UpgradeLexer.l.cvs b/tools/llvm-upgrade/UpgradeLexer.l.cvs index 300cf5cc1aa..5318736bc4f 100644 --- a/tools/llvm-upgrade/UpgradeLexer.l.cvs +++ b/tools/llvm-upgrade/UpgradeLexer.l.cvs @@ -410,8 +410,10 @@ shufflevector { RET_TOK(OtherOpVal, ShuffleVectorOp, SHUFFLEVECTOR); } return SINTVAL; } -{FPConstant} { Upgradelval.FPVal = atof(yytext); return FPVAL; } -{HexFPConstant} { Upgradelval.FPVal = HexToFP(yytext); return FPVAL; } +{FPConstant} { Upgradelval.FPVal = new APFloat(atof(yytext)); return FPVAL; } +{HexFPConstant} { Upgradelval.FPVal = new APFloat(HexToFP(yytext)); + return FPVAL; + } <> { /* Make sure to free the internal buffers for flex when we are diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y index 9cc1af2ed9f..bc6342c94de 100644 --- a/tools/llvm-upgrade/UpgradeParser.y +++ b/tools/llvm-upgrade/UpgradeParser.y @@ -533,9 +533,13 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) { return ConstantInt::get(Ty, D.UConstPool64); case ValID::ConstFPVal: // Is it a floating point const pool reference? - if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) + if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) error("FP constant invalid for type"); - return ConstantFP::get(Ty, D.ConstPoolFP); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if (Ty==Type::FloatTy) + D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + return ConstantFP::get(Ty, *D.ConstPoolFP); case ValID::ConstNullVal: // Is it a null value? if (!isa(Ty)) @@ -1773,7 +1777,7 @@ using namespace llvm; uint64_t UInt64Val; int SIntVal; unsigned UIntVal; - double FPVal; + llvm::APFloat *FPVal; bool BoolVal; char *StrVal; // This memory is strdup'd! @@ -2514,9 +2518,13 @@ ConstVal $$.S.makeUnsigned(); } | FPType FPVAL { // Float & Double constants - if (!ConstantFP::isValueValidForType($1.T, $2)) + if (!ConstantFP::isValueValidForType($1.T, *$2)) error("Floating point constant invalid for type"); - $$.C = ConstantFP::get($1.T, $2); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if ($1.T==Type::FloatTy) + $2->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + $$.C = ConstantFP::get($1.T, *$2); $$.S.makeSignless(); } ; diff --git a/tools/llvm-upgrade/UpgradeParser.y.cvs b/tools/llvm-upgrade/UpgradeParser.y.cvs index 9cc1af2ed9f..bc6342c94de 100644 --- a/tools/llvm-upgrade/UpgradeParser.y.cvs +++ b/tools/llvm-upgrade/UpgradeParser.y.cvs @@ -533,9 +533,13 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) { return ConstantInt::get(Ty, D.UConstPool64); case ValID::ConstFPVal: // Is it a floating point const pool reference? - if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) + if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) error("FP constant invalid for type"); - return ConstantFP::get(Ty, D.ConstPoolFP); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if (Ty==Type::FloatTy) + D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + return ConstantFP::get(Ty, *D.ConstPoolFP); case ValID::ConstNullVal: // Is it a null value? if (!isa(Ty)) @@ -1773,7 +1777,7 @@ using namespace llvm; uint64_t UInt64Val; int SIntVal; unsigned UIntVal; - double FPVal; + llvm::APFloat *FPVal; bool BoolVal; char *StrVal; // This memory is strdup'd! @@ -2514,9 +2518,13 @@ ConstVal $$.S.makeUnsigned(); } | FPType FPVAL { // Float & Double constants - if (!ConstantFP::isValueValidForType($1.T, $2)) + if (!ConstantFP::isValueValidForType($1.T, *$2)) error("Floating point constant invalid for type"); - $$.C = ConstantFP::get($1.T, $2); + // Lexer has no type info, so builds all FP constants as double. + // Fix this here. + if ($1.T==Type::FloatTy) + $2->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); + $$.C = ConstantFP::get($1.T, *$2); $$.S.makeSignless(); } ; diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp index 0b7b0eea002..1551dc3be78 100644 --- a/tools/llvm2cpp/CppWriter.cpp +++ b/tools/llvm2cpp/CppWriter.cpp @@ -209,25 +209,30 @@ CppWriter::error(const std::string& msg) { // result so that we don't lose precision. void CppWriter::printCFP(const ConstantFP *CFP) { + APFloat APF = APFloat(CFP->getValueAPF()); // copy + if (CFP->getType() == Type::FloatTy) + APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven); Out << "ConstantFP::get("; if (CFP->getType() == Type::DoubleTy) Out << "Type::DoubleTy, "; else Out << "Type::FloatTy, "; + Out << "APFloat("; #if HAVE_PRINTF_A char Buffer[100]; - sprintf(Buffer, "%A", CFP->getValue()); + sprintf(Buffer, "%A", APF.convertToDouble()); if ((!strncmp(Buffer, "0x", 2) || !strncmp(Buffer, "-0x", 3) || !strncmp(Buffer, "+0x", 3)) && - (atof(Buffer) == CFP->getValue())) + APF.bitwiseIsEqual(APFloat(atof(Buffer)))) { if (CFP->getType() == Type::DoubleTy) Out << "BitsToDouble(" << Buffer << ")"; else - Out << "BitsToFloat(" << Buffer << ")"; - else { + Out << "BitsToFloat((float)" << Buffer << ")"; + Out << ")"; + } else { #endif - std::string StrVal = ftostr(CFP->getValue()); + std::string StrVal = ftostr(CFP->getValueAPF()); while (StrVal[0] == ' ') StrVal.erase(StrVal.begin()); @@ -237,17 +242,21 @@ CppWriter::printCFP(const ConstantFP *CFP) { if (((StrVal[0] >= '0' && StrVal[0] <= '9') || ((StrVal[0] == '-' || StrVal[0] == '+') && (StrVal[1] >= '0' && StrVal[1] <= '9'))) && - (atof(StrVal.c_str()) == CFP->getValue())) + (CFP->isExactlyValue(atof(StrVal.c_str())))) { if (CFP->getType() == Type::DoubleTy) Out << StrVal; else - Out << StrVal; + Out << StrVal << "f"; + } else if (CFP->getType() == Type::DoubleTy) - Out << "BitsToDouble(0x" << std::hex << DoubleToBits(CFP->getValue()) + Out << "BitsToDouble(0x" << std::hex + << DoubleToBits(CFP->getValueAPF().convertToDouble()) << std::dec << "ULL) /* " << StrVal << " */"; else - Out << "BitsToFloat(0x" << std::hex << FloatToBits(CFP->getValue()) + Out << "BitsToFloat(0x" << std::hex + << FloatToBits(CFP->getValueAPF().convertToFloat()) << std::dec << "U) /* " << StrVal << " */"; + Out << ")"; #if HAVE_PRINTF_A } #endif