[flang-commits] [clang] [flang] [Flang][LoongArch] Emit target features for Loongarch64. (PR #114735)

via flang-commits flang-commits at lists.llvm.org
Sun Nov 3 20:52:44 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Zhaoxin Yang (ylzsx)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/114735.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+3) 
- (modified) flang/test/Driver/target-cpu-features.f90 (+6) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index f9d2fdffe3b2fc..11070c23c75f4a 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -414,6 +414,9 @@ void Flang::addTargetOptions(const ArgList &Args,
   case llvm::Triple::ppc64le:
     AddPPCTargetArgs(Args, CmdArgs);
     break;
+  case llvm::Triple::loongarch64:
+    getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
+    break;
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fveclib)) {
diff --git a/flang/test/Driver/target-cpu-features.f90 b/flang/test/Driver/target-cpu-features.f90
index e3eb8491058c7f..5a3fd0d8380027 100644
--- a/flang/test/Driver/target-cpu-features.f90
+++ b/flang/test/Driver/target-cpu-features.f90
@@ -41,6 +41,9 @@
 ! RUN: %flang --target=r600-unknown-unknown -mcpu=cayman -nogpulib -c %s -### 2>&1 \
 ! RUN: | FileCheck %s -check-prefix=CHECK-AMDGPU-R600
 
+! RUN: %flang --target=loongarch64-linux-gnu -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-LOONGARCH64
+
 ! CHECK-A57: "-fc1" "-triple" "aarch64-unknown-linux-gnu"
 ! CHECK-A57-SAME: "-target-cpu" "cortex-a57"
 ! CHECK-A57-SAME: "-target-feature" "+v8a" "-target-feature" "+aes" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+perfmon" "-target-feature" "+sha2
@@ -86,3 +89,6 @@
 
 ! CHECK-AMDGPU-R600: "-fc1" "-triple" "r600-unknown-unknown"
 ! CHECK-AMDGPU-R600-SAME: "-target-cpu" "cayman"
+
+! CHECK-LOONGARCH64: "-fc1" "-triple" "loongarch64-unknown-linux-gnu"
+! CHECK-LOONGARCH64-SAME: "-target-cpu" "loongarch64" "-target-feature" "+lsx" "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+ual"

``````````

</details>


https://github.com/llvm/llvm-project/pull/114735


More information about the flang-commits mailing list