mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-02 18:56:05 +00:00
[flang] Add -f[no-]honor-nans and -menable-no-nans
Only add the option processing and store the result. No attributes are added to FIR yet. Differential Revision: https://reviews.llvm.org/D137325
This commit is contained in:
parent
a7fa5febaa
commit
b5e93e390c
@ -5444,9 +5444,6 @@ def mframe_pointer_EQ : Joined<["-"], "mframe-pointer=">,
|
||||
HelpText<"Specify which frame pointers to retain.">, Values<"all,non-leaf,none">,
|
||||
NormalizedValuesScope<"CodeGenOptions::FramePointerKind">, NormalizedValues<["All", "NonLeaf", "None"]>,
|
||||
MarshallingInfoEnum<CodeGenOpts<"FramePointer">, "None">;
|
||||
def menable_no_nans : Flag<["-"], "menable-no-nans">,
|
||||
HelpText<"Allow optimization to assume there are no NaNs.">,
|
||||
MarshallingInfoFlag<LangOpts<"NoHonorNaNs">>, ImpliedByAnyOf<[ffinite_math_only.KeyPath]>;
|
||||
def mreassociate : Flag<["-"], "mreassociate">,
|
||||
HelpText<"Allow reassociation transformations for floating-point instructions">,
|
||||
MarshallingInfoFlag<LangOpts<"AllowFPReassoc">>, ImpliedByAnyOf<[funsafe_math_optimizations.KeyPath]>;
|
||||
@ -6057,6 +6054,9 @@ def split_dwarf_output : Separate<["-"], "split-dwarf-output">,
|
||||
|
||||
let Flags = [CC1Option, FC1Option, NoDriverOption] in {
|
||||
|
||||
def menable_no_nans : Flag<["-"], "menable-no-nans">,
|
||||
HelpText<"Allow optimization to assume there are no NaNs.">,
|
||||
MarshallingInfoFlag<LangOpts<"NoHonorNaNs">>, ImpliedByAnyOf<[ffinite_math_only.KeyPath]>;
|
||||
def menable_no_infinities : Flag<["-"], "menable-no-infs">,
|
||||
HelpText<"Allow optimization to assume there are no infinities.">,
|
||||
MarshallingInfoFlag<LangOpts<"NoHonorInfs">>, ImpliedByAnyOf<[ffinite_math_only.KeyPath]>;
|
||||
|
@ -84,6 +84,7 @@ static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
|
||||
ArgStringList &CmdArgs) {
|
||||
StringRef FPContract;
|
||||
bool HonorINFs = true;
|
||||
bool HonorNaNs = true;
|
||||
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_ffp_contract)) {
|
||||
const StringRef Val = A->getValue();
|
||||
@ -115,6 +116,12 @@ static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
|
||||
case options::OPT_fno_honor_infinities:
|
||||
HonorINFs = false;
|
||||
break;
|
||||
case options::OPT_fhonor_nans:
|
||||
HonorNaNs = true;
|
||||
break;
|
||||
case options::OPT_fno_honor_nans:
|
||||
HonorNaNs = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// If we handled this option claim it
|
||||
@ -126,6 +133,9 @@ static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
|
||||
|
||||
if (!HonorINFs)
|
||||
CmdArgs.push_back("-menable-no-infs");
|
||||
|
||||
if (!HonorNaNs)
|
||||
CmdArgs.push_back("-menable-no-nans");
|
||||
}
|
||||
|
||||
void Flang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
|
@ -23,6 +23,8 @@ ENUM_LANGOPT(FPContractMode, FPModeKind, 2, FPM_Off) ///< FP Contract Mode (off/
|
||||
|
||||
/// Permit floating point optimization without regard to infinities
|
||||
LANGOPT(NoHonorInfs, 1, false)
|
||||
/// Permit floating point optimization without regard to NaN
|
||||
LANGOPT(NoHonorNaNs, 1, false)
|
||||
|
||||
#undef LANGOPT
|
||||
#undef ENUM_LANGOPT
|
||||
|
@ -702,6 +702,12 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
|
||||
opts.NoHonorInfs = true;
|
||||
}
|
||||
|
||||
if (const llvm::opt::Arg *a =
|
||||
args.getLastArg(clang::driver::options::OPT_menable_no_nans)) {
|
||||
diags.Report(diagUnimplemented) << a->getOption().getName();
|
||||
opts.NoHonorNaNs = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,7 @@
|
||||
! HELP-FC1-NEXT: -I <dir> Add directory to the end of the list of include search paths
|
||||
! HELP-FC1-NEXT: -load <dsopath> Load the named plugin (dynamic shared object)
|
||||
! HELP-FC1-NEXT: -menable-no-infs Allow optimization to assume there are no infinities.
|
||||
! HELP-FC1-NEXT: -menable-no-nans Allow optimization to assume there are no NaNs.
|
||||
! HELP-FC1-NEXT: -mllvm <value> Additional arguments to forward to LLVM's option processing
|
||||
! HELP-FC1-NEXT: -mmlir <value> Additional arguments to forward to MLIR's option processing
|
||||
! HELP-FC1-NEXT: -module-dir <dir> Put MODULE files in <dir>
|
||||
|
@ -1,5 +1,10 @@
|
||||
! Test for handling of floating point options within the frontend driver
|
||||
|
||||
! RUN: %flang_fc1 -ffp-contract=fast -menable-no-infs %s 2>&1 | FileCheck %s
|
||||
! RUN: %flang_fc1 \
|
||||
! RUN: -ffp-contract=fast \
|
||||
! RUN: -menable-no-infs \
|
||||
! RUN: -menable-no-nans \
|
||||
! RUN: %s 2>&1 | FileCheck %s
|
||||
! CHECK: ffp-contract= is not currently implemented
|
||||
! CHECK: menable-no-infs is not currently implemented
|
||||
! CHECK: menable-no-nans is not currently implemented
|
||||
|
@ -10,6 +10,7 @@
|
||||
! RUN: -fconvert=little-endian \
|
||||
! RUN: -ffp-contract=fast \
|
||||
! RUN: -fno-honor-infinities \
|
||||
! RUN: -fno-honor-nans \
|
||||
! RUN: -mllvm -print-before-all\
|
||||
! RUN: -P \
|
||||
! RUN: | FileCheck %s
|
||||
@ -22,5 +23,6 @@
|
||||
! CHECK: "-flarge-sizes"
|
||||
! CHECK: "-ffp-contract=fast"
|
||||
! CHECK: "-menable-no-infs"
|
||||
! CHECK: "-menable-no-nans"
|
||||
! CHECK: "-fconvert=little-endian"
|
||||
! CHECK: "-mllvm" "-print-before-all"
|
||||
|
Loading…
x
Reference in New Issue
Block a user