OLD | NEW |
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 Loading... |
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 : RegNumBitVector(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 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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 case Target_##X: \ | 865 case Target_##X: \ |
864 return ::X::createTargetHeaderLowering(Ctx); | 866 return ::X::createTargetHeaderLowering(Ctx); |
865 #include "llvm/Config/SZTargets.def" | 867 #include "llvm/Config/SZTargets.def" |
866 #undef SUBZERO_TARGET | 868 #undef SUBZERO_TARGET |
867 } | 869 } |
868 } | 870 } |
869 | 871 |
870 TargetHeaderLowering::~TargetHeaderLowering() = default; | 872 TargetHeaderLowering::~TargetHeaderLowering() = default; |
871 | 873 |
872 } // end of namespace Ice | 874 } // end of namespace Ice |
OLD | NEW |