Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: src/PNaClTranslator.cpp

Issue 752603003: Merge remote-tracking branch 'origin/merge_35' (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTranslator.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // translator. 11 // translator.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "llvm/ADT/SmallString.h"
15 #include "llvm/Analysis/NaCl/PNaClABIProps.h" 16 #include "llvm/Analysis/NaCl/PNaClABIProps.h"
16 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h" 17 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h"
17 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h" 18 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h"
18 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" 19 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h"
19 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" 20 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
20 #include "llvm/IR/Constants.h" 21 #include "llvm/IR/Constants.h"
21 #include "llvm/IR/DataLayout.h" 22 #include "llvm/IR/DataLayout.h"
22 #include "llvm/IR/LLVMContext.h" 23 #include "llvm/IR/LLVMContext.h"
23 #include "llvm/IR/Module.h" 24 #include "llvm/IR/Module.h"
24 #include "llvm/Support/Format.h" 25 #include "llvm/Support/Format.h"
25 #include "llvm/Support/MemoryBuffer.h" 26 #include "llvm/Support/MemoryBuffer.h"
26 #include "llvm/Support/raw_ostream.h" 27 #include "llvm/Support/raw_ostream.h"
27 28
28 #include "IceCfg.h" 29 #include "IceCfg.h"
29 #include "IceCfgNode.h" 30 #include "IceCfgNode.h"
30 #include "IceClFlags.h" 31 #include "IceClFlags.h"
31 #include "IceDefs.h" 32 #include "IceDefs.h"
32 #include "IceGlobalInits.h" 33 #include "IceGlobalInits.h"
33 #include "IceInst.h" 34 #include "IceInst.h"
34 #include "IceOperand.h" 35 #include "IceOperand.h"
35 #include "IceTypeConverter.h" 36 #include "IceTypeConverter.h"
36 #include "PNaClTranslator.h" 37 #include "PNaClTranslator.h"
37 38
39 #include <memory>
40
38 namespace { 41 namespace {
39 using namespace llvm; 42 using namespace llvm;
40 43
41 // TODO(kschimpf) Remove error recovery once implementation complete. 44 // TODO(kschimpf) Remove error recovery once implementation complete.
42 static cl::opt<bool> AllowErrorRecovery( 45 static cl::opt<bool> AllowErrorRecovery(
43 "allow-pnacl-reader-error-recovery", 46 "allow-pnacl-reader-error-recovery",
44 cl::desc("Allow error recovery when reading PNaCl bitcode."), 47 cl::desc("Allow error recovery when reading PNaCl bitcode."),
45 cl::init(false)); 48 cl::init(false));
46 49
47 // Models elements in the list of types defined in the types block. 50 // Models elements in the list of types defined in the types block.
(...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2820 // Generate error message by using default block implementation. 2823 // Generate error message by using default block implementation.
2821 BlockParserBaseClass Parser(BlockID, this); 2824 BlockParserBaseClass Parser(BlockID, this);
2822 return Parser.ParseThisBlock(); 2825 return Parser.ParseThisBlock();
2823 } 2826 }
2824 2827
2825 } // end of anonymous namespace 2828 } // end of anonymous namespace
2826 2829
2827 namespace Ice { 2830 namespace Ice {
2828 2831
2829 void PNaClTranslator::translate(const std::string &IRFilename) { 2832 void PNaClTranslator::translate(const std::string &IRFilename) {
2830 OwningPtr<MemoryBuffer> MemBuf; 2833 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrOrFile =
2831 if (error_code ec = 2834 MemoryBuffer::getFileOrSTDIN(IRFilename);
2832 MemoryBuffer::getFileOrSTDIN(IRFilename.c_str(), MemBuf)) { 2835 if (std::error_code EC = ErrOrFile.getError()) {
2833 errs() << "Error reading '" << IRFilename << "': " << ec.message() << "\n"; 2836 errs() << "Error reading '" << IRFilename << "': " << EC.message() << "\n";
2834 ErrorStatus = true; 2837 ErrorStatus = true;
2835 return; 2838 return;
2836 } 2839 }
2837 2840
2841 std::unique_ptr<MemoryBuffer> MemBuf(ErrOrFile.get().release());
2838 if (MemBuf->getBufferSize() % 4 != 0) { 2842 if (MemBuf->getBufferSize() % 4 != 0) {
2839 errs() << IRFilename 2843 errs() << IRFilename
2840 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; 2844 << ": Bitcode stream should be a multiple of 4 bytes in length.\n";
2841 ErrorStatus = true; 2845 ErrorStatus = true;
2842 return; 2846 return;
2843 } 2847 }
2844 2848
2845 const unsigned char *BufPtr = (const unsigned char *)MemBuf->getBufferStart(); 2849 const unsigned char *BufPtr = (const unsigned char *)MemBuf->getBufferStart();
2846 const unsigned char *EndBufPtr = BufPtr + MemBuf->getBufferSize(); 2850 const unsigned char *EndBufPtr = BufPtr + MemBuf->getBufferSize();
2847 2851
(...skipping 22 matching lines...) Expand all
2870 2874
2871 if (TopLevelBlocks != 1) { 2875 if (TopLevelBlocks != 1) {
2872 errs() << IRFilename 2876 errs() << IRFilename
2873 << ": Contains more than one module. Found: " << TopLevelBlocks 2877 << ": Contains more than one module. Found: " << TopLevelBlocks
2874 << "\n"; 2878 << "\n";
2875 ErrorStatus = true; 2879 ErrorStatus = true;
2876 } 2880 }
2877 } 2881 }
2878 2882
2879 } // end of namespace Ice 2883 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTranslator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698