| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 /// Returns the number of global declarations (i.e. IDs) defined in | 328 /// Returns the number of global declarations (i.e. IDs) defined in |
| 329 /// the bitcode file. | 329 /// the bitcode file. |
| 330 unsigned getNumGlobalIDs() const { | 330 unsigned getNumGlobalIDs() const { |
| 331 return FunctionDeclarationList.size() + VariableDeclarations.size(); | 331 return FunctionDeclarationList.size() + VariableDeclarations.size(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 /// Creates Count global variable declarations. | 334 /// Creates Count global variable declarations. |
| 335 void CreateGlobalVariables(size_t Count) { | 335 void CreateGlobalVariables(size_t Count) { |
| 336 assert(VariableDeclarations.empty()); | 336 assert(VariableDeclarations.empty()); |
| 337 Ice::GlobalContext *Context = getTranslator().getContext(); | |
| 338 for (size_t i = 0; i < Count; ++i) { | 337 for (size_t i = 0; i < Count; ++i) { |
| 339 VariableDeclarations.push_back(Ice::VariableDeclaration::create(Context)); | 338 VariableDeclarations.push_back(Ice::VariableDeclaration::create()); |
| 340 } | 339 } |
| 341 } | 340 } |
| 342 | 341 |
| 343 /// Returns the number of global variable declarations in the | 342 /// Returns the number of global variable declarations in the |
| 344 /// bitcode file. | 343 /// bitcode file. |
| 345 Ice::SizeT getNumGlobalVariables() const { | 344 Ice::SizeT getNumGlobalVariables() const { |
| 346 return VariableDeclarations.size(); | 345 return VariableDeclarations.size(); |
| 347 } | 346 } |
| 348 | 347 |
| 349 /// Returns the global variable declaration with the given index. | 348 /// Returns the global variable declaration with the given index. |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 838 } |
| 840 | 839 |
| 841 /// Parses the globals block (i.e. global variable declarations and | 840 /// Parses the globals block (i.e. global variable declarations and |
| 842 /// corresponding initializers). | 841 /// corresponding initializers). |
| 843 class GlobalsParser : public BlockParserBaseClass { | 842 class GlobalsParser : public BlockParserBaseClass { |
| 844 public: | 843 public: |
| 845 GlobalsParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) | 844 GlobalsParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) |
| 846 : BlockParserBaseClass(BlockID, EnclosingParser), | 845 : BlockParserBaseClass(BlockID, EnclosingParser), |
| 847 Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()), | 846 Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()), |
| 848 InitializersNeeded(0), NextGlobalID(0), | 847 InitializersNeeded(0), NextGlobalID(0), |
| 849 DummyGlobalVar( | 848 DummyGlobalVar(Ice::VariableDeclaration::create()), |
| 850 Ice::VariableDeclaration::create(getTranslator().getContext())), | |
| 851 CurGlobalVar(DummyGlobalVar) {} | 849 CurGlobalVar(DummyGlobalVar) {} |
| 852 | 850 |
| 853 ~GlobalsParser() final {} | 851 ~GlobalsParser() final {} |
| 854 | 852 |
| 855 const char *getBlockName() const override { return "globals"; } | 853 const char *getBlockName() const override { return "globals"; } |
| 856 | 854 |
| 857 private: | 855 private: |
| 858 Ice::TimerMarker Timer; | 856 Ice::TimerMarker Timer; |
| 859 // Keeps track of how many initializers are expected for the global variable | 857 // Keeps track of how many initializers are expected for the global variable |
| 860 // declaration being built. | 858 // declaration being built. |
| (...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 } | 2920 } |
| 2923 GlobalValue::LinkageTypes Linkage; | 2921 GlobalValue::LinkageTypes Linkage; |
| 2924 if (!naclbitc::DecodeLinkage(Values[3], Linkage)) { | 2922 if (!naclbitc::DecodeLinkage(Values[3], Linkage)) { |
| 2925 std::string Buffer; | 2923 std::string Buffer; |
| 2926 raw_string_ostream StrBuf(Buffer); | 2924 raw_string_ostream StrBuf(Buffer); |
| 2927 StrBuf << "Function address has unknown linkage. Found " << Values[3]; | 2925 StrBuf << "Function address has unknown linkage. Found " << Values[3]; |
| 2928 Error(StrBuf.str()); | 2926 Error(StrBuf.str()); |
| 2929 return; | 2927 return; |
| 2930 } | 2928 } |
| 2931 Ice::FunctionDeclaration *Func = Ice::FunctionDeclaration::create( | 2929 Ice::FunctionDeclaration *Func = Ice::FunctionDeclaration::create( |
| 2932 getTranslator().getContext(), Signature, CallingConv, Linkage, | 2930 Signature, CallingConv, Linkage, Values[2] == 0); |
| 2933 Values[2] == 0); | |
| 2934 if (Values[2] == 0) | 2931 if (Values[2] == 0) |
| 2935 Context->setNextValueIDAsImplementedFunction(); | 2932 Context->setNextValueIDAsImplementedFunction(); |
| 2936 Context->setNextFunctionID(Func); | 2933 Context->setNextFunctionID(Func); |
| 2937 return; | 2934 return; |
| 2938 } | 2935 } |
| 2939 default: | 2936 default: |
| 2940 BlockParserBaseClass::ProcessRecord(); | 2937 BlockParserBaseClass::ProcessRecord(); |
| 2941 return; | 2938 return; |
| 2942 } | 2939 } |
| 2943 } | 2940 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3005 | 3002 |
| 3006 if (TopLevelBlocks != 1) { | 3003 if (TopLevelBlocks != 1) { |
| 3007 errs() << IRFilename | 3004 errs() << IRFilename |
| 3008 << ": Contains more than one module. Found: " << TopLevelBlocks | 3005 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 3009 << "\n"; | 3006 << "\n"; |
| 3010 ErrorStatus = true; | 3007 ErrorStatus = true; |
| 3011 } | 3008 } |
| 3012 } | 3009 } |
| 3013 | 3010 |
| 3014 } // end of namespace Ice | 3011 } // end of namespace Ice |
| OLD | NEW |