Implement long negate instruction in the optimizing compiler.
- Add support for the neg-long (long integer two's
complement negate) instruction in the optimizing compiler.
- Add a 64-bit NEG instruction (negq) to the x86-64
assembler.
- Generate ARM, x86 and x86-64 code for integer HNeg nodes.
- Put neg-related tests into test/415-optimizing-arith-neg.
Change-Id: I1fbe9611e134408a6b8745d1df20ab6ffa5e50f2
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc
index 7b00d2f..5edf0f0 100644
--- a/compiler/optimizing/code_generator_arm.cc
+++ b/compiler/optimizing/code_generator_arm.cc
@@ -1043,11 +1043,13 @@
new (GetGraph()->GetArena()) LocationSummary(neg, LocationSummary::kNoCall);
switch (neg->GetResultType()) {
case Primitive::kPrimInt:
+ case Primitive::kPrimLong: {
+ bool output_overlaps = (neg->GetResultType() == Primitive::kPrimLong);
locations->SetInAt(0, Location::RequiresRegister());
- locations->SetOut(Location::RequiresRegister());
+ locations->SetOut(Location::RequiresRegister(), output_overlaps);
break;
+ }
- case Primitive::kPrimLong:
case Primitive::kPrimFloat:
case Primitive::kPrimDouble:
LOG(FATAL) << "Not yet implemented neg type " << neg->GetResultType();
@@ -1069,6 +1071,15 @@
break;
case Primitive::kPrimLong:
+ DCHECK(in.IsRegisterPair());
+ __ rsbs(out.AsRegisterPairLow<Register>(),
+ in.AsRegisterPairLow<Register>(),
+ ShifterOperand(0));
+ __ rsc(out.AsRegisterPairHigh<Register>(),
+ in.AsRegisterPairHigh<Register>(),
+ ShifterOperand(0));
+ break;
+
case Primitive::kPrimFloat:
case Primitive::kPrimDouble:
LOG(FATAL) << "Not yet implemented neg type " << neg->GetResultType();