[llvm-commits] [llvm] r128488 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/floating-literals.s
Kevin Enderby
enderby at apple.com
Tue Mar 29 14:11:52 PDT 2011
Author: enderby
Date: Tue Mar 29 16:11:52 2011
New Revision: 128488
URL: http://llvm.org/viewvc/llvm-project?rev=128488&view=rev
Log:
Added support symbolic floating point constants in the MC assembler for Infinity
and Nans with the same strings as GAS supports. rdar://8673024
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/floating-literals.s
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=128488&r1=128487&r2=128488&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Mar 29 16:11:52 2011
@@ -1552,13 +1552,21 @@
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)
Modified: llvm/trunk/test/MC/AsmParser/floating-literals.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/floating-literals.s?rev=128488&r1=128487&r2=128488&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/floating-literals.s (original)
+++ llvm/trunk/test/MC/AsmParser/floating-literals.s Tue Mar 29 16:11:52 2011
@@ -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
More information about the llvm-commits
mailing list