| 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 /// \file | 10 /// \file |
| (...skipping 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2988 /// Parses the module block in the bitcode file. | 2988 /// Parses the module block in the bitcode file. |
| 2989 class ModuleParser final : public BlockParserBaseClass { | 2989 class ModuleParser final : public BlockParserBaseClass { |
| 2990 ModuleParser() = delete; | 2990 ModuleParser() = delete; |
| 2991 ModuleParser(const ModuleParser &) = delete; | 2991 ModuleParser(const ModuleParser &) = delete; |
| 2992 ModuleParser &operator=(const ModuleParser &) = delete; | 2992 ModuleParser &operator=(const ModuleParser &) = delete; |
| 2993 | 2993 |
| 2994 public: | 2994 public: |
| 2995 ModuleParser(unsigned BlockID, TopLevelParser *Context) | 2995 ModuleParser(unsigned BlockID, TopLevelParser *Context) |
| 2996 : BlockParserBaseClass(BlockID, Context), | 2996 : BlockParserBaseClass(BlockID, Context), |
| 2997 Timer(Ice::TimerStack::TT_parseModule, | 2997 Timer(Ice::TimerStack::TT_parseModule, |
| 2998 Context->getTranslator().getContext()) {} | 2998 Context->getTranslator().getContext()), |
| 2999 IsParseParallel(Ice::GlobalContext::Flags.isParseParallel()) {} |
| 2999 ~ModuleParser() override = default; | 3000 ~ModuleParser() override = default; |
| 3000 const char *getBlockName() const override { return "module"; } | 3001 const char *getBlockName() const override { return "module"; } |
| 3001 NaClBitstreamCursor &getCursor() const { return Record.GetCursor(); } | 3002 NaClBitstreamCursor &getCursor() const { return Record.GetCursor(); } |
| 3002 | 3003 |
| 3003 private: | 3004 private: |
| 3004 Ice::TimerMarker Timer; | 3005 Ice::TimerMarker Timer; |
| 3005 // True if we have already installed names for unnamed global declarations, | 3006 // True if we have already installed names for unnamed global declarations, |
| 3006 // and have generated global constant initializers. | 3007 // and have generated global constant initializers. |
| 3007 bool GlobalDeclarationNamesAndInitializersInstalled = false; | 3008 bool GlobalDeclarationNamesAndInitializersInstalled = false; |
| 3008 // True if we have already processed the symbol table for the module. | 3009 // True if we have already processed the symbol table for the module. |
| 3009 bool FoundValuesymtab = false; | 3010 bool FoundValuesymtab = false; |
| 3011 const bool IsParseParallel; |
| 3010 | 3012 |
| 3011 // Generates names for unnamed global addresses (i.e. functions and global | 3013 // Generates names for unnamed global addresses (i.e. functions and global |
| 3012 // variables). Then lowers global variable declaration initializers to the | 3014 // variables). Then lowers global variable declaration initializers to the |
| 3013 // target. May be called multiple times. Only the first call will do the | 3015 // target. May be called multiple times. Only the first call will do the |
| 3014 // installation. | 3016 // installation. |
| 3015 void installGlobalNamesAndGlobalVarInitializers() { | 3017 void installGlobalNamesAndGlobalVarInitializers() { |
| 3016 if (!GlobalDeclarationNamesAndInitializersInstalled) { | 3018 if (!GlobalDeclarationNamesAndInitializersInstalled) { |
| 3017 Context->installGlobalNames(); | 3019 Context->installGlobalNames(); |
| 3018 Context->createValueIDs(); | 3020 Context->createValueIDs(); |
| 3019 Context->verifyFunctionTypeSignatures(); | 3021 Context->verifyFunctionTypeSignatures(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3141 | 3143 |
| 3142 FoundValuesymtab = true; | 3144 FoundValuesymtab = true; |
| 3143 ModuleValuesymtabParser Parser(BlockID, this); | 3145 ModuleValuesymtabParser Parser(BlockID, this); |
| 3144 return Parser.ParseThisBlock(); | 3146 return Parser.ParseThisBlock(); |
| 3145 } | 3147 } |
| 3146 case naclbitc::FUNCTION_BLOCK_ID: { | 3148 case naclbitc::FUNCTION_BLOCK_ID: { |
| 3147 installGlobalNamesAndGlobalVarInitializers(); | 3149 installGlobalNamesAndGlobalVarInitializers(); |
| 3148 Ice::GlobalContext *Ctx = Context->getTranslator().getContext(); | 3150 Ice::GlobalContext *Ctx = Context->getTranslator().getContext(); |
| 3149 uint32_t SeqNumber = Context->getTranslator().getNextSequenceNumber(); | 3151 uint32_t SeqNumber = Context->getTranslator().getNextSequenceNumber(); |
| 3150 NaClBcIndexSize_t FcnId = Context->getNextFunctionBlockValueID(); | 3152 NaClBcIndexSize_t FcnId = Context->getNextFunctionBlockValueID(); |
| 3151 if (Ctx->getFlags().getParseParallel()) { | 3153 if (IsParseParallel) { |
| 3152 // Skip the block and copy into a buffer. Note: We copy into a buffer | 3154 // Skip the block and copy into a buffer. Note: We copy into a buffer |
| 3153 // using the top-level parser to make sure that the underlying | 3155 // using the top-level parser to make sure that the underlying |
| 3154 // buffer reading from the data streamer is not thread safe. | 3156 // buffer reading from the data streamer is not thread safe. |
| 3155 NaClBitstreamCursor &Cursor = Record.GetCursor(); | 3157 NaClBitstreamCursor &Cursor = Record.GetCursor(); |
| 3156 uint64_t StartBit = Cursor.GetCurrentBitNo(); | 3158 uint64_t StartBit = Cursor.GetCurrentBitNo(); |
| 3157 if (SkipBlock()) | 3159 if (SkipBlock()) |
| 3158 return true; | 3160 return true; |
| 3159 const uint64_t EndBit = Cursor.GetCurrentBitNo(); | 3161 const uint64_t EndBit = Cursor.GetCurrentBitNo(); |
| 3160 const uintptr_t StartByte = Cursor.getStartWordByteForBit(StartBit); | 3162 const uintptr_t StartByte = Cursor.getStartWordByteForBit(StartBit); |
| 3161 const uintptr_t EndByte = Cursor.getEndWordByteForBit(EndBit); | 3163 const uintptr_t EndByte = Cursor.getEndWordByteForBit(EndBit); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3296 raw_string_ostream StrBuf(Buffer); | 3298 raw_string_ostream StrBuf(Buffer); |
| 3297 StrBuf << IRFilename << ": Does not contain a module!"; | 3299 StrBuf << IRFilename << ": Does not contain a module!"; |
| 3298 llvm::report_fatal_error(StrBuf.str()); | 3300 llvm::report_fatal_error(StrBuf.str()); |
| 3299 } | 3301 } |
| 3300 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3302 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
| 3301 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); | 3303 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); |
| 3302 } | 3304 } |
| 3303 } | 3305 } |
| 3304 | 3306 |
| 3305 } // end of namespace Ice | 3307 } // end of namespace Ice |
| OLD | NEW |