mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-13 08:54:59 +00:00
Temporarily Revert "Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior="
and a follow-up NFC rearrangement as it's causing a crash on valid. Testcase is on the original review thread. This reverts commits af57dbf12e54f3a8ff48534bf1078f4de104c1cd and e6584b2b7b2de06f1e59aac41971760cac1e1b79
This commit is contained in:
parent
4f6955c715
commit
f6be1a2758
@ -1,70 +0,0 @@
|
||||
//===- FPEnv.h ---- FP Environment ------------------------------*- C++ -*-===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// @file
|
||||
/// This file contains the declarations of entities that describe floating
|
||||
/// point environment and related functions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_IR_FLOATINGPOINT_H
|
||||
#define LLVM_IR_FLOATINGPOINT_H
|
||||
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
namespace fp {
|
||||
|
||||
/// Rounding mode used for floating point operations.
|
||||
///
|
||||
/// Each of these values correspond to some metadata argument value of a
|
||||
/// constrained floating point intrinsic. See the LLVM Language Reference Manual
|
||||
/// for details.
|
||||
enum RoundingMode : uint8_t {
|
||||
rmDynamic, ///< This corresponds to "fpround.dynamic".
|
||||
rmToNearest, ///< This corresponds to "fpround.tonearest".
|
||||
rmDownward, ///< This corresponds to "fpround.downward".
|
||||
rmUpward, ///< This corresponds to "fpround.upward".
|
||||
rmTowardZero ///< This corresponds to "fpround.tozero".
|
||||
};
|
||||
|
||||
/// Exception behavior used for floating point operations.
|
||||
///
|
||||
/// Each of these values correspond to some metadata argument value of a
|
||||
/// constrained floating point intrinsic. See the LLVM Language Reference Manual
|
||||
/// for details.
|
||||
enum ExceptionBehavior : uint8_t {
|
||||
ebIgnore, ///< This corresponds to "fpexcept.ignore".
|
||||
ebMayTrap, ///< This corresponds to "fpexcept.maytrap".
|
||||
ebStrict ///< This corresponds to "fpexcept.strict".
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/// Returns a valid RoundingMode enumerator when given a string
|
||||
/// that is valid as input in constrained intrinsic rounding mode
|
||||
/// metadata.
|
||||
Optional<fp::RoundingMode> StrToRoundingMode(StringRef);
|
||||
|
||||
/// For any RoundingMode enumerator, returns a string valid as input in
|
||||
/// constrained intrinsic rounding mode metadata.
|
||||
Optional<StringRef> RoundingModeToStr(fp::RoundingMode);
|
||||
|
||||
/// Returns a valid ExceptionBehavior enumerator when given a string
|
||||
/// valid as input in constrained intrinsic exception behavior metadata.
|
||||
Optional<fp::ExceptionBehavior> StrToExceptionBehavior(StringRef);
|
||||
|
||||
/// For any ExceptionBehavior enumerator, returns a string valid as
|
||||
/// input in constrained intrinsic exception behavior metadata.
|
||||
Optional<StringRef> ExceptionBehaviorToStr(fp::ExceptionBehavior);
|
||||
|
||||
}
|
||||
#endif
|
@ -97,8 +97,8 @@ protected:
|
||||
FastMathFlags FMF;
|
||||
|
||||
bool IsFPConstrained;
|
||||
fp::ExceptionBehavior DefaultConstrainedExcept;
|
||||
fp::RoundingMode DefaultConstrainedRounding;
|
||||
ConstrainedFPIntrinsic::ExceptionBehavior DefaultConstrainedExcept;
|
||||
ConstrainedFPIntrinsic::RoundingMode DefaultConstrainedRounding;
|
||||
|
||||
ArrayRef<OperandBundleDef> DefaultOperandBundles;
|
||||
|
||||
@ -106,8 +106,8 @@ public:
|
||||
IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: Context(context), DefaultFPMathTag(FPMathTag), IsFPConstrained(false),
|
||||
DefaultConstrainedExcept(fp::ebStrict),
|
||||
DefaultConstrainedRounding(fp::rmDynamic),
|
||||
DefaultConstrainedExcept(ConstrainedFPIntrinsic::ebStrict),
|
||||
DefaultConstrainedRounding(ConstrainedFPIntrinsic::rmDynamic),
|
||||
DefaultOperandBundles(OpBundles) {
|
||||
ClearInsertionPoint();
|
||||
}
|
||||
@ -234,22 +234,24 @@ public:
|
||||
bool getIsFPConstrained() { return IsFPConstrained; }
|
||||
|
||||
/// Set the exception handling to be used with constrained floating point
|
||||
void setDefaultConstrainedExcept(fp::ExceptionBehavior NewExcept) {
|
||||
void setDefaultConstrainedExcept(
|
||||
ConstrainedFPIntrinsic::ExceptionBehavior NewExcept) {
|
||||
DefaultConstrainedExcept = NewExcept;
|
||||
}
|
||||
|
||||
/// Set the rounding mode handling to be used with constrained floating point
|
||||
void setDefaultConstrainedRounding(fp::RoundingMode NewRounding) {
|
||||
void setDefaultConstrainedRounding(
|
||||
ConstrainedFPIntrinsic::RoundingMode NewRounding) {
|
||||
DefaultConstrainedRounding = NewRounding;
|
||||
}
|
||||
|
||||
/// Get the exception handling used with constrained floating point
|
||||
fp::ExceptionBehavior getDefaultConstrainedExcept() {
|
||||
ConstrainedFPIntrinsic::ExceptionBehavior getDefaultConstrainedExcept() {
|
||||
return DefaultConstrainedExcept;
|
||||
}
|
||||
|
||||
/// Get the rounding mode handling used with constrained floating point
|
||||
fp::RoundingMode getDefaultConstrainedRounding() {
|
||||
ConstrainedFPIntrinsic::RoundingMode getDefaultConstrainedRounding() {
|
||||
return DefaultConstrainedRounding;
|
||||
}
|
||||
|
||||
@ -1095,26 +1097,32 @@ private:
|
||||
return (LC && RC) ? Insert(Folder.CreateBinOp(Opc, LC, RC), Name) : nullptr;
|
||||
}
|
||||
|
||||
Value *getConstrainedFPRounding(Optional<fp::RoundingMode> Rounding) {
|
||||
fp::RoundingMode UseRounding = DefaultConstrainedRounding;
|
||||
Value *getConstrainedFPRounding(
|
||||
Optional<ConstrainedFPIntrinsic::RoundingMode> Rounding) {
|
||||
ConstrainedFPIntrinsic::RoundingMode UseRounding =
|
||||
DefaultConstrainedRounding;
|
||||
|
||||
if (Rounding.hasValue())
|
||||
UseRounding = Rounding.getValue();
|
||||
|
||||
Optional<StringRef> RoundingStr = RoundingModeToStr(UseRounding);
|
||||
Optional<StringRef> RoundingStr =
|
||||
ConstrainedFPIntrinsic::RoundingModeToStr(UseRounding);
|
||||
assert(RoundingStr.hasValue() && "Garbage strict rounding mode!");
|
||||
auto *RoundingMDS = MDString::get(Context, RoundingStr.getValue());
|
||||
|
||||
return MetadataAsValue::get(Context, RoundingMDS);
|
||||
}
|
||||
|
||||
Value *getConstrainedFPExcept(Optional<fp::ExceptionBehavior> Except) {
|
||||
fp::ExceptionBehavior UseExcept = DefaultConstrainedExcept;
|
||||
Value *getConstrainedFPExcept(
|
||||
Optional<ConstrainedFPIntrinsic::ExceptionBehavior> Except) {
|
||||
ConstrainedFPIntrinsic::ExceptionBehavior UseExcept =
|
||||
DefaultConstrainedExcept;
|
||||
|
||||
if (Except.hasValue())
|
||||
UseExcept = Except.getValue();
|
||||
|
||||
Optional<StringRef> ExceptStr = ExceptionBehaviorToStr(UseExcept);
|
||||
Optional<StringRef> ExceptStr =
|
||||
ConstrainedFPIntrinsic::ExceptionBehaviorToStr(UseExcept);
|
||||
assert(ExceptStr.hasValue() && "Garbage strict exception behavior!");
|
||||
auto *ExceptMDS = MDString::get(Context, ExceptStr.getValue());
|
||||
|
||||
@ -1475,8 +1483,8 @@ public:
|
||||
CallInst *CreateConstrainedFPBinOp(
|
||||
Intrinsic::ID ID, Value *L, Value *R, Instruction *FMFSource = nullptr,
|
||||
const Twine &Name = "", MDNode *FPMathTag = nullptr,
|
||||
Optional<fp::RoundingMode> Rounding = None,
|
||||
Optional<fp::ExceptionBehavior> Except = None) {
|
||||
Optional<ConstrainedFPIntrinsic::RoundingMode> Rounding = None,
|
||||
Optional<ConstrainedFPIntrinsic::ExceptionBehavior> Except = None) {
|
||||
Value *RoundingV = getConstrainedFPRounding(Rounding);
|
||||
Value *ExceptV = getConstrainedFPExcept(Except);
|
||||
|
||||
@ -2070,8 +2078,8 @@ public:
|
||||
Intrinsic::ID ID, Value *V, Type *DestTy,
|
||||
Instruction *FMFSource = nullptr, const Twine &Name = "",
|
||||
MDNode *FPMathTag = nullptr,
|
||||
Optional<fp::RoundingMode> Rounding = None,
|
||||
Optional<fp::ExceptionBehavior> Except = None) {
|
||||
Optional<ConstrainedFPIntrinsic::RoundingMode> Rounding = None,
|
||||
Optional<ConstrainedFPIntrinsic::ExceptionBehavior> Except = None) {
|
||||
Value *ExceptV = getConstrainedFPExcept(Except);
|
||||
|
||||
FastMathFlags UseFMF = FMF;
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/FPEnv.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
@ -209,10 +208,47 @@ namespace llvm {
|
||||
/// This is the common base class for constrained floating point intrinsics.
|
||||
class ConstrainedFPIntrinsic : public IntrinsicInst {
|
||||
public:
|
||||
/// Specifies the rounding mode to be assumed. This is only used when
|
||||
/// when constrained floating point is enabled. See the LLVM Language
|
||||
/// Reference Manual for details.
|
||||
enum RoundingMode : uint8_t {
|
||||
rmDynamic, ///< This corresponds to "fpround.dynamic".
|
||||
rmToNearest, ///< This corresponds to "fpround.tonearest".
|
||||
rmDownward, ///< This corresponds to "fpround.downward".
|
||||
rmUpward, ///< This corresponds to "fpround.upward".
|
||||
rmTowardZero ///< This corresponds to "fpround.tozero".
|
||||
};
|
||||
|
||||
/// Specifies the required exception behavior. This is only used when
|
||||
/// when constrained floating point is used. See the LLVM Language
|
||||
/// Reference Manual for details.
|
||||
enum ExceptionBehavior : uint8_t {
|
||||
ebIgnore, ///< This corresponds to "fpexcept.ignore".
|
||||
ebMayTrap, ///< This corresponds to "fpexcept.maytrap".
|
||||
ebStrict ///< This corresponds to "fpexcept.strict".
|
||||
};
|
||||
|
||||
bool isUnaryOp() const;
|
||||
bool isTernaryOp() const;
|
||||
Optional<fp::RoundingMode> getRoundingMode() const;
|
||||
Optional<fp::ExceptionBehavior> getExceptionBehavior() const;
|
||||
Optional<RoundingMode> getRoundingMode() const;
|
||||
Optional<ExceptionBehavior> getExceptionBehavior() const;
|
||||
|
||||
/// Returns a valid RoundingMode enumerator when given a string
|
||||
/// that is valid as input in constrained intrinsic rounding mode
|
||||
/// metadata.
|
||||
static Optional<RoundingMode> StrToRoundingMode(StringRef);
|
||||
|
||||
/// For any RoundingMode enumerator, returns a string valid as input in
|
||||
/// constrained intrinsic rounding mode metadata.
|
||||
static Optional<StringRef> RoundingModeToStr(RoundingMode);
|
||||
|
||||
/// Returns a valid ExceptionBehavior enumerator when given a string
|
||||
/// valid as input in constrained intrinsic exception behavior metadata.
|
||||
static Optional<ExceptionBehavior> StrToExceptionBehavior(StringRef);
|
||||
|
||||
/// For any ExceptionBehavior enumerator, returns a string valid as
|
||||
/// input in constrained intrinsic exception behavior metadata.
|
||||
static Optional<StringRef> ExceptionBehaviorToStr(ExceptionBehavior);
|
||||
|
||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||
static bool classof(const IntrinsicInst *I) {
|
||||
|
@ -107,7 +107,7 @@ namespace llvm {
|
||||
public:
|
||||
TargetOptions()
|
||||
: PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
|
||||
NoNaNsFPMath(false), NoTrappingFPMath(true),
|
||||
NoNaNsFPMath(false), NoTrappingFPMath(false),
|
||||
NoSignedZerosFPMath(false),
|
||||
HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
|
||||
GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
|
||||
|
@ -7032,7 +7032,8 @@ void SelectionDAGBuilder::visitConstrainedFPIntrinsic(
|
||||
SDVTList VTs = DAG.getVTList(ValueVTs);
|
||||
SDValue Result = DAG.getNode(Opcode, sdl, VTs, Opers);
|
||||
|
||||
if (FPI.getExceptionBehavior() != fp::ExceptionBehavior::ebIgnore) {
|
||||
if (FPI.getExceptionBehavior() !=
|
||||
ConstrainedFPIntrinsic::ExceptionBehavior::ebIgnore) {
|
||||
SDNodeFlags Flags;
|
||||
Flags.setFPExcept(true);
|
||||
Result->setFlags(Flags);
|
||||
|
@ -22,7 +22,6 @@ add_llvm_library(LLVMCore
|
||||
DiagnosticInfo.cpp
|
||||
DiagnosticPrinter.cpp
|
||||
Dominators.cpp
|
||||
FPEnv.cpp
|
||||
Function.cpp
|
||||
GVMaterializer.cpp
|
||||
Globals.cpp
|
||||
|
@ -1,78 +0,0 @@
|
||||
//===-- FPEnv.cpp ---- FP Environment -------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// @file
|
||||
/// This file contains the implementations of entities that describe floating
|
||||
/// point environment.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/IR/FPEnv.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
Optional<fp::RoundingMode> StrToRoundingMode(StringRef RoundingArg) {
|
||||
// For dynamic rounding mode, we use round to nearest but we will set the
|
||||
// 'exact' SDNodeFlag so that the value will not be rounded.
|
||||
return StringSwitch<Optional<fp::RoundingMode>>(RoundingArg)
|
||||
.Case("round.dynamic", fp::rmDynamic)
|
||||
.Case("round.tonearest", fp::rmToNearest)
|
||||
.Case("round.downward", fp::rmDownward)
|
||||
.Case("round.upward", fp::rmUpward)
|
||||
.Case("round.towardzero", fp::rmTowardZero)
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
Optional<StringRef> RoundingModeToStr(fp::RoundingMode UseRounding) {
|
||||
Optional<StringRef> RoundingStr = None;
|
||||
switch (UseRounding) {
|
||||
case fp::rmDynamic:
|
||||
RoundingStr = "round.dynamic";
|
||||
break;
|
||||
case fp::rmToNearest:
|
||||
RoundingStr = "round.tonearest";
|
||||
break;
|
||||
case fp::rmDownward:
|
||||
RoundingStr = "round.downward";
|
||||
break;
|
||||
case fp::rmUpward:
|
||||
RoundingStr = "round.upward";
|
||||
break;
|
||||
case fp::rmTowardZero:
|
||||
RoundingStr = "round.towardzero";
|
||||
break;
|
||||
}
|
||||
return RoundingStr;
|
||||
}
|
||||
|
||||
Optional<fp::ExceptionBehavior> StrToExceptionBehavior(StringRef ExceptionArg) {
|
||||
return StringSwitch<Optional<fp::ExceptionBehavior>>(ExceptionArg)
|
||||
.Case("fpexcept.ignore", fp::ebIgnore)
|
||||
.Case("fpexcept.maytrap", fp::ebMayTrap)
|
||||
.Case("fpexcept.strict", fp::ebStrict)
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
Optional<StringRef> ExceptionBehaviorToStr(fp::ExceptionBehavior UseExcept) {
|
||||
Optional<StringRef> ExceptStr = None;
|
||||
switch (UseExcept) {
|
||||
case fp::ebStrict:
|
||||
ExceptStr = "fpexcept.strict";
|
||||
break;
|
||||
case fp::ebIgnore:
|
||||
ExceptStr = "fpexcept.ignore";
|
||||
break;
|
||||
case fp::ebMayTrap:
|
||||
ExceptStr = "fpexcept.maytrap";
|
||||
break;
|
||||
}
|
||||
return ExceptStr;
|
||||
}
|
||||
|
||||
}
|
@ -102,7 +102,8 @@ Value *InstrProfIncrementInst::getStep() const {
|
||||
return ConstantInt::get(Type::getInt64Ty(Context), 1);
|
||||
}
|
||||
|
||||
Optional<fp::RoundingMode> ConstrainedFPIntrinsic::getRoundingMode() const {
|
||||
Optional<ConstrainedFPIntrinsic::RoundingMode>
|
||||
ConstrainedFPIntrinsic::getRoundingMode() const {
|
||||
unsigned NumOperands = getNumArgOperands();
|
||||
Metadata *MD =
|
||||
cast<MetadataAsValue>(getArgOperand(NumOperands - 2))->getMetadata();
|
||||
@ -111,7 +112,43 @@ Optional<fp::RoundingMode> ConstrainedFPIntrinsic::getRoundingMode() const {
|
||||
return StrToRoundingMode(cast<MDString>(MD)->getString());
|
||||
}
|
||||
|
||||
Optional<fp::ExceptionBehavior>
|
||||
Optional<ConstrainedFPIntrinsic::RoundingMode>
|
||||
ConstrainedFPIntrinsic::StrToRoundingMode(StringRef RoundingArg) {
|
||||
// For dynamic rounding mode, we use round to nearest but we will set the
|
||||
// 'exact' SDNodeFlag so that the value will not be rounded.
|
||||
return StringSwitch<Optional<RoundingMode>>(RoundingArg)
|
||||
.Case("round.dynamic", rmDynamic)
|
||||
.Case("round.tonearest", rmToNearest)
|
||||
.Case("round.downward", rmDownward)
|
||||
.Case("round.upward", rmUpward)
|
||||
.Case("round.towardzero", rmTowardZero)
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
Optional<StringRef>
|
||||
ConstrainedFPIntrinsic::RoundingModeToStr(RoundingMode UseRounding) {
|
||||
Optional<StringRef> RoundingStr = None;
|
||||
switch (UseRounding) {
|
||||
case ConstrainedFPIntrinsic::rmDynamic:
|
||||
RoundingStr = "round.dynamic";
|
||||
break;
|
||||
case ConstrainedFPIntrinsic::rmToNearest:
|
||||
RoundingStr = "round.tonearest";
|
||||
break;
|
||||
case ConstrainedFPIntrinsic::rmDownward:
|
||||
RoundingStr = "round.downward";
|
||||
break;
|
||||
case ConstrainedFPIntrinsic::rmUpward:
|
||||
RoundingStr = "round.upward";
|
||||
break;
|
||||
case ConstrainedFPIntrinsic::rmTowardZero:
|
||||
RoundingStr = "round.towardzero";
|
||||
break;
|
||||
}
|
||||
return RoundingStr;
|
||||
}
|
||||
|
||||
Optional<ConstrainedFPIntrinsic::ExceptionBehavior>
|
||||
ConstrainedFPIntrinsic::getExceptionBehavior() const {
|
||||
unsigned NumOperands = getNumArgOperands();
|
||||
Metadata *MD =
|
||||
@ -121,6 +158,32 @@ ConstrainedFPIntrinsic::getExceptionBehavior() const {
|
||||
return StrToExceptionBehavior(cast<MDString>(MD)->getString());
|
||||
}
|
||||
|
||||
Optional<ConstrainedFPIntrinsic::ExceptionBehavior>
|
||||
ConstrainedFPIntrinsic::StrToExceptionBehavior(StringRef ExceptionArg) {
|
||||
return StringSwitch<Optional<ExceptionBehavior>>(ExceptionArg)
|
||||
.Case("fpexcept.ignore", ebIgnore)
|
||||
.Case("fpexcept.maytrap", ebMayTrap)
|
||||
.Case("fpexcept.strict", ebStrict)
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
Optional<StringRef>
|
||||
ConstrainedFPIntrinsic::ExceptionBehaviorToStr(ExceptionBehavior UseExcept) {
|
||||
Optional<StringRef> ExceptStr = None;
|
||||
switch (UseExcept) {
|
||||
case ConstrainedFPIntrinsic::ebStrict:
|
||||
ExceptStr = "fpexcept.strict";
|
||||
break;
|
||||
case ConstrainedFPIntrinsic::ebIgnore:
|
||||
ExceptStr = "fpexcept.ignore";
|
||||
break;
|
||||
case ConstrainedFPIntrinsic::ebMayTrap:
|
||||
ExceptStr = "fpexcept.maytrap";
|
||||
break;
|
||||
}
|
||||
return ExceptStr;
|
||||
}
|
||||
|
||||
bool ConstrainedFPIntrinsic::isUnaryOp() const {
|
||||
switch (getIntrinsicID()) {
|
||||
default:
|
||||
|
@ -242,52 +242,52 @@ TEST_F(IRBuilderTest, ConstrainedFP) {
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
ASSERT_TRUE(isa<ConstrainedFPIntrinsic>(V));
|
||||
auto *CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
EXPECT_EQ(fp::ebStrict, CII->getExceptionBehavior());
|
||||
EXPECT_EQ(fp::rmDynamic, CII->getRoundingMode());
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(fp::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(fp::rmUpward);
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmUpward);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
EXPECT_EQ(fp::ebIgnore, CII->getExceptionBehavior());
|
||||
EXPECT_EQ(CII->getRoundingMode(), fp::rmUpward);
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmUpward);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(fp::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(fp::rmToNearest);
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmToNearest);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
EXPECT_EQ(fp::ebIgnore, CII->getExceptionBehavior());
|
||||
EXPECT_EQ(fp::rmToNearest, CII->getRoundingMode());
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmToNearest);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(fp::ebMayTrap);
|
||||
Builder.setDefaultConstrainedRounding(fp::rmDownward);
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebMayTrap);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmDownward);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
EXPECT_EQ(fp::ebMayTrap, CII->getExceptionBehavior());
|
||||
EXPECT_EQ(fp::rmDownward, CII->getRoundingMode());
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebMayTrap);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDownward);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(fp::ebStrict);
|
||||
Builder.setDefaultConstrainedRounding(fp::rmTowardZero);
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebStrict);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmTowardZero);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
EXPECT_EQ(fp::ebStrict, CII->getExceptionBehavior());
|
||||
EXPECT_EQ(fp::rmTowardZero, CII->getRoundingMode());
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebStrict);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmTowardZero);
|
||||
|
||||
Builder.setDefaultConstrainedExcept(fp::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(fp::rmDynamic);
|
||||
Builder.setDefaultConstrainedExcept(ConstrainedFPIntrinsic::ebIgnore);
|
||||
Builder.setDefaultConstrainedRounding(ConstrainedFPIntrinsic::rmDynamic);
|
||||
V = Builder.CreateFAdd(V, V);
|
||||
CII = cast<ConstrainedFPIntrinsic>(V);
|
||||
EXPECT_EQ(fp::ebIgnore, CII->getExceptionBehavior());
|
||||
EXPECT_EQ(fp::rmDynamic, CII->getRoundingMode());
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebIgnore);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDynamic);
|
||||
|
||||
// Now override the defaults.
|
||||
Call = Builder.CreateConstrainedFPBinOp(
|
||||
Intrinsic::experimental_constrained_fadd, V, V, nullptr, "", nullptr,
|
||||
fp::rmDownward, fp::ebMayTrap);
|
||||
ConstrainedFPIntrinsic::rmDownward, ConstrainedFPIntrinsic::ebMayTrap);
|
||||
CII = cast<ConstrainedFPIntrinsic>(Call);
|
||||
EXPECT_EQ(CII->getIntrinsicID(), Intrinsic::experimental_constrained_fadd);
|
||||
EXPECT_EQ(fp::ebMayTrap, CII->getExceptionBehavior());
|
||||
EXPECT_EQ(fp::rmDownward, CII->getRoundingMode());
|
||||
ASSERT_TRUE(CII->getExceptionBehavior() == ConstrainedFPIntrinsic::ebMayTrap);
|
||||
ASSERT_TRUE(CII->getRoundingMode() == ConstrainedFPIntrinsic::rmDownward);
|
||||
|
||||
Builder.CreateRetVoid();
|
||||
EXPECT_FALSE(verifyModule(*M));
|
||||
|
Loading…
x
Reference in New Issue
Block a user