From dbb17e378b538133750e56375bbdbb217db7b248 Mon Sep 17 00:00:00 2001 From: Yixin Shou Date: Fri, 7 Feb 2014 05:09:30 -0800 Subject: Added inlined abs method with float and double type This patch added the implementation for inlining java.lang.Math.abs() method with float and double type. Change-Id: Ic99471b4ab4176e4a0153bef383bb49944fb636f Signed-off-by: Yixin Shou --- compiler/dex/quick/gen_invoke.cc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'compiler/dex/quick/gen_invoke.cc') diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc index 3823fb31d4..d7aecaf3f5 100644 --- a/compiler/dex/quick/gen_invoke.cc +++ b/compiler/dex/quick/gen_invoke.cc @@ -1076,6 +1076,43 @@ bool Mir2Lir::GenInlinedAbsLong(CallInfo* info) { } } +bool Mir2Lir::GenInlinedAbsFloat(CallInfo* info) { + if (cu_->instruction_set == kMips) { + // TODO - add Mips implementation + return false; + } + RegLocation rl_src = info->args[0]; + rl_src = LoadValue(rl_src, kCoreReg); + RegLocation rl_dest = InlineTarget(info); + RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); + int signMask = AllocTemp(); + LoadConstant(signMask, 0x7fffffff); + OpRegRegReg(kOpAnd, rl_result.low_reg, rl_src.low_reg, signMask); + FreeTemp(signMask); + StoreValue(rl_dest, rl_result); + return true; +} + +bool Mir2Lir::GenInlinedAbsDouble(CallInfo* info) { + if (cu_->instruction_set == kMips) { + // TODO - add Mips implementation + return false; + } + RegLocation rl_src = info->args[0]; + rl_src = LoadValueWide(rl_src, kCoreReg); + RegLocation rl_dest = InlineTargetWide(info); + RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); + OpRegCopyWide(rl_result.low_reg, rl_result.high_reg, rl_src.low_reg, rl_src.high_reg); + FreeTemp(rl_src.low_reg); + FreeTemp(rl_src.high_reg); + int signMask = AllocTemp(); + LoadConstant(signMask, 0x7fffffff); + OpRegReg(kOpAnd, rl_result.high_reg, signMask); + FreeTemp(signMask); + StoreValueWide(rl_dest, rl_result); + return true; +} + bool Mir2Lir::GenInlinedFloatCvt(CallInfo* info) { if (cu_->instruction_set == kMips) { // TODO - add Mips implementation -- cgit v1.2.3-59-g8ed1b