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

Unified Diff: src/IceTargetLoweringARM32.cpp

Issue 1571433004: Implements include/exclude register lists for translation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: fix nits. Created 4 years, 11 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/IceTargetLoweringARM32.cpp
diff --git a/src/IceTargetLoweringARM32.cpp b/src/IceTargetLoweringARM32.cpp
index 878f95ec059fbcf5c1e186cd4ff77b8d003cc0ad..d12a339fec0f0f1e24debaa52e8d31b47a87a6ae 100644
--- a/src/IceTargetLoweringARM32.cpp
+++ b/src/IceTargetLoweringARM32.cpp
@@ -1828,11 +1828,70 @@ Operand *TargetARM32::hiOperand(Operand *Operand) {
return nullptr;
}
+namespace {
+
+void applyUseRestrictedRegisters(
+ llvm::SmallBitVector &Registers,
+ const std::unordered_set<std::string> &RestrictedUses) {
+ assert(Registers.size() == RegARM32::Reg_NUM);
+
+ llvm::SmallBitVector GPKeepRegisters(RegARM32::Reg_NUM);
Jim Stichnoth 2016/01/10 16:51:25 I think it might not be too hard to generalize thi
Karl 2016/01/12 23:44:04 Ok. Refactored the code to put this function in Ic
+ llvm::SmallBitVector NotGPRegisters(RegARM32::Reg_NUM);
+ llvm::SmallBitVector SKeepRegisters(RegARM32::Reg_NUM);
+ llvm::SmallBitVector NotSRegisters(RegARM32::Reg_NUM);
+ llvm::SmallBitVector DKeepRegisters(RegARM32::Reg_NUM);
+ llvm::SmallBitVector NotDRegisters(RegARM32::Reg_NUM);
+ llvm::SmallBitVector VectorKeepRegisters(RegARM32::Reg_NUM);
+ llvm::SmallBitVector NotVectorRegisters(RegARM32::Reg_NUM);
Jim Stichnoth 2016/01/10 16:51:25 Do we need IsI64Pair as well? If so, there are so
John 2016/01/11 15:43:26 I64 pairs should probably be turned off by disabli
Karl 2016/01/12 23:44:05 Kept the register pairs, so that all registers can
+ for (size_t i = 0; i < RegARM32::Reg_NUM; ++i) {
+ const auto &Entry = RegARM32::Table[i];
+ NotGPRegisters[i] = !Entry.IsGPR;
John 2016/01/11 15:43:26 Register pairs are not being handled here at all.
Karl 2016/01/12 23:44:04 Fixed this by adding enum "RegClass" and static me
+ NotSRegisters[i] = !Entry.IsFP32;
+ NotDRegisters[i] = !Entry.IsFP64;
+ NotVectorRegisters[i] = !Entry.IsVec128;
+ if (RestrictedUses.find(Entry.Name) != RestrictedUses.end()) {
+ GPKeepRegisters[i] = Entry.IsGPR;
+ SKeepRegisters[i] = Entry.IsFP32;
+ DKeepRegisters[i] = Entry.IsFP64;
+ VectorKeepRegisters[i] = Entry.IsVec128;
+ }
+ }
+ if (GPKeepRegisters.any()) {
+ Registers &= NotGPRegisters;
+ Registers |= GPKeepRegisters;
+ }
+ if (SKeepRegisters.any()) {
+ Registers &= NotSRegisters;
+ Registers |= SKeepRegisters;
+ }
+ if (DKeepRegisters.any()) {
+ Registers &= NotDRegisters;
+ Registers |= DKeepRegisters;
+ }
+ if (VectorKeepRegisters.any()) {
+ Registers &= NotVectorRegisters;
+ Registers |= VectorKeepRegisters;
+ }
+}
+
+void applyExcludedRegisters(llvm::SmallBitVector &Registers,
John 2016/01/11 15:43:26 pass registers by pointer (i.e., SmallBitVector *)
Karl 2016/01/12 23:44:05 Removed. Now refactored into Ice::TargetLowering::
+ const std::unordered_set<std::string> Excluded) {
Jim Stichnoth 2016/01/10 16:51:26 &Excluded
Karl 2016/01/12 23:44:05 No longer applicable.
+ for (size_t i = 0; i < RegARM32::Reg_NUM; ++i) {
+ const auto &Entry = RegARM32::Table[i];
+ if (Excluded.find(Entry.Name) != Excluded.end()) {
John 2016/01/11 15:43:26 nit: this is less efficient than Excluded.count(E
Karl 2016/01/12 23:44:04 Changed code to use method count rather than find.
+ if (Registers[i])
+ Registers[i] = 0;
Jim Stichnoth 2016/01/10 16:51:25 Registers[i] = false; Might as well remove the "i
Karl 2016/01/12 23:44:05 Acknowledged.
+ }
+ }
+}
+
+} // end of anonymous namespace
+
llvm::SmallBitVector TargetARM32::getRegisterSet(RegSetMask Include,
RegSetMask Exclude) const {
llvm::SmallBitVector Registers(RegARM32::Reg_NUM);
- for (int i = 0; i < RegARM32::Reg_NUM; ++i) {
+ for (size_t i = 0; i < RegARM32::Reg_NUM; ++i) {
John 2016/01/11 15:43:26 why? just curious...
Karl 2016/01/12 23:44:05 Actually, I probably should have used SizeT. I did
const auto &Entry = RegARM32::Table[i];
if (Entry.Scratch && (Include & RegSet_CallerSave))
Registers[i] = true;
@@ -1852,6 +1911,16 @@ llvm::SmallBitVector TargetARM32::getRegisterSet(RegSetMask Include,
Registers[i] = false;
}
+ const std::unordered_set<std::string> &RestrictedUses =
Jim Stichnoth 2016/01/10 16:51:25 A problem with calculating the restrictions here i
John 2016/01/11 15:43:26 s/RestrictedUses/RestrictedRegisters s/ExcludedUse
Karl 2016/01/12 23:44:05 Factored out into staticInit() that sets static fi
+ Ctx->getFlags().getUseRestrictedRegisters();
+ if (!RestrictedUses.empty())
+ applyUseRestrictedRegisters(Registers, RestrictedUses);
+
+ const std::unordered_set<std::string> &ExcludedUses =
John 2016/01/11 15:43:26 I **really** wish we used `auto' here and above.
Karl 2016/01/12 23:44:05 Acknowledged.
+ Ctx->getFlags().getExcludedRegisters();
+ if (!ExcludedUses.empty())
+ applyExcludedRegisters(Registers, ExcludedUses);
+
return Registers;
}

Powered by Google App Engine
This is Rietveld 408576698