[PATCH] D96784: Pass the cmdline aapcs bitfield options to cc1
Ties Stuij via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 18 03:46:15 PST 2021
stuij updated this revision to Diff 324589.
stuij added a comment.
added unit tests for the cmdline args
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96784/new/
https://reviews.llvm.org/D96784
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/arm-aarch64-bitfield-flags.c
Index: clang/test/Driver/arm-aarch64-bitfield-flags.c
===================================================================
--- /dev/null
+++ clang/test/Driver/arm-aarch64-bitfield-flags.c
@@ -0,0 +1,18 @@
+// check -faapcs-bitfield-width/-fno-aapcs-bitfield-width
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main -faapcs-bitfield-width -### %s 2>&1 | FileCheck --check-prefixes=WIDTH,INVERSE-WIDTH %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-m.main -faapcs-bitfield-width -### %s 2>&1 | FileCheck --check-prefixes=WIDTH,INVERSE-WIDTH %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main -fno-aapcs-bitfield-width -### %s 2>&1 | FileCheck --check-prefixes=NO-WIDTH,WIDTH %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-m.main -fno-aapcs-bitfield-width -### %s 2>&1 | FileCheck --check-prefixes=NO-WIDTH,WIDTH %s
+// WIDTH-NOT: -faapcs-bitfield-width
+// NO-WIDTH: -fno-aapcs-bitfield-width
+
+// check -faapcs-bitfield-load
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main -faapcs-bitfield-load -### %s 2>&1 | FileCheck --check-prefix=LOAD %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-m.main -faapcs-bitfield-load -### %s 2>&1 | FileCheck --check-prefix=LOAD %s
+// LOAD: -faapcs-bitfield-load
+
+// check absence of the above argument when not given
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main -### %s 2>&1 | FileCheck --check-prefixes=INVERSE-WIDTH,INVERSE-LOAD %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-m.main -### %s 2>&1 | FileCheck --check-prefixes=INVERSE-WIDTH,INVERSE-LOAD %s
+// INVERSE-WIDTH-NOT: -fno-aapcs-bitfield-width
+// INVERSE-LOAD-NOT: -fno-aapcs-bitfield-load
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1522,6 +1522,15 @@
}
}
+void AddAAPCSVolatileBitfieldArgs(const ArgList &Args, ArgStringList &CmdArgs) {
+ if (!Args.hasFlag(options::OPT_faapcs_bitfield_width,
+ options::OPT_fno_aapcs_bitfield_width, true))
+ CmdArgs.push_back("-fno-aapcs-bitfield-width");
+
+ if (Args.getLastArg(options::OPT_ForceAAPCSBitfieldLoad))
+ CmdArgs.push_back("-faapcs-bitfield-load");
+}
+
namespace {
void RenderARMABI(const llvm::Triple &Triple, const ArgList &Args,
ArgStringList &CmdArgs) {
@@ -1580,6 +1589,8 @@
if (Args.getLastArg(options::OPT_mcmse))
CmdArgs.push_back("-mcmse");
+
+ AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
}
void Clang::RenderTargetOptions(const llvm::Triple &EffectiveTriple,
@@ -1768,6 +1779,8 @@
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getOption().getName() << Val;
}
+
+ AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
}
void Clang::AddMIPSTargetArgs(const ArgList &Args,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96784.324589.patch
Type: text/x-patch
Size: 2901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210218/61aa72d9/attachment.bin>
More information about the cfe-commits
mailing list