[clang] 6890b9b - Add missing changes for "[Clang][LoongArch] Handle -march/-m{single,double,soft}-float/-mfpu options"

Weining Lu via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 10 17:07:48 PST 2022


Author: Weining Lu
Date: 2022-11-11T09:06:53+08:00
New Revision: 6890b9b71e525020ab58d436336664beede71575

URL: https://github.com/llvm/llvm-project/commit/6890b9b71e525020ab58d436336664beede71575
DIFF: https://github.com/llvm/llvm-project/commit/6890b9b71e525020ab58d436336664beede71575.diff

LOG: Add missing changes for "[Clang][LoongArch] Handle -march/-m{single,double,soft}-float/-mfpu options"

Some changes in D136146 were lost by an accidentally sumbit. So recover
them.

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticDriverKinds.td
    clang/test/Driver/loongarch-default-features.c
    clang/test/Driver/loongarch-march-error.c
    clang/test/Driver/loongarch-march.c
    clang/test/Driver/loongarch-mdouble-float.c
    clang/test/Driver/loongarch-mfpu-error.c
    clang/test/Driver/loongarch-mfpu.c
    clang/test/Driver/loongarch-msingle-float.c
    clang/test/Driver/loongarch-msoft-float.c
    llvm/lib/Support/LoongArchTargetParser.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 1b24d9c70a0b6..551ebf1c9bc2e 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -693,5 +693,5 @@ def err_drv_riscv_unsupported_with_linker_relaxation : Error<
   "%0 is unsupported with RISC-V linker relaxation (-mrelax)">;
 
 def err_drv_loongarch_invalid_mfpu_EQ : Error<
-  "invalid argument '%0' to -mfpu=; must be one of: 64, 32, 0, none">;
+  "invalid argument '%0' to -mfpu=; must be one of: 64, 32, none, 0 (alias for none)">;
 }

diff  --git a/clang/test/Driver/loongarch-default-features.c b/clang/test/Driver/loongarch-default-features.c
index 27cca85abb6a4..8abc68b9ee744 100644
--- a/clang/test/Driver/loongarch-default-features.c
+++ b/clang/test/Driver/loongarch-default-features.c
@@ -4,7 +4,6 @@
 // LA32-NOT: "target-features"=
 // LA64: "target-features"="+64bit,+d,+f"
 
-/// Dummy function
 int foo(void) {
-  return  3;
+  return 3;
 }

diff  --git a/clang/test/Driver/loongarch-march-error.c b/clang/test/Driver/loongarch-march-error.c
index ec1e065f1d06c..f447de655bdb8 100644
--- a/clang/test/Driver/loongarch-march-error.c
+++ b/clang/test/Driver/loongarch-march-error.c
@@ -1,7 +1,7 @@
-// RUN: not %clang --target=loongarch64 -march=loongarch -fsyntax-only %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=LOONGARCH %s
+// RUN: not %clang --target=loongarch64 -march=loongarch -fsyntax-only %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=LOONGARCH %s
 // LOONGARCH: error: invalid arch name '-march=loongarch'
 
-// RUN: not %clang --target=loongarch64 -march=LA464 -fsyntax-only %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=LA464-UPPER %s
+// RUN: not %clang --target=loongarch64 -march=LA464 -fsyntax-only %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=LA464-UPPER %s
 // LA464-UPPER: error: invalid arch name '-march=LA464'

diff  --git a/clang/test/Driver/loongarch-march.c b/clang/test/Driver/loongarch-march.c
index 486feb0797ac5..6416f427421b0 100644
--- a/clang/test/Driver/loongarch-march.c
+++ b/clang/test/Driver/loongarch-march.c
@@ -1,32 +1,25 @@
-// RUN: %clang --target=loongarch64 -march=loongarch64 -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1-LOONGARCH64
-// RUN: %clang --target=loongarch64 -march=la464 -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1-LA464
-// RUN: %clang --target=loongarch64 -march=loongarch64 -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR-LOONGARCH64
-// RUN: %clang --target=loongarch64 -march=la464 -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR-LA464
+// RUN: %clang --target=loongarch64 -march=loongarch64 -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1-LOONGARCH64
+// RUN: %clang --target=loongarch64 -march=la464 -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1-LA464
+// RUN: %clang --target=loongarch64 -march=loongarch64 -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR-LOONGARCH64
+// RUN: %clang --target=loongarch64 -march=la464 -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR-LA464
 
 // CC1-LOONGARCH64-NOT: "-target-feature"
-// CC1-LOONGARCH64: "-target-feature" "+64bit"
-// CC1-LOONGARCH64-SAME: {{^}} "-target-feature" "+f"
-// CC1-LOONGARCH64-SAME: {{^}} "-target-feature" "+d"
+// CC1-LOONGARCH64: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d"
 // CC1-LOONGARCH64-NOT: "-target-feature"
 // CC1-LOONGARCH64: "-target-abi" "lp64d"
 
 // CC1-LA464-NOT: "-target-feature"
