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

Side by Side Diff: src/IceTargetLowering.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: Make it possible to do "auto NewReg = RegNumT::NoRegister;" 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 unified diff | Download patch
« no previous file with comments | « src/IceTargetLowering.h ('k') | src/IceTargetLoweringARM32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===// 1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 Variable *LoweringContext::availabilityGet(Operand *Src) const { 112 Variable *LoweringContext::availabilityGet(Operand *Src) const {
113 assert(Src); 113 assert(Src);
114 if (Src == LastDest) 114 if (Src == LastDest)
115 return LastSrc; 115 return LastSrc;
116 return nullptr; 116 return nullptr;
117 } 117 }
118 118
119 namespace { 119 namespace {
120 120
121 void printRegisterSet(Ostream &Str, const llvm::SmallBitVector &Bitset, 121 void printRegisterSet(Ostream &Str, const llvm::SmallBitVector &Bitset,
122 std::function<IceString(int32_t)> getRegName, 122 std::function<IceString(RegNumT)> getRegName,
123 const IceString &LineIndentString) { 123 const IceString &LineIndentString) {
124 constexpr size_t RegistersPerLine = 16; 124 constexpr size_t RegistersPerLine = 16;
125 size_t Count = 0; 125 size_t Count = 0;
126 for (int i = Bitset.find_first(); i != -1; i = Bitset.find_next(i)) { 126 for (RegNumT RegNum : RegNumBVIter(Bitset)) {
127 if (Count == 0) { 127 if (Count == 0) {
128 Str << LineIndentString; 128 Str << LineIndentString;
129 } else { 129 } else {
130 Str << ","; 130 Str << ",";
131 } 131 }
132 if (Count > 0 && Count % RegistersPerLine == 0) 132 if (Count > 0 && Count % RegistersPerLine == 0)
133 Str << "\n" << LineIndentString; 133 Str << "\n" << LineIndentString;
134 ++Count; 134 ++Count;
135 Str << getRegName(i); 135 Str << getRegName(RegNum);
136 } 136 }
137 if (Count) 137 if (Count)
138 Str << "\n"; 138 Str << "\n";
139 } 139 }
140 140
141 // Splits "<class>:<reg>" into "<class>" plus "<reg>". If there is no <class> 141 // Splits "<class>:<reg>" into "<class>" plus "<reg>". If there is no <class>
142 // component, the result is "" plus "<reg>". 142 // component, the result is "" plus "<reg>".
143 void splitToClassAndName(const IceString &RegName, IceString *SplitRegClass, 143 void splitToClassAndName(const IceString &RegName, IceString *SplitRegClass,
144 IceString *SplitRegName) { 144 IceString *SplitRegName) {
145 constexpr const char Separator[] = ":"; 145 constexpr const char Separator[] = ":";
146 constexpr size_t SeparatorWidth = llvm::array_lengthof(Separator) - 1; 146 constexpr size_t SeparatorWidth = llvm::array_lengthof(Separator) - 1;
147 size_t Pos = RegName.find(Separator); 147 size_t Pos = RegName.find(Separator);
148 if (Pos == std::string::npos) { 148 if (Pos == std::string::npos) {
149 *SplitRegClass = ""; 149 *SplitRegClass = "";
150 *SplitRegName = RegName; 150 *SplitRegName = RegName;
151 } else { 151 } else {
152 *SplitRegClass = RegName.substr(0, Pos); 152 *SplitRegClass = RegName.substr(0, Pos);
153 *SplitRegName = RegName.substr(Pos + SeparatorWidth); 153 *SplitRegName = RegName.substr(Pos + SeparatorWidth);
154 } 154 }
155 } 155 }
156 156
157 } // end of anonymous namespace 157 } // end of anonymous namespace
158 158
159 void TargetLowering::filterTypeToRegisterSet( 159 void TargetLowering::filterTypeToRegisterSet(
160 GlobalContext *Ctx, int32_t NumRegs, 160 GlobalContext *Ctx, int32_t NumRegs,
161 llvm::SmallBitVector TypeToRegisterSet[], size_t TypeToRegisterSetSize, 161 llvm::SmallBitVector TypeToRegisterSet[], size_t TypeToRegisterSetSize,
162 std::function<IceString(int32_t)> getRegName, 162 std::function<IceString(RegNumT)> getRegName,
163 std::function<IceString(RegClass)> getRegClassName) { 163 std::function<IceString(RegClass)> getRegClassName) {
164 std::vector<llvm::SmallBitVector> UseSet(TypeToRegisterSetSize, 164 std::vector<llvm::SmallBitVector> UseSet(TypeToRegisterSetSize,
165 llvm::SmallBitVector(NumRegs)); 165 llvm::SmallBitVector(NumRegs));
166 std::vector<llvm::SmallBitVector> ExcludeSet(TypeToRegisterSetSize, 166 std::vector<llvm::SmallBitVector> ExcludeSet(TypeToRegisterSetSize,
167 llvm::SmallBitVector(NumRegs)); 167 llvm::SmallBitVector(NumRegs));
168 168
169 std::unordered_map<IceString, int32_t> RegNameToIndex; 169 std::unordered_map<IceString, RegNumT> RegNameToIndex;
170 for (int32_t RegIndex = 0; RegIndex < NumRegs; ++RegIndex) 170 for (int32_t RegIndex = 0; RegIndex < NumRegs; ++RegIndex) {
171 RegNameToIndex[getRegName(RegIndex)] = RegIndex; 171 const auto RegNum = RegNumT::fromInt(RegIndex);
172 RegNameToIndex[getRegName(RegNum)] = RegNum;
173 }
172 174
173 ClFlags::StringVector BadRegNames; 175 ClFlags::StringVector BadRegNames;
174 176
175 // The processRegList function iterates across the RegNames vector. Each 177 // The processRegList function iterates across the RegNames vector. Each
176 // entry in the vector is a string of the form "<reg>" or "<class>:<reg>". 178 // entry in the vector is a string of the form "<reg>" or "<class>:<reg>".
177 // The register class and register number are computed, and the corresponding 179 // The register class and register number are computed, and the corresponding
178 // bit is set in RegSet[][]. If "<class>:" is missing, then the bit is set 180 // bit is set in RegSet[][]. If "<class>:" is missing, then the bit is set
179 // for all classes. 181 // for all classes.
180 auto processRegList = [&](const ClFlags::StringVector &RegNames, 182 auto processRegList = [&](const ClFlags::StringVector &RegNames,
181 std::vector<llvm::SmallBitVector> &RegSet) { 183 std::vector<llvm::SmallBitVector> &RegSet) {
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 case Target_##X: \ 898 case Target_##X: \
897 return ::X::createTargetHeaderLowering(Ctx); 899 return ::X::createTargetHeaderLowering(Ctx);
898 #include "llvm/Config/SZTargets.def" 900 #include "llvm/Config/SZTargets.def"
899 #undef SUBZERO_TARGET 901 #undef SUBZERO_TARGET
900 } 902 }
901 } 903 }
902 904
903 TargetHeaderLowering::~TargetHeaderLowering() = default; 905 TargetHeaderLowering::~TargetHeaderLowering() = default;
904 906
905 } // end of namespace Ice 907 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLowering.h ('k') | src/IceTargetLoweringARM32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698