| OLD | NEW |
| 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// | 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// |
| 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 // This file implements the PNaCl bitcode file to Ice, to machine code | 10 // This file implements the PNaCl bitcode file to Ice, to machine code |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 ExpectedSize = ID; | 279 ExpectedSize = ID; |
| 280 ValueIDConstants.resize(ExpectedSize); | 280 ValueIDConstants.resize(ExpectedSize); |
| 281 } else { | 281 } else { |
| 282 C = ValueIDConstants[ID]; | 282 C = ValueIDConstants[ID]; |
| 283 } | 283 } |
| 284 if (C != nullptr) | 284 if (C != nullptr) |
| 285 return C; | 285 return C; |
| 286 | 286 |
| 287 // If reached, no such constant exists, create one. | 287 // If reached, no such constant exists, create one. |
| 288 // TODO(kschimpf) Don't get addresses of intrinsic function declarations. | 288 // TODO(kschimpf) Don't get addresses of intrinsic function declarations. |
| 289 std::string Name; | 289 Ice::GlobalDeclaration *Decl = nullptr; |
| 290 unsigned FcnIDSize = FunctionDeclarationList.size(); | 290 unsigned FcnIDSize = FunctionDeclarationList.size(); |
| 291 if (ID < FcnIDSize) { | 291 if (ID < FcnIDSize) { |
| 292 Name = FunctionDeclarationList[ID]->getName(); | 292 Decl = FunctionDeclarationList[ID]; |
| 293 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) { | 293 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) { |
| 294 Name = VariableDeclarations[ID - FcnIDSize]->getName(); | 294 Decl = VariableDeclarations[ID - FcnIDSize]; |
| 295 } |
| 296 std::string Name; |
| 297 bool SuppressMangling; |
| 298 if (Decl) { |
| 299 Name = Decl->getName(); |
| 300 SuppressMangling = Decl->getSuppressMangling(); |
| 295 } else { | 301 } else { |
| 296 std::string Buffer; | 302 std::string Buffer; |
| 297 raw_string_ostream StrBuf(Buffer); | 303 raw_string_ostream StrBuf(Buffer); |
| 298 StrBuf << "Reference to global not defined: " << ID; | 304 StrBuf << "Reference to global not defined: " << ID; |
| 299 Error(StrBuf.str()); | 305 Error(StrBuf.str()); |
| 306 // TODO(kschimpf) Remove error recovery once implementation complete. |
| 300 Name = "??"; | 307 Name = "??"; |
| 308 SuppressMangling = false; |
| 301 } | 309 } |
| 302 const Ice::RelocOffsetT Offset = 0; | 310 const Ice::RelocOffsetT Offset = 0; |
| 303 C = getTranslator().getContext()->getConstantSym( | 311 C = getTranslator().getContext()->getConstantSym( |
| 304 getIcePointerType(), Offset, Name); | 312 getIcePointerType(), Offset, Name, SuppressMangling); |
| 305 ValueIDConstants[ID] = C; | 313 ValueIDConstants[ID] = C; |
| 306 return C; | 314 return C; |
| 307 } | 315 } |
| 308 | 316 |
| 309 /// Returns the number of function declarations in the bitcode file. | 317 /// Returns the number of function declarations in the bitcode file. |
| 310 unsigned getNumFunctionIDs() const { return NumFunctionIds; } | 318 unsigned getNumFunctionIDs() const { return NumFunctionIds; } |
| 311 | 319 |
| 312 /// Returns the number of global declarations (i.e. IDs) defined in | 320 /// Returns the number of global declarations (i.e. IDs) defined in |
| 313 /// the bitcode file. | 321 /// the bitcode file. |
| 314 unsigned getNumGlobalIDs() const { | 322 unsigned getNumGlobalIDs() const { |
| (...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 | 2599 |
| 2592 if (TopLevelBlocks != 1) { | 2600 if (TopLevelBlocks != 1) { |
| 2593 errs() << IRFilename | 2601 errs() << IRFilename |
| 2594 << ": Contains more than one module. Found: " << TopLevelBlocks | 2602 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 2595 << "\n"; | 2603 << "\n"; |
| 2596 ErrorStatus = true; | 2604 ErrorStatus = true; |
| 2597 } | 2605 } |
| 2598 } | 2606 } |
| 2599 | 2607 |
| 2600 } // end of namespace Ice | 2608 } // end of namespace Ice |
| OLD | NEW |