19
19
#include " llvm/ADT/APSInt.h"
20
20
#include " llvm/ADT/Hashing.h"
21
21
#include " llvm/ADT/SmallString.h"
22
+ #include " llvm/Support/Compiler.h"
22
23
#include " llvm/Support/raw_ostream.h"
23
24
24
25
namespace llvm {
@@ -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,26 @@ 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
- bool *Overflow = nullptr ) const ;
194
+ LLVM_ABI APFixedPoint convert (const FixedPointSemantics &DstSema,
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,
202
+ bool *Overflow = nullptr ) const ;
203
+ LLVM_ABI APFixedPoint sub (const APFixedPoint &Other,
204
+ bool *Overflow = nullptr ) const ;
205
+ LLVM_ABI APFixedPoint mul (const APFixedPoint &Other,
206
+ bool *Overflow = nullptr ) const ;
207
+ LLVM_ABI APFixedPoint div (const APFixedPoint &Other,
208
+ bool *Overflow = nullptr ) const ;
204
209
205
210
// Perform shift operations on a fixed point type. Unlike the other binary
206
211
// operations, the resulting fixed point value will be in the original
207
212
// semantic.
208
- APFixedPoint shl (unsigned Amt, bool *Overflow = nullptr ) const ;
213
+ LLVM_ABI APFixedPoint shl (unsigned Amt, bool *Overflow = nullptr ) const ;
209
214
APFixedPoint shr (unsigned Amt, bool *Overflow = nullptr ) const {
210
215
// Right shift cannot overflow.
211
216
if (Overflow)
@@ -215,7 +220,7 @@ class APFixedPoint {
215
220
216
221
// / Perform a unary negation (-X) on this fixed point type, taking into
217
222
// / account saturation if applicable.
218
- APFixedPoint negate (bool *Overflow = nullptr ) const ;
223
+ LLVM_ABI APFixedPoint negate (bool *Overflow = nullptr ) const ;
219
224
220
225
// / Return the integral part of this fixed point number, rounded towards
221
226
// / zero. (-2.5k -> -2)
@@ -234,28 +239,28 @@ class APFixedPoint {
234
239
// / If the overflow parameter is provided, and the integral value is not able
235
240
// / to be fully stored in the provided width and sign, the overflow parameter
236
241
// / is set to true.
237
- APSInt convertToInt (unsigned DstWidth, bool DstSign,
238
- bool *Overflow = nullptr ) const ;
242
+ LLVM_ABI APSInt convertToInt (unsigned DstWidth, bool DstSign,
243
+ bool *Overflow = nullptr ) const ;
239
244
240
245
// / Convert this fixed point number to a floating point value with the
241
246
// / provided semantics.
242
- APFloat convertToFloat (const fltSemantics &FloatSema) const ;
247
+ LLVM_ABI APFloat convertToFloat (const fltSemantics &FloatSema) const ;
243
248
244
- void toString (SmallVectorImpl<char > &Str) const ;
249
+ LLVM_ABI void toString (SmallVectorImpl<char > &Str) const ;
245
250
std::string toString () const {
246
251
SmallString<40 > S;
247
252
toString (S);
248
253
return std::string (S);
249
254
}
250
255
251
- void print (raw_ostream &) const ;
256
+ LLVM_ABI void print (raw_ostream &) const ;
252
257
253
258
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
254
259
LLVM_DUMP_METHOD void dump () const ;
255
260
#endif
256
261
257
262
// If LHS > RHS, return 1. If LHS == RHS, return 0. If LHS < RHS, return -1.
258
- int compare (const APFixedPoint &Other) const ;
263
+ LLVM_ABI int compare (const APFixedPoint &Other) const ;
259
264
bool operator ==(const APFixedPoint &Other) const {
260
265
return compare (Other) == 0 ;
261
266
}
@@ -271,21 +276,22 @@ class APFixedPoint {
271
276
return compare (Other) <= 0 ;
272
277
}
273
278
274
- static APFixedPoint getMax (const FixedPointSemantics &Sema);
275
- static APFixedPoint getMin (const FixedPointSemantics &Sema);
276
- static APFixedPoint getEpsilon (const FixedPointSemantics &Sema);
279
+ LLVM_ABI static APFixedPoint getMax (const FixedPointSemantics &Sema);
280
+ LLVM_ABI static APFixedPoint getMin (const FixedPointSemantics &Sema);
281
+ LLVM_ABI static APFixedPoint getEpsilon (const FixedPointSemantics &Sema);
277
282
278
283
// / Given a floating point semantic, return the next floating point semantic
279
284
// / with a larger exponent and larger or equal mantissa.
280
- static const fltSemantics *promoteFloatSemantics (const fltSemantics *S);
285
+ LLVM_ABI static const fltSemantics *
286
+ promoteFloatSemantics (const fltSemantics *S);
281
287
282
288
// / Create an APFixedPoint with a value equal to that of the provided integer,
283
289
// / and in the same semantics as the provided target semantics. If the value
284
290
// / is not able to fit in the specified fixed point semantics, and the
285
291
// / overflow parameter is provided, it is set to true.
286
- static APFixedPoint getFromIntValue ( const APSInt &Value,
287
- const FixedPointSemantics &DstFXSema,
288
- bool *Overflow = nullptr );
292
+ LLVM_ABI static APFixedPoint
293
+ getFromIntValue ( const APSInt &Value, const FixedPointSemantics &DstFXSema,
294
+ bool *Overflow = nullptr );
289
295
290
296
// / Create an APFixedPoint with a value equal to that of the provided
291
297
// / floating point value, in the provided target semantics. If the value is
@@ -294,9 +300,9 @@ class APFixedPoint {
294
300
// / For NaN, the Overflow flag is always set. For +inf and -inf, if the
295
301
// / semantic is saturating, the value saturates. Otherwise, the Overflow flag
296
302
// / is set.
297
- static APFixedPoint getFromFloatValue ( const APFloat &Value,
298
- const FixedPointSemantics &DstFXSema,
299
- bool *Overflow = nullptr );
303
+ LLVM_ABI static APFixedPoint
304
+ getFromFloatValue ( const APFloat &Value, const FixedPointSemantics &DstFXSema,
305
+ bool *Overflow = nullptr );
300
306
301
307
private:
302
308
APSInt Val;
0 commit comments