-// CC1-LA464: "-target-feature" "+64bit"
-// CC1-LA464-SAME: {{^}} "-target-feature" "+f"
-// CC1-LA464-SAME: {{^}} "-target-feature" "+d"
-// CC1-LA464-SAME: {{^}} "-target-feature" "+lsx"
-// CC1-LA464-SAME: {{^}} "-target-feature" "+lasx"
+// CC1-LA464: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+lsx" "-target-feature" "+lasx"
 // CC1-LA464-NOT: "-target-feature"
 // CC1-LA464: "-target-abi" "lp64d"
 
-// IR-LOONGARCH64: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f"
-// IR-LA464: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f,+lasx,+lsx"
+// IR-LOONGARCH64: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f"
+// IR-LA464: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f,+lasx,+lsx"
 
-/// Dummy function
 int foo(void) {
-  return  3;
+  return 3;
 }

diff  --git a/clang/test/Driver/loongarch-mdouble-float.c b/clang/test/Driver/loongarch-mdouble-float.c
index fb8b13bf8ab25..63bc1c9111cd5 100644
--- a/clang/test/Driver/loongarch-mdouble-float.c
+++ b/clang/test/Driver/loongarch-mdouble-float.c
@@ -1,18 +1,20 @@
-// RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1
-// RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR
+// RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,WARN
+// RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR
+
+// WARN: warning: argument unused during compilation: '-mfpu=0'
+// WARN: warning: argument unused during compilation: '-mabi=lp64s'
 
 // CC1-NOT: "-target-feature"
-// CC1: "-target-feature" "+64bit"
-// CC1-SAME: {{^}} "-target-feature" "+f"
-// CC1-SAME: {{^}} "-target-feature" "+d"
+// CC1: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d"
 // CC1-NOT: "-target-feature"
 // CC1: "-target-abi" "lp64d"
 
-// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f"
+// IR: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f"
 
-/// Dummy function
 int foo(void) {
-  return  3;
+  return 3;
 }

diff  --git a/clang/test/Driver/loongarch-mfpu-error.c b/clang/test/Driver/loongarch-mfpu-error.c
index 6c1fc165c7361..1dbc556ddbcb4 100644
--- a/clang/test/Driver/loongarch-mfpu-error.c
+++ b/clang/test/Driver/loongarch-mfpu-error.c
@@ -1,4 +1,3 @@
-// RUN: %clang --target=loongarch64 -mfpu=xxx -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s
+// RUN: %clang --target=loongarch64 -mfpu=xxx %s -### 2>&1 | FileCheck %s
 
-// CHECK: invalid argument 'xxx' to -mfpu=; must be one of: 64, 32, 0, none
+// CHECK: invalid argument 'xxx' to -mfpu=; must be one of: 64, 32, none, 0 (alias for none)

diff  --git a/clang/test/Driver/loongarch-mfpu.c b/clang/test/Driver/loongarch-mfpu.c
index d5fb293d917b4..7fc7d45a72b33 100644
--- a/clang/test/Driver/loongarch-mfpu.c
+++ b/clang/test/Driver/loongarch-mfpu.c
@@ -1,47 +1,40 @@
-// RUN: %clang --target=loongarch64 -mfpu=64 -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1-FPU64
-// RUN: %clang --target=loongarch64 -mfpu=32 -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1-FPU32
-// RUN: %clang --target=loongarch64 -mfpu=0 -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1-FPU0
-// RUN: %clang --target=loongarch64 -mfpu=none -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1-FPU0
+// RUN: %clang --target=loongarch64 -mfpu=64 -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1-FPU64
+// RUN: %clang --target=loongarch64 -mfpu=32 -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1-FPU32
+// RUN: %clang --target=loongarch64 -mfpu=0 -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1-FPU0
+// RUN: %clang --target=loongarch64 -mfpu=none -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1-FPU0
 
-// RUN: %clang --target=loongarch64 -mfpu=64 -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR-FPU64
-// RUN: %clang --target=loongarch64 -mfpu=32 -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR-FPU32
-// RUN: %clang --target=loongarch64 -mfpu=0 -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR-FPU0
-// RUN: %clang --target=loongarch64 -mfpu=none -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR-FPU0
+// RUN: %clang --target=loongarch64 -mfpu=64 -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR-FPU64
+// RUN: %clang --target=loongarch64 -mfpu=32 -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR-FPU32
+// RUN: %clang --target=loongarch64 -mfpu=0 -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR-FPU0
+// RUN: %clang --target=loongarch64 -mfpu=none -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR-FPU0
 
 // CC1-FPU64-NOT: "-target-feature"
-// CC1-FPU64: "-target-feature" "+64bit"
-// CC1-FPU64-SAME: "-target-feature" "+f"
-// CC1-FPU64-SAME: "-target-feature" "+d"
+// CC1-FPU64: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d"
 // CC1-FPU64-NOT: "-target-feature"
 // CC1-FPU64: "-target-abi" "lp64d"
 
 // CC1-FPU32-NOT: "-target-feature"
