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 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 | 2988 |
2989 // Read header and verify it is good. | 2989 // Read header and verify it is good. |
2990 NaClBitcodeHeader Header; | 2990 NaClBitcodeHeader Header; |
2991 if (Header.Read(MemObj.get()) || !Header.IsSupported()) { | 2991 if (Header.Read(MemObj.get()) || !Header.IsSupported()) { |
2992 errs() << "Invalid PNaCl bitcode header.\n"; | 2992 errs() << "Invalid PNaCl bitcode header.\n"; |
2993 ErrorStatus.assign(EC_Bitcode); | 2993 ErrorStatus.assign(EC_Bitcode); |
2994 return; | 2994 return; |
2995 } | 2995 } |
2996 | 2996 |
2997 // Create a bitstream reader to read the bitcode file. | 2997 // Create a bitstream reader to read the bitcode file. |
2998 NaClBitstreamReader InputStreamFile(MemObj.release(), Header.getHeaderSize()); | 2998 NaClBitstreamReader InputStreamFile(MemObj.release(), Header); |
2999 NaClBitstreamCursor InputStream(InputStreamFile); | 2999 NaClBitstreamCursor InputStream(InputStreamFile); |
3000 | 3000 |
3001 TopLevelParser Parser(*this, InputStream, ErrorStatus); | 3001 TopLevelParser Parser(*this, InputStream, ErrorStatus); |
3002 int TopLevelBlocks = 0; | 3002 int TopLevelBlocks = 0; |
3003 while (!InputStream.AtEndOfStream()) { | 3003 while (!InputStream.AtEndOfStream()) { |
3004 if (Parser.Parse()) { | 3004 if (Parser.Parse()) { |
3005 ErrorStatus.assign(EC_Bitcode); | 3005 ErrorStatus.assign(EC_Bitcode); |
3006 return; | 3006 return; |
3007 } | 3007 } |
3008 ++TopLevelBlocks; | 3008 ++TopLevelBlocks; |
3009 } | 3009 } |
3010 | 3010 |
3011 if (TopLevelBlocks != 1) { | 3011 if (TopLevelBlocks != 1) { |
3012 errs() << IRFilename | 3012 errs() << IRFilename |
3013 << ": Contains more than one module. Found: " << TopLevelBlocks | 3013 << ": Contains more than one module. Found: " << TopLevelBlocks |
3014 << "\n"; | 3014 << "\n"; |
3015 ErrorStatus.assign(EC_Bitcode); | 3015 ErrorStatus.assign(EC_Bitcode); |
3016 } | 3016 } |
3017 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3017 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
3018 errs() << IRFilename | 3018 errs() << IRFilename |
3019 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; | 3019 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; |
3020 ErrorStatus.assign(EC_Bitcode); | 3020 ErrorStatus.assign(EC_Bitcode); |
3021 return; | 3021 return; |
3022 } | 3022 } |
3023 } | 3023 } |
3024 | 3024 |
3025 } // end of namespace Ice | 3025 } // end of namespace Ice |
OLD | NEW |