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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 622443002: Subzero: Change llvm::OwningPtr to C++11's std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove ErrorOr for now Created 6 years, 2 months 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/PNaClTranslator.h ('k') | src/llvm2ice.cpp » ('j') | 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 "IceCfg.h" 15 #include <cassert>
16 #include "IceCfgNode.h" 16 #include <memory>
17 #include "IceClFlags.h" 17 #include <vector>
18 #include "IceDefs.h" 18
19 #include "IceInst.h"
20 #include "IceOperand.h"
21 #include "IceTypeConverter.h"
22 #include "PNaClTranslator.h"
23 #include "llvm/Analysis/NaCl/PNaClABIProps.h" 19 #include "llvm/Analysis/NaCl/PNaClABIProps.h"
24 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h" 20 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h"
25 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h" 21 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h"
26 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" 22 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h"
27 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" 23 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
28 #include "llvm/IR/Constants.h" 24 #include "llvm/IR/Constants.h"
29 #include "llvm/IR/DataLayout.h" 25 #include "llvm/IR/DataLayout.h"
30 #include "llvm/IR/LLVMContext.h" 26 #include "llvm/IR/LLVMContext.h"
31 #include "llvm/IR/Module.h" 27 #include "llvm/IR/Module.h"
32 #include "llvm/Support/Format.h" 28 #include "llvm/Support/Format.h"
33 #include "llvm/Support/MemoryBuffer.h" 29 #include "llvm/Support/MemoryBuffer.h"
34 #include "llvm/Support/raw_ostream.h" 30 #include "llvm/Support/raw_ostream.h"
35 #include "llvm/Support/ValueHandle.h" 31 #include "llvm/Support/ValueHandle.h"
36 32
37 #include <vector> 33 #include "IceCfg.h"
38 #include <cassert> 34 #include "IceCfgNode.h"
35 #include "IceClFlags.h"
36 #include "IceDefs.h"
37 #include "IceInst.h"
38 #include "IceOperand.h"
39 #include "IceTypeConverter.h"
40 #include "PNaClTranslator.h"
39 41
40 using namespace llvm; 42 using namespace llvm;
41 43
42 namespace { 44 namespace {
43 45
44 // TODO(kschimpf) Remove error recovery once implementation complete. 46 // TODO(kschimpf) Remove error recovery once implementation complete.
45 static cl::opt<bool> AllowErrorRecovery( 47 static cl::opt<bool> AllowErrorRecovery(
46 "allow-pnacl-reader-error-recovery", 48 "allow-pnacl-reader-error-recovery",
47 cl::desc("Allow error recovery when reading PNaCl bitcode."), 49 cl::desc("Allow error recovery when reading PNaCl bitcode."),
48 cl::init(false)); 50 cl::init(false));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 247
246 /// Returns the model for pointer types in ICE. 248 /// Returns the model for pointer types in ICE.
247 Ice::Type getIcePointerType() const { 249 Ice::Type getIcePointerType() const {
248 return TypeConverter.getIcePointerType(); 250 return TypeConverter.getIcePointerType();
249 } 251 }
250 252
251 private: 253 private:
252 // The translator associated with the parser. 254 // The translator associated with the parser.
253 Ice::Translator &Translator; 255 Ice::Translator &Translator;
254 // The parsed module. 256 // The parsed module.
255 OwningPtr<Module> Mod; 257 std::unique_ptr<Module> Mod;
256 // The data layout to use. 258 // The data layout to use.
257 DataLayout DL; 259 DataLayout DL;
258 // The bitcode header. 260 // The bitcode header.
259 NaClBitcodeHeader &Header; 261 NaClBitcodeHeader &Header;
260 // Converter between LLVM and ICE types. 262 // Converter between LLVM and ICE types.
261 Ice::TypeConverter TypeConverter; 263 Ice::TypeConverter TypeConverter;
262 // The exit status that should be set to true if an error occurs. 264 // The exit status that should be set to true if an error occurs.
263 bool &ErrorStatus; 265 bool &ErrorStatus;
264 // The number of errors reported. 266 // The number of errors reported.
265 unsigned NumErrors; 267 unsigned NumErrors;
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 // Generate error message by using default block implementation. 2373 // Generate error message by using default block implementation.
2372 BlockParserBaseClass Parser(BlockID, this); 2374 BlockParserBaseClass Parser(BlockID, this);
2373 return Parser.ParseThisBlock(); 2375 return Parser.ParseThisBlock();
2374 } 2376 }
2375 2377
2376 } // end of anonymous namespace 2378 } // end of anonymous namespace
2377 2379
2378 namespace Ice { 2380 namespace Ice {
2379 2381
2380 void PNaClTranslator::translate(const std::string &IRFilename) { 2382 void PNaClTranslator::translate(const std::string &IRFilename) {
2381 OwningPtr<MemoryBuffer> MemBuf; 2383 OwningPtr<MemoryBuffer> MemBuf;
Jim Stichnoth 2014/10/01 00:36:49 The obvious OwningPtr-->std::unique_ptr doesn't wo
JF 2014/10/01 01:18:35 Yes, that API changed in 3.5. Leaving as-is is the
2382 if (error_code ec = 2384 if (error_code ec =
2383 MemoryBuffer::getFileOrSTDIN(IRFilename.c_str(), MemBuf)) { 2385 MemoryBuffer::getFileOrSTDIN(IRFilename.c_str(), MemBuf)) {
2384 errs() << "Error reading '" << IRFilename << "': " << ec.message() << "\n"; 2386 errs() << "Error reading '" << IRFilename << "': " << ec.message() << "\n";
2385 ErrorStatus = true; 2387 ErrorStatus = true;
2386 return; 2388 return;
2387 } 2389 }
2388 2390
2389 if (MemBuf->getBufferSize() % 4 != 0) { 2391 if (MemBuf->getBufferSize() % 4 != 0) {
2390 errs() << IRFilename 2392 errs() << IRFilename
2391 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; 2393 << ": Bitcode stream should be a multiple of 4 bytes in length.\n";
(...skipping 29 matching lines...) Expand all
2421 2423
2422 if (TopLevelBlocks != 1) { 2424 if (TopLevelBlocks != 1) {
2423 errs() << IRFilename 2425 errs() << IRFilename
2424 << ": Contains more than one module. Found: " << TopLevelBlocks 2426 << ": Contains more than one module. Found: " << TopLevelBlocks
2425 << "\n"; 2427 << "\n";
2426 ErrorStatus = true; 2428 ErrorStatus = true;
2427 } 2429 }
2428 } 2430 }
2429 2431
2430 } // end of namespace Ice 2432 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/PNaClTranslator.h ('k') | src/llvm2ice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698