| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 277 |
| 278 if (isIRGenerationDisabled()) { | 278 if (isIRGenerationDisabled()) { |
| 279 ValueIDConstants[ID] = nullptr; | 279 ValueIDConstants[ID] = nullptr; |
| 280 return nullptr; | 280 return nullptr; |
| 281 } | 281 } |
| 282 | 282 |
| 283 // If reached, no such constant exists, create one. | 283 // If reached, no such constant exists, create one. |
| 284 // TODO(kschimpf) Don't get addresses of intrinsic function declarations. | 284 // TODO(kschimpf) Don't get addresses of intrinsic function declarations. |
| 285 Ice::GlobalDeclaration *Decl = nullptr; | 285 Ice::GlobalDeclaration *Decl = nullptr; |
| 286 unsigned FcnIDSize = FunctionDeclarationList.size(); | 286 unsigned FcnIDSize = FunctionDeclarationList.size(); |
| 287 bool IsUndefined = false; |
| 287 if (ID < FcnIDSize) { | 288 if (ID < FcnIDSize) { |
| 288 Decl = FunctionDeclarationList[ID]; | 289 Decl = FunctionDeclarationList[ID]; |
| 290 const auto Func = llvm::cast<Ice::FunctionDeclaration>(Decl); |
| 291 IsUndefined = Func->isProto(); |
| 289 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) { | 292 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) { |
| 290 Decl = VariableDeclarations[ID - FcnIDSize]; | 293 Decl = VariableDeclarations[ID - FcnIDSize]; |
| 294 const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl); |
| 295 IsUndefined = !Var->hasInitializer(); |
| 291 } | 296 } |
| 292 std::string Name; | 297 std::string Name; |
| 293 bool SuppressMangling; | 298 bool SuppressMangling; |
| 294 if (Decl) { | 299 if (Decl) { |
| 295 Name = Decl->getName(); | 300 Name = Decl->getName(); |
| 296 SuppressMangling = Decl->getSuppressMangling(); | 301 SuppressMangling = Decl->getSuppressMangling(); |
| 297 } else { | 302 } else { |
| 298 std::string Buffer; | 303 std::string Buffer; |
| 299 raw_string_ostream StrBuf(Buffer); | 304 raw_string_ostream StrBuf(Buffer); |
| 300 StrBuf << "Reference to global not defined: " << ID; | 305 StrBuf << "Reference to global not defined: " << ID; |
| 301 BlockError(StrBuf.str()); | 306 BlockError(StrBuf.str()); |
| 302 // TODO(kschimpf) Remove error recovery once implementation complete. | 307 // TODO(kschimpf) Remove error recovery once implementation complete. |
| 303 Name = "??"; | 308 Name = "??"; |
| 304 SuppressMangling = false; | 309 SuppressMangling = false; |
| 305 } | 310 } |
| 306 const Ice::RelocOffsetT Offset = 0; | 311 if (IsUndefined) |
| 307 C = getTranslator().getContext()->getConstantSym(Offset, Name, | 312 C = getTranslator().getContext()->getConstantExternSym(Name); |
| 308 SuppressMangling); | 313 else { |
| 314 const Ice::RelocOffsetT Offset = 0; |
| 315 C = getTranslator().getContext()->getConstantSym(Offset, Name, |
| 316 SuppressMangling); |
| 317 } |
| 309 ValueIDConstants[ID] = C; | 318 ValueIDConstants[ID] = C; |
| 310 return C; | 319 return C; |
| 311 } | 320 } |
| 312 | 321 |
| 313 /// Returns the number of function declarations in the bitcode file. | 322 /// Returns the number of function declarations in the bitcode file. |
| 314 unsigned getNumFunctionIDs() const { return FunctionDeclarationList.size(); } | 323 unsigned getNumFunctionIDs() const { return FunctionDeclarationList.size(); } |
| 315 | 324 |
| 316 /// Returns the number of global declarations (i.e. IDs) defined in | 325 /// Returns the number of global declarations (i.e. IDs) defined in |
| 317 /// the bitcode file. | 326 /// the bitcode file. |
| 318 unsigned getNumGlobalIDs() const { | 327 unsigned getNumGlobalIDs() const { |
| (...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2977 | 2986 |
| 2978 if (TopLevelBlocks != 1) { | 2987 if (TopLevelBlocks != 1) { |
| 2979 errs() << IRFilename | 2988 errs() << IRFilename |
| 2980 << ": Contains more than one module. Found: " << TopLevelBlocks | 2989 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 2981 << "\n"; | 2990 << "\n"; |
| 2982 ErrorStatus.assign(EC_Bitcode); | 2991 ErrorStatus.assign(EC_Bitcode); |
| 2983 } | 2992 } |
| 2984 } | 2993 } |
| 2985 | 2994 |
| 2986 } // end of namespace Ice | 2995 } // end of namespace Ice |
| OLD | NEW |