summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-12-11 21:09:19 +0000
committerCraig Topper <craig.topper@intel.com>2017-12-11 21:09:19 +0000
commit9a724aa38ff83c0d5654632e67f84b40559e3831 (patch)
tree0b95a2b63e46f2f8ad1d10a2fc5dfee185372509 /clang/lib/Driver/ToolChains
parent188252dd1e156ff96def744d3db23bce3b1a8f0c (diff)
downloadbcm5719-llvm-9a724aa38ff83c0d5654632e67f84b40559e3831.tar.gz
bcm5719-llvm-9a724aa38ff83c0d5654632e67f84b40559e3831.zip
[Driver][CodeGen] Add -mprefer-vector-width driver option and attribute during CodeGen.
This adds a new command line option -mprefer-vector-width to specify a preferred vector width for the vectorizers. Valid values are 'none' and unsigned integers. The driver will check that it meets those constraints. Specific supported integers will be managed by the targets in the backend. Clang will take the value and add it as a new function attribute during CodeGen. This represents the alternate direction proposed by Sanjay in this RFC: http://lists.llvm.org/pipermail/llvm-dev/2017-November/118734.html The syntax here matches gcc, though gcc treats it as an x86 specific command line argument. gcc only allows values of 128, 256, and 512. I'm not having clang check any values. Differential Revision: https://reviews.llvm.org/D40230 llvm-svn: 320419
Diffstat (limited to 'clang/lib/Driver/ToolChains')
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 2d6ac642f0f..706ac5bee29 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -274,6 +274,27 @@ static void ParseMRecip(const Driver &D, const ArgList &Args,
OutStrings.push_back(Args.MakeArgString(Out));
}
+/// The -mprefer-vector-width option accepts either a positive integer
+/// or the string "none".
+static void ParseMPreferVectorWidth(const Driver &D, const ArgList &Args,
+ ArgStringList &CmdArgs) {
+ Arg *A = Args.getLastArg(options::OPT_mprefer_vector_width_EQ);
+ if (!A)
+ return;
+
+ StringRef Value = A->getValue();
+ if (Value == "none") {
+ CmdArgs.push_back("-mprefer-vector-width=none");
+ } else {
+ unsigned Width;
+ if (Value.getAsInteger(10, Width)) {
+ D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value;
+ return;
+ }
+ CmdArgs.push_back(Args.MakeArgString("-mprefer-vector-width=" + Value));
+ }
+}
+
static void getWebAssemblyTargetFeatures(const ArgList &Args,
std::vector<StringRef> &Features) {
handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group);
@@ -4333,6 +4354,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
options::OPT_fno_slp_vectorize, EnableSLPVec))
CmdArgs.push_back("-vectorize-slp");
+ ParseMPreferVectorWidth(D, Args, CmdArgs);
+
if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
A->render(Args, CmdArgs);
OpenPOWER on IntegriCloud