[PATCH] [Mips] Generate warning for invalid combination of '-mnan' and '-march' options.

Simon Atanasyan simon at atanasyan.com
Sun Mar 15 03:02:10 PDT 2015


================
Comment at: lib/Basic/Targets.cpp:5729
@@ +5728,3 @@
+        .Case("mips5", true)
+        .Case("mips32", true)
+        .Case("mips64", true)
----------------
dsanders wrote:
> petarj wrote:
> > According to the documentation, Has2008 field in FIR Register is optional as of R3. So, if I understand this correctly, mips32r2 always uses legacy encoding. Is that correct? If so, should we add mips32r2 case as well?
> That's my understanding. Although it's worth pointing out that we also accept microMIPS in mips32r2 at the moment even though it was added in mips32r3 as far as I know.
> 
> For -mnan, I think we should add mips32r2 to the legacy-only list and explain the reason to anyone who asks about it.
I think it is better to explicitly express 2008/legacy support status for each CPU. Let's consider the following code:

```
enum NanMode { NanLegacy = 1, Nan2008 = 2 };

NanMode getSupportedNanMode() {
    return llvm::StringSwitch<int>(CPU)
        .Case("mips1", NanLegacy)
        ....
        .Case("mips32r2", NanLegacy | Nan2008)
        ...
        .Case("mips32r6", Nan2008)
}

...

IsNan2008 = getSupportedNanMode() == Nan2008;

...

else if (*it == "+nan2008") {
  if (getSupportedNanMode() & Nan2008)
    IsNan2008 = true;
  else
    Diags.Report(diag::warn_target_unsupported_nan2008) << CPU;
}
```

================
Comment at: lib/Basic/Targets.cpp:5964
@@ +5963,3 @@
+        if (hasOnlyNaNLegacyEncoding()) {
+          unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
+                    "the '%0' architecture does not support '-mnan=2008'");
----------------
Why do we write a warning message right here instead to put it to the DiagnosticXXX.td file?

http://reviews.llvm.org/D8170

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list