Commit 779fce37 authored by bbudge's avatar bbudge Committed by Commit bot

Add the concept of FloatRegister for all platforms.

Changes some platform specific class names and uses typedefs
to define FloatRegister, DoubleRegister, etc.

This will be needed to do register allocation on ARM/MIPS where
registers combine to form larger registers.

LOG=N
BUG=v8:4124

Review-Url: https://codereview.chromium.org/1954953002
Cr-Commit-Position: refs/heads/master@{#36117}
parent 41d571df
...@@ -57,6 +57,12 @@ namespace internal { ...@@ -57,6 +57,12 @@ namespace internal {
#define ALLOCATABLE_GENERAL_REGISTERS(V) \ #define ALLOCATABLE_GENERAL_REGISTERS(V) \
V(r0) V(r1) V(r2) V(r3) V(r4) V(r5) V(r6) V(r7) V(r8) V(r0) V(r1) V(r2) V(r3) V(r4) V(r5) V(r6) V(r7) V(r8)
#define FLOAT_REGISTERS(V) \
V(s0) V(s1) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) \
V(s8) V(s9) V(s10) V(s11) V(s12) V(s13) V(s14) V(s15) \
V(s16) V(s17) V(s18) V(s19) V(s20) V(s21) V(s22) V(s23) \
V(s24) V(s25) V(s26) V(s27) V(s28) V(s29) V(s30) V(s31)
#define DOUBLE_REGISTERS(V) \ #define DOUBLE_REGISTERS(V) \
V(d0) V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \ V(d0) V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \
V(d8) V(d9) V(d10) V(d11) V(d12) V(d13) V(d14) V(d15) \ V(d8) V(d9) V(d10) V(d11) V(d12) V(d13) V(d14) V(d15) \
...@@ -154,6 +160,10 @@ struct SwVfpRegister { ...@@ -154,6 +160,10 @@ struct SwVfpRegister {
DCHECK(is_valid()); DCHECK(is_valid());
return 1 << reg_code; return 1 << reg_code;
} }
static SwVfpRegister from_code(int code) {
SwVfpRegister r = {code};
return r;
}
void split_code(int* vm, int* m) const { void split_code(int* vm, int* m) const {
DCHECK(is_valid()); DCHECK(is_valid());
*m = reg_code & 0x1; *m = reg_code & 0x1;
...@@ -163,9 +173,10 @@ struct SwVfpRegister { ...@@ -163,9 +173,10 @@ struct SwVfpRegister {
int reg_code; int reg_code;
}; };
typedef SwVfpRegister FloatRegister;
// Double word VFP register. // Double word VFP register.
struct DoubleRegister { struct DwVfpRegister {
enum Code { enum Code {
#define REGISTER_CODE(R) kCode_##R, #define REGISTER_CODE(R) kCode_##R,
DOUBLE_REGISTERS(REGISTER_CODE) DOUBLE_REGISTERS(REGISTER_CODE)
...@@ -187,7 +198,7 @@ struct DoubleRegister { ...@@ -187,7 +198,7 @@ struct DoubleRegister {
const char* ToString(); const char* ToString();
bool IsAllocatable() const; bool IsAllocatable() const;
bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; } bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; }
bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } bool is(DwVfpRegister reg) const { return reg_code == reg.reg_code; }
int code() const { int code() const {
DCHECK(is_valid()); DCHECK(is_valid());
return reg_code; return reg_code;
...@@ -197,8 +208,8 @@ struct DoubleRegister { ...@@ -197,8 +208,8 @@ struct DoubleRegister {
return 1 << reg_code; return 1 << reg_code;
} }
static DoubleRegister from_code(int code) { static DwVfpRegister from_code(int code) {
DoubleRegister r = {code}; DwVfpRegister r = {code};
return r; return r;
} }
void split_code(int* vm, int* m) const { void split_code(int* vm, int* m) const {
...@@ -211,7 +222,7 @@ struct DoubleRegister { ...@@ -211,7 +222,7 @@ struct DoubleRegister {
}; };
typedef DoubleRegister DwVfpRegister; typedef DwVfpRegister DoubleRegister;
// Double word VFP register d0-15. // Double word VFP register d0-15.
......
...@@ -40,6 +40,12 @@ namespace internal { ...@@ -40,6 +40,12 @@ namespace internal {
R(x8) R(x9) R(x10) R(x11) R(x12) R(x13) R(x14) R(x15) \ R(x8) R(x9) R(x10) R(x11) R(x12) R(x13) R(x14) R(x15) \
R(x18) R(x19) R(x20) R(x21) R(x22) R(x23) R(x24) R(x27) R(x18) R(x19) R(x20) R(x21) R(x22) R(x23) R(x24) R(x27)
#define FLOAT_REGISTERS(V) \
V(s0) V(s1) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) \
V(s8) V(s9) V(s10) V(s11) V(s12) V(s13) V(s14) V(s15) \
V(s16) V(s17) V(s18) V(s19) V(s20) V(s21) V(s22) V(s23) \
V(s24) V(s25) V(s26) V(s27) V(s28) V(s29) V(s30) V(s31)
#define DOUBLE_REGISTERS(R) \ #define DOUBLE_REGISTERS(R) \
R(d0) R(d1) R(d2) R(d3) R(d4) R(d5) R(d6) R(d7) \ R(d0) R(d1) R(d2) R(d3) R(d4) R(d5) R(d6) R(d7) \
R(d8) R(d9) R(d10) R(d11) R(d12) R(d13) R(d14) R(d15) \ R(d8) R(d9) R(d10) R(d11) R(d12) R(d13) R(d14) R(d15) \
...@@ -366,7 +372,7 @@ bool AreSameSizeAndType(const CPURegister& reg1, ...@@ -366,7 +372,7 @@ bool AreSameSizeAndType(const CPURegister& reg1,
const CPURegister& reg7 = NoCPUReg, const CPURegister& reg7 = NoCPUReg,
const CPURegister& reg8 = NoCPUReg); const CPURegister& reg8 = NoCPUReg);
typedef FPRegister FloatRegister;
typedef FPRegister DoubleRegister; typedef FPRegister DoubleRegister;
// TODO(arm64) Define SIMD registers. // TODO(arm64) Define SIMD registers.
......
...@@ -74,6 +74,9 @@ namespace internal { ...@@ -74,6 +74,9 @@ namespace internal {
V(xmm6) \ V(xmm6) \
V(xmm7) V(xmm7)
#define FLOAT_REGISTERS DOUBLE_REGISTERS
#define SIMD_REGISTERS DOUBLE_REGISTERS
#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ #define ALLOCATABLE_DOUBLE_REGISTERS(V) \
V(xmm1) \ V(xmm1) \
V(xmm2) \ V(xmm2) \
...@@ -146,8 +149,7 @@ GENERAL_REGISTERS(DECLARE_REGISTER) ...@@ -146,8 +149,7 @@ GENERAL_REGISTERS(DECLARE_REGISTER)
#undef DECLARE_REGISTER #undef DECLARE_REGISTER
const Register no_reg = {Register::kCode_no_reg}; const Register no_reg = {Register::kCode_no_reg};
struct XMMRegister {
struct DoubleRegister {
enum Code { enum Code {
#define REGISTER_CODE(R) kCode_##R, #define REGISTER_CODE(R) kCode_##R,
DOUBLE_REGISTERS(REGISTER_CODE) DOUBLE_REGISTERS(REGISTER_CODE)
...@@ -158,8 +160,8 @@ struct DoubleRegister { ...@@ -158,8 +160,8 @@ struct DoubleRegister {
static const int kMaxNumRegisters = Code::kAfterLast; static const int kMaxNumRegisters = Code::kAfterLast;
static DoubleRegister from_code(int code) { static XMMRegister from_code(int code) {
DoubleRegister result = {code}; XMMRegister result = {code};
return result; return result;
} }
...@@ -171,23 +173,25 @@ struct DoubleRegister { ...@@ -171,23 +173,25 @@ struct DoubleRegister {
return reg_code; return reg_code;
} }
bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } bool is(XMMRegister reg) const { return reg_code == reg.reg_code; }
const char* ToString(); const char* ToString();
int reg_code; int reg_code;
}; };
typedef XMMRegister FloatRegister;
typedef XMMRegister DoubleRegister;
typedef XMMRegister Simd128Register;
#define DECLARE_REGISTER(R) \ #define DECLARE_REGISTER(R) \
const DoubleRegister R = {DoubleRegister::kCode_##R}; const DoubleRegister R = {DoubleRegister::kCode_##R};
DOUBLE_REGISTERS(DECLARE_REGISTER) DOUBLE_REGISTERS(DECLARE_REGISTER)
#undef DECLARE_REGISTER #undef DECLARE_REGISTER
const DoubleRegister no_double_reg = {DoubleRegister::kCode_no_reg}; const DoubleRegister no_double_reg = {DoubleRegister::kCode_no_reg};
typedef DoubleRegister Simd128Register;
typedef DoubleRegister XMMRegister;
enum Condition { enum Condition {
// any value < 0 is considered no_condition // any value < 0 is considered no_condition
no_condition = -1, no_condition = -1,
......
...@@ -63,6 +63,8 @@ namespace internal { ...@@ -63,6 +63,8 @@ namespace internal {
V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \ V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \
V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31) V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31)
#define FLOAT_REGISTERS DOUBLE_REGISTERS
#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ #define ALLOCATABLE_DOUBLE_REGISTERS(V) \
V(f0) V(f2) V(f4) V(f6) V(f8) V(f10) V(f12) V(f14) \ V(f0) V(f2) V(f4) V(f6) V(f8) V(f10) V(f12) V(f14) \
V(f16) V(f18) V(f20) V(f22) V(f24) V(f26) V(f16) V(f18) V(f20) V(f22) V(f24) V(f26)
...@@ -154,7 +156,7 @@ int ToNumber(Register reg); ...@@ -154,7 +156,7 @@ int ToNumber(Register reg);
Register ToRegister(int num); Register ToRegister(int num);
// Coprocessor register. // Coprocessor register.
struct DoubleRegister { struct FPURegister {
enum Code { enum Code {
#define REGISTER_CODE(R) kCode_##R, #define REGISTER_CODE(R) kCode_##R,
DOUBLE_REGISTERS(REGISTER_CODE) DOUBLE_REGISTERS(REGISTER_CODE)
...@@ -174,19 +176,19 @@ struct DoubleRegister { ...@@ -174,19 +176,19 @@ struct DoubleRegister {
const char* ToString(); const char* ToString();
bool IsAllocatable() const; bool IsAllocatable() const;
bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; } bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; }
bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } bool is(FPURegister reg) const { return reg_code == reg.reg_code; }
DoubleRegister low() const { FPURegister low() const {
// Find low reg of a Double-reg pair, which is the reg itself. // Find low reg of a Double-reg pair, which is the reg itself.
DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. DCHECK(reg_code % 2 == 0); // Specified Double reg must be even.
DoubleRegister reg; FPURegister reg;
reg.reg_code = reg_code; reg.reg_code = reg_code;
DCHECK(reg.is_valid()); DCHECK(reg.is_valid());
return reg; return reg;
} }
DoubleRegister high() const { FPURegister high() const {
// Find high reg of a Doubel-reg pair, which is reg + 1. // Find high reg of a Doubel-reg pair, which is reg + 1.
DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. DCHECK(reg_code % 2 == 0); // Specified Double reg must be even.
DoubleRegister reg; FPURegister reg;
reg.reg_code = reg_code + 1; reg.reg_code = reg_code + 1;
DCHECK(reg.is_valid()); DCHECK(reg.is_valid());
return reg; return reg;
...@@ -201,8 +203,8 @@ struct DoubleRegister { ...@@ -201,8 +203,8 @@ struct DoubleRegister {
return 1 << reg_code; return 1 << reg_code;
} }
static DoubleRegister from_code(int code) { static FPURegister from_code(int code) {
DoubleRegister r = {code}; FPURegister r = {code};
return r; return r;
} }
void setcode(int f) { void setcode(int f) {
...@@ -227,8 +229,12 @@ struct DoubleRegister { ...@@ -227,8 +229,12 @@ struct DoubleRegister {
// but it is not in common use. Someday we will want to support this in v8.) // but it is not in common use. Someday we will want to support this in v8.)
// For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers. // For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers.
typedef DoubleRegister FPURegister; typedef FPURegister FloatRegister;
typedef DoubleRegister FloatRegister;
typedef FPURegister DoubleRegister;
// TODO(mips) Define SIMD registers.
typedef FPURegister Simd128Register;
const DoubleRegister no_freg = {-1}; const DoubleRegister no_freg = {-1};
...@@ -304,9 +310,6 @@ struct FPUControlRegister { ...@@ -304,9 +310,6 @@ struct FPUControlRegister {
const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister }; const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister };
const FPUControlRegister FCSR = { kFCSRRegister }; const FPUControlRegister FCSR = { kFCSRRegister };
// TODO(mips) Define SIMD registers.
typedef DoubleRegister Simd128Register;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Machine instruction Operands. // Machine instruction Operands.
......
...@@ -63,6 +63,8 @@ namespace internal { ...@@ -63,6 +63,8 @@ namespace internal {
V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \ V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \
V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31) V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31)
#define FLOAT_REGISTERS DOUBLE_REGISTERS
#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ #define ALLOCATABLE_DOUBLE_REGISTERS(V) \
V(f0) V(f2) V(f4) V(f6) V(f8) V(f10) V(f12) V(f14) \ V(f0) V(f2) V(f4) V(f6) V(f8) V(f10) V(f12) V(f14) \
V(f16) V(f18) V(f20) V(f22) V(f24) V(f26) V(f16) V(f18) V(f20) V(f22) V(f24) V(f26)
...@@ -154,7 +156,7 @@ int ToNumber(Register reg); ...@@ -154,7 +156,7 @@ int ToNumber(Register reg);
Register ToRegister(int num); Register ToRegister(int num);
// Coprocessor register. // Coprocessor register.
struct DoubleRegister { struct FPURegister {
enum Code { enum Code {
#define REGISTER_CODE(R) kCode_##R, #define REGISTER_CODE(R) kCode_##R,
DOUBLE_REGISTERS(REGISTER_CODE) DOUBLE_REGISTERS(REGISTER_CODE)
...@@ -174,21 +176,21 @@ struct DoubleRegister { ...@@ -174,21 +176,21 @@ struct DoubleRegister {
const char* ToString(); const char* ToString();
bool IsAllocatable() const; bool IsAllocatable() const;
bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; } bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; }
bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } bool is(FPURegister reg) const { return reg_code == reg.reg_code; }
DoubleRegister low() const { FPURegister low() const {
// TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1. // TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1.
// Find low reg of a Double-reg pair, which is the reg itself. // Find low reg of a Double-reg pair, which is the reg itself.
DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. DCHECK(reg_code % 2 == 0); // Specified Double reg must be even.
DoubleRegister reg; FPURegister reg;
reg.reg_code = reg_code; reg.reg_code = reg_code;
DCHECK(reg.is_valid()); DCHECK(reg.is_valid());
return reg; return reg;
} }
DoubleRegister high() const { FPURegister high() const {
// TODO(plind): Create DCHECK for FR=0 mode. This usage illegal in FR=1. // TODO(plind): Create DCHECK for FR=0 mode. This usage illegal in FR=1.
// Find high reg of a Doubel-reg pair, which is reg + 1. // Find high reg of a Doubel-reg pair, which is reg + 1.
DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. DCHECK(reg_code % 2 == 0); // Specified Double reg must be even.
DoubleRegister reg; FPURegister reg;
reg.reg_code = reg_code + 1; reg.reg_code = reg_code + 1;
DCHECK(reg.is_valid()); DCHECK(reg.is_valid());
return reg; return reg;
...@@ -203,8 +205,8 @@ struct DoubleRegister { ...@@ -203,8 +205,8 @@ struct DoubleRegister {
return 1 << reg_code; return 1 << reg_code;
} }
static DoubleRegister from_code(int code) { static FPURegister from_code(int code) {
DoubleRegister r = {code}; FPURegister r = {code};
return r; return r;
} }
void setcode(int f) { void setcode(int f) {
...@@ -229,8 +231,12 @@ struct DoubleRegister { ...@@ -229,8 +231,12 @@ struct DoubleRegister {
// but it is not in common use. Someday we will want to support this in v8.) // but it is not in common use. Someday we will want to support this in v8.)
// For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers. // For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers.
typedef DoubleRegister FPURegister; typedef FPURegister FloatRegister;
typedef DoubleRegister FloatRegister;
typedef FPURegister DoubleRegister;
// TODO(mips64) Define SIMD registers.
typedef FPURegister Simd128Register;
const DoubleRegister no_freg = {-1}; const DoubleRegister no_freg = {-1};
...@@ -306,9 +312,6 @@ struct FPUControlRegister { ...@@ -306,9 +312,6 @@ struct FPUControlRegister {
const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister }; const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister };
const FPUControlRegister FCSR = { kFCSRRegister }; const FPUControlRegister FCSR = { kFCSRRegister };
// TODO(mips64) Define SIMD registers.
typedef DoubleRegister Simd128Register;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Machine instruction Operands. // Machine instruction Operands.
const int kSmiShift = kSmiTagSize + kSmiShiftSize; const int kSmiShift = kSmiTagSize + kSmiShiftSize;
......
...@@ -109,6 +109,8 @@ namespace internal { ...@@ -109,6 +109,8 @@ namespace internal {
V(d16) V(d17) V(d18) V(d19) V(d20) V(d21) V(d22) V(d23) \ V(d16) V(d17) V(d18) V(d19) V(d20) V(d21) V(d22) V(d23) \
V(d24) V(d25) V(d26) V(d27) V(d28) V(d29) V(d30) V(d31) V(d24) V(d25) V(d26) V(d27) V(d28) V(d29) V(d30) V(d31)
#define FLOAT_REGISTERS DOUBLE_REGISTERS
#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ #define ALLOCATABLE_DOUBLE_REGISTERS(V) \
V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \ V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \
V(d8) V(d9) V(d10) V(d11) V(d12) V(d15) \ V(d8) V(d9) V(d10) V(d11) V(d12) V(d15) \
...@@ -238,6 +240,11 @@ struct DoubleRegister { ...@@ -238,6 +240,11 @@ struct DoubleRegister {
int reg_code; int reg_code;
}; };
typedef DoubleRegister FloatRegister;
// TODO(ppc) Define SIMD registers.
typedef DoubleRegister Simd128Register;
#define DECLARE_REGISTER(R) \ #define DECLARE_REGISTER(R) \
const DoubleRegister R = {DoubleRegister::kCode_##R}; const DoubleRegister R = {DoubleRegister::kCode_##R};
DOUBLE_REGISTERS(DECLARE_REGISTER) DOUBLE_REGISTERS(DECLARE_REGISTER)
...@@ -283,9 +290,6 @@ const CRegister cr5 = {5}; ...@@ -283,9 +290,6 @@ const CRegister cr5 = {5};
const CRegister cr6 = {6}; const CRegister cr6 = {6};
const CRegister cr7 = {7}; const CRegister cr7 = {7};
// TODO(ppc) Define SIMD registers.
typedef DoubleRegister Simd128Register;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Machine instruction Operands // Machine instruction Operands
......
...@@ -90,6 +90,8 @@ namespace internal { ...@@ -90,6 +90,8 @@ namespace internal {
V(d0) V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \ V(d0) V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \
V(d8) V(d9) V(d10) V(d11) V(d12) V(d13) V(d14) V(d15) V(d8) V(d9) V(d10) V(d11) V(d12) V(d13) V(d14) V(d15)
#define FLOAT_REGISTERS DOUBLE_REGISTERS
#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ #define ALLOCATABLE_DOUBLE_REGISTERS(V) \
V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \ V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \
V(d8) V(d9) V(d10) V(d11) V(d12) V(d15) V(d0) V(d8) V(d9) V(d10) V(d11) V(d12) V(d15) V(d0)
...@@ -221,7 +223,10 @@ struct DoubleRegister { ...@@ -221,7 +223,10 @@ struct DoubleRegister {
int reg_code; int reg_code;
}; };
typedef DoubleRegister DoubleRegister; typedef DoubleRegister FloatRegister;
// TODO(john.yan) Define SIMD registers.
typedef DoubleRegister Simd128Register;
#define DECLARE_REGISTER(R) \ #define DECLARE_REGISTER(R) \
const DoubleRegister R = {DoubleRegister::kCode_##R}; const DoubleRegister R = {DoubleRegister::kCode_##R};
...@@ -265,9 +270,6 @@ const CRegister cr5 = {5}; ...@@ -265,9 +270,6 @@ const CRegister cr5 = {5};
const CRegister cr6 = {6}; const CRegister cr6 = {6};
const CRegister cr7 = {7}; const CRegister cr7 = {7};
// TODO(john.yan) Define SIMD registers.
typedef DoubleRegister Simd128Register;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Machine instruction Operands // Machine instruction Operands
......
...@@ -183,6 +183,8 @@ const Register arg_reg_4 = {Register::kCode_rcx}; ...@@ -183,6 +183,8 @@ const Register arg_reg_4 = {Register::kCode_rcx};
V(xmm14) \ V(xmm14) \
V(xmm15) V(xmm15)
#define FLOAT_REGISTERS DOUBLE_REGISTERS
#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ #define ALLOCATABLE_DOUBLE_REGISTERS(V) \
V(xmm1) \ V(xmm1) \
V(xmm2) \ V(xmm2) \
...@@ -200,8 +202,7 @@ const Register arg_reg_4 = {Register::kCode_rcx}; ...@@ -200,8 +202,7 @@ const Register arg_reg_4 = {Register::kCode_rcx};
V(xmm14) \ V(xmm14) \
V(xmm15) V(xmm15)
struct XMMRegister {
struct DoubleRegister {
enum Code { enum Code {
#define REGISTER_CODE(R) kCode_##R, #define REGISTER_CODE(R) kCode_##R,
DOUBLE_REGISTERS(REGISTER_CODE) DOUBLE_REGISTERS(REGISTER_CODE)
...@@ -212,15 +213,15 @@ struct DoubleRegister { ...@@ -212,15 +213,15 @@ struct DoubleRegister {
static const int kMaxNumRegisters = Code::kAfterLast; static const int kMaxNumRegisters = Code::kAfterLast;
static DoubleRegister from_code(int code) { static XMMRegister from_code(int code) {
DoubleRegister result = {code}; XMMRegister result = {code};
return result; return result;
} }
const char* ToString(); const char* ToString();
bool IsAllocatable() const; bool IsAllocatable() const;
bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; } bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; }
bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } bool is(XMMRegister reg) const { return reg_code == reg.reg_code; }
int code() const { int code() const {
DCHECK(is_valid()); DCHECK(is_valid());
return reg_code; return reg_code;
...@@ -238,6 +239,11 @@ struct DoubleRegister { ...@@ -238,6 +239,11 @@ struct DoubleRegister {
int reg_code; int reg_code;
}; };
typedef XMMRegister FloatRegister;
typedef XMMRegister DoubleRegister;
typedef XMMRegister Simd128Register;
#define DECLARE_REGISTER(R) \ #define DECLARE_REGISTER(R) \
const DoubleRegister R = {DoubleRegister::kCode_##R}; const DoubleRegister R = {DoubleRegister::kCode_##R};
...@@ -245,11 +251,6 @@ DOUBLE_REGISTERS(DECLARE_REGISTER) ...@@ -245,11 +251,6 @@ DOUBLE_REGISTERS(DECLARE_REGISTER)
#undef DECLARE_REGISTER #undef DECLARE_REGISTER
const DoubleRegister no_double_reg = {DoubleRegister::kCode_no_reg}; const DoubleRegister no_double_reg = {DoubleRegister::kCode_no_reg};
typedef DoubleRegister XMMRegister;
typedef DoubleRegister Simd128Register;
enum Condition { enum Condition {
// any value < 0 is considered no_condition // any value < 0 is considered no_condition
no_condition = -1, no_condition = -1,
......
...@@ -74,6 +74,8 @@ namespace internal { ...@@ -74,6 +74,8 @@ namespace internal {
V(stX_6) \ V(stX_6) \
V(stX_7) V(stX_7)
#define FLOAT_REGISTERS DOUBLE_REGISTERS
#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ #define ALLOCATABLE_DOUBLE_REGISTERS(V) \
V(stX_0) \ V(stX_0) \
V(stX_1) \ V(stX_1) \
...@@ -145,8 +147,7 @@ GENERAL_REGISTERS(DECLARE_REGISTER) ...@@ -145,8 +147,7 @@ GENERAL_REGISTERS(DECLARE_REGISTER)
#undef DECLARE_REGISTER #undef DECLARE_REGISTER
const Register no_reg = {Register::kCode_no_reg}; const Register no_reg = {Register::kCode_no_reg};
struct X87Register {
struct DoubleRegister {
enum Code { enum Code {
#define REGISTER_CODE(R) kCode_##R, #define REGISTER_CODE(R) kCode_##R,
DOUBLE_REGISTERS(REGISTER_CODE) DOUBLE_REGISTERS(REGISTER_CODE)
...@@ -158,8 +159,8 @@ struct DoubleRegister { ...@@ -158,8 +159,8 @@ struct DoubleRegister {
static const int kMaxNumRegisters = Code::kAfterLast; static const int kMaxNumRegisters = Code::kAfterLast;
static const int kMaxNumAllocatableRegisters = 6; static const int kMaxNumAllocatableRegisters = 6;
static DoubleRegister from_code(int code) { static X87Register from_code(int code) {
DoubleRegister result = {code}; X87Register result = {code};
return result; return result;
} }
...@@ -171,24 +172,26 @@ struct DoubleRegister { ...@@ -171,24 +172,26 @@ struct DoubleRegister {
return reg_code; return reg_code;
} }
bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } bool is(X87Register reg) const { return reg_code == reg.reg_code; }
const char* ToString(); const char* ToString();
int reg_code; int reg_code;
}; };
typedef X87Register FloatRegister;
typedef X87Register DoubleRegister;
// TODO(x87) Define SIMD registers.
typedef X87Register Simd128Register;
#define DECLARE_REGISTER(R) \ #define DECLARE_REGISTER(R) \
const DoubleRegister R = {DoubleRegister::kCode_##R}; const DoubleRegister R = {DoubleRegister::kCode_##R};
DOUBLE_REGISTERS(DECLARE_REGISTER) DOUBLE_REGISTERS(DECLARE_REGISTER)
#undef DECLARE_REGISTER #undef DECLARE_REGISTER
const DoubleRegister no_double_reg = {DoubleRegister::kCode_no_reg}; const DoubleRegister no_double_reg = {DoubleRegister::kCode_no_reg};
typedef DoubleRegister X87Register;
// TODO(x87) Define SIMD registers.
typedef DoubleRegister Simd128Register;
enum Condition { enum Condition {
// any value < 0 is considered no_condition // any value < 0 is considered no_condition
no_condition = -1, no_condition = -1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment