From dbce0d738e9d7956d2bd73e932a0fdd28f2229b4 Mon Sep 17 00:00:00 2001 From: Chris Larsen Date: Thu, 17 Sep 2015 13:34:00 -0700 Subject: 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 --- runtime/base/bit_utils.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'runtime/base/bit_utils.h') 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(value)); } +// Generate maximum/minimum values for signed/unsigned n-bit integers +template +static constexpr T MaxInt(size_t bits) { + return + DCHECK_CONSTEXPR(bits > 0, "bits cannot be zero", 0) + DCHECK_CONSTEXPR(bits <= BitSizeOf(), "kBits must be < max.", 0) + bits == BitSizeOf() + ? std::numeric_limits::max() + : std::is_signed::value + ? (bits == 1 + ? 0 + : static_cast(MaxInt::type>(bits - 1))) + : static_cast(UINT64_C(1) << bits) - static_cast(1); +} + +template +static constexpr T MinInt(size_t bits) { + return + DCHECK_CONSTEXPR(bits > 0, "bits cannot be zero", 0) + DCHECK_CONSTEXPR(bits <= BitSizeOf(), "kBits must be < max.", 0) + bits == BitSizeOf() + ? std::numeric_limits::min() + : std::is_signed::value + ? (bits == 1 ? -1 : static_cast(-1) - MaxInt(bits)) + : static_cast(0); +} + // Using the Curiously Recurring Template Pattern to implement everything shared // by LowToHighBitIterator and HighToLowBitIterator, i.e. everything but operator*(). template -- cgit v1.2.3-59-g8ed1b