[PATCH] D145883: [Flang][RISCV] Emit target features for RISC-V
Shao-Ce SUN via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 13 01:53:39 PDT 2023
sunshaoce updated this revision to Diff 504548.
sunshaoce added a comment.
Based on everyone's comments, I merged the test into `target-cpu-features.f90` and only kept the generic `-target-feature`. At the same time, I removed the `switch (TC.getArch())` and passed the test on x86 and RISC-V 64.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145883/new/
https://reviews.llvm.org/D145883
Files:
clang/lib/Driver/ToolChains/Flang.cpp
flang/test/Driver/target-cpu-features.f90
Index: flang/test/Driver/target-cpu-features.f90
===================================================================
--- flang/test/Driver/target-cpu-features.f90
+++ flang/test/Driver/target-cpu-features.f90
@@ -22,6 +22,12 @@
! RUN: %flang --target=x86_64h-linux-gnu -c %s -### 2>&1 \
! RUN: | FileCheck %s -check-prefix=CHECK-X86_64H
+! RUN: %flang --target=riscv32-linux-gnu -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-RV32
+
+! RUN: %flang --target=riscv64-linux-gnu -c %s -### 2>&1 \
+! RUN: | FileCheck %s -check-prefix=CHECK-RV64
+
! Test that invalid cpu and features are ignored.
@@ -52,5 +58,12 @@
! CHECK-X86_64H: "-fc1" "-triple" "x86_64h-unknown-linux-gnu"
! CHECK-X86_64H-SAME: "-target-cpu" "x86-64" "-target-feature" "-rdrnd" "-target-feature" "-aes" "-target-feature" "-pclmul" "-target-feature" "-rtm" "-target-feature" "-fsgsbase"
+! CHECK-RV32: "-fc1" "-triple" "riscv32-unknown-linux-gnu"
+! CHECK-RV32-SAME: "-target-cpu" "generic-rv32" "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+c" "-target-feature" "-e"
+
+! CHECK-RV64: "-fc1" "-triple" "riscv64-unknown-linux-gnu"
+! CHECK-RV64-SAME: "-target-cpu" "generic-rv64" "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+c" "-target-feature" "-e"
+
+
! CHECK-INVALID-CPU: 'supercpu' is not a recognized processor for this target (ignoring processor)
! CHECK-INVALID-FEATURE: '+superspeed' is not a recognized feature for this target (ignoring feature)
Index: clang/lib/Driver/ToolChains/Flang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -101,15 +101,7 @@
}
// Add the target features.
- switch (TC.getArch()) {
- default:
- break;
- case llvm::Triple::aarch64:
- [[fallthrough]];
- case llvm::Triple::x86_64:
- getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
- break;
- }
+ getTargetFeatures(D, Triple, Args, CmdArgs, /*ForAs*/ false);
// TODO: Add target specific flags, ABI, mtune option etc.
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145883.504548.patch
Type: text/x-patch
Size: 2190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230313/d699f97f/attachment.bin>
More information about the cfe-commits
mailing list