16
16
#ifndef LLVM_ADT_APFIXEDPOINT_H
17
17
#define LLVM_ADT_APFIXEDPOINT_H
18
18
19
+ #include " llvm/Support/Compiler.h"
19
20
#include " llvm/ADT/APSInt.h"
20
21
#include " llvm/ADT/Hashing.h"
21
22
#include " llvm/ADT/SmallString.h"
@@ -84,11 +85,11 @@ class FixedPointSemantics {
84
85
// / precision semantic that can precisely represent the precision and ranges
85
86
// / of both input values. This does not compute the resulting semantics for a
86
87
// / given binary operation.
87
- FixedPointSemantics
88
+ LLVM_ABI FixedPointSemantics
88
89
getCommonSemantics (const FixedPointSemantics &Other) const ;
89
90
90
91
// / Print semantics for debug purposes
91
- void print (llvm::raw_ostream& OS) const ;
92
+ LLVM_ABI void print (llvm::raw_ostream& OS) const ;
92
93
93
94
// / Returns true if this fixed-point semantic with its value bits interpreted
94
95
// / as an integer can fit in the given floating point semantic without
@@ -97,7 +98,7 @@ class FixedPointSemantics {
97
98
// / minimum integer representation of 127 and -128, respectively. If both of
98
99
// / these values can be represented (possibly inexactly) in the floating
99
100
// / point semantic without overflowing, this returns true.
100
- bool fitsInFloatSemantics (const fltSemantics &FloatSema) const ;
101
+ LLVM_ABI bool fitsInFloatSemantics (const fltSemantics &FloatSema) const ;
101
102
102
103
// / Return the FixedPointSemantics for an integer type.
103
104
static FixedPointSemantics GetIntegerSemantics (unsigned Width,
@@ -118,10 +119,10 @@ class FixedPointSemantics {
118
119
// / The result is dependent on the host endianness and not stable across LLVM
119
120
// / versions. See getFromOpaqueInt() to convert it back to a
120
121
// / FixedPointSemantics object.
121
- uint32_t toOpaqueInt () const ;
122
+ LLVM_ABI uint32_t toOpaqueInt () const ;
122
123
// / Create a FixedPointSemantics object from an integer created via
123
124
// / toOpaqueInt().
124
- static FixedPointSemantics getFromOpaqueInt (uint32_t );
125
+ LLVM_ABI static FixedPointSemantics getFromOpaqueInt (uint32_t );
125
126
126
127
private:
127
128
unsigned Width : WidthBitWidth;
@@ -190,22 +191,22 @@ class APFixedPoint {
190
191
// Convert this number to match the semantics provided. If the overflow
191
192
// parameter is provided, set this value to true or false to indicate if this
192
193
// operation results in an overflow.
193
- APFixedPoint convert (const FixedPointSemantics &DstSema,
194
+ LLVM_ABI APFixedPoint convert (const FixedPointSemantics &DstSema,
194
195
bool *Overflow = nullptr ) const ;
195
196
196
197
// Perform binary operations on a fixed point type. The resulting fixed point
197
198
// value will be in the common, full precision semantics that can represent
198
199
// the precision and ranges of both input values. See convert() for an
199
200
// explanation of the Overflow parameter.
200
- APFixedPoint add (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
201
- APFixedPoint sub (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
202
- APFixedPoint mul (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
203
- APFixedPoint div (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
201
+ LLVM_ABI APFixedPoint add (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
202
+ LLVM_ABI APFixedPoint sub (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
203
+ LLVM_ABI APFixedPoint mul (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
204
+ LLVM_ABI APFixedPoint div (const APFixedPoint &Other, bool *Overflow = nullptr ) const ;
204
205
205
206
// Perform shift operations on a fixed point type. Unlike the other binary
206
207
// operations, the resulting fixed point value will be in the original
207
208
// semantic.
208
- APFixedPoint shl (unsigned Amt, bool *Overflow = nullptr ) const ;
209
+ LLVM_ABI APFixedPoint shl (unsigned Amt, bool *Overflow = nullptr ) const ;
209
210
APFixedPoint shr (unsigned Amt, bool *Overflow = nullptr ) const {
210
211
// Right shift cannot overflow.
211
212
if (Overflow)
@@ -215,7 +216,7 @@ class APFixedPoint {
215
216
216
217
// / Perform a unary negation (-X) on this fixed point type, taking into
217
218
// / account saturation if applicable.
218
- APFixedPoint negate (bool *Overflow = nullptr ) const ;
219
+ LLVM_ABI APFixedPoint negate (bool *Overflow = nullptr ) const ;
219
220
220
221
// / Return the integral part of this fixed point number, rounded towards
221
222
// / zero. (-2.5k -> -2)
@@ -234,25 +235,25 @@ class APFixedPoint {
234
235
// / If the overflow parameter is provided, and the integral value is not able
235
236
// / to be fully stored in the provided width and sign, the overflow parameter
236
237
// / is set to true.
237
- APSInt convertToInt (unsigned DstWidth, bool DstSign,
238
+ LLVM_ABI APSInt convertToInt (unsigned DstWidth, bool DstSign,
238
239
bool *Overflow = nullptr ) const ;
239
240
240
241
// / Convert this fixed point number to a floating point value with the
241
242
// / provided semantics.
242
- APFloat convertToFloat (const fltSemantics &FloatSema) const ;
243
+ LLVM_ABI APFloat convertToFloat (const fltSemantics &FloatSema) const ;
243
244
244
- void toString (SmallVectorImpl<char > &Str) const ;
245
+ LLVM_ABI void toString (SmallVectorImpl<char > &Str) const ;
245
246
std::string toString () const {
246
247
SmallString<40 > S;
247
248
toString (S);
248
249
return std::string (S);
249
250
}
250
251
251
- void print (raw_ostream &) const ;
252
- void dump () const ;
252
+ LLVM_ABI void print (raw_ostream &) const ;
253
+ LLVM_ABI void dump () const ;
253
254
254
255
// If LHS > RHS, return 1. If LHS == RHS, return 0. If LHS < RHS, return -1.
255
- int compare (const APFixedPoint &Other) const ;
256
+ LLVM_ABI int compare (const APFixedPoint &Other) const ;
256
257
bool operator ==(const APFixedPoint &Other) const {
257
258
return compare (Other) == 0 ;
258
259
}
@@ -268,19 +269,19 @@ class APFixedPoint {
268
269
return compare (Other) <= 0 ;
269
270
}
270
271
271
- static APFixedPoint getMax (const FixedPointSemantics &Sema);
272
- static APFixedPoint getMin (const FixedPointSemantics &Sema);
273
- static APFixedPoint getEpsilon (const FixedPointSemantics &Sema);
272
+ LLVM_ABI static APFixedPoint getMax (const FixedPointSemantics &Sema);
273
+ LLVM_ABI static APFixedPoint getMin (const FixedPointSemantics &Sema);
274
+ LLVM_ABI static APFixedPoint getEpsilon (const FixedPointSemantics &Sema);
274
275
275
276
// / Given a floating point semantic, return the next floating point semantic
276
277
// / with a larger exponent and larger or equal mantissa.
277
- static const fltSemantics *promoteFloatSemantics (const fltSemantics *S);
278
+ LLVM_ABI static const fltSemantics *promoteFloatSemantics (const fltSemantics *S);
278
279
279
280
// / Create an APFixedPoint with a value equal to that of the provided integer,
280
281
// / and in the same semantics as the provided target semantics. If the value
281
282
// / is not able to fit in the specified fixed point semantics, and the
282
283
// / overflow parameter is provided, it is set to true.
283
- static APFixedPoint getFromIntValue (const APSInt &Value,
284
+ LLVM_ABI static APFixedPoint getFromIntValue (const APSInt &Value,
284
285
const FixedPointSemantics &DstFXSema,
285
286
bool *Overflow = nullptr );
286
287
@@ -291,7 +292,7 @@ class APFixedPoint {
291
292
// / For NaN, the Overflow flag is always set. For +inf and -inf, if the
292
293
// / semantic is saturating, the value saturates. Otherwise, the Overflow flag
293
294
// / is set.
294
- static APFixedPoint getFromFloatValue (const APFloat &Value,
295
+ LLVM_ABI static APFixedPoint getFromFloatValue (const APFloat &Value,
295
296
const FixedPointSemantics &DstFXSema,
296
297
bool *Overflow = nullptr );
297
298
0 commit comments