diff options
author | Simon Dardis <simon.dardis@imgtec.com> | 2016-05-27 15:13:31 +0000 |
---|---|---|
committer | Simon Dardis <simon.dardis@imgtec.com> | 2016-05-27 15:13:31 +0000 |
commit | d0e83bad13b1f61e4f4821042fadee9b85ea6d22 (patch) | |
tree | 22ef85d8d1ed3a5a81a949e72916877a68fdf14f /clang/lib/Driver/Tools.cpp | |
parent | 406b469de44583da88bfba158a161643908d14e0 (diff) | |
download | llvm-d0e83bad13b1f61e4f4821042fadee9b85ea6d22.zip llvm-d0e83bad13b1f61e4f4821042fadee9b85ea6d22.tar.gz llvm-d0e83bad13b1f61e4f4821042fadee9b85ea6d22.tar.bz2 |
[mips] Compact branch policy setting.
This patch adds the commandline option -mcompact-branches={never,optimal,always),
which controls how LLVM generates compact branches for MIPSR6 targets. By default,
the compact branch policy is 'optimal' where LLVM will generate the most
appropriate branch for any situation. The 'never' and 'always' policy will disable
or always generate compact branches wherever possible respectfully.
Reviewers: dsanders, vkalintiris, atanasyan
Differential Revision: http://reviews.llvm.org/D20729
llvm-svn: 271000
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 33de18d..95f0a801 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1436,6 +1436,19 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, CmdArgs.push_back(Args.MakeArgString("-mips-ssection-threshold=" + v)); A->claim(); } + + if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) { + StringRef Val = StringRef(A->getValue()); + if (mips::hasCompactBranches(CPUName)) { + if (Val == "never" || Val == "always" || Val == "optimal") { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back(Args.MakeArgString("-mips-compact-branches=" + Val)); + } else + D.Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << Val; + } else + D.Diag(diag::warn_target_unsupported_compact_branches) << CPUName; + } } /// getPPCTargetCPU - Get the (LLVM) name of the PowerPC cpu we are targeting. @@ -7065,6 +7078,14 @@ mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) { .Default(NanLegacy); } +bool mips::hasCompactBranches(StringRef &CPU) { + // mips32r6 and mips64r6 have compact branches. + return llvm::StringSwitch<bool>(CPU) + .Case("mips32r6", true) + .Case("mips64r6", true) + .Default(false); +} + bool mips::hasMipsAbiArg(const ArgList &Args, const char *Value) { Arg *A = Args.getLastArg(options::OPT_mabi_EQ); return A && (A->getValue() == StringRef(Value)); |