1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

IR: Add ConstantFP::getNaN()

This is a wrapper around APFloat::getNaN().

llvm-svn: 235332
This commit is contained in:
Tom Stellard 2015-04-20 19:38:24 +00:00
parent 13554f3cb5
commit 1b7911183d
2 changed files with 12 additions and 0 deletions

View File

@ -251,6 +251,7 @@ public:
static Constant *get(Type* Ty, double V); static Constant *get(Type* Ty, double V);
static Constant *get(Type* Ty, StringRef Str); static Constant *get(Type* Ty, StringRef Str);
static ConstantFP *get(LLVMContext &Context, const APFloat &V); static ConstantFP *get(LLVMContext &Context, const APFloat &V);
static Constant *getNaN(Type *Ty, bool Negative = false, unsigned type = 0);
static Constant *getNegativeZero(Type *Ty); static Constant *getNegativeZero(Type *Ty);
static Constant *getInfinity(Type *Ty, bool Negative = false); static Constant *getInfinity(Type *Ty, bool Negative = false);

View File

@ -663,6 +663,17 @@ Constant *ConstantFP::get(Type *Ty, StringRef Str) {
return C; return C;
} }
Constant *ConstantFP::getNaN(Type *Ty, bool Negative, unsigned Type) {
const fltSemantics &Semantics = *TypeToFloatSemantics(Ty->getScalarType());
APFloat NaN = APFloat::getNaN(Semantics, Negative, Type);
Constant *C = get(Ty->getContext(), NaN);
if (VectorType *VTy = dyn_cast<VectorType>(Ty))
return ConstantVector::getSplat(VTy->getNumElements(), C);
return C;
}
Constant *ConstantFP::getNegativeZero(Type *Ty) { Constant *ConstantFP::getNegativeZero(Type *Ty) {
const fltSemantics &Semantics = *TypeToFloatSemantics(Ty->getScalarType()); const fltSemantics &Semantics = *TypeToFloatSemantics(Ty->getScalarType());
APFloat NegZero = APFloat::getZero(Semantics, /*Negative=*/true); APFloat NegZero = APFloat::getZero(Semantics, /*Negative=*/true);