[PATCH] D159145: [RISCV] Don't add -unaligned-scalar-mem to target features by default.
Craig Topper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 29 15:33:04 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: wangpc, kito-cheng, asb, reames, jrtc27.
Herald added subscribers: jobnoorman, luke, sunshaoce, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, eopXD, MaskRay.
Herald added projects: clang, LLVM.
Only pass it +unaligned-scalar-mem/-unaligned-scalar-mem if the
user has passed one of the alignment options.
This allows us to add unaligned-scalar-mem as a feature on CPUs
that support it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159145
Files:
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-default-features.c
clang/test/Driver/riscv-features.c
llvm/lib/Target/RISCV/RISCVProcessors.td
Index: llvm/lib/Target/RISCV/RISCVProcessors.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVProcessors.td
+++ llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -181,7 +181,8 @@
FeatureStdExtZfh,
FeatureStdExtZvfh,
FeatureStdExtZba,
- FeatureStdExtZbb],
+ FeatureStdExtZbb,
+ FeatureUnalignedScalarMem],
[TuneSiFive7,
TuneDLenFactor2]>;
Index: clang/test/Driver/riscv-features.c
===================================================================
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -39,8 +39,6 @@
// NO-UNALIGNED-SCALAR-MEM: "-target-feature" "-unaligned-scalar-mem"
// UNALIGNED-VECTOR-MEM: "-target-feature" "+unaligned-vector-mem"
// NO-UNALIGNED-VECTOR-MEM: "-target-feature" "-unaligned-vector-mem"
-// DEFAULT: "-target-feature" "-unaligned-scalar-mem"
-// DEFAULT-NOT: "-target-feature" "+unaligned-scalar-mem"
// RUN: %clang --target=riscv32-linux -### %s -fsyntax-only 2>&1 \
// RUN: | FileCheck %s -check-prefix=DEFAULT-LINUX
Index: clang/test/Driver/riscv-default-features.c
===================================================================
--- clang/test/Driver/riscv-default-features.c
+++ clang/test/Driver/riscv-default-features.c
@@ -3,10 +3,8 @@
// RV32: "target-features"="+32bit,+a,+c,+m,+relax,
// RV32-SAME: -save-restore
-// RV32-SAME: -unaligned-scalar-mem
// RV64: "target-features"="+64bit,+a,+c,+m,+relax,
// RV64-SAME: -save-restore
-// RV64-SAME: -unaligned-scalar-mem
// Dummy function
int foo(void){
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -169,15 +169,17 @@
// -mno-unaligned-access is default, unless -munaligned-access is specified.
bool HasV = llvm::is_contained(Features, "+zve32x");
- if (Args.hasFlag(options::OPT_munaligned_access,
- options::OPT_mno_unaligned_access, false)) {
- Features.push_back("+unaligned-scalar-mem");
- if (HasV)
- Features.push_back("+unaligned-vector-mem");
- } else {
- Features.push_back("-unaligned-scalar-mem");
- if (HasV)
- Features.push_back("-unaligned-vector-mem");
+ if (const Arg *A = Args.getLastArg(options::OPT_munaligned_access,
+ options::OPT_mno_unaligned_access)) {
+ if (A->getOption().matches(options::OPT_munaligned_access)) {
+ Features.push_back("+unaligned-scalar-mem");
+ if (HasV)
+ Features.push_back("+unaligned-vector-mem");
+ } else {
+ Features.push_back("-unaligned-scalar-mem");
+ if (HasV)
+ Features.push_back("-unaligned-vector-mem");
+ }
}
// Now add any that the user explicitly requested on the command line,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159145.554511.patch
Type: text/x-patch
Size: 3156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230829/103aa578/attachment.bin>
More information about the cfe-commits
mailing list