From 59c9454b92c2096a30a2bbdffb64edf33dbdd916 Mon Sep 17 00:00:00 2001 From: Aart Bik Date: Mon, 25 Jan 2016 14:20:58 -0800 Subject: Recognize common utilities as intrinsics. Rationale: Recognizing these method calls as intrinsics already has major advantages (compiler knows about no-side-effects/no-throw properties). Next step is, of course, to implement these with native instructions on each architecture. Change-Id: I06fd12973238caec00d67b31b195d7f8807a538e --- compiler/optimizing/intrinsics.cc | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'compiler/optimizing/intrinsics.cc') diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc index 5caf077858..a6be324730 100644 --- a/compiler/optimizing/intrinsics.cc +++ b/compiler/optimizing/intrinsics.cc @@ -131,6 +131,16 @@ static Intrinsics GetIntrinsic(InlineMethod method) { return ((method.d.data & kIntrinsicFlagToFloatingPoint) == 0) ? Intrinsics::kFloatFloatToRawIntBits : Intrinsics::kFloatIntBitsToFloat; + // Floating-point tests. + case kIntrinsicFloatIsInfinite: + return Intrinsics::kFloatIsInfinite; + case kIntrinsicDoubleIsInfinite: + return Intrinsics::kDoubleIsInfinite; + case kIntrinsicFloatIsNaN: + return Intrinsics::kFloatIsNaN; + case kIntrinsicDoubleIsNaN: + return Intrinsics::kDoubleIsNaN; + // Bit manipulations. case kIntrinsicReverseBits: switch (GetType(method.d.data, true)) { @@ -186,6 +196,36 @@ static Intrinsics GetIntrinsic(InlineMethod method) { LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; UNREACHABLE(); } + case kIntrinsicCompare: + switch (GetType(method.d.data, true)) { + case Primitive::kPrimInt: + return Intrinsics::kIntegerCompare; + case Primitive::kPrimLong: + return Intrinsics::kLongCompare; + default: + LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; + UNREACHABLE(); + } + case kIntrinsicHighestOneBit: + switch (GetType(method.d.data, true)) { + case Primitive::kPrimInt: + return Intrinsics::kIntegerHighestOneBit; + case Primitive::kPrimLong: + return Intrinsics::kLongHighestOneBit; + default: + LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; + UNREACHABLE(); + } + case kIntrinsicLowestOneBit: + switch (GetType(method.d.data, true)) { + case Primitive::kPrimInt: + return Intrinsics::kIntegerLowestOneBit; + case Primitive::kPrimLong: + return Intrinsics::kLongLowestOneBit; + default: + LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; + UNREACHABLE(); + } case kIntrinsicNumberOfLeadingZeros: switch (GetType(method.d.data, true)) { case Primitive::kPrimInt: @@ -206,6 +246,16 @@ static Intrinsics GetIntrinsic(InlineMethod method) { LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; UNREACHABLE(); } + case kIntrinsicSignum: + switch (GetType(method.d.data, true)) { + case Primitive::kPrimInt: + return Intrinsics::kIntegerSignum; + case Primitive::kPrimLong: + return Intrinsics::kLongSignum; + default: + LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; + UNREACHABLE(); + } // Abs. case kIntrinsicAbsDouble: -- cgit v1.2.3-59-g8ed1b