Files
llvm-project/flang/lib/Support/FPMaxminBehavior.cpp
Slava Zakharin 5230955af7 [flang,acc] Support -ffp-maxmin-behavior option in lowering. (#184730)
This patch adds `flang -fc1` option `-ffp-maxmin-behavior` and
propagates it throughout Flang, so that semantics context,
lowering and the pass pipeline builder can use it.

MAX/MIN intrinsic and OpenACC max/min reduction lowering
are now controlled by the option.

I kept the `Legacy` mode, which is the default and matches the current
behavior. I am going to test and merge a follow-up patch that
replaces `Legacy` with `Portable`.

RFC:
https://discourse.llvm.org/t/flang-canonical-and-optimizable-representation-for-min-max/90037
2026-03-06 12:21:58 -08:00

24 lines
880 B
C++

//===--- Support/FPMaxminBehavior.cpp - Parse FP max/min behavior ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "flang/Support/FPMaxminBehavior.h"
#include "llvm/ADT/StringSwitch.h"
namespace Fortran::common {
FPMaxminBehavior parseFPMaxminBehavior(llvm::StringRef value) {
return llvm::StringSwitch<FPMaxminBehavior>(value)
.Case("legacy", FPMaxminBehavior::Legacy)
.Case("portable", FPMaxminBehavior::Portable)
.Case("extremum", FPMaxminBehavior::Extremum)
.Case("extremenum", FPMaxminBehavior::ExtremeNum)
.Default(FPMaxminBehavior::Legacy);
}
} // namespace Fortran::common