diff options
author | Kevin Enderby <enderby@apple.com> | 2011-03-29 21:11:52 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2011-03-29 21:11:52 +0000 |
commit | 5bbe957155824106a4f230b202109ea272d03ea0 (patch) | |
tree | 98d15ac4b43281df2d5c41cb33d70a6b3fb415ec | |
parent | dcb29ae8ee4302fb41a2e7a1b4dbde2a0051ac2f (diff) | |
download | bcm5719-llvm-5bbe957155824106a4f230b202109ea272d03ea0.tar.gz bcm5719-llvm-5bbe957155824106a4f230b202109ea272d03ea0.zip |
Added support symbolic floating point constants in the MC assembler for Infinity
and Nans with the same strings as GAS supports. rdar://8673024
llvm-svn: 128488
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 14 | ||||
-rw-r--r-- | llvm/test/MC/AsmParser/floating-literals.s | 6 |
2 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 19f7bd8959a..ff5298fe1be 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -1552,13 +1552,21 @@ bool AsmParser::ParseDirectiveRealValue(const fltSemantics &Semantics) { Lex(); if (getLexer().isNot(AsmToken::Integer) && - getLexer().isNot(AsmToken::Real)) + getLexer().isNot(AsmToken::Real) && + getLexer().isNot(AsmToken::Identifier)) return TokError("unexpected token in directive"); // Convert to an APFloat. APFloat Value(Semantics); - if (Value.convertFromString(getTok().getString(), - APFloat::rmNearestTiesToEven) == + StringRef IDVal = getTok().getString(); + if (getLexer().is(AsmToken::Identifier)) { + if (!IDVal.compare_lower("infinity") || !IDVal.compare_lower("inf")) + Value = APFloat::getInf(Semantics); + else if (!IDVal.compare_lower("nan")) + Value = APFloat::getNaN(Semantics, false, ~0); + else + return TokError("invalid floating point literal"); + } else if (Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven) == APFloat::opInvalidOp) return TokError("invalid floating point literal"); if (IsNeg) diff --git a/llvm/test/MC/AsmParser/floating-literals.s b/llvm/test/MC/AsmParser/floating-literals.s index bd122a8cf0e..0e96571e1ac 100644 --- a/llvm/test/MC/AsmParser/floating-literals.s +++ b/llvm/test/MC/AsmParser/floating-literals.s @@ -6,6 +6,12 @@ # CHECK: .long 1082549862 .single 1.2455, +2.3, 3, + 4.2 +# CHECK: .long 2139095040 +.single InFinIty + +# CHECK: .long 2147483647 +.single nAN + # CHECK: .long 1067928519 .float 1.307 |