From 549231d38e10de7371adb85f5452d42ad42f4201 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 20 Sep 2022 12:13:01 -0700 Subject: [PATCH] [RISCV] Support -mno-implicit-float. This can be used to disable vectorization and memcpy/memset expansion for things like OS kernels. It also disables implicit uses of scalar FP, but I don't know if we have any of those for RISC-V. NOTE: Without this patch you can still do -Xclang -no-implicit-float Reviewed By: rui.zhang Differential Revision: https://reviews.llvm.org/D134077 --- clang/lib/Driver/ToolChains/Clang.cpp | 4 ++++ clang/test/Driver/flags.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 7af0f9998455..fb64722b4456 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2194,6 +2194,10 @@ void Clang::AddRISCVTargetArgs(const ArgList &Args, SetRISCVSmallDataLimit(getToolChain(), Args, CmdArgs); + if (!Args.hasFlag(options::OPT_mimplicit_float, + options::OPT_mno_implicit_float, true)) + CmdArgs.push_back("-no-implicit-float"); + if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) { CmdArgs.push_back("-tune-cpu"); CmdArgs.push_back(A->getValue()); diff --git a/clang/test/Driver/flags.c b/clang/test/Driver/flags.c index 656ac41a944f..da25a5cd3335 100644 --- a/clang/test/Driver/flags.c +++ b/clang/test/Driver/flags.c @@ -27,3 +27,9 @@ // RUN: %clang -target x86_64-linux-gnu -### -c -fclang-abi-compat=3.2 %s 2>&1 | FileCheck -check-prefix=TEST9 %s // TEST9: "-fclang-abi-compat=3.2" +// +// RUN: %clang -target riscv32 -### -S -mno-implicit-float %s 2>&1 | FileCheck -check-prefix=TEST10 %s +// TEST10: "-no-implicit-float" +// +// RUN: %clang -target riscv64 -### -S -mno-implicit-float %s 2>&1 | FileCheck -check-prefix=TEST11 %s +// TEST11: "-no-implicit-float"