| Index: src/x87/assembler-x87.h
|
| diff --git a/src/x87/assembler-x87.h b/src/x87/assembler-x87.h
|
| index 399d81ba19466761d3f745114a382b216bc7db43..a5127d30259d4771c9b63e9271ade03c4583cfd2 100644
|
| --- a/src/x87/assembler-x87.h
|
| +++ b/src/x87/assembler-x87.h
|
| @@ -41,10 +41,47 @@
|
|
|
| #include "src/assembler.h"
|
| #include "src/isolate.h"
|
| +#include "src/utils.h"
|
|
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +#define GENERAL_REGISTERS(V) \
|
| + V(eax) \
|
| + V(ecx) \
|
| + V(edx) \
|
| + V(ebx) \
|
| + V(esp) \
|
| + V(ebp) \
|
| + V(esi) \
|
| + V(edi)
|
| +
|
| +#define ALLOCATABLE_GENERAL_REGISTERS(V) \
|
| + V(eax) \
|
| + V(ecx) \
|
| + V(edx) \
|
| + V(ebx) \
|
| + V(esi) \
|
| + V(edi)
|
| +
|
| +#define DOUBLE_REGISTERS(V) \
|
| + V(stX_0) \
|
| + V(stX_1) \
|
| + V(stX_2) \
|
| + V(stX_3) \
|
| + V(stX_4) \
|
| + V(stX_5) \
|
| + V(stX_6) \
|
| + V(stX_7)
|
| +
|
| +#define ALLOCATABLE_DOUBLE_REGISTERS(V) \
|
| + V(stX_0) \
|
| + V(stX_1) \
|
| + V(stX_2) \
|
| + V(stX_3) \
|
| + V(stX_4) \
|
| + V(stX_5)
|
| +
|
| // CPU Registers.
|
| //
|
| // 1) We would prefer to use an enum, but enum values are assignment-
|
| @@ -67,129 +104,87 @@ namespace internal {
|
| // and best performance in optimized code.
|
| //
|
| struct Register {
|
| - static const int kMaxNumAllocatableRegisters = 6;
|
| - static int NumAllocatableRegisters() {
|
| - return kMaxNumAllocatableRegisters;
|
| - }
|
| - static const int kNumRegisters = 8;
|
| + enum Code {
|
| +#define REGISTER_CODE(R) kCode_##R,
|
| + GENERAL_REGISTERS(REGISTER_CODE)
|
| +#undef REGISTER_CODE
|
| + kAfterLast,
|
| + kCode_no_reg = -1
|
| + };
|
|
|
| - static inline const char* AllocationIndexToString(int index);
|
| + static const int kNumRegisters = Code::kAfterLast;
|
|
|
| static Register from_code(int code) {
|
| DCHECK(code >= 0);
|
| DCHECK(code < kNumRegisters);
|
| - Register r = { code };
|
| + Register r = {code};
|
| return r;
|
| }
|
| - bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; }
|
| - bool is(Register reg) const { return code_ == reg.code_; }
|
| - // eax, ebx, ecx and edx are byte registers, the rest are not.
|
| - bool is_byte_register() const { return code_ <= 3; }
|
| + const char* ToString();
|
| + bool IsAllocatable() const;
|
| + bool is_valid() const { return 0 <= reg_code && reg_code < kNumRegisters; }
|
| + bool is(Register reg) const { return reg_code == reg.reg_code; }
|
| int code() const {
|
| DCHECK(is_valid());
|
| - return code_;
|
| + return reg_code;
|
| }
|
| int bit() const {
|
| DCHECK(is_valid());
|
| - return 1 << code_;
|
| + return 1 << reg_code;
|
| }
|
|
|
| + bool is_byte_register() const { return reg_code <= 3; }
|
| +
|
| // Unfortunately we can't make this private in a struct.
|
| - int code_;
|
| + int reg_code;
|
| };
|
|
|
| -const int kRegister_eax_Code = 0;
|
| -const int kRegister_ecx_Code = 1;
|
| -const int kRegister_edx_Code = 2;
|
| -const int kRegister_ebx_Code = 3;
|
| -const int kRegister_esp_Code = 4;
|
| -const int kRegister_ebp_Code = 5;
|
| -const int kRegister_esi_Code = 6;
|
| -const int kRegister_edi_Code = 7;
|
| -const int kRegister_no_reg_Code = -1;
|
| -
|
| -const Register eax = { kRegister_eax_Code };
|
| -const Register ecx = { kRegister_ecx_Code };
|
| -const Register edx = { kRegister_edx_Code };
|
| -const Register ebx = { kRegister_ebx_Code };
|
| -const Register esp = { kRegister_esp_Code };
|
| -const Register ebp = { kRegister_ebp_Code };
|
| -const Register esi = { kRegister_esi_Code };
|
| -const Register edi = { kRegister_edi_Code };
|
| -const Register no_reg = { kRegister_no_reg_Code };
|
| -
|
| -
|
| -inline const char* Register::AllocationIndexToString(int index) {
|
| - DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters);
|
| - // This is the mapping of allocation indices to registers.
|
| - const char* const kNames[] = { "eax", "ecx", "edx", "ebx", "esi", "edi" };
|
| - return kNames[index];
|
| -}
|
| -
|
| -
|
| -struct X87Register {
|
| - static const int kMaxNumAllocatableRegisters = 6;
|
| - static const int kMaxNumRegisters = 8;
|
| - static int NumAllocatableRegisters() {
|
| - return kMaxNumAllocatableRegisters;
|
| - }
|
| -
|
|
|
| - // TODO(turbofan): Proper support for float32.
|
| - static int NumAllocatableAliasedRegisters() {
|
| - return NumAllocatableRegisters();
|
| - }
|
| +#define DECLARE_REGISTER(R) const Register R = {Register::kCode_##R};
|
| +GENERAL_REGISTERS(DECLARE_REGISTER)
|
| +#undef DECLARE_REGISTER
|
| +const Register no_reg = {Register::kCode_no_reg};
|
|
|
|
|
| - static int ToAllocationIndex(X87Register reg) {
|
| - return reg.code_;
|
| - }
|
| +struct DoubleRegister {
|
| + enum Code {
|
| +#define REGISTER_CODE(R) kCode_##R,
|
| + DOUBLE_REGISTERS(REGISTER_CODE)
|
| +#undef REGISTER_CODE
|
| + kAfterLast,
|
| + kCode_no_reg = -1
|
| + };
|
|
|
| - static const char* AllocationIndexToString(int index) {
|
| - DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters);
|
| - const char* const names[] = {
|
| - "stX_0", "stX_1", "stX_2", "stX_3", "stX_4",
|
| - "stX_5", "stX_6", "stX_7"
|
| - };
|
| - return names[index];
|
| - }
|
| + static const int kMaxNumRegisters = Code::kAfterLast;
|
| + static const int kMaxNumAllocatableRegisters = 6;
|
|
|
| - static X87Register FromAllocationIndex(int index) {
|
| - DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters);
|
| - X87Register result;
|
| - result.code_ = index;
|
| + static DoubleRegister from_code(int code) {
|
| + DoubleRegister result = {code};
|
| return result;
|
| }
|
|
|
| - bool is_valid() const {
|
| - return 0 <= code_ && code_ < kMaxNumRegisters;
|
| - }
|
| + bool IsAllocatable() const;
|
| + bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; }
|
|
|
| int code() const {
|
| DCHECK(is_valid());
|
| - return code_;
|
| + return reg_code;
|
| }
|
|
|
| - bool is(X87Register reg) const {
|
| - return code_ == reg.code_;
|
| - }
|
| -
|
| - int code_;
|
| -};
|
| + bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; }
|
|
|
| + const char* ToString();
|
|
|
| -typedef X87Register DoubleRegister;
|
| -
|
| + int reg_code;
|
| +};
|
|
|
| -const X87Register stX_0 = { 0 };
|
| -const X87Register stX_1 = { 1 };
|
| -const X87Register stX_2 = { 2 };
|
| -const X87Register stX_3 = { 3 };
|
| -const X87Register stX_4 = { 4 };
|
| -const X87Register stX_5 = { 5 };
|
| -const X87Register stX_6 = { 6 };
|
| -const X87Register stX_7 = { 7 };
|
| +#define DECLARE_REGISTER(R) \
|
| + const DoubleRegister R = {DoubleRegister::kCode_##R};
|
| +DOUBLE_REGISTERS(DECLARE_REGISTER)
|
| +#undef DECLARE_REGISTER
|
| +const DoubleRegister no_double_reg = {DoubleRegister::kCode_no_reg};
|
|
|
| +typedef DoubleRegister X87Register;
|
|
|
| enum Condition {
|
| // any value < 0 is considered no_condition
|
|
|