@@ -239,23 +239,23 @@ template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> {
239
239
240
240
// An opaque type to store a floating point exponent.
241
241
// We define special values but it is valid to create arbitrary values as long
242
- // as they are in the range [MIN, MAX ].
242
+ // as they are in the range [min, max ].
243
243
struct Exponent : public TypedInt <int32_t > {
244
244
using UP = TypedInt<int32_t >;
245
245
using UP::UP;
246
- LIBC_INLINE static constexpr auto SUBNORMAL () {
246
+ LIBC_INLINE static constexpr auto subnormal () {
247
247
return Exponent (-EXP_BIAS);
248
248
}
249
- LIBC_INLINE static constexpr auto MIN () { return Exponent (1 - EXP_BIAS); }
250
- LIBC_INLINE static constexpr auto ZERO () { return Exponent (0 ); }
251
- LIBC_INLINE static constexpr auto MAX () { return Exponent (EXP_BIAS); }
252
- LIBC_INLINE static constexpr auto INF () { return Exponent (EXP_BIAS + 1 ); }
249
+ LIBC_INLINE static constexpr auto min () { return Exponent (1 - EXP_BIAS); }
250
+ LIBC_INLINE static constexpr auto zero () { return Exponent (0 ); }
251
+ LIBC_INLINE static constexpr auto max () { return Exponent (EXP_BIAS); }
252
+ LIBC_INLINE static constexpr auto inf () { return Exponent (EXP_BIAS + 1 ); }
253
253
};
254
254
255
255
// An opaque type to store a floating point biased exponent.
256
256
// We define special values but it is valid to create arbitrary values as long
257
- // as they are in the range [BITS_ALL_ZEROES, BITS_ALL_ONES ].
258
- // Values greater than BITS_ALL_ONES are truncated.
257
+ // as they are in the range [zero, bits_all_ones ].
258
+ // Values greater than bits_all_ones are truncated.
259
259
struct BiasedExponent : public TypedInt <uint32_t > {
260
260
using UP = TypedInt<uint32_t >;
261
261
using UP::UP;
@@ -269,23 +269,23 @@ template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> {
269
269
}
270
270
271
271
LIBC_INLINE constexpr BiasedExponent &operator ++() {
272
- LIBC_ASSERT (*this != BiasedExponent (Exponent::INF ()));
272
+ LIBC_ASSERT (*this != BiasedExponent (Exponent::inf ()));
273
273
++UP::value;
274
274
return *this ;
275
275
}
276
276
277
277
LIBC_INLINE constexpr BiasedExponent &operator --() {
278
- LIBC_ASSERT (*this != BiasedExponent (Exponent::SUBNORMAL ()));
278
+ LIBC_ASSERT (*this != BiasedExponent (Exponent::subnormal ()));
279
279
--UP::value;
280
280
return *this ;
281
281
}
282
282
};
283
283
284
284
// An opaque type to store a floating point significand.
285
285
// We define special values but it is valid to create arbitrary values as long
286
- // as they are in the range [ZERO, BITS_ALL_ONES ].
286
+ // as they are in the range [zero, bits_all_ones ].
287
287
// Note that the semantics of the Significand are implementation dependent.
288
- // Values greater than BITS_ALL_ONES are truncated.
288
+ // Values greater than bits_all_ones are truncated.
289
289
struct Significand : public TypedInt <StorageType> {
290
290
using UP = TypedInt<StorageType>;
291
291
using UP::UP;
@@ -305,16 +305,16 @@ template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> {
305
305
return Significand (StorageType (a.to_storage_type () >> shift));
306
306
}
307
307
308
- LIBC_INLINE static constexpr auto ZERO () {
308
+ LIBC_INLINE static constexpr auto zero () {
309
309
return Significand (StorageType (0 ));
310
310
}
311
- LIBC_INLINE static constexpr auto LSB () {
311
+ LIBC_INLINE static constexpr auto lsb () {
312
312
return Significand (StorageType (1 ));
313
313
}
314
- LIBC_INLINE static constexpr auto MSB () {
314
+ LIBC_INLINE static constexpr auto msb () {
315
315
return Significand (StorageType (1 ) << (SIG_LEN - 1 ));
316
316
}
317
- LIBC_INLINE static constexpr auto BITS_ALL_ONES () {
317
+ LIBC_INLINE static constexpr auto bits_all_ones () {
318
318
return Significand (SIG_MASK);
319
319
}
320
320
};
@@ -393,58 +393,58 @@ struct FPRepSem : public FPStorage<fp_type> {
393
393
public:
394
394
// Builders
395
395
LIBC_INLINE static constexpr RetT zero (Sign sign = Sign::POS) {
396
- return RetT (encode (sign, Exponent::SUBNORMAL (), Significand::ZERO ()));
396
+ return RetT (encode (sign, Exponent::subnormal (), Significand::zero ()));
397
397
}
398
398
LIBC_INLINE static constexpr RetT one (Sign sign = Sign::POS) {
399
- return RetT (encode (sign, Exponent::ZERO (), Significand::ZERO ()));
399
+ return RetT (encode (sign, Exponent::zero (), Significand::zero ()));
400
400
}
401
401
LIBC_INLINE static constexpr RetT min_subnormal (Sign sign = Sign::POS) {
402
- return RetT (encode (sign, Exponent::SUBNORMAL (), Significand::LSB ()));
402
+ return RetT (encode (sign, Exponent::subnormal (), Significand::lsb ()));
403
403
}
404
404
LIBC_INLINE static constexpr RetT max_subnormal (Sign sign = Sign::POS) {
405
405
return RetT (
406
- encode (sign, Exponent::SUBNORMAL (), Significand::BITS_ALL_ONES ()));
406
+ encode (sign, Exponent::subnormal (), Significand::bits_all_ones ()));
407
407
}
408
408
LIBC_INLINE static constexpr RetT min_normal (Sign sign = Sign::POS) {
409
- return RetT (encode (sign, Exponent::MIN (), Significand::ZERO ()));
409
+ return RetT (encode (sign, Exponent::min (), Significand::zero ()));
410
410
}
411
411
LIBC_INLINE static constexpr RetT max_normal (Sign sign = Sign::POS) {
412
- return RetT (encode (sign, Exponent::MAX (), Significand::BITS_ALL_ONES ()));
412
+ return RetT (encode (sign, Exponent::max (), Significand::bits_all_ones ()));
413
413
}
414
414
LIBC_INLINE static constexpr RetT inf (Sign sign = Sign::POS) {
415
- return RetT (encode (sign, Exponent::INF (), Significand::ZERO ()));
415
+ return RetT (encode (sign, Exponent::inf (), Significand::zero ()));
416
416
}
417
417
LIBC_INLINE static constexpr RetT signaling_nan (Sign sign = Sign::POS,
418
418
StorageType v = 0 ) {
419
- return RetT (encode (sign, Exponent::INF (),
420
- (v ? Significand (v) : (Significand::MSB () >> 1 ))));
419
+ return RetT (encode (sign, Exponent::inf (),
420
+ (v ? Significand (v) : (Significand::msb () >> 1 ))));
421
421
}
422
422
LIBC_INLINE static constexpr RetT quiet_nan (Sign sign = Sign::POS,
423
423
StorageType v = 0 ) {
424
424
return RetT (
425
- encode (sign, Exponent::INF (), Significand::MSB () | Significand (v)));
425
+ encode (sign, Exponent::inf (), Significand::msb () | Significand (v)));
426
426
}
427
427
428
428
// Observers
429
429
LIBC_INLINE constexpr bool is_zero () const { return exp_sig_bits () == 0 ; }
430
430
LIBC_INLINE constexpr bool is_nan () const {
431
- return exp_sig_bits () > encode (Exponent::INF (), Significand::ZERO ());
431
+ return exp_sig_bits () > encode (Exponent::inf (), Significand::zero ());
432
432
}
433
433
LIBC_INLINE constexpr bool is_quiet_nan () const {
434
- return exp_sig_bits () >= encode (Exponent::INF (), Significand::MSB ());
434
+ return exp_sig_bits () >= encode (Exponent::inf (), Significand::msb ());
435
435
}
436
436
LIBC_INLINE constexpr bool is_signaling_nan () const {
437
437
return is_nan () && !is_quiet_nan ();
438
438
}
439
439
LIBC_INLINE constexpr bool is_inf () const {
440
- return exp_sig_bits () == encode (Exponent::INF (), Significand::ZERO ());
440
+ return exp_sig_bits () == encode (Exponent::inf (), Significand::zero ());
441
441
}
442
442
LIBC_INLINE constexpr bool is_finite () const {
443
- return exp_bits () != encode (Exponent::INF ());
443
+ return exp_bits () != encode (Exponent::inf ());
444
444
}
445
445
LIBC_INLINE
446
446
constexpr bool is_subnormal () const {
447
- return exp_bits () == encode (Exponent::SUBNORMAL ());
447
+ return exp_bits () == encode (Exponent::subnormal ());
448
448
}
449
449
LIBC_INLINE constexpr bool is_normal () const {
450
450
return is_finite () && !is_subnormal ();
@@ -493,37 +493,37 @@ struct FPRepSem<FPType::X86_Binary80, RetT>
493
493
public:
494
494
// Builders
495
495
LIBC_INLINE static constexpr RetT zero (Sign sign = Sign::POS) {
496
- return RetT (encode (sign, Exponent::SUBNORMAL (), Significand::ZERO ()));
496
+ return RetT (encode (sign, Exponent::subnormal (), Significand::zero ()));
497
497
}
498
498
LIBC_INLINE static constexpr RetT one (Sign sign = Sign::POS) {
499
- return RetT (encode (sign, Exponent::ZERO (), Significand::MSB ()));
499
+ return RetT (encode (sign, Exponent::zero (), Significand::msb ()));
500
500
}
501
501
LIBC_INLINE static constexpr RetT min_subnormal (Sign sign = Sign::POS) {
502
- return RetT (encode (sign, Exponent::SUBNORMAL (), Significand::LSB ()));
502
+ return RetT (encode (sign, Exponent::subnormal (), Significand::lsb ()));
503
503
}
504
504
LIBC_INLINE static constexpr RetT max_subnormal (Sign sign = Sign::POS) {
505
- return RetT (encode (sign, Exponent::SUBNORMAL (),
506
- Significand::BITS_ALL_ONES () ^ Significand::MSB ()));
505
+ return RetT (encode (sign, Exponent::subnormal (),
506
+ Significand::bits_all_ones () ^ Significand::msb ()));
507
507
}
508
508
LIBC_INLINE static constexpr RetT min_normal (Sign sign = Sign::POS) {
509
- return RetT (encode (sign, Exponent::MIN (), Significand::MSB ()));
509
+ return RetT (encode (sign, Exponent::min (), Significand::msb ()));
510
510
}
511
511
LIBC_INLINE static constexpr RetT max_normal (Sign sign = Sign::POS) {
512
- return RetT (encode (sign, Exponent::MAX (), Significand::BITS_ALL_ONES ()));
512
+ return RetT (encode (sign, Exponent::max (), Significand::bits_all_ones ()));
513
513
}
514
514
LIBC_INLINE static constexpr RetT inf (Sign sign = Sign::POS) {
515
- return RetT (encode (sign, Exponent::INF (), Significand::MSB ()));
515
+ return RetT (encode (sign, Exponent::inf (), Significand::msb ()));
516
516
}
517
517
LIBC_INLINE static constexpr RetT signaling_nan (Sign sign = Sign::POS,
518
518
StorageType v = 0 ) {
519
- return RetT (encode (sign, Exponent::INF (),
520
- Significand::MSB () |
521
- (v ? Significand (v) : (Significand::MSB () >> 2 ))));
519
+ return RetT (encode (sign, Exponent::inf (),
520
+ Significand::msb () |
521
+ (v ? Significand (v) : (Significand::msb () >> 2 ))));
522
522
}
523
523
LIBC_INLINE static constexpr RetT quiet_nan (Sign sign = Sign::POS,
524
524
StorageType v = 0 ) {
525
- return RetT (encode (sign, Exponent::INF (),
526
- Significand::MSB () | (Significand::MSB () >> 1 ) |
525
+ return RetT (encode (sign, Exponent::inf (),
526
+ Significand::msb () | (Significand::msb () >> 1 ) |
527
527
Significand (v)));
528
528
}
529
529
@@ -541,33 +541,33 @@ struct FPRepSem<FPType::X86_Binary80, RetT>
541
541
// - Quiet Not a Number
542
542
// - Unnormal
543
543
// This can be reduced to the following logic:
544
- if (exp_bits () == encode (Exponent::INF ()))
544
+ if (exp_bits () == encode (Exponent::inf ()))
545
545
return !is_inf ();
546
- if (exp_bits () != encode (Exponent::SUBNORMAL ()))
547
- return (sig_bits () & encode (Significand::MSB ())) == 0 ;
546
+ if (exp_bits () != encode (Exponent::subnormal ()))
547
+ return (sig_bits () & encode (Significand::msb ())) == 0 ;
548
548
return false ;
549
549
}
550
550
LIBC_INLINE constexpr bool is_quiet_nan () const {
551
551
return exp_sig_bits () >=
552
- encode (Exponent::INF (),
553
- Significand::MSB () | (Significand::MSB () >> 1 ));
552
+ encode (Exponent::inf (),
553
+ Significand::msb () | (Significand::msb () >> 1 ));
554
554
}
555
555
LIBC_INLINE constexpr bool is_signaling_nan () const {
556
556
return is_nan () && !is_quiet_nan ();
557
557
}
558
558
LIBC_INLINE constexpr bool is_inf () const {
559
- return exp_sig_bits () == encode (Exponent::INF (), Significand::MSB ());
559
+ return exp_sig_bits () == encode (Exponent::inf (), Significand::msb ());
560
560
}
561
561
LIBC_INLINE constexpr bool is_finite () const {
562
562
return !is_inf () && !is_nan ();
563
563
}
564
564
LIBC_INLINE
565
565
constexpr bool is_subnormal () const {
566
- return exp_bits () == encode (Exponent::SUBNORMAL ());
566
+ return exp_bits () == encode (Exponent::subnormal ());
567
567
}
568
568
LIBC_INLINE constexpr bool is_normal () const {
569
569
const auto exp = exp_bits ();
570
- if (exp == encode (Exponent::SUBNORMAL ()) || exp == encode (Exponent::INF ()))
570
+ if (exp == encode (Exponent::subnormal ()) || exp == encode (Exponent::inf ()))
571
571
return false ;
572
572
return get_implicit_bit ();
573
573
}
@@ -578,7 +578,7 @@ struct FPRepSem<FPType::X86_Binary80, RetT>
578
578
} else if (exp_sig_bits () == max_subnormal ().uintval ()) {
579
579
return min_normal (sign ());
580
580
} else if (sig_bits () == SIG_MASK) {
581
- return RetT (encode (sign (), ++biased_exponent (), Significand::ZERO ()));
581
+ return RetT (encode (sign (), ++biased_exponent (), Significand::zero ()));
582
582
} else {
583
583
return RetT (bits + StorageType (1 ));
584
584
}
@@ -715,9 +715,9 @@ struct FPRepImpl : public FPRepSem<fp_type, RetT> {
715
715
LIBC_INLINE constexpr int get_explicit_exponent () const {
716
716
Exponent exponent (UP::biased_exponent ());
717
717
if (is_zero ())
718
- exponent = Exponent::ZERO ();
719
- if (exponent == Exponent::SUBNORMAL ())
720
- exponent = Exponent::MIN ();
718
+ exponent = Exponent::zero ();
719
+ if (exponent == Exponent::subnormal ())
720
+ exponent = Exponent::min ();
721
721
return static_cast <int32_t >(exponent);
722
722
}
723
723
0 commit comments