| Index: src/IceTargetLoweringX8664Traits.h
|
| diff --git a/src/IceTargetLoweringX8664Traits.h b/src/IceTargetLoweringX8664Traits.h
|
| index f49bb6b2cd8979ceb222ec7ede7da5e7cc0746ac..7f3699de735c4ebba62f22df5b46aa20a149c812 100644
|
| --- a/src/IceTargetLoweringX8664Traits.h
|
| +++ b/src/IceTargetLoweringX8664Traits.h
|
| @@ -296,12 +296,12 @@ template <> struct MachineTraits<TargetX8664> {
|
| static constexpr Type WordType = IceType_i64;
|
|
|
| static IceString getRegName(int32_t RegNum) {
|
| - static const char *const RegNames[] = {
|
| + static const char *const RegNames[] = {{/*Empty for Reg_Invalid */},
|
| #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
|
| isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| isTrunc8Rcvr, isAhRcvr, aliases) \
|
| name,
|
| - REGX8664_TABLE
|
| + REGX8664_TABLE
|
| #undef X
|
| };
|
| assert(RegNum >= 0);
|
| @@ -310,12 +310,12 @@ template <> struct MachineTraits<TargetX8664> {
|
| }
|
|
|
| static GPRRegister getEncodedGPR(int32_t RegNum) {
|
| - static const GPRRegister GPRRegs[] = {
|
| + static const GPRRegister GPRRegs[] = {{/*Empty for Reg_Invalid */},
|
| #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
|
| isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| isTrunc8Rcvr, isAhRcvr, aliases) \
|
| GPRRegister(isGPR ? encode : GPRRegister::Encoded_Not_GPR),
|
| - REGX8664_TABLE
|
| + REGX8664_TABLE
|
| #undef X
|
| };
|
| assert(RegNum >= 0);
|
| @@ -325,12 +325,12 @@ template <> struct MachineTraits<TargetX8664> {
|
| }
|
|
|
| static ByteRegister getEncodedByteReg(int32_t RegNum) {
|
| - static const ByteRegister ByteRegs[] = {
|
| + static const ByteRegister ByteRegs[] = {{/*Empty for Reg_Invalid */},
|
| #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
|
| isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| isTrunc8Rcvr, isAhRcvr, aliases) \
|
| ByteRegister(is8 ? encode : ByteRegister::Encoded_Not_ByteReg),
|
| - REGX8664_TABLE
|
| + REGX8664_TABLE
|
| #undef X
|
| };
|
| assert(RegNum >= 0);
|
| @@ -340,12 +340,12 @@ template <> struct MachineTraits<TargetX8664> {
|
| }
|
|
|
| static XmmRegister getEncodedXmm(int32_t RegNum) {
|
| - static const XmmRegister XmmRegs[] = {
|
| + static const XmmRegister XmmRegs[] = {{/*Empty for Reg_Invalid */},
|
| #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
|
| isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| isTrunc8Rcvr, isAhRcvr, aliases) \
|
| XmmRegister(isXmm ? encode : XmmRegister::Encoded_Not_Xmm),
|
| - REGX8664_TABLE
|
| + REGX8664_TABLE
|
| #undef X
|
| };
|
| assert(RegNum >= 0);
|
| @@ -355,12 +355,12 @@ template <> struct MachineTraits<TargetX8664> {
|
| }
|
|
|
| static uint32_t getEncoding(int32_t RegNum) {
|
| - static const uint32_t Encoding[] = {
|
| + static const uint32_t Encoding[] = {{/*Empty for Reg_Invalid */},
|
| #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
|
| isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| isTrunc8Rcvr, isAhRcvr, aliases) \
|
| encode,
|
| - REGX8664_TABLE
|
| + REGX8664_TABLE
|
| #undef X
|
| };
|
| assert(RegNum >= 0);
|
| @@ -369,12 +369,12 @@ template <> struct MachineTraits<TargetX8664> {
|
| }
|
|
|
| static inline int32_t getBaseReg(int32_t RegNum) {
|
| - static const int32_t BaseRegs[] = {
|
| + static const int32_t BaseRegs[] = {{/*empty for Reg_Invalid */},
|
| #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
|
| isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| isTrunc8Rcvr, isAhRcvr, aliases) \
|
| RegisterSet::base,
|
| - REGX8664_TABLE
|
| + REGX8664_TABLE
|
| #undef X
|
| };
|
| assert(RegNum >= 0);
|
| @@ -402,6 +402,7 @@ private:
|
| public:
|
| static int32_t getGprForType(Type Ty, int32_t RegNum) {
|
| assert(RegNum != Variable::NoRegister);
|
| + assert(RegNum != RegisterSet::Reg_Invalid);
|
|
|
| if (!isScalarIntegerType(Ty)) {
|
| return RegNum;
|
| @@ -468,30 +469,58 @@ public:
|
| llvm::SmallBitVector InvalidRegisters(RegisterSet::Reg_NUM);
|
| ScratchRegs->resize(RegisterSet::Reg_NUM);
|
|
|
| + static struct {
|
| + uint16_t Val;
|
| + int Is64 : 1;
|
| + int Is32 : 1;
|
| + int Is16 : 1;
|
| + int Is8 : 1;
|
| + int IsXmm : 1;
|
| + int Is64To8 : 1;
|
| + int Is32To8 : 1;
|
| + int Is16To8 : 1;
|
| + int IsTrunc8Rcvr : 1;
|
| + int IsAhRcvr : 1;
|
| + int Scratch : 1;
|
| + uint16_t Aliases[4];
|
| + } X8664RegTable[RegisterSet::Reg_NUM] = {
|
| + {/* Empty entry for RegInvalid. */},
|
| #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
|
| isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| isTrunc8Rcvr, isAhRcvr, aliases) \
|
| - (IntegerRegistersI64)[RegisterSet::val] = is64; \
|
| - (IntegerRegistersI32)[RegisterSet::val] = is32; \
|
| - (IntegerRegistersI16)[RegisterSet::val] = is16; \
|
| - (IntegerRegistersI8)[RegisterSet::val] = is8; \
|
| - (FloatRegisters)[RegisterSet::val] = isXmm; \
|
| - (VectorRegisters)[RegisterSet::val] = isXmm; \
|
| - (Trunc64To8Registers)[RegisterSet::val] = is64To8; \
|
| - (Trunc32To8Registers)[RegisterSet::val] = is32To8; \
|
| - (Trunc16To8Registers)[RegisterSet::val] = is16To8; \
|
| - (Trunc8RcvrRegisters)[RegisterSet::val] = isTrunc8Rcvr; \
|
| - (AhRcvrRegisters)[RegisterSet::val] = isAhRcvr; \
|
| - (*RegisterAliases)[RegisterSet::val].resize(RegisterSet::Reg_NUM); \
|
| - for (SizeT RegAlias : aliases) { \
|
| - assert(!(*RegisterAliases)[RegisterSet::val][RegAlias] && \
|
| - "Duplicate alias for " #val); \
|
| - (*RegisterAliases)[RegisterSet::val].set(RegAlias); \
|
| + { \
|
| + RegisterSet::val, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
|
| + isTrunc8Rcvr, isAhRcvr, scratch, aliases \
|
| } \
|
| - (*RegisterAliases)[RegisterSet::val].set(RegisterSet::val); \
|
| - (*ScratchRegs)[RegisterSet::val] = scratch;
|
| - REGX8664_TABLE;
|
| + ,
|
| + REGX8664_TABLE
|
| #undef X
|
| + };
|
| +
|
| + for (SizeT ii = 1; ii < llvm::array_lengthof(X8664RegTable); ++ii) {
|
| + const auto &Entry = X8664RegTable[ii];
|
| + (IntegerRegistersI64)[Entry.Val] = Entry.Is64;
|
| + (IntegerRegistersI32)[Entry.Val] = Entry.Is32;
|
| + (IntegerRegistersI16)[Entry.Val] = Entry.Is16;
|
| + (IntegerRegistersI8)[Entry.Val] = Entry.Is8;
|
| + (FloatRegisters)[Entry.Val] = Entry.IsXmm;
|
| + (VectorRegisters)[Entry.Val] = Entry.IsXmm;
|
| + (Trunc64To8Registers)[Entry.Val] = Entry.Is64To8;
|
| + (Trunc32To8Registers)[Entry.Val] = Entry.Is32To8;
|
| + (Trunc16To8Registers)[Entry.Val] = Entry.Is16To8;
|
| + (Trunc8RcvrRegisters)[Entry.Val] = Entry.IsTrunc8Rcvr;
|
| + (AhRcvrRegisters)[Entry.Val] = Entry.IsAhRcvr;
|
| + (*RegisterAliases)[Entry.Val].resize(RegisterSet::Reg_NUM);
|
| + for (SizeT Alias : Entry.Aliases) {
|
| + if (Alias == 0) {
|
| + break;
|
| + }
|
| + assert(!(*RegisterAliases)[Entry.Val][Alias] && "Duplicate alias");
|
| + (*RegisterAliases)[Entry.Val].set(Alias);
|
| + }
|
| + (*RegisterAliases)[Entry.Val].set(Entry.Val);
|
| + (*ScratchRegs)[Entry.Val] = Entry.Scratch;
|
| + }
|
|
|
| (*TypeToRegisterSet)[RC_void] = InvalidRegisters;
|
| (*TypeToRegisterSet)[RC_i1] = IntegerRegistersI8;
|
| @@ -611,7 +640,8 @@ public:
|
| }
|
| }
|
|
|
| - assert(NumShuffled + NumPreserved == RegisterSet::Reg_NUM);
|
| + // We need to subtract one to account for Reg_Invalid.
|
| + assert(NumShuffled + NumPreserved == RegisterSet::Reg_NUM - 1);
|
|
|
| if (Func->isVerbose(IceV_Random)) {
|
| OstreamLocker L(Func->getContext());
|
|
|