Stop converting from Location to ManagedRegister.

Now the source of truth is the Location object that knows
which register (core, pair, fpu) it needs to refer to.

Change-Id: I62401343d7479ecfb24b5ed161ec7829cda5a0b1
diff --git a/compiler/optimizing/locations.h b/compiler/optimizing/locations.h
index 5f85b6a..ac44a42 100644
--- a/compiler/optimizing/locations.h
+++ b/compiler/optimizing/locations.h
@@ -21,7 +21,6 @@
 #include "base/bit_vector.h"
 #include "utils/allocation.h"
 #include "utils/growable_array.h"
-#include "utils/managed_register.h"
 
 namespace art {
 
@@ -45,21 +44,26 @@
     kRegister = 4,  // Core register.
 
     // We do not use the value 5 because it conflicts with kLocationConstantMask.
-    kDoNotUse = 5,
+    kDoNotUse5 = 5,
 
     kFpuRegister = 6,  // Floating point processor.
 
+    kRegisterPair = 7,
+
     // On 32bits architectures, quick can pass a long where the
     // low bits are in the last parameter register, and the high
     // bits are in a stack slot. The kQuickParameter kind is for
     // handling this special case.
-    kQuickParameter = 7,
+    kQuickParameter = 8,
+
+    // We do not use the value 9 because it conflicts with kLocationConstantMask.
+    kDoNotUse9 = 9,
 
     // Unallocated location represents a location that is not fixed and can be
     // allocated by a register allocator.  Each unallocated location has
     // a policy that specifies what kind of location is suitable. Payload
     // contains register allocation policy.
-    kUnallocated = 8,
+    kUnallocated = 10,
   };
 
   Location() : value_(kInvalid) {
@@ -71,6 +75,7 @@
     COMPILE_ASSERT((kRegister & kLocationConstantMask) != kConstant, TagError);
     COMPILE_ASSERT((kQuickParameter & kLocationConstantMask) != kConstant, TagError);
     COMPILE_ASSERT((kFpuRegister & kLocationConstantMask) != kConstant, TagError);
+    COMPILE_ASSERT((kRegisterPair & kLocationConstantMask) != kConstant, TagError);
     COMPILE_ASSERT((kConstant & kLocationConstantMask) == kConstant, TagError);
 
     DCHECK(!IsValid());
@@ -111,12 +116,16 @@
   }
 
   // Register locations.
-  static Location RegisterLocation(ManagedRegister reg) {
-    return Location(kRegister, reg.RegId());
+  static Location RegisterLocation(int reg) {
+    return Location(kRegister, reg);
   }
 
-  static Location FpuRegisterLocation(ManagedRegister reg) {
-    return Location(kFpuRegister, reg.RegId());
+  static Location FpuRegisterLocation(int reg) {
+    return Location(kFpuRegister, reg);
+  }
+
+  static Location RegisterPairLocation(int low, int high) {
+    return Location(kRegisterPair, low << 16 | high);
   }
 
   bool IsRegister() const {
@@ -127,15 +136,36 @@
     return GetKind() == kFpuRegister;
   }
 
-  ManagedRegister reg() const {
-    DCHECK(IsRegister() || IsFpuRegister());
-    return static_cast<ManagedRegister>(GetPayload());
+  bool IsRegisterPair() const {
+    return GetKind() == kRegisterPair;
   }
 
-  static uword EncodeStackIndex(intptr_t stack_index) {
+  int reg() const {
+    DCHECK(IsRegister() || IsFpuRegister());
+    return GetPayload();
+  }
+
+  template <typename T>
+  T As() const {
+    return static_cast<T>(reg());
+  }
+
+  template <typename T>
+  T AsRegisterPairLow() const {
+    DCHECK(IsRegisterPair());
+    return static_cast<T>(GetPayload() >> 16);
+  }
+
+  template <typename T>
+  T AsRegisterPairHigh() const {
+    DCHECK(IsRegisterPair());
+    return static_cast<T>(GetPayload() & 0xFFFF);
+  }
+
+  static uintptr_t EncodeStackIndex(intptr_t stack_index) {
     DCHECK(-kStackIndexBias <= stack_index);
     DCHECK(stack_index < kStackIndexBias);
-    return static_cast<uword>(kStackIndexBias + stack_index);
+    return static_cast<uintptr_t>(kStackIndexBias + stack_index);
   }
 
   static Location StackSlot(intptr_t stack_index) {
@@ -187,10 +217,6 @@
     return GetKind() == kQuickParameter;
   }
 
-  arm::ArmManagedRegister AsArm() const;
-  x86::X86ManagedRegister AsX86() const;
-  x86_64::X86_64ManagedRegister AsX86_64() const;
-
   Kind GetKind() const {
     return IsConstant() ? kConstant : KindField::Decode(value_);
   }
@@ -209,7 +235,9 @@
       case kUnallocated: return "U";
       case kConstant: return "C";
       case kFpuRegister: return "F";
-      case kDoNotUse:
+      case kRegisterPair: return "RP";
+      case kDoNotUse5:  // fall-through
+      case kDoNotUse9:
         LOG(FATAL) << "Should not use this location kind";
     }
     UNREACHABLE();
@@ -246,7 +274,7 @@
   }
 
   static Location RegisterOrConstant(HInstruction* instruction);
-  static Location ByteRegisterOrConstant(ManagedRegister reg, HInstruction* instruction);
+  static Location ByteRegisterOrConstant(int reg, HInstruction* instruction);
 
   // The location of the first input to the instruction will be
   // used to replace this unallocated location.
@@ -299,8 +327,12 @@
   RegisterSet() : core_registers_(0), floating_point_registers_(0) {}
 
   void Add(Location loc) {
-    // TODO: floating point registers.
-    core_registers_ |= (1 << loc.reg().RegId());
+    if (loc.IsRegister()) {
+      core_registers_ |= (1 << loc.reg());
+    } else {
+      DCHECK(loc.IsFpuRegister());
+      floating_point_registers_ |= (1 << loc.reg());
+    }
   }
 
   bool ContainsCoreRegister(uint32_t id) {