aboutsummaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorTom Eccles <tom.eccles@arm.com>2022-10-18 17:59:03 +0000
committerTom Eccles <tom.eccles@arm.com>2022-11-04 17:22:34 +0000
commitb5b8a8cfbe1ee3c2d3684dd62e7f0ddeeeb73273 (patch)
treed75e0ad2fd7965ecf275530b12110a7b73027dc2 /flang
parent36b37a1ed561404a32a4b4b6e2bd92d915894a7c (diff)
downloadllvm-b5b8a8cfbe1ee3c2d3684dd62e7f0ddeeeb73273.zip
llvm-b5b8a8cfbe1ee3c2d3684dd62e7f0ddeeeb73273.tar.gz
llvm-b5b8a8cfbe1ee3c2d3684dd62e7f0ddeeeb73273.tar.bz2
[flang] Add -f[no-]signed-zeros
Only add the option processing and store the result. No attributes are added to FIR yet. Differential Revision: https://reviews.llvm.org/D137328
Diffstat (limited to 'flang')
-rw-r--r--flang/include/flang/Frontend/LangOptions.def2
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp6
-rw-r--r--flang/test/Driver/driver-help-hidden.f901
-rw-r--r--flang/test/Driver/driver-help.f902
-rw-r--r--flang/test/Driver/flang_fp_opts.f902
-rw-r--r--flang/test/Driver/frontend-forwarding.f902
6 files changed, 15 insertions, 0 deletions
diff --git a/flang/include/flang/Frontend/LangOptions.def b/flang/include/flang/Frontend/LangOptions.def
index 4a5c47f..e357182 100644
--- a/flang/include/flang/Frontend/LangOptions.def
+++ b/flang/include/flang/Frontend/LangOptions.def
@@ -27,6 +27,8 @@ LANGOPT(NoHonorInfs, 1, false)
LANGOPT(NoHonorNaNs, 1, false)
/// Allow math functions to be replaced with an approximately equivalent calculation
LANGOPT(ApproxFunc, 1, false)
+/// Allow optimizations that ignore the sign of floating point zeros
+LANGOPT(NoSignedZeros, 1, false)
#undef LANGOPT
#undef ENUM_LANGOPT
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index dd461c7..eeadb21 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -714,6 +714,12 @@ static bool parseFloatingPointArgs(CompilerInvocation &invoc,
opts.ApproxFunc = true;
}
+ if (const llvm::opt::Arg *a =
+ args.getLastArg(clang::driver::options::OPT_fno_signed_zeros)) {
+ diags.Report(diagUnimplemented) << a->getOption().getName();
+ opts.NoSignedZeros = true;
+ }
+
return true;
}
diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90
index 3c249e4..b3913e9 100644
--- a/flang/test/Driver/driver-help-hidden.f90
+++ b/flang/test/Driver/driver-help-hidden.f90
@@ -45,6 +45,7 @@
! CHECK-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
+! CHECK-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros
! CHECK-NEXT: -fopenacc Enable OpenACC
! CHECK-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
! CHECK-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages
diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90
index 3ca3d06..1c48ec5 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -43,6 +43,7 @@
! HELP-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
! HELP-NEXT: -fno-integrated-as Disable the integrated assembler
+! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros
! HELP-NEXT: -fopenacc Enable OpenACC
! HELP-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
! HELP-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages
@@ -124,6 +125,7 @@
! HELP-FC1-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
! HELP-FC1-NEXT: -fno-debug-pass-manager Disables debug printing for the new pass manager
! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode
+! HELP-FC1-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros
! HELP-FC1-NEXT: -fopenacc Enable OpenACC
! HELP-FC1-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code.
! HELP-FC1-NEXT: -fsyntax-only Run the preprocessor, parser and semantic analysis stages
diff --git a/flang/test/Driver/flang_fp_opts.f90 b/flang/test/Driver/flang_fp_opts.f90
index 3b9d0f2..a305cdd 100644
--- a/flang/test/Driver/flang_fp_opts.f90
+++ b/flang/test/Driver/flang_fp_opts.f90
@@ -5,8 +5,10 @@
! RUN: -menable-no-infs \
! RUN: -menable-no-nans \
! RUN: -fapprox-func \
+! RUN: -fno-signed-zeros \
! 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
! CHECK: fapprox-func is not currently implemented
+! CHECK: fno-signed-zeros is not currently implemented
diff --git a/flang/test/Driver/frontend-forwarding.f90 b/flang/test/Driver/frontend-forwarding.f90
index ed0e89a..a00c45a 100644
--- a/flang/test/Driver/frontend-forwarding.f90
+++ b/flang/test/Driver/frontend-forwarding.f90
@@ -12,6 +12,7 @@
! RUN: -fno-honor-infinities \
! RUN: -fno-honor-nans \
! RUN: -fapprox-func \
+! RUN: -fno-signed-zeros \
! RUN: -mllvm -print-before-all\
! RUN: -P \
! RUN: | FileCheck %s
@@ -26,5 +27,6 @@
! CHECK: "-menable-no-infs"
! CHECK: "-menable-no-nans"
! CHECK: "-fapprox-func"
+! CHECK: "-fno-signed-zeros"
! CHECK: "-fconvert=little-endian"
! CHECK: "-mllvm" "-print-before-all"