diff options
Diffstat (limited to 'deps/v8/src/x87/assembler-x87.h')
-rw-r--r-- | deps/v8/src/x87/assembler-x87.h | 193 |
1 files changed, 87 insertions, 106 deletions
diff --git a/deps/v8/src/x87/assembler-x87.h b/deps/v8/src/x87/assembler-x87.h index 1f454bcd90..aa5195c951 100644 --- a/deps/v8/src/x87/assembler-x87.h +++ b/deps/v8/src/x87/assembler-x87.h @@ -40,12 +40,48 @@ #include <deque> #include "src/assembler.h" -#include "src/compiler.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- @@ -68,145 +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; - - static inline const char* AllocationIndexToString(int index); + enum Code { +#define REGISTER_CODE(R) kCode_##R, + GENERAL_REGISTERS(REGISTER_CODE) +#undef REGISTER_CODE + kAfterLast, + kCode_no_reg = -1 + }; - static inline int ToAllocationIndex(Register reg); - - static inline Register FromAllocationIndex(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]; -} +#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}; -inline int Register::ToAllocationIndex(Register reg) { - DCHECK(reg.is_valid() && !reg.is(esp) && !reg.is(ebp)); - return (reg.code() >= 6) ? reg.code() - 2 : reg.code(); -} - - -inline Register Register::FromAllocationIndex(int index) { - DCHECK(index >= 0 && index < kMaxNumAllocatableRegisters); - return (index >= 4) ? from_code(index + 2) : from_code(index); -} +struct DoubleRegister { + enum Code { +#define REGISTER_CODE(R) kCode_##R, + DOUBLE_REGISTERS(REGISTER_CODE) +#undef REGISTER_CODE + kAfterLast, + kCode_no_reg = -1 + }; -struct X87Register { + static const int kMaxNumRegisters = Code::kAfterLast; 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(); - } - - - static int ToAllocationIndex(X87Register reg) { - return reg.code_; - } - - 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 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_; - } - - bool is(X87Register reg) const { - return code_ == reg.code_; + return reg_code; } - int code_; -}; - + bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } -typedef X87Register DoubleRegister; + const char* ToString(); + 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 @@ -793,6 +771,8 @@ class Assembler : public AssemblerBase { void bts(const Operand& dst, Register src); void bsr(Register dst, Register src) { bsr(dst, Operand(src)); } void bsr(Register dst, const Operand& src); + void bsf(Register dst, Register src) { bsf(dst, Operand(src)); } + void bsf(Register dst, const Operand& src); // Miscellaneous void hlt(); @@ -1097,6 +1077,7 @@ class EnsureSpace BASE_EMBEDDED { #endif }; -} } // namespace v8::internal +} // namespace internal +} // namespace v8 #endif // V8_X87_ASSEMBLER_X87_H_ |