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

Zhaoxin Yang via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 23:50:53 PST 2024


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

>From dd4aca55c1e35ebd6dbb9d849ba9de8b930ae209 Mon Sep 17 00:00:00 2001
From: ylzsx <2375355630 at qq.com>
Date: Sat, 2 Nov 2024 10:48:29 +0800
Subject: [PATCH 1/2] [Flang][LoongArch] Emit target features for Loongarch64.

---
 clang/lib/Driver/ToolChains/Flang.cpp     | 3 +++
 flang/test/Driver/target-cpu-features.f90 | 6 ++++++
 2 files changed, 9 insertions(+)

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"

>From ecf24aee9dc731d3ed72ad7a0fc269ee6271fef6 Mon Sep 17 00:00:00 2001
From: yangzhaoxin <yangzhaoxin at loongson.cn>
Date: Wed, 6 Nov 2024 15:44:35 +0800
Subject: [PATCH 2/2] Modify email address. NFC




More information about the cfe-commits mailing list