|
@@ -1931,10 +1931,17 @@ public:
|
|
|
|
|
|
Value *CreateFPTrunc(Value *V, Type *DestTy,
|
|
|
const Twine &Name = "") {
|
|
|
+ if (IsFPConstrained)
|
|
|
+ return CreateConstrainedFPCast(
|
|
|
+ Intrinsic::experimental_constrained_fptrunc, V, DestTy, nullptr,
|
|
|
+ Name);
|
|
|
return CreateCast(Instruction::FPTrunc, V, DestTy, Name);
|
|
|
}
|
|
|
|
|
|
Value *CreateFPExt(Value *V, Type *DestTy, const Twine &Name = "") {
|
|
|
+ if (IsFPConstrained)
|
|
|
+ return CreateConstrainedFPCast(Intrinsic::experimental_constrained_fpext,
|
|
|
+ V, DestTy, nullptr, Name);
|
|
|
return CreateCast(Instruction::FPExt, V, DestTy, Name);
|
|
|
}
|
|
|
|
|
@@ -2046,6 +2053,29 @@ public:
|
|
|
return Insert(CastInst::CreateFPCast(V, DestTy), Name);
|
|
|
}
|
|
|
|
|
|
+ CallInst *CreateConstrainedFPCast(
|
|
|
+ Intrinsic::ID ID, Value *V, Type *DestTy,
|
|
|
+ Instruction *FMFSource = nullptr, const Twine &Name = "",
|
|
|
+ MDNode *FPMathTag = nullptr,
|
|
|
+ Optional<ConstrainedFPIntrinsic::RoundingMode> Rounding = None,
|
|
|
+ Optional<ConstrainedFPIntrinsic::ExceptionBehavior> Except = None) {
|
|
|
+ Value *RoundingV = getConstrainedFPRounding(Rounding);
|
|
|
+ Value *ExceptV = getConstrainedFPExcept(Except);
|
|
|
+
|
|
|
+ FastMathFlags UseFMF = FMF;
|
|
|
+ if (FMFSource)
|
|
|
+ UseFMF = FMFSource->getFastMathFlags();
|
|
|
+
|
|
|
+ CallInst *C;
|
|
|
+ if (ID == Intrinsic::experimental_constrained_fpext)
|
|
|
+ C = CreateIntrinsic(ID, {DestTy, V->getType()}, {V, ExceptV}, nullptr,
|
|
|
+ Name);
|
|
|
+ else
|
|
|
+ C = CreateIntrinsic(ID, {DestTy, V->getType()}, {V, RoundingV, ExceptV},
|
|
|
+ nullptr, Name);
|
|
|
+ return cast<CallInst>(setFPAttrs(C, FPMathTag, UseFMF));
|
|
|
+ }
|
|
|
+
|
|
|
// Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
|
|
|
// compile time error, instead of converting the string to bool for the
|
|
|
// isSigned parameter.
|