[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
asb added a comment. I wonder if it would be safer to change this patch so it adds -mrelax and -mno-relax but doesn't compile with linker relaxation by default. That makes it easier to test linker relaxation support, and gives more time for testing before then flipping to -mrelax as the default. Comment at: test/Driver/riscv-features.c:8 +// RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX + +// RELAX: "-target-feature" "+relax" We need a another RUN line and CHECK here to determine the default whether +relax is passed or not when the user specifies neither -mrelax or -mno-relax. Repository: rL LLVM https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
shiva0217 added inline comments. Comment at: lib/Driver/ToolChains/Arch/RISCV.cpp:130 + // which may override the defaults. + handleTargetFeaturesGroup(Args, Features, options::OPT_m_riscv_Features_Group); } kito-cheng wrote: > This part should move to the begin of the function, otherwise it never > executed if `Exts` is empty string. > Hi Kito. I have rebased the patch to D45465. Could you help me to check when you download raw diff and apply with `patch -p0<` does it still patch to the wrong function? Repository: rL LLVM https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
shiva0217 updated this revision to Diff 146737. shiva0217 added a comment. Rebase patch to https://reviews.llvm.org/D45465 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,9 @@ // 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 @@ -15,6 +15,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; @@ -363,6 +364,21 @@ // Handle all other types of extensions. getExtensionFeatures(D, Args, Features, MArch, OtherExts); } + + // -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 , const llvm::Triple ) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -151,6 +151,8 @@ Group, DocName<"WebAssembly">; def m_x86_Features_Group : OptionGroup<"">, Group, Flags<[CoreOption]>, DocName<"X86">; +def m_riscv_Features_Group : OptionGroup<"">, + Group, DocName<"RISCV">; def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; @@ -1950,6 +1952,11 @@ def mno_soft_float : Flag<["-"], "mno-soft-float">, Group; def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group; +def mrelax : Flag<["-"], "mrelax">, Group, + HelpText<"Enable linker relaxation">; +def mno_relax : Flag<["-"], "mno-relax">, Group, + HelpText<"Disable linker relaxation">; + def munaligned_access : Flag<["-"], "munaligned-access">, Group, HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">; def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group, Index: test/Driver/riscv-features.c === --- test/Driver/riscv-features.c +++ test/Driver/riscv-features.c @@ -2,3 +2,9 @@ // 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 @@ -15,6 +15,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; @@ -363,6 +364,21 @@ // Handle all other types of extensions. getExtensionFeatures(D, Args, Features, MArch, OtherExts); } + + // -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 , const llvm::Triple ) { Index: include/clang/Driver/Options.td
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
kito-cheng added inline comments. Comment at: lib/Driver/ToolChains/Arch/RISCV.cpp:130 + // which may override the defaults. + handleTargetFeaturesGroup(Args, Features, options::OPT_m_riscv_Features_Group); } This part should move to the begin of the function, otherwise it never executed if `Exts` is empty string. Repository: rL LLVM https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
shiva0217 added a comment. In https://reviews.llvm.org/D44888#1068806, @asb wrote: > Thanks Kito. -mrelax and -mno-relax currently only affect the backend. For > completeness, I think this patch needs to pass the appropriate flag to the > linker depending on relax/no-relax. Hi Alex. RISCVToolChain class does not define yet, so we can't pass --no-relax in RISCV::Linker::ConstructJob. Should we passing --no-relax when we introduce RISCVToolchain? Or there is another place we could implement passing RISCV linker flags? Repository: rL LLVM https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
asb requested changes to this revision. asb added a comment. This revision now requires changes to proceed. Thanks Kito. -mrelax and -mno-relax currently only affect the backend. For completeness, I think this patch needs to pass the appropriate flag to the linker depending on relax/no-relax. Repository: rL LLVM https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
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 , const llvm::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<"">, Group, Flags<[CoreOption]>, DocName<"X86">; +def m_riscv_Features_Group : OptionGroup<"">, + Group, DocName<"RISCV">; + def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; @@ -1880,6 +1883,11 @@ def meabi : Separate<["-"], "meabi">, 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, + HelpText<"Enable linker relaxation">; +def mno_relax : Flag<["-"], "mno-relax">, Group, + HelpText<"Disable linker relaxation">; + def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group; def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>, HelpText<"Disable merging of globals">; 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 , const llvm::Triple ) { Index: include/clang/Driver/Options.td ===
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
asb added a comment. Looks good to me, just missing help text on the command line options. Repository: rL LLVM https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
shiva0217 updated this revision to Diff 141591. shiva0217 added a comment. Update patch to address 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 , const llvm::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<"">, Group, Flags<[CoreOption]>, DocName<"X86">; +def m_riscv_Features_Group : OptionGroup<"">, + Group, DocName<"RISCV">; + def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; @@ -1880,6 +1883,11 @@ def meabi : Separate<["-"], "meabi">, 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; +def mno_relax : Flag<["-"], "mno-relax">, +Group; + def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group; def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>, HelpText<"Disable merging of globals">; 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 , const llvm::Triple ) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -150,6 +150,9 @@ def
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
asb added a comment. In https://reviews.llvm.org/D44888#1058257, @asb wrote: > Could you please add a test? Given that the current version of > https://reviews.llvm.org/D44886 enables linker relaxation by default in the > backend, shouldn't -mno-relax cause -relax to be set? Sorry, I misready D444886. Still, we should do Features.push_back("-relax") at least in the case where -mno-relax is given explicitly, meaning we don't have to rely on the backend default. Repository: rC Clang https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
asb added a comment. Could you please add a test? Given that the current version of https://reviews.llvm.org/D44886 enables linker relaxation by default in the backend, shouldn't -mno-relax cause -relax to be set? Repository: rC Clang https://reviews.llvm.org/D44888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags
shiva0217 updated this revision to Diff 140038. shiva0217 retitled this revision from "[RISCV] Default enable linker relaxation and add -mno-relax flag to disable it" to "[RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags". shiva0217 edited the summary of this revision. shiva0217 added a comment. Update patch to address Ana's comments. Repository: rC Clang https://reviews.llvm.org/D44888 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/Arch/RISCV.cpp 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; @@ -51,6 +52,19 @@ } } } + + // -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; + + 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 , const llvm::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<"">, Group, Flags<[CoreOption]>, DocName<"X86">; +def m_riscv_Features_Group : OptionGroup<"">, + Group, DocName<"RISCV">; + def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; @@ -1873,6 +1876,11 @@ def meabi : Separate<["-"], "meabi">, 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; +def mno_relax : Flag<["-"], "mno-relax">, +Group; + def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group; def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>, HelpText<"Disable merging of globals">; 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; @@ -51,6 +52,19 @@ } } } + + // -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; + + 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 , const llvm::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<"">, Group, Flags<[CoreOption]>, DocName<"X86">; +def m_riscv_Features_Group : OptionGroup<"">, + Group, DocName<"RISCV">; + def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; @@ -1873,6 +1876,11 @@ def meabi : Separate<["-"], "meabi">, 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; +def mno_relax : Flag<["-"], "mno-relax">, +Group; + def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group; def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, Flags<[CC1Option]>, HelpText<"Disable merging of globals">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits