diff options
| author | 2015-09-17 13:34:00 -0700 | |
|---|---|---|
| committer | 2015-10-05 18:12:30 -0700 | |
| commit | dbce0d738e9d7956d2bd73e932a0fdd28f2229b4 (patch) | |
| tree | 336a92e522c4f20386f65f2a34534f982cf28089 /runtime/base/bit_utils.h | |
| parent | 002117f95896ffa5db74bee808ae61e876b6e8b0 (diff) | |
MIPS64r6 Assembler Tests
Assembler tests for:
- SQRT.fmt - ABS.fmt - ROUND.L.fmt - ROUND.W.fmt
- CEIL.L.fmt - CEIL.W.fmt - FLOOR.L.fmt - FLOOR.W.fmt
- SEL.fmt - RINT.fmt - CLASS.fmt - MIN.fmt
- MAX.fmt - cvt.d.l - BITSWAP - DBITSWAP
- DSBH - DSHD - WSBH - ROTR
- SELEQZ - SELNEZ - CLZ - CLO
- DCLZ - DCLO - SC - SCD
- LL - LLD
These are the assembler instructions which were added to support
intrinsic functions on MIPS64. Tests for additional assembler
instructions will follow.
Support added to the testing infrastructure for:
- Assembler instructions which use three registers; previously
instructions were limited to one, or two, registers.
- Immediate values which have their sizes specified by the number of
bits required to store them rather than the number of bytes, in both
signed and unsigned versions.
Change-Id: I38c07dcbf2539825b25bed13aac05a26fa594b0b
Diffstat (limited to 'runtime/base/bit_utils.h')
| -rw-r--r-- | runtime/base/bit_utils.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/base/bit_utils.h b/runtime/base/bit_utils.h index 1b0d774419..9c78ee59dd 100644 --- a/runtime/base/bit_utils.h +++ b/runtime/base/bit_utils.h @@ -263,6 +263,33 @@ static constexpr bool IsAbsoluteUint(T value) { : static_cast<unsigned_type>(value)); } +// Generate maximum/minimum values for signed/unsigned n-bit integers +template <typename T> +static constexpr T MaxInt(size_t bits) { + return + DCHECK_CONSTEXPR(bits > 0, "bits cannot be zero", 0) + DCHECK_CONSTEXPR(bits <= BitSizeOf<T>(), "kBits must be < max.", 0) + bits == BitSizeOf<T>() + ? std::numeric_limits<T>::max() + : std::is_signed<T>::value + ? (bits == 1 + ? 0 + : static_cast<T>(MaxInt<typename std::make_unsigned<T>::type>(bits - 1))) + : static_cast<T>(UINT64_C(1) << bits) - static_cast<T>(1); +} + +template <typename T> +static constexpr T MinInt(size_t bits) { + return + DCHECK_CONSTEXPR(bits > 0, "bits cannot be zero", 0) + DCHECK_CONSTEXPR(bits <= BitSizeOf<T>(), "kBits must be < max.", 0) + bits == BitSizeOf<T>() + ? std::numeric_limits<T>::min() + : std::is_signed<T>::value + ? (bits == 1 ? -1 : static_cast<T>(-1) - MaxInt<T>(bits)) + : static_cast<T>(0); +} + // Using the Curiously Recurring Template Pattern to implement everything shared // by LowToHighBitIterator and HighToLowBitIterator, i.e. everything but operator*(). template <typename T, typename Iter> |