aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Bramley <jacob.bramley@arm.com>2018-05-08 14:28:59 +0100
committerJacob Bramley <jacob.bramley@arm.com>2018-06-15 10:53:13 +0000
commitd6166b0a0c6168dddcf1529b7271c3e4b7807372 (patch)
tree736f73469bbc71b668ad8c7b486a8db22ca809cf
parentc41760bef82c9431a06a970d48103fb67ac55cd0 (diff)
downloadvixl-master.tar.gz
Clean up some implementation-defined casts.HEADmaster
Change-Id: If363f306c3052b14c3c299e6fd6f9024c4934b85
-rw-r--r--src/aarch64/utils-aarch64.h26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/aarch64/utils-aarch64.h b/src/aarch64/utils-aarch64.h
index 8bd1591..d714516 100644
--- a/src/aarch64/utils-aarch64.h
+++ b/src/aarch64/utils-aarch64.h
@@ -27,6 +27,8 @@
#ifndef VIXL_AARCH64_UTILS_AARCH64_H_
#define VIXL_AARCH64_UTILS_AARCH64_H_
+#include <limits>
+
#include "instructions-aarch64.h"
namespace vixl {
@@ -185,6 +187,10 @@ T FPRound(int64_t sign,
mantissa &= ~(UINT64_C(1) << highest_significant_bit);
}
+ // The casts below are only well-defined for unsigned integers.
+ VIXL_STATIC_ASSERT(std::numeric_limits<T>::is_integer);
+ VIXL_STATIC_ASSERT(!std::numeric_limits<T>::is_signed);
+
if (shift > 0) {
if (round_mode == FPTieEven) {
// We have to shift the mantissa to the right. Some precision is lost, so
@@ -237,11 +243,11 @@ inline double FPRoundToDouble(int64_t sign,
int64_t exponent,
uint64_t mantissa,
FPRounding round_mode) {
- int64_t bits =
- FPRound<int64_t, kDoubleExponentBits, kDoubleMantissaBits>(sign,
- exponent,
- mantissa,
- round_mode);
+ uint64_t bits =
+ FPRound<uint64_t, kDoubleExponentBits, kDoubleMantissaBits>(sign,
+ exponent,
+ mantissa,
+ round_mode);
return RawbitsToDouble(bits);
}
@@ -262,11 +268,11 @@ static inline float FPRoundToFloat(int64_t sign,
int64_t exponent,
uint64_t mantissa,
FPRounding round_mode) {
- int32_t bits =
- FPRound<int32_t, kFloatExponentBits, kFloatMantissaBits>(sign,
- exponent,
- mantissa,
- round_mode);
+ uint32_t bits =
+ FPRound<uint32_t, kFloatExponentBits, kFloatMantissaBits>(sign,
+ exponent,
+ mantissa,
+ round_mode);
return RawbitsToFloat(bits);
}