Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: src/IceTargetLoweringX8632Traits.h

Issue 1546373003: Subzero. X86. Refactors initRegisterSet. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Removes unneeded initializer. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceRegistersX8664.h ('k') | src/IceTargetLoweringX8664Traits.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX8632Traits.h
diff --git a/src/IceTargetLoweringX8632Traits.h b/src/IceTargetLoweringX8632Traits.h
index d02f69a1d7c02076b441b877c5fecf48a5864241..8091ce2153dab7cacb787e5edb5189dba7b34555 100644
--- a/src/IceTargetLoweringX8632Traits.h
+++ b/src/IceTargetLoweringX8632Traits.h
@@ -271,12 +271,12 @@ template <> struct MachineTraits<TargetX8632> {
static constexpr Type WordType = IceType_i32;
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,
- REGX8632_TABLE
+ REGX8632_TABLE
#undef X
};
assert(RegNum >= 0);
@@ -285,12 +285,12 @@ template <> struct MachineTraits<TargetX8632> {
}
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),
- REGX8632_TABLE
+ REGX8632_TABLE
#undef X
};
assert(RegNum >= 0);
@@ -300,12 +300,12 @@ template <> struct MachineTraits<TargetX8632> {
}
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),
- REGX8632_TABLE
+ REGX8632_TABLE
#undef X
};
assert(RegNum >= 0);
@@ -315,12 +315,12 @@ template <> struct MachineTraits<TargetX8632> {
}
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),
- REGX8632_TABLE
+ REGX8632_TABLE
#undef X
};
assert(RegNum >= 0);
@@ -330,12 +330,12 @@ template <> struct MachineTraits<TargetX8632> {
}
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,
- REGX8632_TABLE
+ REGX8632_TABLE
#undef X
};
assert(RegNum >= 0);
@@ -344,12 +344,12 @@ template <> struct MachineTraits<TargetX8632> {
}
static 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,
- REGX8632_TABLE
+ REGX8632_TABLE
#undef X
};
assert(RegNum >= 0);
@@ -416,29 +416,58 @@ template <> struct MachineTraits<TargetX8632> {
llvm::SmallBitVector AhRcvrRegisters(RegisterSet::Reg_NUM);
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];
+ } X8632RegTable[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) \
- (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;
- REGX8632_TABLE;
+ ,
+ REGX8632_TABLE
#undef X
+ };
+
+ for (SizeT ii = 1; ii < llvm::array_lengthof(X8632RegTable); ++ii) {
+ const auto &Entry = X8632RegTable[ii];
+ (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;
@@ -558,7 +587,8 @@ template <> struct MachineTraits<TargetX8632> {
}
}
- assert(NumShuffled + NumPreserved == RegisterSet::Reg_NUM);
+ // We need to subtract one to account for Reg_Invalid.
Jim Stichnoth 2015/12/30 02:50:24 Any chance this would be unnecessary, and everythi
John 2015/12/30 17:55:36 Yes, and no. I don't know anyway of telling the li
+ assert(NumShuffled + NumPreserved == RegisterSet::Reg_NUM - 1);
if (Func->isVerbose(IceV_Random)) {
OstreamLocker L(Func->getContext());
« no previous file with comments | « src/IceRegistersX8664.h ('k') | src/IceTargetLoweringX8664Traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698