Index: src/x64/assembler-x64.h |
diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h |
index 7bcc7c56dd873786c6e86deb1c190a24303b9686..6822c1c3ad0304b8c3f04d18ca6d72eb1db6139d 100644 |
--- a/src/x64/assembler-x64.h |
+++ b/src/x64/assembler-x64.h |
@@ -98,6 +98,16 @@ struct Register { |
static const int kNumRegisters = 16; |
static const int kNumAllocatableRegisters = 10; |
+ static int ToAllocationIndex(Register reg) { |
+ return allocationIndexByRegisterCode[reg.code()]; |
+ } |
+ |
+ static Register FromAllocationIndex(int index) { |
+ ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
+ Register result = { registerCodeByAllocationIndex[index] }; |
+ return result; |
+ } |
+ |
static const char* AllocationIndexToString(int index) { |
ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
const char* const names[] = { |
@@ -143,6 +153,9 @@ struct Register { |
// Unfortunately we can't make this private in a struct when initializing |
// by assignment. |
int code_; |
+ private: |
+ static const int registerCodeByAllocationIndex[kNumAllocatableRegisters]; |
+ static const int allocationIndexByRegisterCode[kNumRegisters]; |
}; |
const Register rax = { 0 }; |
@@ -173,6 +186,12 @@ struct XMMRegister { |
return reg.code() - 1; |
} |
+ static XMMRegister FromAllocationIndex(int index) { |
+ ASSERT(0 <= index && index < kNumAllocatableRegisters); |
+ XMMRegister result = { index + 1 }; |
+ return result; |
+ } |
+ |
static const char* AllocationIndexToString(int index) { |
ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
const char* const names[] = { |