ART: Refactor InstructionCodeGeneratorARM64::GenerateDivRemWithAnyConstant

InstructionCodeGeneratorARM64::GenerateDivRemWithAnyConstant handles
both Int32 and Int64 cases. However Int32 cases can have additional
optimizations. Having them in GenerateDivRemWithAnyConstant makes code
difficult to read.

This CL splits the code of GenerateDivRemWithAnyConstant to:
* GenerateInt32DivRemWithAnyConstant
* GenerateInt64DivRemWithAnyConstant
* GenerateResultDivRemWithAnyConstant

Test: test.py --host --optimizing --jit
Test: test.py --target --optimizing --jit
Change-Id: I267331c026e87d6a233b593586f1b74759382896
diff --git a/compiler/optimizing/code_generator_arm64.h b/compiler/optimizing/code_generator_arm64.h
index 627cf72..1e1c2a9 100644
--- a/compiler/optimizing/code_generator_arm64.h
+++ b/compiler/optimizing/code_generator_arm64.h
@@ -342,6 +342,24 @@
                              vixl::aarch64::Label* false_target);
   void DivRemOneOrMinusOne(HBinaryOperation* instruction);
   void DivRemByPowerOfTwo(HBinaryOperation* instruction);
+
+  // Helper to generate code producing the final result of HDiv/HRem with a constant divisor.
+  // 'temp_result' holds the result of multiplication of the dividend by a sort of reciprocal
+  // of the divisor (magic_number). Based on magic_number and divisor, temp_result might need
+  // to be corrected before applying final_right_shift.
+  // If the code is generated for HRem the final temp_result is used for producing the
+  // remainder.
+  void GenerateResultDivRemWithAnyConstant(bool is_rem,
+                                           int final_right_shift,
+                                           int64_t magic_number,
+                                           int64_t divisor,
+                                           vixl::aarch64::Register dividend,
+                                           vixl::aarch64::Register temp_result,
+                                           vixl::aarch64::Register out,
+                                           // This function may acquire a scratch register.
+                                           vixl::aarch64::UseScratchRegisterScope* temps_scope);
+  void GenerateInt64DivRemWithAnyConstant(HBinaryOperation* instruction);
+  void GenerateInt32DivRemWithAnyConstant(HBinaryOperation* instruction);
   void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction);
   void GenerateIntDiv(HDiv* instruction);
   void GenerateIntDivForConstDenom(HDiv *instruction);