[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

WÁNG Xuěruì via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 25 08:26:35 PDT 2023


xen0n added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:64
+    // conflicts with the higher-priority settings implied by -m*-float.
+    if (!ImpliedABI.empty()) {
+      if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
----------------
SixWeining wrote:
> Seems that this condition is always `true`.
Yes you're right. I'll simplify it (and add comment detailing why it's safe to assume non-emptiness) shortly.


================
Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:85
   // Select abi based on -mfpu=xx.
-  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ)) {
-    StringRef FPU = A->getValue();
-    if (FPU == "64")
-      return IsLA32 ? "ilp32d" : "lp64d";
-    if (FPU == "32")
-      return IsLA32 ? "ilp32f" : "lp64f";
-    if (FPU == "0" || FPU == "none")
-      return IsLA32 ? "ilp32s" : "lp64s";
-    D.Diag(diag::err_drv_loongarch_invalid_mfpu_EQ) << FPU;
+  switch (FPU) {
+  case 64:
----------------
SixWeining wrote:
> Without `default`, there may be compiling warning?
I didn't remember seeing such warnings; plus the case's body would be empty anyway...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153707/new/

https://reviews.llvm.org/D153707



More information about the cfe-commits mailing list