136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines//===- llvm/ADT/APFloat.h - Arbitrary Precision Floating Point ---*- C++ -*-==// 2b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner// 3b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner// The LLVM Compiler Infrastructure 4b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner// 57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source 67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details. 7b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner// 8b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner//===----------------------------------------------------------------------===// 97f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 107f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// \file 117f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// \brief 127f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// This file declares a class to represent arbitrary precision floating point 137f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// values and provide a variety of arithmetic operations on them. 147f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 15b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner//===----------------------------------------------------------------------===// 16b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner 17674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#ifndef LLVM_ADT_APFLOAT_H 18674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#define LLVM_ADT_APFLOAT_H 19b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner 20b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner#include "llvm/ADT/APInt.h" 21b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner 22b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattnernamespace llvm { 23b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner 24fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanstruct fltSemantics; 25fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanclass APSInt; 26fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanclass StringRef; 27fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 287f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Enum that represents what fraction of the LSB truncated bits of an fp number 297f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// represent. 307f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 317f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// This essentially combines the roles of guard and sticky bits. 32fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanenum lostFraction { // Example of truncated bits: 33fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lfExactlyZero, // 000000 34fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lfLessThanHalf, // 0xxxxx x's not all zero 35fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lfExactlyHalf, // 100000 36fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lfMoreThanHalf // 1xxxxx x's not all zero 37fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman}; 38fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 397f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// \brief A self-contained host- and target-independent arbitrary-precision 407f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// floating-point software implementation. 417f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 427f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// APFloat uses bignum integer arithmetic as provided by static functions in 437f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// the APInt class. The library will work with bignum integers whose parts are 447f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// any unsigned type at least 16 bits wide, but 64 bits is recommended. 457f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 467f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Written for clarity rather than speed, in particular with a view to use in 477f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// the front-end of a cross compiler so that target arithmetic can be correctly 487f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// performed on the host. Performance should nonetheless be reasonable, 497f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// particularly for its intended use. It may be useful as a base 507f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// implementation for a run-time library during development of a faster 517f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// target-specific one. 527f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 537f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// All 5 rounding modes in the IEEE-754R draft are handled correctly for all 547f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// implemented operations. Currently implemented operations are add, subtract, 557f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// multiply, divide, fused-multiply-add, conversion-to-float, 567f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// conversion-to-integer and conversion-from-integer. New rounding modes 577f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// (e.g. away from zero) can be added with three or four lines of code. 587f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 597f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Four formats are built-in: IEEE single precision, double precision, 607f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// quadruple precision, and x87 80-bit extended double (when operating with 617f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// full extended precision). Adding a new format that obeys IEEE semantics 627f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// only requires adding two lines of code: a declaration and definition of the 637f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// format. 647f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 657f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// All operations return the status of that operation as an exception bit-mask, 667f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// so multiple operations can be done consecutively with their results or-ed 677f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// together. The returned status can be useful for compiler diagnostics; e.g., 687f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// inexact, underflow and overflow can be easily diagnosed on constant folding, 697f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// and compiler optimizers can determine what exceptions would be raised by 707f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// folding operations and optimize, or perhaps not optimize, accordingly. 717f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 727f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// At present, underflow tininess is detected after rounding; it should be 737f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// straight forward to add support for the before-rounding case too. 747f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 757f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// The library reads hexadecimal floating point numbers as per C99, and 767f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// correctly rounds if necessary according to the specified rounding mode. 777f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Syntax is required to have been validated by the caller. It also converts 787f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// floating point numbers to hexadecimal text as per the C99 %a and %A 797f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// conversions. The output precision (or alternatively the natural minimal 807f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// precision) can be specified; if the requested precision is less than the 817f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// natural precision the output is correctly rounded for the specified rounding 827f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// mode. 837f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 847f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// It also reads decimal floating point numbers and correctly rounds according 857f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// to the specified rounding mode. 867f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 877f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Conversion to decimal text is not currently implemented. 887f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 897f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Non-zero finite numbers are represented internally as a sign bit, a 16-bit 907f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// signed exponent, and the significand as an array of integer parts. After 917f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// normalization of a number of precision P the exponent is within the range of 927f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// the format, and if the number is not denormal the P-th bit of the 937f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// significand is set as an explicit integer bit. For denormals the most 947f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// significant bit is shifted right so that the exponent is maintained at the 957f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// format's minimum, so that the smallest denormal has just the least 967f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// significant bit of the significand set. The sign of zeroes and infinities 977f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// is significant; the exponent and significand of such numbers is not stored, 987f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// but has a known implicit (deterministic) value: 0 for the significands, 0 997f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// for zero exponent, all 1 bits for infinity exponent. For NaNs the sign and 1007f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// significand are deterministic, although not really meaningful, and preserved 1017f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// in non-conversion operations. The exponent is implicitly all 1 bits. 1027f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 1037f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// APFloat does not provide any exception handling beyond default exception 1047f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// handling. We represent Signaling NaNs via IEEE-754R 2008 6.2.1 should clause 1057f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// by encoding Signaling NaNs with the first bit of its trailing significand as 1067f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 0. 1077f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 1087f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// TODO 1097f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// ==== 1107f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 1117f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Some features that may or may not be worth adding: 1127f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 1137f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Binary to decimal conversion (hard). 1147f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 1157f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// Optional ability to detect underflow tininess before rounding. 1167f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 1177f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// New formats: x87 in single and double precision mode (IEEE apart from 1187f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// extended exponent range) (hard). 1197f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 1207ffc854002282b0a6fd018d967a6def971dc341eMichael Gottesman/// New operations: sqrt, IEEE remainder, C90 fmod, nexttoward. 1217f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 122fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanclass APFloat { 123fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanpublic: 124fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 125db045ab1532469551a56e5811e684920a6f7a10cMichael Gottesman /// A signed type to represent a floating point numbers unbiased exponent. 126db045ab1532469551a56e5811e684920a6f7a10cMichael Gottesman typedef signed short ExponentType; 127db045ab1532469551a56e5811e684920a6f7a10cMichael Gottesman 1287f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Floating Point Semantics. 1297f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 1307f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 131fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static const fltSemantics IEEEhalf; 132fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static const fltSemantics IEEEsingle; 133fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static const fltSemantics IEEEdouble; 134fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static const fltSemantics IEEEquad; 135fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static const fltSemantics PPCDoubleDouble; 136fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static const fltSemantics x87DoubleExtended; 1377f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 1387f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// A Pseudo fltsemantic used to construct APFloats that cannot conflict with 1397f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// anything real. 140fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static const fltSemantics Bogus; 141fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 1422e2922cd90922eaf3736421bd0ad4331f89f3e75Michael Gottesman /// @} 1432e2922cd90922eaf3736421bd0ad4331f89f3e75Michael Gottesman 144fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static unsigned int semanticsPrecision(const fltSemantics &); 145fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 1467f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// IEEE-754R 5.11: Floating Point Comparison Relations. 147fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman enum cmpResult { 148fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman cmpLessThan, 149fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman cmpEqual, 150fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman cmpGreaterThan, 151fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman cmpUnordered 152b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner }; 153b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner 1547f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// IEEE-754R 4.3: Rounding-direction attributes. 155fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman enum roundingMode { 156fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman rmNearestTiesToEven, 157fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman rmTowardPositive, 158fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman rmTowardNegative, 159fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman rmTowardZero, 160fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman rmNearestTiesToAway 161fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman }; 162e12b73816b50bbe2cc54b8005d86c95413b4f465John McCall 1637f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// IEEE-754R 7: Default exception handling. 1647f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// 1657f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// opUnderflow or opOverflow are always returned or-ed with opInexact. 166fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman enum opStatus { 167fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opOK = 0x00, 168fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opInvalidOp = 0x01, 169fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opDivByZero = 0x02, 170fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opOverflow = 0x04, 171fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opUnderflow = 0x08, 172fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opInexact = 0x10 173fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman }; 174e12b73816b50bbe2cc54b8005d86c95413b4f465John McCall 1757f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Category of internally-represented number. 176fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman enum fltCategory { 177fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman fcInfinity, 178fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman fcNaN, 179fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman fcNormal, 180fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman fcZero 181fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman }; 1823a54b3dc87a581c203b18050b4f787b4ca28a12cMisha Brukman 1837f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Convenience enum used to construct an uninitialized APFloat. 184fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman enum uninitializedTag { 185fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman uninitialized 186b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner }; 1873a9b71434cda6f66d65a031effec1bbe58e1dda3Rafael Espindola 1887f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Constructors 1897f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 1907f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 191fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APFloat(const fltSemantics &); // Default construct to 0.0 192fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APFloat(const fltSemantics &, StringRef); 193fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APFloat(const fltSemantics &, integerPart); 194fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APFloat(const fltSemantics &, uninitializedTag); 195fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APFloat(const fltSemantics &, const APInt &); 196fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman explicit APFloat(double d); 197fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman explicit APFloat(float f); 198fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APFloat(const APFloat &); 19936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines APFloat(APFloat &&); 200fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman ~APFloat(); 201fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2027f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 2037f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 204abff3aa8217049cffe6da77c91e510c66b8c2313Manuel Klimek /// \brief Returns whether this instance allocated memory. 205abff3aa8217049cffe6da77c91e510c66b8c2313Manuel Klimek bool needsCleanup() const { return partCount() > 1; } 206abff3aa8217049cffe6da77c91e510c66b8c2313Manuel Klimek 2077f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Convenience "constructors" 2087f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 2097f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 2108a70f5815dda98d23f0bbf519532703886159cdaMichael Gottesman /// Factory for Positive and Negative Zero. 2118a70f5815dda98d23f0bbf519532703886159cdaMichael Gottesman /// 2128a70f5815dda98d23f0bbf519532703886159cdaMichael Gottesman /// \param Negative True iff the number should be negative. 213fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getZero(const fltSemantics &Sem, bool Negative = false) { 214fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman APFloat Val(Sem, uninitialized); 215fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman Val.makeZero(Negative); 216fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman return Val; 217fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } 2188a70f5815dda98d23f0bbf519532703886159cdaMichael Gottesman 2198a70f5815dda98d23f0bbf519532703886159cdaMichael Gottesman /// Factory for Positive and Negative Infinity. 2208a70f5815dda98d23f0bbf519532703886159cdaMichael Gottesman /// 2218a70f5815dda98d23f0bbf519532703886159cdaMichael Gottesman /// \param Negative True iff the number should be negative. 222fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getInf(const fltSemantics &Sem, bool Negative = false) { 223fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman APFloat Val(Sem, uninitialized); 224fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman Val.makeInf(Negative); 225fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman return Val; 226fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } 227fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2287f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Factory for QNaN values. 229fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 230fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param Negative - True iff the NaN generated should be negative. 231fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param type - The unspecified fill bits for creating the NaN, 0 by 232fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// default. The value is truncated as necessary. 233fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getNaN(const fltSemantics &Sem, bool Negative = false, 234fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman unsigned type = 0) { 235fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman if (type) { 236fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt fill(64, type); 237fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman return getQNaN(Sem, Negative, &fill); 238fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } else { 239dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines return getQNaN(Sem, Negative, nullptr); 240fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } 241fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } 242fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2437f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Factory for QNaN values. 244fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getQNaN(const fltSemantics &Sem, bool Negative = false, 245dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines const APInt *payload = nullptr) { 246fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman return makeNaN(Sem, false, Negative, payload); 247fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } 248fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2497f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Factory for SNaN values. 250fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getSNaN(const fltSemantics &Sem, bool Negative = false, 251dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines const APInt *payload = nullptr) { 252fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman return makeNaN(Sem, true, Negative, payload); 253fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } 254fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2557f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Returns the largest finite number in the given semantics. 256fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 257fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param Negative - True iff the number should be negative 258fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getLargest(const fltSemantics &Sem, bool Negative = false); 259fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2607f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Returns the smallest (by magnitude) finite number in the given semantics. 2617f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Might be denormalized, which implies a relative loss of precision. 262fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 263fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param Negative - True iff the number should be negative 264fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getSmallest(const fltSemantics &Sem, bool Negative = false); 265fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2667f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Returns the smallest (by magnitude) normalized finite number in the given 2677f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// semantics. 268fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 269fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param Negative - True iff the number should be negative 270fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getSmallestNormalized(const fltSemantics &Sem, 271fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool Negative = false); 272fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2737f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Returns a float which is bitcasted from an all one value int. 274fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 275fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param BitWidth - Select float type 276fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param isIEEE - If 128 bit number, select between PPC and IEEE 277fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat getAllOnesValue(unsigned BitWidth, bool isIEEE = false); 278fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2797f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 2807f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 2817f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Used to insert APFloat objects, or objects that contain APFloat objects, 2827f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// into FoldingSets. 283fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void Profile(FoldingSetNodeID &NID) const; 284fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2857f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \brief Used by the Bitcode serializer to emit APInts to Bitcode. 286fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void Emit(Serializer &S) const; 287fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2887f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \brief Used by the Bitcode deserializer to deserialize APInts. 289fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat ReadVal(Deserializer &D); 290fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 2917f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Arithmetic 2927f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 2937f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 294fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus add(const APFloat &, roundingMode); 295fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus subtract(const APFloat &, roundingMode); 296fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus multiply(const APFloat &, roundingMode); 297fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus divide(const APFloat &, roundingMode); 2987f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// IEEE remainder. 299fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus remainder(const APFloat &); 3007f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// C fmod, or llvm frem. 301fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus mod(const APFloat &, roundingMode); 302fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode); 303fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus roundToIntegral(roundingMode); 304964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman /// IEEE-754R 5.3.1: nextUp/nextDown. 305964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman opStatus next(bool nextDown); 306fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 307d3d03fe758d4ee93ea225c6740742eb56b6dca3bMichael Gottesman /// @} 308d3d03fe758d4ee93ea225c6740742eb56b6dca3bMichael Gottesman 3097f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Sign operations. 3107f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 3117f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 312fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void changeSign(); 313fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void clearSign(); 314fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void copySign(const APFloat &); 315fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 3167f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 3177f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 3187f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Conversions 3197f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 3207f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 321fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convert(const fltSemantics &, roundingMode, bool *); 322fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertToInteger(integerPart *, unsigned int, bool, roundingMode, 323fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool *) const; 324fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertToInteger(APSInt &, roundingMode, bool *) const; 325fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertFromAPInt(const APInt &, bool, roundingMode); 326fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int, 327fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool, roundingMode); 328fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, 329fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool, roundingMode); 330fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertFromString(StringRef, roundingMode); 331fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt bitcastToAPInt() const; 332fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman double convertToDouble() const; 333fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman float convertToFloat() const; 334fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 3357f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 3367f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 3377f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// The definition of equality is not straightforward for floating point, so 3387f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// we won't use operator==. Use one of the following, or write whatever it 3397f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// is you really mean. 340fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool operator==(const APFloat &) const LLVM_DELETED_FUNCTION; 341fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 3427f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// IEEE comparison with another floating point number (NaNs compare 3437f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// unordered, 0==-0). 344fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman cmpResult compare(const APFloat &) const; 345fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 3467f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Bitwise comparison for equality (QNaNs compare equal, 0!=-0). 347fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool bitwiseIsEqual(const APFloat &) const; 348fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 3497f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Write out a hexadecimal representation of the floating point value to DST, 3507f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// which must be of sufficient size, in the C99 form [-]0xh.hhhhp[+-]d. 3517f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Return the number of characters written, excluding the terminating NUL. 352fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman unsigned int convertToHexString(char *dst, unsigned int hexDigits, 353fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool upperCase, roundingMode) const; 354fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 355b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// \name IEEE-754R 5.7.2 General operations. 356b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// @{ 357b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 358b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// IEEE-754R isSignMinus: Returns true if and only if the current value is 359b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// negative. 360b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// 361b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// This applies to zeros and NaNs as well. 362b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman bool isNegative() const { return sign; } 363b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 364b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// IEEE-754R isNormal: Returns true if and only if the current value is normal. 365b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// 366b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// This implies that the current value of the float is not zero, subnormal, 367b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// infinite, or NaN following the definition of normality from IEEE-754R. 368a1694e578492c90c246e59ec861c1a34f8ad7b4dMichael Gottesman bool isNormal() const { return !isDenormal() && isFiniteNonZero(); } 369b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 370b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// Returns true if and only if the current value is zero, subnormal, or 371b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// normal. 372b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// 373b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// This means that the value is not infinite or NaN. 374b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman bool isFinite() const { return !isNaN() && !isInfinity(); } 375b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 376b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// Returns true if and only if the float is plus or minus zero. 377b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman bool isZero() const { return category == fcZero; } 378b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 379b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// IEEE-754R isSubnormal(): Returns true if and only if the float is a 380b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// denormal. 381b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman bool isDenormal() const; 382b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 383b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// IEEE-754R isInfinite(): Returns true if and only if the float is infinity. 384b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman bool isInfinity() const { return category == fcInfinity; } 385b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 386b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// Returns true if and only if the float is a quiet or signaling NaN. 387b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman bool isNaN() const { return category == fcNaN; } 388b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 389b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// Returns true if and only if the float is a signaling NaN. 390b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman bool isSignaling() const; 391b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 392b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman /// @} 393b30718af1ada4b68c7c44e3dcbf4891efd5e3ba1Michael Gottesman 3947f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Simple Queries 3957f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 3967f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 397fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman fltCategory getCategory() const { return category; } 398fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman const fltSemantics &getSemantics() const { return *semantics; } 399fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool isNonZero() const { return category != fcZero; } 4007032c883cdf8da579fbf9bf499d36a711eef676fMichael Gottesman bool isFiniteNonZero() const { return isFinite() && !isZero(); } 401fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool isPosZero() const { return isZero() && !isNegative(); } 402fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool isNegZero() const { return isZero() && isNegative(); } 403fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 404c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman /// Returns true if and only if the number has the smallest possible non-zero 405c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman /// magnitude in the current semantics. 406c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman bool isSmallest() const; 407c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman 408c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman /// Returns true if and only if the number has the largest possible finite 409c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman /// magnitude in the current semantics. 410c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman bool isLargest() const; 411c896020dd8d6c2f25f5bf7eb9191fd4e72407015Michael Gottesman 4127f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 4137f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 414fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APFloat &operator=(const APFloat &); 41536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines APFloat &operator=(APFloat &&); 416fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 417fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \brief Overload to compute a hash code for an APFloat value. 418fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 419fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// Note that the use of hash codes for floating point values is in general 420fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// frought with peril. Equality is hard to define for these values. For 421fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// example, should negative and positive zero hash to different codes? Are 422fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// they equal or not? This hash value implementation specifically 423fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// emphasizes producing different codes for different inputs in order to 424fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// be used in canonicalization and memoization. As such, equality is 425fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// bitwiseIsEqual, and 0 != -0. 426fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman friend hash_code hash_value(const APFloat &Arg); 427fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 428fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// Converts this value into a decimal string. 429fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 430fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param FormatPrecision The maximum number of digits of 431fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// precision to output. If there are fewer digits available, 432fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// zero padding will not be used unless the value is 433fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// integral and small enough to be expressed in 434fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// FormatPrecision digits. 0 means to use the natural 435fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// precision of the number. 436fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// \param FormatMaxPadding The maximum number of zeros to 437fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// consider inserting before falling back to scientific 438fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// notation. 0 means to always use scientific notation. 439fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 440fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// Number Precision MaxPadding Result 441fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// ------ --------- ---------- ------ 442fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 1.01E+4 5 2 10100 443fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 1.01E+4 4 2 1.01E+4 444fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 1.01E+4 5 1 1.01E+4 445fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 1.01E-2 5 2 0.0101 446fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 1.01E-2 4 2 0.0101 447fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman /// 1.01E-2 4 1 1.01E-2 448fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void toString(SmallVectorImpl<char> &Str, unsigned FormatPrecision = 0, 449fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman unsigned FormatMaxPadding = 3) const; 450fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 4517f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// If this value has an exact multiplicative inverse, store it in inv and 4527f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// return true. 453fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool getExactInverse(APFloat *inv) const; 454fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 455fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanprivate: 456fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 4577f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Simple Queries 4587f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 4597f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 460fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman integerPart *significandParts(); 461fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman const integerPart *significandParts() const; 462fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman unsigned int partCount() const; 463fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 4647f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 4657f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 4667f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Significand operations. 4677f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 4687f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 469fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman integerPart addSignificand(const APFloat &); 470fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman integerPart subtractSignificand(const APFloat &, integerPart); 471fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lostFraction addOrSubtractSignificand(const APFloat &, bool subtract); 472fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lostFraction multiplySignificand(const APFloat &, const APFloat *); 473fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lostFraction divideSignificand(const APFloat &); 474fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void incrementSignificand(); 475fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initialize(const fltSemantics *); 476fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void shiftSignificandLeft(unsigned int); 477fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman lostFraction shiftSignificandRight(unsigned int); 478fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman unsigned int significandLSB() const; 479fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman unsigned int significandMSB() const; 480fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void zeroSignificand(); 481964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman /// Return true if the significand excluding the integral bit is all ones. 482964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman bool isSignificandAllOnes() const; 483964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman /// Return true if the significand excluding the integral bit is all zeros. 484964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman bool isSignificandAllZeros() const; 485fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 4867f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 4877f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 4887f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Arithmetic on special values. 4897f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 4907f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 491fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus addOrSubtractSpecials(const APFloat &, bool subtract); 492fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus divideSpecials(const APFloat &); 493fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus multiplySpecials(const APFloat &); 494fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus modSpecials(const APFloat &); 495fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 4967f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 4977f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 4987f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Special value setters. 4997f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 5007f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 501964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman void makeLargest(bool Neg = false); 502964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman void makeSmallest(bool Neg = false); 503dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines void makeNaN(bool SNaN = false, bool Neg = false, 504dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines const APInt *fill = nullptr); 505fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative, 506fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman const APInt *fill); 507fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman void makeInf(bool Neg = false); 508fdec0c7a7302702d08f1221609221018af8085ecMichael Gottesman void makeZero(bool Neg = false); 509964722ca40f48c65605e459e3a732bb8783b92f6Michael Gottesman 5107f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 5117f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 5127f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// \name Miscellany 5137f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @{ 5147f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 515575694b6a7d49004acc93294bc88d0bc337e4d27Michael Gottesman bool convertFromStringSpecials(StringRef str); 516fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus normalize(roundingMode, lostFraction); 517fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract); 518fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman cmpResult compareAbsoluteValue(const APFloat &) const; 519fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus handleOverflow(roundingMode); 520fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman bool roundAwayFromZero(roundingMode, lostFraction, unsigned int) const; 521fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertToSignExtendedInteger(integerPart *, unsigned int, bool, 522fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman roundingMode, bool *) const; 523fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertFromUnsignedParts(const integerPart *, unsigned int, 524fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman roundingMode); 525fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertFromHexadecimalString(StringRef, roundingMode); 526fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus convertFromDecimalString(StringRef, roundingMode); 527fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman char *convertNormalToHexString(char *, unsigned int, bool, 528fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman roundingMode) const; 529fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman opStatus roundSignificandWithExponent(const integerPart *, unsigned int, int, 530fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman roundingMode); 531fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 5327f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// @} 5337f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman 534fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt convertHalfAPFloatToAPInt() const; 535fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt convertFloatAPFloatToAPInt() const; 536fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt convertDoubleAPFloatToAPInt() const; 537fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt convertQuadrupleAPFloatToAPInt() const; 538fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt convertF80LongDoubleAPFloatToAPInt() const; 539fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman APInt convertPPCDoubleDoubleAPFloatToAPInt() const; 540fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initFromAPInt(const fltSemantics *Sem, const APInt &api); 541fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initFromHalfAPInt(const APInt &api); 542fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initFromFloatAPInt(const APInt &api); 543fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initFromDoubleAPInt(const APInt &api); 544fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initFromQuadrupleAPInt(const APInt &api); 545fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initFromF80LongDoubleAPInt(const APInt &api); 546fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void initFromPPCDoubleDoubleAPInt(const APInt &api); 547fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 548fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void assign(const APFloat &); 549fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void copySignificand(const APFloat &); 550fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman void freeSignificand(); 551fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 5527f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// The semantics that this value obeys. 553fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman const fltSemantics *semantics; 554fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 5557f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// A binary fraction with an explicit integer bit. 5567f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// 5577f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// The significand must be at least one bit wider than the target precision. 558fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman union Significand { 559fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman integerPart part; 560fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman integerPart *parts; 561fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman } significand; 562fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 5637f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// The signed unbiased exponent of the value. 564db045ab1532469551a56e5811e684920a6f7a10cMichael Gottesman ExponentType exponent; 565fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 5667f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// What kind of floating point number this is. 5677f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// 5687f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Only 2 bits are required, but VisualStudio incorrectly sign extends it. 5697f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Using the extra bit keeps it from failing under VisualStudio. 570fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman fltCategory category : 3; 571fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 5727f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman /// Sign bit of the number. 573fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman unsigned int sign : 1; 574fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman}; 575fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesman 5767f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// See friend declaration above. 5777f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// 5787f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// This additional declaration is required in order to compile LLVM with IBM 5797f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman/// xlC compiler. 580fce7b6b5d9905bf35641ee7f001b6b66dbc26c2dMichael Gottesmanhash_code hash_value(const APFloat &Arg); 5817f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman} // namespace llvm 582b39cdde41d3c91d1fd48a038e63b78122607bb10Chris Lattner 5837f88a3b20dbaee2a9b265f60a7bc19d2dc6a8f3eMichael Gottesman#endif // LLVM_ADT_APFLOAT_H 584