Bug 1112164 part 10 - Clean-up: Use SetType for register mask declarations. r=bbouvier

This commit is contained in:
Nicolas B. Pierron 2015-02-26 12:18:25 +01:00
parent fe5896764c
commit 4be8ea003d
5 changed files with 103 additions and 100 deletions

View File

@ -95,16 +95,18 @@ class Registers
static const uint32_t Total = 16;
static const uint32_t Allocatable = 13;
static const uint32_t AllMask = (1 << Total) - 1;
static const uint32_t ArgRegMask = (1 << r0) | (1 << r1) | (1 << r2) | (1 << r3);
typedef uint32_t SetType;
static const uint32_t VolatileMask =
static const SetType AllMask = (1 << Total) - 1;
static const SetType ArgRegMask = (1 << r0) | (1 << r1) | (1 << r2) | (1 << r3);
static const SetType VolatileMask =
(1 << r0) |
(1 << r1) |
(1 << Registers::r2) |
(1 << Registers::r3);
static const uint32_t NonVolatileMask =
static const SetType NonVolatileMask =
(1 << Registers::r4) |
(1 << Registers::r5) |
(1 << Registers::r6) |
@ -116,35 +118,35 @@ class Registers
(1 << Registers::r12) |
(1 << Registers::r14);
static const uint32_t WrapperMask =
static const SetType WrapperMask =
VolatileMask | // = arguments
(1 << Registers::r4) | // = outReg
(1 << Registers::r5); // = argBase
static const uint32_t SingleByteRegs =
static const SetType SingleByteRegs =
VolatileMask | NonVolatileMask;
static const uint32_t NonAllocatableMask =
static const SetType NonAllocatableMask =
(1 << Registers::sp) |
(1 << Registers::r12) | // r12 = ip = scratch
(1 << Registers::lr) |
(1 << Registers::pc);
// Registers that can be allocated without being saved, generally.
static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
static const SetType TempMask = VolatileMask & ~NonAllocatableMask;
// Registers returned from a JS -> JS call.
static const uint32_t JSCallMask =
static const SetType JSCallMask =
(1 << Registers::r2) |
(1 << Registers::r3);
// Registers returned from a JS -> C call.
static const uint32_t CallMask =
static const SetType CallMask =
(1 << Registers::r0) |
(1 << Registers::r1); // Used for double-size returns.
static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
typedef uint32_t SetType;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
static uint32_t SetSize(SetType x) {
static_assert(sizeof(SetType) == 4, "SetType must be 32 bits");
return mozilla::CountPopulation32(x);
@ -266,11 +268,13 @@ class FloatRegisters
// There are only 32 places that we can put values.
static const uint32_t TotalPhys = 32;
static uint32_t ActualTotalPhys();
static const uint64_t AllDoubleMask = ((1ull << 16) - 1) << 32;
static const uint64_t AllMask = ((1ull << 48) - 1);
typedef uint64_t SetType;
static const SetType AllDoubleMask = ((1ull << 16) - 1) << 32;
static const SetType AllMask = ((1ull << 48) - 1);
// d15 is the ScratchFloatReg.
static const uint64_t NonVolatileDoubleMask =
static const SetType NonVolatileDoubleMask =
((1ULL << d8) |
(1ULL << d9) |
(1ULL << d10) |
@ -279,7 +283,7 @@ class FloatRegisters
(1ULL << d13) |
(1ULL << d14));
// s30 and s31 alias d15.
static const uint64_t NonVolatileMask =
static const SetType NonVolatileMask =
(NonVolatileDoubleMask |
((1 << s16) |
(1 << s17) |
@ -297,22 +301,21 @@ class FloatRegisters
(1 << s29) |
(1 << s30)));
static const uint64_t VolatileMask = AllMask & ~NonVolatileMask;
static const uint64_t VolatileDoubleMask = AllDoubleMask & ~NonVolatileDoubleMask;
static const SetType VolatileMask = AllMask & ~NonVolatileMask;
static const SetType VolatileDoubleMask = AllDoubleMask & ~NonVolatileDoubleMask;
static const uint64_t WrapperMask = VolatileMask;
static const SetType WrapperMask = VolatileMask;
// d15 is the ARM scratch float register.
// s30 and s31 alias d15.
static const uint64_t NonAllocatableMask = ((1ULL << d15)) |
(1ULL << s30) |
(1ULL << s31);
static const SetType NonAllocatableMask = ((1ULL << d15)) |
(1ULL << s30) |
(1ULL << s31);
// Registers that can be allocated without being saved, generally.
static const uint64_t TempMask = VolatileMask & ~NonAllocatableMask;
static const SetType TempMask = VolatileMask & ~NonAllocatableMask;
static const uint64_t AllocatableMask = AllMask & ~NonAllocatableMask;
typedef uint64_t SetType;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
};
template <typename T>

