ART: Refactor Int64ConstantFrom to use Int64FromConstant; rename it to Int64FromLocation

Int64ConstantFrom function duplicates code of the Int64FromConstant. Its
code can be replaced with a call: Int64FromConstant(location.getConstant()).

The patch removes the duplicating code. It also changes the function name to
Int64FromLocation to be consistent with its usage.

Test: test-art-host, test-art-target
Change-Id: I5624259aa72523f97ca8fc132a6152f338425c8e
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index 1965135..634f6fb 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -69,7 +69,7 @@
 using helpers::InputFPRegisterAt;
 using helpers::InputOperandAt;
 using helpers::InputRegisterAt;
-using helpers::Int64ConstantFrom;
+using helpers::Int64FromLocation;
 using helpers::IsConstantZeroBitPattern;
 using helpers::LocationFrom;
 using helpers::OperandFromMemOperand;
@@ -2702,7 +2702,7 @@
 void InstructionCodeGeneratorARM64::VisitIntermediateAddressIndex(
     HIntermediateAddressIndex* instruction) {
   Register index_reg = InputRegisterAt(instruction, 0);
-  uint32_t shift = Int64ConstantFrom(instruction->GetLocations()->InAt(2));
+  uint32_t shift = Int64FromLocation(instruction->GetLocations()->InAt(2));
   uint32_t offset = instruction->GetOffset()->AsIntConstant()->GetValue();
 
   if (shift == 0) {
@@ -2832,7 +2832,7 @@
     DCHECK(!instruction->CanDoImplicitNullCheckOn(instruction->InputAt(0)));
     if (index.IsConstant()) {
       // Array load with a constant index can be treated as a field load.
-      offset += Int64ConstantFrom(index) << DataType::SizeShift(type);
+      offset += Int64FromLocation(index) << DataType::SizeShift(type);
       Location maybe_temp =
           (locations->GetTempCount() != 0) ? locations->GetTemp(0) : Location::NoLocation();
       codegen_->GenerateFieldLoadWithBakerReadBarrier(instruction,
@@ -2877,14 +2877,14 @@
                       "Expecting 0=compressed, 1=uncompressed");
         __ Tbnz(length.W(), 0, &uncompressed_load);
         __ Ldrb(Register(OutputCPURegister(instruction)),
-                HeapOperand(obj, offset + Int64ConstantFrom(index)));
+                HeapOperand(obj, offset + Int64FromLocation(index)));
         __ B(&done);
         __ Bind(&uncompressed_load);
         __ Ldrh(Register(OutputCPURegister(instruction)),
-                HeapOperand(obj, offset + (Int64ConstantFrom(index) << 1)));
+                HeapOperand(obj, offset + (Int64FromLocation(index) << 1)));
         __ Bind(&done);
       } else {
-        offset += Int64ConstantFrom(index) << DataType::SizeShift(type);
+        offset += Int64FromLocation(index) << DataType::SizeShift(type);
         source = HeapOperand(obj, offset);
       }
     } else {
@@ -2997,7 +2997,7 @@
   if (!needs_write_barrier) {
     DCHECK(!may_need_runtime_call_for_type_check);
     if (index.IsConstant()) {
-      offset += Int64ConstantFrom(index) << DataType::SizeShift(value_type);
+      offset += Int64FromLocation(index) << DataType::SizeShift(value_type);
       destination = HeapOperand(array, offset);
     } else {
       UseScratchRegisterScope temps(masm);
@@ -3035,7 +3035,7 @@
       UseScratchRegisterScope temps(masm);
       Register temp = temps.AcquireSameSizeAs(array);
       if (index.IsConstant()) {
-        offset += Int64ConstantFrom(index) << DataType::SizeShift(value_type);
+        offset += Int64FromLocation(index) << DataType::SizeShift(value_type);
         destination = HeapOperand(array, offset);
       } else {
         destination = HeapOperand(temp,
@@ -3345,7 +3345,7 @@
 #undef FOR_EACH_CONDITION_INSTRUCTION
 
 void InstructionCodeGeneratorARM64::GenerateIntDivForPower2Denom(HDiv* instruction) {
-  int64_t imm = Int64ConstantFrom(instruction->GetLocations()->InAt(1));
+  int64_t imm = Int64FromLocation(instruction->GetLocations()->InAt(1));
   uint64_t abs_imm = static_cast<uint64_t>(AbsOrMin(imm));
   DCHECK(IsPowerOfTwo(abs_imm)) << abs_imm;
 
@@ -3424,7 +3424,7 @@
 }
 
 void InstructionCodeGeneratorARM64::GenerateIntDivForConstDenom(HDiv *instruction) {
-  int64_t imm = Int64ConstantFrom(instruction->GetLocations()->InAt(1));
+  int64_t imm = Int64FromLocation(instruction->GetLocations()->InAt(1));
 
   if (imm == 0) {
     // Do not generate anything. DivZeroCheck would prevent any code to be executed.
@@ -3514,7 +3514,7 @@
   }
 
   if (value.IsConstant()) {
-    int64_t divisor = Int64ConstantFrom(value);
+    int64_t divisor = Int64FromLocation(value);
     if (divisor == 0) {
       __ B(slow_path->GetEntryLabel());
     } else {
@@ -5634,7 +5634,7 @@
 }
 
 void InstructionCodeGeneratorARM64::GenerateIntRemForPower2Denom(HRem *instruction) {
-  int64_t imm = Int64ConstantFrom(instruction->GetLocations()->InAt(1));
+  int64_t imm = Int64FromLocation(instruction->GetLocations()->InAt(1));
   uint64_t abs_imm = static_cast<uint64_t>(AbsOrMin(imm));
   DCHECK(IsPowerOfTwo(abs_imm)) << abs_imm;
 
@@ -5657,7 +5657,7 @@
 }
 
 void InstructionCodeGeneratorARM64::GenerateIntRemForOneOrMinusOneDenom(HRem *instruction) {
-  int64_t imm = Int64ConstantFrom(instruction->GetLocations()->InAt(1));
+  int64_t imm = Int64FromLocation(instruction->GetLocations()->InAt(1));
   DCHECK(imm == 1 || imm == -1) << imm;
 
   Register out = OutputRegister(instruction);
@@ -5665,7 +5665,7 @@
 }
 
 void InstructionCodeGeneratorARM64::GenerateIntRemForConstDenom(HRem *instruction) {
-  int64_t imm = Int64ConstantFrom(instruction->GetLocations()->InAt(1));
+  int64_t imm = Int64FromLocation(instruction->GetLocations()->InAt(1));
 
   if (imm == 0) {
     // Do not generate anything.
@@ -6664,7 +6664,7 @@
       // ArrayGet and UnsafeGetObject and UnsafeCASObject intrinsics cases.
       // /* HeapReference<mirror::Object> */ ref = *(obj + offset + (index << scale_factor))
       if (index.IsConstant()) {
-        uint32_t computed_offset = offset + (Int64ConstantFrom(index) << scale_factor);
+        uint32_t computed_offset = offset + (Int64FromLocation(index) << scale_factor);
         EmissionCheckScope guard(GetVIXLAssembler(), kMaxMacroInstructionSizeInBytes);
         Load(type, ref_reg, HeapOperand(obj, computed_offset));
         if (needs_null_check) {