Currently, the NaN values emitted for MIPS architectures, do not cover non-2008 compliant case. This change fixes the issue.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/AST/ExprConstant.cpp | ||
---|---|---|
7599–7603 ↗ | (On Diff #20678) | Could you add a comment explaining the relevant history and why that leads to QNaN and SNaN being reversed here. It won't be obvious to most readers. |
lib/Basic/Targets.cpp | ||
5679 ↗ | (On Diff #20678) | This isn't quite right. It should just be IsNan2008 since IsNan2008 is initialized with the result of isNaN2008Default(). |
test/CodeGen/builtin-nan-legacy.c | ||
2–3 ↗ | (On Diff #20678) | New tests should be using FileCheck rather than grep. |
lib/Basic/Targets.cpp | ||
---|---|---|
5679 ↗ | (On Diff #20678) | When you generating code for mips32r6/mips64r6 with option -mnan=legacy, IsNan2008 will be set to false. else if (*it == "-nan2008") IsNan2008 = false; Because of that, I use the result of isNaN2008Default(). |
lib/Basic/Targets.cpp | ||
---|---|---|
5679 ↗ | (On Diff #20678) | We should not allow that case. Clang should (at least) issue a warning if "-mnan=legacy" is passed for the revisions that do not support the NaN legacy encoding. |
lib/Basic/Targets.cpp | ||
---|---|---|
5679 ↗ | (On Diff #20678) | Agreed. I'd prefer an error* since the user is requesting an impossible combination of options but it should at least warn instead of quietly ignoring the user. *Ideally with a suggestion for fixing it, e.g. "error: IEEE754(2008) compliant NaN's are mandatory on Mips32r6. Did you mean -mnan=2008?" |
lib/Basic/Targets.cpp | ||
---|---|---|
5679 ↗ | (On Diff #20678) | I would also prefer an error, but gcc seems to produce a warning only. |
lib/AST/ExprConstant.cpp | ||
---|---|---|
7599–7603 ↗ | (On Diff #20678) | Done. |
lib/Basic/Targets.cpp | ||
5679 ↗ | (On Diff #20678) | Done. |
5679 ↗ | (On Diff #20678) | Ok. This will be part of the next patch. |
test/CodeGen/builtin-nan-legacy.c | ||
2–3 ↗ | (On Diff #20678) | Done. |
lib/Basic/Targets.cpp | ||
---|---|---|
5679 ↗ | (On Diff #20678) |
Off hand, I'm not sure exactly which ISA introduced the ABS2008 and NAN2008 config bits but at least some of the ISA's prior to 32r6/64r6 supported 2008 in addition to legacy. I don't think it's seen widespread use though. |
LGTM with a couple tiny nits.
include/clang/Basic/TargetInfo.h | ||
---|---|---|
642 ↗ | (On Diff #20765) | Small nit: The grammar is a little odd, possibly a missing word? Maybe use 'Only MIPS allows a different encoding' |
lib/AST/ExprConstant.cpp | ||
7599–7603 ↗ | (On Diff #20765) | Just a couple tiny grammar nits: "...to choose the first bit of their significand set for qNaN and sNaN." -> "...to choose whether the first bit of their significand was set for qNaN or sNaN." "MIPS chose different encoding..." -> "MIPS chose a different encoding...". |
include/clang/Basic/TargetInfo.h | ||
---|---|---|
642 ↗ | (On Diff #20765) | Done. |
lib/AST/ExprConstant.cpp | ||
7599–7603 ↗ | (On Diff #20765) | Done. |