View File

@ -135,10 +135,11 @@ class Registers
static const uint32_t Total = 32;
static const uint32_t Allocatable = 14;
static const uint32_t AllMask = 0xffffffff;
static const uint32_t ArgRegMask = (1 << a0) | (1 << a1) | (1 << a2) | (1 << a3);
typedef uint32_t SetType;
static const SetType AllMask = 0xffffffff;
static const SetType ArgRegMask = (1 << a0) | (1 << a1) | (1 << a2) | (1 << a3);
static const uint32_t VolatileMask =
static const SetType VolatileMask =
(1 << Registers::v0) |
(1 << Registers::v1) |
(1 << Registers::a0) |
@ -156,7 +157,7 @@ class Registers
// We use this constant to save registers when entering functions. This
// is why $ra is added here even though it is not "Non Volatile".
static const uint32_t NonVolatileMask =
static const SetType NonVolatileMask =
(1 << Registers::s0) |
(1 << Registers::s1) |
(1 << Registers::s2) |
@ -167,12 +168,12 @@ class Registers
(1 << Registers::s7) |
(1 << Registers::ra);
static const uint32_t WrapperMask =
static const SetType WrapperMask =
VolatileMask | // = arguments
(1 << Registers::t0) | // = outReg
(1 << Registers::t1); // = argBase
static const uint32_t NonAllocatableMask =
static const SetType NonAllocatableMask =
(1 << Registers::zero) |
(1 << Registers::at) | // at = scratch
(1 << Registers::t8) | // t8 = scratch
@ -185,21 +186,20 @@ class Registers
(1 << Registers::ra);
// Registers that can be allocated without being saved, generally.
static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
static const SetType TempMask = VolatileMask & ~NonAllocatableMask;
// Registers returned from a JS -> JS call.
static const uint32_t JSCallMask =
static const SetType JSCallMask =
(1 << Registers::a2) |
(1 << Registers::a3);
// Registers returned from a JS -> C call.
static const uint32_t CallMask =
static const SetType CallMask =
(1 << Registers::v0) |
(1 << Registers::v1); // used for double-size returns
static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
typedef uint32_t SetType;
static uint32_t SetSize(SetType x) {
static_assert(sizeof(SetType) == 4, "SetType must be 32 bits");
return mozilla::CountPopulation32(x);
@ -290,10 +290,12 @@ class FloatRegisters
static const uint32_t Allocatable = 42;
// When saving all registers we only need to do is save double registers.
static const uint32_t TotalPhys = 16;
static const uint64_t AllDoubleMask = 0x55555555ULL << 32;
static const uint64_t AllMask = AllDoubleMask | ((1ULL << 32) - 1);
static const uint64_t NonVolatileDoubleMask =
typedef uint64_t SetType;
static const SetType AllDoubleMask = 0x55555555ULL << 32;
static const SetType AllMask = AllDoubleMask | ((1ULL << 32) - 1);
static const SetType NonVolatileDoubleMask =
((1ULL << FloatRegisters::f20) |
(1ULL << FloatRegisters::f22) |
(1ULL << FloatRegisters::f24) |
@ -302,7 +304,7 @@ class FloatRegisters
(1ULL << FloatRegisters::f30)) << 32;
// f20-single and f21-single alias f20-double ...
static const uint64_t NonVolatileMask =
static const SetType NonVolatileMask =
NonVolatileDoubleMask |
(1ULL << FloatRegisters::f20) |
(1ULL << FloatRegisters::f21) |
@ -317,16 +319,16 @@ class FloatRegisters
(1ULL << FloatRegisters::f30) |
(1ULL << FloatRegisters::f31);
static const uint64_t VolatileMask = AllMask & ~NonVolatileMask;
static const uint64_t VolatileDoubleMask = AllDoubleMask & ~NonVolatileDoubleMask;
static const SetType VolatileMask = AllMask & ~NonVolatileMask;
static const SetType VolatileDoubleMask = AllDoubleMask & ~NonVolatileDoubleMask;
static const uint64_t WrapperMask = VolatileMask;
static const SetType WrapperMask = VolatileMask;
static const uint64_t NonAllocatableDoubleMask =
static const SetType NonAllocatableDoubleMask =
((1ULL << FloatRegisters::f16) |
(1ULL << FloatRegisters::f18)) << 32;
// f16-single and f17-single alias f16-double ...
static const uint64_t NonAllocatableMask =
static const SetType NonAllocatableMask =
NonAllocatableDoubleMask |
(1ULL << FloatRegisters::f16) |
(1ULL << FloatRegisters::f17) |
@ -334,11 +336,9 @@ class FloatRegisters
(1ULL << FloatRegisters::f19);
// Registers that can be allocated without being saved, generally.
static const uint64_t TempMask = VolatileMask & ~NonAllocatableMask;
static const SetType TempMask = VolatileMask & ~NonAllocatableMask;
static const uint64_t AllocatableMask = AllMask & ~NonAllocatableMask;
typedef uint64_t SetType;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
};
template <typename T>

