| OLD | NEW |
| 1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===// | 1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===// |
| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 else | 131 else |
| 132 Stream << ", "; | 132 Stream << ", "; |
| 133 Stream << ArgTy; | 133 Stream << ArgTy; |
| 134 } | 134 } |
| 135 Stream << ")"; | 135 Stream << ")"; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void VariableDeclaration::dumpType(Ostream &Stream) const { | 138 void VariableDeclaration::dumpType(Ostream &Stream) const { |
| 139 if (!Ice::BuildDefs::dump()) | 139 if (!Ice::BuildDefs::dump()) |
| 140 return; | 140 return; |
| 141 if (Initializers->size() == 1) { | 141 if (Initializers.size() == 1) { |
| 142 Initializers->front()->dumpType(Stream); | 142 Initializers.front()->dumpType(Stream); |
| 143 } else { | 143 } else { |
| 144 Stream << "<{ "; | 144 Stream << "<{ "; |
| 145 bool IsFirst = true; | 145 bool IsFirst = true; |
| 146 for (const std::unique_ptr<Initializer> &Init : *Initializers) { | 146 for (const auto *Init : Initializers) { |
| 147 if (IsFirst) { | 147 if (IsFirst) { |
| 148 IsFirst = false; | 148 IsFirst = false; |
| 149 } else { | 149 } else { |
| 150 Stream << ", "; | 150 Stream << ", "; |
| 151 } | 151 } |
| 152 Init->dumpType(Stream); | 152 Init->dumpType(Stream); |
| 153 } | 153 } |
| 154 Stream << " }>"; | 154 Stream << " }>"; |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 void VariableDeclaration::dump(Ostream &Stream) const { | 158 void VariableDeclaration::dump(Ostream &Stream) const { |
| 159 if (!Ice::BuildDefs::dump()) | 159 if (!Ice::BuildDefs::dump()) |
| 160 return; | 160 return; |
| 161 Stream << "@" << Name << " = "; | 161 Stream << "@" << Name << " = "; |
| 162 ::dumpLinkage(Stream, Linkage); | 162 ::dumpLinkage(Stream, Linkage); |
| 163 Stream << " " << (IsConstant ? "constant" : "global") << " "; | 163 Stream << " " << (IsConstant ? "constant" : "global") << " "; |
| 164 | 164 |
| 165 // Add initializer. | 165 // Add initializer. |
| 166 if (Initializers->size() == 1) { | 166 if (Initializers.size() == 1) { |
| 167 Initializers->front()->dump(Stream); | 167 Initializers.front()->dump(Stream); |
| 168 } else { | 168 } else { |
| 169 dumpType(Stream); | 169 dumpType(Stream); |
| 170 Stream << " <{ "; | 170 Stream << " <{ "; |
| 171 bool IsFirst = true; | 171 bool IsFirst = true; |
| 172 for (const std::unique_ptr<Initializer> &Init : *Initializers) { | 172 for (const auto *Init : Initializers) { |
| 173 if (IsFirst) { | 173 if (IsFirst) { |
| 174 IsFirst = false; | 174 IsFirst = false; |
| 175 } else { | 175 } else { |
| 176 Stream << ", "; | 176 Stream << ", "; |
| 177 } | 177 } |
| 178 Init->dump(Stream); | 178 Init->dump(Stream); |
| 179 } | 179 } |
| 180 Stream << " }>"; | 180 Stream << " }>"; |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Add alignment. | 183 // Add alignment. |
| 184 if (Alignment > 0) | 184 if (Alignment > 0) |
| 185 Stream << ", align " << Alignment; | 185 Stream << ", align " << Alignment; |
| 186 Stream << "\n"; | 186 Stream << "\n"; |
| 187 } | 187 } |
| 188 | 188 |
| 189 void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const { | 189 void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const { |
| 190 if (!Ice::BuildDefs::dump()) | 190 if (!Ice::BuildDefs::dump()) |
| 191 return; | 191 return; |
| 192 Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]"; | 192 Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]"; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void VariableDeclaration::DataInitializer::dump(Ostream &Stream) const { | 195 void VariableDeclaration::DataInitializer::dump(Ostream &Stream) const { |
| 196 if (!Ice::BuildDefs::dump()) | 196 if (!Ice::BuildDefs::dump()) |
| 197 return; | 197 return; |
| 198 dumpType(Stream); | 198 dumpType(Stream); |
| 199 Stream << " c\""; | 199 Stream << " c\""; |
| 200 // Code taken from PrintEscapedString() in AsmWriter.cpp. Keep the strings in | 200 // Code taken from PrintEscapedString() in AsmWriter.cpp. Keep the strings in |
| 201 // the same format as the .ll file for practical diffing. | 201 // the same format as the .ll file for practical diffing. |
| 202 for (uint8_t C : Contents) { | 202 for (SizeT i = 0; i < ContentsSize; ++i) { |
| 203 uint8_t C = Contents[i]; |
| 203 if (isprint(C) && C != '\\' && C != '"') | 204 if (isprint(C) && C != '\\' && C != '"') |
| 204 Stream << C; | 205 Stream << C; |
| 205 else | 206 else |
| 206 Stream << '\\' << hexdigit(C >> 4) << hexdigit(C & 0x0F); | 207 Stream << '\\' << hexdigit(C >> 4) << hexdigit(C & 0x0F); |
| 207 } | 208 } |
| 208 Stream << "\""; | 209 Stream << "\""; |
| 209 } | 210 } |
| 210 | 211 |
| 211 void VariableDeclaration::ZeroInitializer::dump(Ostream &Stream) const { | 212 void VariableDeclaration::ZeroInitializer::dump(Ostream &Stream) const { |
| 212 if (!Ice::BuildDefs::dump()) | 213 if (!Ice::BuildDefs::dump()) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 236 dumpType(Stream); | 237 dumpType(Stream); |
| 237 Stream << ")"; | 238 Stream << ")"; |
| 238 if (Offset != 0) { | 239 if (Offset != 0) { |
| 239 Stream << ", "; | 240 Stream << ", "; |
| 240 dumpType(Stream); | 241 dumpType(Stream); |
| 241 Stream << " " << Offset << ")"; | 242 Stream << " " << Offset << ")"; |
| 242 } | 243 } |
| 243 } | 244 } |
| 244 | 245 |
| 245 } // end of namespace Ice | 246 } // end of namespace Ice |
| OLD | NEW |