[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
Shiva Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 13 00:03:15 PDT 2018
shiva0217 updated this revision to Diff 142338.
shiva0217 added a comment.
Add help text for -mrelax, -mno-relax flags as Alex's comments.
Repository:
rL LLVM
https://reviews.llvm.org/D44888
Files:
include/clang/Driver/Options.td
lib/Driver/ToolChains/Arch/RISCV.cpp
test/Driver/riscv-features.c
Index: test/Driver/riscv-features.c
===================================================================
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -2,3 +2,10 @@
// RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
// CHECK: fno-signed-char
+
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
+
+// RELAX: "-target-feature" "+relax"
+// NO-RELAX: "-target-feature" "-relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===================================================================
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -14,6 +14,7 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/raw_ostream.h"
+#include "ToolChains/CommonArgs.h"
using namespace clang::driver;
using namespace clang::driver::tools;
@@ -112,6 +113,21 @@
if (HasD && !HasF)
D.Diag(diag::err_drv_invalid_arch_name) << MArch;
}
+
+ // -mrelax is default, unless -mno-relax is specified.
+ bool Relax = true;
+ if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax))
+ if (A->getOption().matches(options::OPT_mno_relax)) {
+ Relax = false;
+ Features.push_back("-relax");
+ }
+
+ if (Relax)
+ Features.push_back("+relax");
+
+ // Now add any that the user explicitly requested on the command line,
+ // which may override the defaults.
+ handleTargetFeaturesGroup(Args, Features, options::OPT_m_riscv_Features_Group);
}
StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -150,6 +150,9 @@
def m_x86_Features_Group : OptionGroup<"<x86 features group>">,
Group<m_Group>, Flags<[CoreOption]>, DocName<"X86">;
+def m_riscv_Features_Group : OptionGroup<"<riscv features group>">,
+ Group<m_Group>, DocName<"RISCV">;
+
def m_libc_Group : OptionGroup<"<m libc group>">, Group<m_Group>,
Flags<[HelpHidden]>;
@@ -1880,6 +1883,11 @@
def meabi : Separate<["-"], "meabi">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">;
+def mrelax : Flag<["-"], "mrelax">, Group<m_riscv_Features_Group>,
+ HelpText<"Enable linker relaxation">;
+def mno_relax : Flag<["-"], "mno-relax">, Group<m_riscv_Features_Group>,
+ HelpText<"Disable linker relaxation">;
+
def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group<m_Group>;
def mno_global_merge : Flag<["-"], "mno-global-merge">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Disable merging of globals">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44888.142338.patch
Type: text/x-patch
Size: 2998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180413/16efeb1d/attachment.bin>
More information about the cfe-commits
mailing list