View File

@ -40,15 +40,15 @@ class Registers
static const uint32_t Total = 1;
static const uint32_t TotalPhys = 0;
static const uint32_t Allocatable = 0;
static const uint32_t AllMask = 0;
static const uint32_t ArgRegMask = 0;
static const uint32_t VolatileMask = 0;
static const uint32_t NonVolatileMask = 0;
static const uint32_t NonAllocatableMask = 0;
static const uint32_t AllocatableMask = 0;
static const uint32_t TempMask = 0;
static const uint32_t JSCallMask = 0;
static const uint32_t CallMask = 0;
static const SetType AllMask = 0;
static const SetType ArgRegMask = 0;
static const SetType VolatileMask = 0;
static const SetType NonVolatileMask = 0;
static const SetType NonAllocatableMask = 0;
static const SetType AllocatableMask = 0;
static const SetType TempMask = 0;
static const SetType JSCallMask = 0;
static const SetType CallMask = 0;
};
typedef uint8_t PackedRegisterMask;
@ -71,12 +71,12 @@ class FloatRegisters
static const uint32_t Total = 0;
static const uint32_t TotalPhys = 0;
static const uint32_t Allocatable = 0;
static const uint32_t AllMask = 0;
static const uint32_t AllDoubleMask = 0;
static const uint32_t VolatileMask = 0;
static const uint32_t NonVolatileMask = 0;
static const uint32_t NonAllocatableMask = 0;
static const uint32_t AllocatableMask = 0;
static const SetType AllMask = 0;
static const SetType AllDoubleMask = 0;
static const SetType VolatileMask = 0;
static const SetType NonVolatileMask = 0;
static const SetType NonAllocatableMask = 0;
static const SetType AllocatableMask = 0;
};
template <typename T>

View File

