[PATCH] D55460: APFloat: allow 64-bit of payload
JF Bastien via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 7 15:54:55 PST 2018
jfb created this revision.
jfb added reviewers: scanon, rjmccall.
Herald added subscribers: llvm-commits, kristina, dexonsmith, jkorous.
The APFloat and Constant APIs taking an APInt allow arbitrary payloads, and that's great. There's a convenience API which takes an unsigned, and that's silly because it then directly creates a 64-bit APInt. Just change it to 64-bits directly.
Repository:
rL LLVM
https://reviews.llvm.org/D55460
Files:
include/llvm/ADT/APFloat.h
include/llvm/IR/Constants.h
lib/IR/Constants.cpp
Index: lib/IR/Constants.cpp
===================================================================
--- lib/IR/Constants.cpp
+++ lib/IR/Constants.cpp
@@ -719,9 +719,9 @@
return C;
}
-Constant *ConstantFP::getNaN(Type *Ty, bool Negative, unsigned Type) {
+Constant *ConstantFP::getNaN(Type *Ty, bool Negative, uint64_t Payload) {
const fltSemantics &Semantics = *TypeToFloatSemantics(Ty->getScalarType());
- APFloat NaN = APFloat::getNaN(Semantics, Negative, Type);
+ APFloat NaN = APFloat::getNaN(Semantics, Negative, Payload);
Constant *C = get(Ty->getContext(), NaN);
if (VectorType *VTy = dyn_cast<VectorType>(Ty))
Index: include/llvm/IR/Constants.h
===================================================================
--- include/llvm/IR/Constants.h
+++ include/llvm/IR/Constants.h
@@ -290,7 +290,7 @@
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 *getNaN(Type *Ty, bool Negative = false, uint64_t Payload = 0);
static Constant *getNegativeZero(Type *Ty);
static Constant *getInfinity(Type *Ty, bool Negative = false);
Index: include/llvm/ADT/APFloat.h
===================================================================
--- include/llvm/ADT/APFloat.h
+++ include/llvm/ADT/APFloat.h
@@ -870,13 +870,13 @@
/// Factory for NaN values.
///
/// \param Negative - True iff the NaN generated should be negative.
- /// \param type - The unspecified fill bits for creating the NaN, 0 by
+ /// \param payload - The unspecified fill bits for creating the NaN, 0 by
/// default. The value is truncated as necessary.
static APFloat getNaN(const fltSemantics &Sem, bool Negative = false,
- unsigned type = 0) {
- if (type) {
- APInt fill(64, type);
- return getQNaN(Sem, Negative, &fill);
+ uint64_t payload = 0) {
+ if (payload) {
+ APInt intPayload(64, payload);
+ return getQNaN(Sem, Negative, &intPayload);
} else {
return getQNaN(Sem, Negative, nullptr);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55460.177347.patch
Type: text/x-patch
Size: 2154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181207/439ab9ab/attachment.bin>
More information about the llvm-commits
mailing list