| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 // TODO(kschimpf) Remove error recovery once implementation complete. | 46 // TODO(kschimpf) Remove error recovery once implementation complete. |
| 47 static cl::opt<bool> AllowErrorRecovery( | 47 static cl::opt<bool> AllowErrorRecovery( |
| 48 "allow-pnacl-reader-error-recovery", | 48 "allow-pnacl-reader-error-recovery", |
| 49 cl::desc("Allow error recovery when reading PNaCl bitcode."), | 49 cl::desc("Allow error recovery when reading PNaCl bitcode."), |
| 50 cl::init(false)); | 50 cl::init(false)); |
| 51 | 51 |
| 52 // Top-level class to read PNaCl bitcode files, and translate to ICE. | 52 // Top-level class to read PNaCl bitcode files, and translate to ICE. |
| 53 class TopLevelParser : public NaClBitcodeParser { | 53 class TopLevelParser : public NaClBitcodeParser { |
| 54 TopLevelParser(const TopLevelParser &) LLVM_DELETED_FUNCTION; | 54 TopLevelParser(const TopLevelParser &) = delete; |
| 55 TopLevelParser &operator=(const TopLevelParser &) LLVM_DELETED_FUNCTION; | 55 TopLevelParser &operator=(const TopLevelParser &) = delete; |
| 56 | 56 |
| 57 public: | 57 public: |
| 58 TopLevelParser(Ice::Translator &Translator, const std::string &InputName, | 58 TopLevelParser(Ice::Translator &Translator, const std::string &InputName, |
| 59 NaClBitcodeHeader &Header, NaClBitstreamCursor &Cursor, | 59 NaClBitcodeHeader &Header, NaClBitstreamCursor &Cursor, |
| 60 bool &ErrorStatus) | 60 bool &ErrorStatus) |
| 61 : NaClBitcodeParser(Cursor), Translator(Translator), | 61 : NaClBitcodeParser(Cursor), Translator(Translator), |
| 62 Mod(new Module(InputName, getGlobalContext())), DL(PNaClDataLayout), | 62 Mod(new Module(InputName, getGlobalContext())), DL(PNaClDataLayout), |
| 63 Header(Header), TypeConverter(getLLVMContext()), | 63 Header(Header), TypeConverter(getLLVMContext()), |
| 64 ErrorStatus(ErrorStatus), NumErrors(0), NumFunctionIds(0), | 64 ErrorStatus(ErrorStatus), NumErrors(0), NumFunctionIds(0), |
| 65 NumFunctionBlocks(0), | 65 NumFunctionBlocks(0), |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 return; | 760 return; |
| 761 } | 761 } |
| 762 // If reached, just processed another initializer. See if time | 762 // If reached, just processed another initializer. See if time |
| 763 // to install global. | 763 // to install global. |
| 764 if (InitializersNeeded == Initializers.size()) | 764 if (InitializersNeeded == Initializers.size()) |
| 765 installGlobalVar(); | 765 installGlobalVar(); |
| 766 } | 766 } |
| 767 | 767 |
| 768 /// Base class for parsing a valuesymtab block in the bitcode file. | 768 /// Base class for parsing a valuesymtab block in the bitcode file. |
| 769 class ValuesymtabParser : public BlockParserBaseClass { | 769 class ValuesymtabParser : public BlockParserBaseClass { |
| 770 ValuesymtabParser(const ValuesymtabParser &) LLVM_DELETED_FUNCTION; | 770 ValuesymtabParser(const ValuesymtabParser &) = delete; |
| 771 void operator=(const ValuesymtabParser &) LLVM_DELETED_FUNCTION; | 771 void operator=(const ValuesymtabParser &) = delete; |
| 772 | 772 |
| 773 public: | 773 public: |
| 774 ValuesymtabParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) | 774 ValuesymtabParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) |
| 775 : BlockParserBaseClass(BlockID, EnclosingParser) {} | 775 : BlockParserBaseClass(BlockID, EnclosingParser) {} |
| 776 | 776 |
| 777 ~ValuesymtabParser() override {} | 777 ~ValuesymtabParser() override {} |
| 778 | 778 |
| 779 protected: | 779 protected: |
| 780 typedef SmallString<128> StringType; | 780 typedef SmallString<128> StringType; |
| 781 | 781 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 822 } |
| 823 // If reached, don't know how to handle record. | 823 // If reached, don't know how to handle record. |
| 824 BlockParserBaseClass::ProcessRecord(); | 824 BlockParserBaseClass::ProcessRecord(); |
| 825 return; | 825 return; |
| 826 } | 826 } |
| 827 | 827 |
| 828 class FunctionValuesymtabParser; | 828 class FunctionValuesymtabParser; |
| 829 | 829 |
| 830 /// Parses function blocks in the bitcode file. | 830 /// Parses function blocks in the bitcode file. |
| 831 class FunctionParser : public BlockParserBaseClass { | 831 class FunctionParser : public BlockParserBaseClass { |
| 832 FunctionParser(const FunctionParser &) LLVM_DELETED_FUNCTION; | 832 FunctionParser(const FunctionParser &) = delete; |
| 833 FunctionParser &operator=(const FunctionParser &) LLVM_DELETED_FUNCTION; | 833 FunctionParser &operator=(const FunctionParser &) = delete; |
| 834 friend class FunctionValuesymtabParser; | 834 friend class FunctionValuesymtabParser; |
| 835 | 835 |
| 836 public: | 836 public: |
| 837 FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) | 837 FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) |
| 838 : BlockParserBaseClass(BlockID, EnclosingParser), | 838 : BlockParserBaseClass(BlockID, EnclosingParser), |
| 839 Func(new Ice::Cfg(getTranslator().getContext())), CurrentBbIndex(0), | 839 Func(new Ice::Cfg(getTranslator().getContext())), CurrentBbIndex(0), |
| 840 FcnId(Context->getNextFunctionBlockValueID()), | 840 FcnId(Context->getNextFunctionBlockValueID()), |
| 841 LLVMFunc(cast<Function>(Context->getGlobalValueByID(FcnId))), | 841 LLVMFunc(cast<Function>(Context->getGlobalValueByID(FcnId))), |
| 842 CachedNumGlobalValueIDs(Context->getNumGlobalValueIDs()), | 842 CachedNumGlobalValueIDs(Context->getNumGlobalValueIDs()), |
| 843 NextLocalInstIndex(Context->getNumGlobalValueIDs()), | 843 NextLocalInstIndex(Context->getNumGlobalValueIDs()), |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 } | 2009 } |
| 2010 default: | 2010 default: |
| 2011 // Generate error message! | 2011 // Generate error message! |
| 2012 BlockParserBaseClass::ProcessRecord(); | 2012 BlockParserBaseClass::ProcessRecord(); |
| 2013 break; | 2013 break; |
| 2014 } | 2014 } |
| 2015 } | 2015 } |
| 2016 | 2016 |
| 2017 /// Parses constants within a function block. | 2017 /// Parses constants within a function block. |
| 2018 class ConstantsParser : public BlockParserBaseClass { | 2018 class ConstantsParser : public BlockParserBaseClass { |
| 2019 ConstantsParser(const ConstantsParser &) LLVM_DELETED_FUNCTION; | 2019 ConstantsParser(const ConstantsParser &) = delete; |
| 2020 ConstantsParser &operator=(const ConstantsParser &) LLVM_DELETED_FUNCTION; | 2020 ConstantsParser &operator=(const ConstantsParser &) = delete; |
| 2021 | 2021 |
| 2022 public: | 2022 public: |
| 2023 ConstantsParser(unsigned BlockID, FunctionParser *FuncParser) | 2023 ConstantsParser(unsigned BlockID, FunctionParser *FuncParser) |
| 2024 : BlockParserBaseClass(BlockID, FuncParser), FuncParser(FuncParser), | 2024 : BlockParserBaseClass(BlockID, FuncParser), FuncParser(FuncParser), |
| 2025 NextConstantType(Ice::IceType_void) {} | 2025 NextConstantType(Ice::IceType_void) {} |
| 2026 | 2026 |
| 2027 ~ConstantsParser() override {} | 2027 ~ConstantsParser() override {} |
| 2028 | 2028 |
| 2029 private: | 2029 private: |
| 2030 // The parser of the function block this constants block appears in. | 2030 // The parser of the function block this constants block appears in. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2125 } | 2125 } |
| 2126 default: | 2126 default: |
| 2127 // Generate error message! | 2127 // Generate error message! |
| 2128 BlockParserBaseClass::ProcessRecord(); | 2128 BlockParserBaseClass::ProcessRecord(); |
| 2129 return; | 2129 return; |
| 2130 } | 2130 } |
| 2131 } | 2131 } |
| 2132 | 2132 |
| 2133 // Parses valuesymtab blocks appearing in a function block. | 2133 // Parses valuesymtab blocks appearing in a function block. |
| 2134 class FunctionValuesymtabParser : public ValuesymtabParser { | 2134 class FunctionValuesymtabParser : public ValuesymtabParser { |
| 2135 FunctionValuesymtabParser(const FunctionValuesymtabParser &) | 2135 FunctionValuesymtabParser(const FunctionValuesymtabParser &) = delete; |
| 2136 LLVM_DELETED_FUNCTION; | 2136 void operator=(const FunctionValuesymtabParser &) = delete; |
| 2137 void operator=(const FunctionValuesymtabParser &) LLVM_DELETED_FUNCTION; | |
| 2138 | 2137 |
| 2139 public: | 2138 public: |
| 2140 FunctionValuesymtabParser(unsigned BlockID, FunctionParser *EnclosingParser) | 2139 FunctionValuesymtabParser(unsigned BlockID, FunctionParser *EnclosingParser) |
| 2141 : ValuesymtabParser(BlockID, EnclosingParser) {} | 2140 : ValuesymtabParser(BlockID, EnclosingParser) {} |
| 2142 | 2141 |
| 2143 private: | 2142 private: |
| 2144 // Returns the enclosing function parser. | 2143 // Returns the enclosing function parser. |
| 2145 FunctionParser *getFunctionParser() const { | 2144 FunctionParser *getFunctionParser() const { |
| 2146 return reinterpret_cast<FunctionParser *>(GetEnclosingParser()); | 2145 return reinterpret_cast<FunctionParser *>(GetEnclosingParser()); |
| 2147 } | 2146 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2237 | 2236 |
| 2238 void ExitBlock() override { | 2237 void ExitBlock() override { |
| 2239 InstallGlobalAddressNamesAndInitializers(); | 2238 InstallGlobalAddressNamesAndInitializers(); |
| 2240 getTranslator().emitConstants(); | 2239 getTranslator().emitConstants(); |
| 2241 } | 2240 } |
| 2242 | 2241 |
| 2243 void ProcessRecord() override; | 2242 void ProcessRecord() override; |
| 2244 }; | 2243 }; |
| 2245 | 2244 |
| 2246 class ModuleValuesymtabParser : public ValuesymtabParser { | 2245 class ModuleValuesymtabParser : public ValuesymtabParser { |
| 2247 ModuleValuesymtabParser(const ModuleValuesymtabParser &) | 2246 ModuleValuesymtabParser(const ModuleValuesymtabParser &) = delete; |
| 2248 LLVM_DELETED_FUNCTION; | 2247 void operator=(const ModuleValuesymtabParser &) = delete; |
| 2249 void operator=(const ModuleValuesymtabParser &) LLVM_DELETED_FUNCTION; | |
| 2250 | 2248 |
| 2251 public: | 2249 public: |
| 2252 ModuleValuesymtabParser(unsigned BlockID, ModuleParser *MP) | 2250 ModuleValuesymtabParser(unsigned BlockID, ModuleParser *MP) |
| 2253 : ValuesymtabParser(BlockID, MP) {} | 2251 : ValuesymtabParser(BlockID, MP) {} |
| 2254 | 2252 |
| 2255 ~ModuleValuesymtabParser() override {} | 2253 ~ModuleValuesymtabParser() override {} |
| 2256 | 2254 |
| 2257 private: | 2255 private: |
| 2258 void setValueName(uint64_t Index, StringType &Name) override; | 2256 void setValueName(uint64_t Index, StringType &Name) override; |
| 2259 void setBbName(uint64_t Index, StringType &Name) override; | 2257 void setBbName(uint64_t Index, StringType &Name) override; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2423 | 2421 |
| 2424 if (TopLevelBlocks != 1) { | 2422 if (TopLevelBlocks != 1) { |
| 2425 errs() << IRFilename | 2423 errs() << IRFilename |
| 2426 << ": Contains more than one module. Found: " << TopLevelBlocks | 2424 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 2427 << "\n"; | 2425 << "\n"; |
| 2428 ErrorStatus = true; | 2426 ErrorStatus = true; |
| 2429 } | 2427 } |
| 2430 } | 2428 } |
| 2431 | 2429 |
| 2432 } // end of namespace Ice | 2430 } // end of namespace Ice |
| OLD | NEW |