@ -62,9 +62,9 @@ class Registers {
static const uint32_t TotalPhys = 16;
static const uint32_t Allocatable = 14;
static const uint32_t AllMask = (1 << Total) - 1;
static const SetType AllMask = (1 << Total) - 1;
static const uint32_t ArgRegMask =
static const SetType ArgRegMask =
# if !defined(_WIN64)
(1 << X86Encoding::rdi) |
(1 << X86Encoding::rsi) |
@ -74,7 +74,7 @@ class Registers {
(1 << X86Encoding::r8) |
(1 << X86Encoding::r9);
static const uint32_t VolatileMask =
static const SetType VolatileMask =
(1 << X86Encoding::rax) |
(1 << X86Encoding::rcx) |
(1 << X86Encoding::rdx) |
@ -87,7 +87,7 @@ class Registers {
(1 << X86Encoding::r10) |
(1 << X86Encoding::r11);
static const uint32_t NonVolatileMask =
static const SetType NonVolatileMask =
(1 << X86Encoding::rbx) |
#if defined(_WIN64)
(1 << X86Encoding::rsi) |
@ -99,25 +99,25 @@ class Registers {
(1 << X86Encoding::r14) |
(1 << X86Encoding::r15);
static const uint32_t WrapperMask = VolatileMask;
static const SetType WrapperMask = VolatileMask;
static const uint32_t SingleByteRegs = VolatileMask | NonVolatileMask;
static const SetType SingleByteRegs = VolatileMask | NonVolatileMask;
static const uint32_t NonAllocatableMask =
static const SetType NonAllocatableMask =
(1 << X86Encoding::rsp) |
(1 << X86Encoding::r11); // This is ScratchReg.
static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
// Registers that can be allocated without being saved, generally.
static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
static const SetType TempMask = VolatileMask & ~NonAllocatableMask;
// Registers returned from a JS -> JS call.
static const uint32_t JSCallMask =
static const SetType JSCallMask =
(1 << X86Encoding::rcx);
// Registers returned from a JS -> C call.
static const uint32_t CallMask =
static const SetType CallMask =
(1 << X86Encoding::rax);
};
@ -147,9 +147,9 @@ class FloatRegisters {
static const uint32_t Allocatable = 15;
static const uint32_t AllMask = (1 << Total) - 1;
static const uint32_t AllDoubleMask = AllMask;
static const uint32_t VolatileMask =
static const SetType AllMask = (1 << Total) - 1;
static const SetType AllDoubleMask = AllMask;
static const SetType VolatileMask =
#if defined(_WIN64)
(1 << X86Encoding::xmm0) |
(1 << X86Encoding::xmm1) |
@ -161,14 +161,14 @@ class FloatRegisters {
AllMask;
#endif
static const uint32_t NonVolatileMask = AllMask & ~VolatileMask;
static const SetType NonVolatileMask = AllMask & ~VolatileMask;
static const uint32_t WrapperMask = VolatileMask;
static const SetType WrapperMask = VolatileMask;
static const uint32_t NonAllocatableMask =
static const SetType NonAllocatableMask =
(1 << X86Encoding::xmm15); // This is ScratchDoubleReg.
static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
};
template <typename T>

View File

@ -67,46 +67,46 @@ class Registers {
static const uint32_t TotalPhys = 8;
static const uint32_t Allocatable = 7;
static const uint32_t AllMask = (1 << Total) - 1;
static const SetType AllMask = (1 << Total) - 1;
static const uint32_t ArgRegMask = 0;
static const SetType ArgRegMask = 0;
static const uint32_t VolatileMask =
static const SetType VolatileMask =
(1 << X86Encoding::rax) |
(1 << X86Encoding::rcx) |
(1 << X86Encoding::rdx);
static const uint32_t NonVolatileMask =
static const SetType NonVolatileMask =
(1 << X86Encoding::rbx) |
(1 << X86Encoding::rsi) |
(1 << X86Encoding::rdi) |
(1 << X86Encoding::rbp);
static const uint32_t WrapperMask =
static const SetType WrapperMask =
VolatileMask |
(1 << X86Encoding::rbx);
static const uint32_t SingleByteRegs =
static const SetType SingleByteRegs =
(1 << X86Encoding::rax) |
(1 << X86Encoding::rcx) |
(1 << X86Encoding::rdx) |
(1 << X86Encoding::rbx);
static const uint32_t NonAllocatableMask =
static const SetType NonAllocatableMask =
(1 << X86Encoding::rsp);
static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
// Registers that can be allocated without being saved, generally.
static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
static const SetType TempMask = VolatileMask & ~NonAllocatableMask;
// Registers returned from a JS -> JS call.
static const uint32_t JSCallMask =
static const SetType JSCallMask =
(1 << X86Encoding::rcx) |
(1 << X86Encoding::rdx);
// Registers returned from a JS -> C call.
static const uint32_t CallMask =
static const SetType CallMask =
(1 << X86Encoding::rax);
};
@ -135,17 +135,17 @@ class FloatRegisters {
static const uint32_t TotalPhys = 8;
static const uint32_t Allocatable = 7;
static const uint32_t AllMask = (1 << Total) - 1;
static const uint32_t AllDoubleMask = AllMask;
static const uint32_t VolatileMask = AllMask;
static const uint32_t NonVolatileMask = 0;
static const SetType AllMask = (1 << Total) - 1;
static const SetType AllDoubleMask = AllMask;
static const SetType VolatileMask = AllMask;
static const SetType NonVolatileMask = 0;
static const uint32_t WrapperMask = VolatileMask;
static const SetType WrapperMask = VolatileMask;
static const uint32_t NonAllocatableMask =
static const SetType NonAllocatableMask =
(1 << X86Encoding::xmm7); // This is ScratchDoubleReg.
static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
static const SetType AllocatableMask = AllMask & ~NonAllocatableMask;
};
template <typename T>