diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2015-04-20 19:38:24 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2015-04-20 19:38:24 +0000 |
commit | 67246d137de9b9d711d1c972eb918f840a8869ab (patch) | |
tree | 1b771a29e191e10d19342350aa9e0a868a7320cd /llvm/lib/IR/Constants.cpp | |
parent | 9928a909c6d91e808ad625031a0e2e18bac6513d (diff) | |
download | bcm5719-llvm-67246d137de9b9d711d1c972eb918f840a8869ab.tar.gz bcm5719-llvm-67246d137de9b9d711d1c972eb918f840a8869ab.zip |
IR: Add ConstantFP::getNaN()
This is a wrapper around APFloat::getNaN().
llvm-svn: 235332
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 3f8d1f1ca6a..20a5206c230 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -663,6 +663,17 @@ Constant *ConstantFP::get(Type *Ty, StringRef Str) { 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) { const fltSemantics &Semantics = *TypeToFloatSemantics(Ty->getScalarType()); APFloat NegZero = APFloat::getZero(Semantics, /*Negative=*/true); |