-// CC1-FPU32: "-target-feature" "+64bit"
-// CC1-FPU32-SAME: "-target-feature" "+f"
-// CC1-FPU32-SAME: "-target-feature" "-d"
+// CC1-FPU32: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "-d"
 // CC1-FPU32-NOT: "-target-feature"
 // CC1-FPU32: "-target-abi" "lp64f"
 
 // CC1-FPU0-NOT: "-target-feature"
-// CC1-FPU0: "-target-feature" "+64bit"
-// CC1-FPU0-SAME: "-target-feature" "-f"
-// CC1-FPU0-SAME: "-target-feature" "-d"
+// CC1-FPU0: "-target-feature" "+64bit" "-target-feature" "-f" "-target-feature" "-d"
 // CC1-FPU0-NOT: "-target-feature"
 // CC1-FPU0: "-target-abi" "lp64s"
 
-// IR-FPU64: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f"
-// IR-FPU32: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+f,-d"
-// IR-FPU0: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,-d,-f"
+// IR-FPU64: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f"
+// IR-FPU32: attributes #[[#]] ={{.*}}"target-features"="+64bit,+f,-d"
+// IR-FPU0: attributes #[[#]] ={{.*}}"target-features"="+64bit,-d,-f"
 
-/// Dummy function
 int foo(void) {
-  return  3;
+  return 3;
 }

diff  --git a/clang/test/Driver/loongarch-msingle-float.c b/clang/test/Driver/loongarch-msingle-float.c
index 6084b80f74c88..5deff86551940 100644
--- a/clang/test/Driver/loongarch-msingle-float.c
+++ b/clang/test/Driver/loongarch-msingle-float.c
@@ -1,18 +1,20 @@
-// RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1
-// RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR
+// RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msingle-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,WARN
+// RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR
+
+// WARN: warning: argument unused during compilation: '-mfpu=0'
+// WARN: warning: argument unused during compilation: '-mabi=lp64s'
 
 // CC1-NOT: "-target-feature"
-// CC1: "-target-feature" "+64bit"
-// CC1-SAME: {{^}} "-target-feature" "+f"
-// CC1-SAME: {{^}} "-target-feature" "-d"
+// CC1: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "-d"
 // CC1-NOT: "-target-feature"
 // CC1: "-target-abi" "lp64f"
 
-// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+f,-d"
+// IR: attributes #[[#]] ={{.*}}"target-features"="+64bit,+f,-d"
 
-/// Dummy function
 int foo(void) {
-  return  3;
+  return 3;
 }

diff  --git a/clang/test/Driver/loongarch-msoft-float.c b/clang/test/Driver/loongarch-msoft-float.c
index 09e49f9873c3f..fd200377af2f7 100644
--- a/clang/test/Driver/loongarch-msoft-float.c
+++ b/clang/test/Driver/loongarch-msoft-float.c
@@ -1,18 +1,20 @@
-// RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CC1
-// RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - \
-// RUN:   | FileCheck %s --check-prefix=IR
+// RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msoft-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,WARN
+// RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - | \
+// RUN:   FileCheck %s --check-prefix=IR
+
+// WARN: warning: argument unused during compilation: '-mfpu=64'
+// WARN: warning: argument unused during compilation: '-mabi=lp64d'
 
 // CC1-NOT: "-target-feature"
-// CC1: "-target-feature" "+64bit"
-// CC1-SAME: {{^}} "-target-feature" "-f"
-// CC1-SAME: {{^}} "-target-feature" "-d"
+// CC1: "-target-feature" "+64bit" "-target-feature" "-f" "-target-feature" "-d"
 // CC1-NOT: "-target-feature"
 // CC1: "-target-abi" "lp64s"
 
-// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,-d,-f"
+// IR: attributes #[[#]] ={{.*}}"target-features"="+64bit,-d,-f"
 
-/// Dummy function
 int foo(void) {
-  return  3;
+  return 3;
 }

diff  --git a/llvm/lib/Support/LoongArchTargetParser.cpp b/llvm/lib/Support/LoongArchTargetParser.cpp
index dbc8184a2f496..a781c63a6c42a 100644
--- a/llvm/lib/Support/LoongArchTargetParser.cpp
+++ b/llvm/lib/Support/LoongArchTargetParser.cpp
@@ -29,10 +29,9 @@ const ArchInfo AllArchs[] = {
 };
 
 LoongArch::ArchKind LoongArch::parseArch(StringRef Arch) {
-  for (const auto A : AllArchs) {
+  for (const auto A : AllArchs)
     if (A.Name == Arch)
       return A.Kind;
-  }
 
   return LoongArch::ArchKind::AK_INVALID;
 }
@@ -41,11 +40,9 @@ bool LoongArch::getArchFeatures(StringRef Arch,
                                 std::vector<StringRef> &Features) {
   for (const auto A : AllArchs) {
     if (A.Name == Arch) {
-      for (const auto F : AllFeatures) {
-        if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID) {
+      for (const auto F : AllFeatures)
+        if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID)
           Features.push_back(F.Name);
-        }
-      }
       return true;
     }
   }


        


More information about the cfe-commits mailing list