[PATCH] IR: Add ConstantFP::getNaN()
Tom Stellard
thomas.stellard at amd.com
Thu Mar 19 15:06:35 PDT 2015
This is a wrapper around APFloat::getNaN().
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8469
Files:
include/llvm/IR/Constants.h
lib/IR/Constants.cpp
Index: include/llvm/IR/Constants.h
===================================================================
--- include/llvm/IR/Constants.h
+++ include/llvm/IR/Constants.h
@@ -251,6 +251,7 @@
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);
Index: lib/IR/Constants.cpp
===================================================================
--- lib/IR/Constants.cpp
+++ lib/IR/Constants.cpp
@@ -663,6 +663,17 @@
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);
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8469.22313.patch
Type: text/x-patch
Size: 1323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150319/146e4882/attachment.bin>
More information about the llvm-commits
mailing list