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

Unified Diff: src/IceTargetLoweringMIPS32.cpp

Issue 1676123002: Subzero: Use a proper RegNumT type instead of int32_t/SizeT. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix int32_t ==> int for the result of BitVector find_first() and find_next() Created 4 years, 10 months 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
Index: src/IceTargetLoweringMIPS32.cpp
diff --git a/src/IceTargetLoweringMIPS32.cpp b/src/IceTargetLoweringMIPS32.cpp
index 40d510d0c5cf266da2e9a1a5bfa3714d66895f26..378d3b0b5393dc8d965a126c1f9430c01eb78067 100644
--- a/src/IceTargetLoweringMIPS32.cpp
+++ b/src/IceTargetLoweringMIPS32.cpp
@@ -290,22 +290,22 @@ const char *RegNames[RegMIPS32::Reg_NUM] = {
} // end of anonymous namespace
-const char *RegMIPS32::getRegName(int32_t RegNum) {
- assert(RegNum < RegMIPS32::Reg_NUM);
+const char *RegMIPS32::getRegName(RegNumT RegNum) {
+ assert(unsigned(RegNum) < RegMIPS32::Reg_NUM);
Eric Holk 2016/02/08 19:37:10 Should there be a fixme somewhere around here?
Jim Stichnoth 2016/02/09 19:33:39 Probably not, given this is basically a bounds che
Eric Holk 2016/02/10 01:11:30 Good point.
return RegNames[RegNum];
}
-IceString TargetMIPS32::getRegName(SizeT RegNum, Type Ty) const {
+IceString TargetMIPS32::getRegName(RegNumT RegNum, Type Ty) const {
(void)Ty;
return RegMIPS32::getRegName(RegNum);
}
-Variable *TargetMIPS32::getPhysicalRegister(SizeT RegNum, Type Ty) {
+Variable *TargetMIPS32::getPhysicalRegister(RegNumT RegNum, Type Ty) {
if (Ty == IceType_void)
Ty = IceType_i32;
if (PhysicalRegisters[Ty].empty())
PhysicalRegisters[Ty].resize(RegMIPS32::Reg_NUM);
- assert(RegNum < PhysicalRegisters[Ty].size());
+ assert(unsigned(RegNum) < PhysicalRegisters[Ty].size());
Eric Holk 2016/02/08 19:37:10 fixme?
Jim Stichnoth 2016/02/09 19:33:39 same as above I think
Eric Holk 2016/02/10 01:11:30 I think so too. Plus, the code is in an assert, so
Variable *Reg = PhysicalRegisters[Ty][RegNum];
if (Reg == nullptr) {
Reg = Func->makeVariable(Ty);
@@ -328,12 +328,12 @@ void TargetMIPS32::emitJumpTable(const Cfg *Func,
}
/// Provide a trivial wrapper to legalize() for this common usage.
-Variable *TargetMIPS32::legalizeToReg(Operand *From, int32_t RegNum) {
+Variable *TargetMIPS32::legalizeToReg(Operand *From, RegNumT RegNum) {
return llvm::cast<Variable>(legalize(From, Legal_Reg, RegNum));
}
/// Legalize undef values to concrete values.
-Operand *TargetMIPS32::legalizeUndef(Operand *From, int32_t RegNum) {
+Operand *TargetMIPS32::legalizeUndef(Operand *From, RegNumT RegNum) {
(void)RegNum;
Type Ty = From->getType();
if (llvm::isa<ConstantUndef>(From)) {
@@ -355,11 +355,11 @@ Operand *TargetMIPS32::legalizeUndef(Operand *From, int32_t RegNum) {
return From;
}
-Variable *TargetMIPS32::makeReg(Type Type, int32_t RegNum) {
+Variable *TargetMIPS32::makeReg(Type Type, RegNumT RegNum) {
// There aren't any 64-bit integer registers for Mips32.
assert(Type != IceType_i64);
Variable *Reg = Func->makeVariable(Type);
- if (RegNum == Variable::NoRegister)
+ if (RegNum == RegNumT::NoRegister)
Reg->setMustHaveReg();
else
Reg->setRegNum(RegNum);
@@ -410,20 +410,20 @@ void TargetMIPS32::lowerArguments() {
if (Ty == IceType_i64) {
if (NumGPRRegsUsed >= MIPS32_MAX_GPR_ARG)
continue;
- int32_t RegLo = RegMIPS32::Reg_A0 + NumGPRRegsUsed;
- int32_t RegHi = RegLo + 1;
+ RegNumT RegLo = RegNumT::fixme(RegMIPS32::Reg_A0 + NumGPRRegsUsed);
+ RegNumT RegHi = RegNumT::fixme(RegLo + 1);
++NumGPRRegsUsed;
// Always start i64 registers at an even register, so this may end
// up padding away a register.
if (RegLo % 2 != 0) {
- ++RegLo;
+ RegLo = RegNumT::fixme(RegLo + 1);
++NumGPRRegsUsed;
}
// If this leaves us without room to consume another register,
// leave any previously speculatively consumed registers as consumed.
if (NumGPRRegsUsed >= MIPS32_MAX_GPR_ARG)
continue;
- // RegHi = RegMIPS32::Reg_A0 + NumGPRRegsUsed;
+ // RegHi = RegNumT::fixme(RegMIPS32::Reg_A0 + NumGPRRegsUsed);
Eric Holk 2016/02/08 19:37:10 Could we just delete this line, since it's comment
Jim Stichnoth 2016/02/09 19:33:39 I'll leave that to Reed, he may be holding the com
Eric Holk 2016/02/10 01:11:30 Ok.
++NumGPRRegsUsed;
Variable *RegisterArg = Func->makeVariable(Ty);
auto *RegisterArg64On32 = llvm::cast<Variable64On32>(RegisterArg);
@@ -441,7 +441,7 @@ void TargetMIPS32::lowerArguments() {
assert(Ty == IceType_i32);
if (NumGPRRegsUsed >= MIPS32_MAX_GPR_ARG)
continue;
- int32_t RegNum = RegMIPS32::Reg_A0 + NumGPRRegsUsed;
+ RegNumT RegNum = RegNumT::fixme(RegMIPS32::Reg_A0 + NumGPRRegsUsed);
++NumGPRRegsUsed;
Variable *RegisterArg = Func->makeVariable(Ty);
if (BuildDefs::dump()) {
@@ -1156,7 +1156,7 @@ void TargetMIPS32::postLower() {
}
void TargetMIPS32::makeRandomRegisterPermutation(
- llvm::SmallVectorImpl<int32_t> &Permutation,
+ llvm::SmallVectorImpl<RegNumT> &Permutation,
const llvm::SmallBitVector &ExcludeRegisters, uint64_t Salt) const {
(void)Permutation;
(void)ExcludeRegisters;
@@ -1213,7 +1213,7 @@ void TargetDataMIPS32::lowerJumpTables() {
// Helper for legalize() to emit the right code to lower an operand to a
// register of the appropriate type.
-Variable *TargetMIPS32::copyToReg(Operand *Src, int32_t RegNum) {
+Variable *TargetMIPS32::copyToReg(Operand *Src, RegNumT RegNum) {
Type Ty = Src->getType();
Variable *Reg = makeReg(Ty, RegNum);
if (isVectorType(Ty) || isFloatingType(Ty)) {
@@ -1227,7 +1227,7 @@ Variable *TargetMIPS32::copyToReg(Operand *Src, int32_t RegNum) {
}
Operand *TargetMIPS32::legalize(Operand *From, LegalMask Allowed,
- int32_t RegNum) {
+ RegNumT RegNum) {
Type Ty = From->getType();
// Assert that a physical register is allowed. To date, all calls
// to legalize() allow a physical register. Legal_Flex converts
@@ -1252,7 +1252,7 @@ Operand *TargetMIPS32::legalize(Operand *From, LegalMask Allowed,
// Also try the inverse and use MVN if possible.
// Do a movw/movt to a register.
Variable *Reg;
- if (RegNum == Variable::NoRegister)
+ if (RegNum == RegNumT::NoRegister)
Reg = makeReg(Ty, RegNum);
else
Reg = getPhysicalRegister(RegNum);
@@ -1280,7 +1280,7 @@ Operand *TargetMIPS32::legalize(Operand *From, LegalMask Allowed,
// register, or
// RegNum is required and Var->getRegNum() doesn't match.
if ((!(Allowed & Legal_Mem) && !MustHaveRegister) ||
- (RegNum != Variable::NoRegister && RegNum != Var->getRegNum())) {
+ (RegNum != RegNumT::NoRegister && RegNum != Var->getRegNum())) {
From = copyToReg(From, RegNum);
}
return From;

Powered by Google App Engine
This is Rietveld 408576698