summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2015-04-20 19:38:24 +0000
committerTom Stellard <thomas.stellard@amd.com>2015-04-20 19:38:24 +0000
commit67246d137de9b9d711d1c972eb918f840a8869ab (patch)
tree1b771a29e191e10d19342350aa9e0a868a7320cd /llvm
parent9928a909c6d91e808ad625031a0e2e18bac6513d (diff)
downloadbcm5719-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')
-rw-r--r--llvm/include/llvm/IR/Constants.h1
-rw-r--r--llvm/lib/IR/Constants.cpp11
2 files changed, 12 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index 70437e66cbf..a16bf1ff092 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -251,6 +251,7 @@ public:
static Constant *get(Type* Ty, double V);
static Constant *get(Type* Ty, StringRef Str);
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 *getInfinity(Type *Ty, bool Negative = false);
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);
OpenPOWER on IntegriCloud