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

Side by Side Diff: include/llvm/Bitcode/NaCl/NaClReaderWriter.h

Issue 1310883003: Install notion of diagnostic handler into PNaCl bitcode readers. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix issues in patch set 2. Created 5 years, 4 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 | « include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h ('k') | include/llvm/IRReader/IRReader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- llvm/Bitcode/NaCl/NaClReaderWriter.h - ------------------*- C++ -*-===// 1 //===-- llvm/Bitcode/NaCl/NaClReaderWriter.h - ------------------*- C++ -*-===//
2 // NaCl Bitcode reader/writer. 2 // NaCl Bitcode reader/writer.
3 // 3 //
4 // The LLVM Compiler Infrastructure 4 // The LLVM Compiler Infrastructure
5 // 5 //
6 // This file is distributed under the University of Illinois Open Source 6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details. 7 // License. See LICENSE.TXT for details.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 // 10 //
11 // This header defines interfaces to read and write NaCl bitcode wire format 11 // This header defines interfaces to read and write NaCl bitcode wire format
12 // files. 12 // files.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #ifndef LLVM_BITCODE_NACL_NACLREADERWRITER_H 16 #ifndef LLVM_BITCODE_NACL_NACLREADERWRITER_H
17 #define LLVM_BITCODE_NACL_NACLREADERWRITER_H 17 #define LLVM_BITCODE_NACL_NACLREADERWRITER_H
18 18
19 #include "llvm/IR/DiagnosticInfo.h"
19 #include "llvm/Support/CommandLine.h" 20 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Support/ErrorOr.h" 21 #include "llvm/Support/ErrorOr.h"
21 #include "llvm/Support/MemoryBuffer.h" 22 #include "llvm/Support/MemoryBuffer.h"
22 23
23 #include <string> 24 #include <string>
24 25
25 namespace llvm { 26 namespace llvm {
26 class LLVMContext; 27 class LLVMContext;
27 class Module; 28 class Module;
28 class NaClBitcodeHeader; 29 class NaClBitcodeHeader;
29 class NaClBitstreamWriter; 30 class NaClBitstreamWriter;
30 class StreamingMemoryObject; 31 class StreamingMemoryObject;
31 class raw_ostream; 32 class raw_ostream;
32 33
33 /// Defines the data layout used for PNaCl bitcode files. We set the 34 /// Defines the data layout used for PNaCl bitcode files. We set the
34 /// data layout of the module in the bitcode readers rather than in 35 /// data layout of the module in the bitcode readers rather than in
35 /// pnacl-llc so that 'opt' will also use the correct data layout if 36 /// pnacl-llc so that 'opt' will also use the correct data layout if
36 /// it is run on a pexe. 37 /// it is run on a pexe.
37 extern const char *PNaClDataLayout; 38 extern const char *PNaClDataLayout;
38 39
39 /// Allows (function) local symbol tables (unsupported) in PNaCl bitcode 40 /// Allows (function) local symbol tables (unsupported) in PNaCl bitcode
40 /// files. 41 /// files.
41 extern cl::opt<bool> PNaClAllowLocalSymbolTables; 42 extern cl::opt<bool> PNaClAllowLocalSymbolTables;
42 43
43 /// \brief Defines the integer bit size used to model pointers in PNaCl. 44 /// \brief Defines the integer bit size used to model pointers in PNaCl.
44 static const unsigned PNaClIntPtrTypeBitSize = 32; 45 static const unsigned PNaClIntPtrTypeBitSize = 32;
45 46
47 /// Diagnostic handler that redirects error diagnostics to the given stream.
48 DiagnosticHandlerFunction redirectNaClDiagnosticToStream(raw_ostream &Out);
49
46 /// Read the header of the specified bitcode buffer and prepare for lazy 50 /// Read the header of the specified bitcode buffer and prepare for lazy
47 /// deserialization of function bodies. If successful, this takes ownership 51 /// deserialization of function bodies. If successful, this takes ownership
48 /// of 'Buffer' (extending its lifetime). On error, this returns an error cod e 52 /// of 'Buffer' (extending its lifetime). On error, this returns an error
49 /// and deletes Buffer. 53 /// code and deletes Buffer.
50 ///
51 /// When Verbose is non-null, more descriptive error messages are also
52 /// written to Verbose.
53 /// 54 ///
54 /// The AcceptSupportedOnly argument is used to decide which PNaCl versions 55 /// The AcceptSupportedOnly argument is used to decide which PNaCl versions
55 /// of the PNaCl bitcode to accept. There are three forms: 56 /// of the PNaCl bitcode to accept. There are three forms:
56 /// 1) Readable and supported. 57 /// 1) Readable and supported.
57 /// 2) Readable and unsupported. Allows testing of code before becoming 58 /// 2) Readable and unsupported. Allows testing of code before becoming
58 /// supported, as well as running experiments on the bitcode format. 59 /// supported, as well as running experiments on the bitcode format.
59 /// 3) Unreadable. 60 /// 3) Unreadable.
60 /// When AcceptSupportedOnly is true, only form 1 is allowed. When 61 /// When AcceptSupportedOnly is true, only form 1 is allowed. When
61 /// AcceptSupportedOnly is false, forms 1 and 2 are allowed. 62 /// AcceptSupportedOnly is false, forms 1 and 2 are allowed.
62 ErrorOr<Module *> getNaClLazyBitcodeModule( 63 ErrorOr<Module *> getNaClLazyBitcodeModule(
63 std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &Context, 64 std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &Context,
64 raw_ostream *Verbose = nullptr, bool AcceptSupportedOnly = true); 65 DiagnosticHandlerFunction DiagnosticHandler = nullptr,
66 bool AcceptSupportedOnly = true);
65 67
66 /// Read the header of the specified stream and prepare for lazy 68 /// Read the header of the specified stream and prepare for lazy
67 /// deserialization and streaming of function bodies. On error, 69 /// deserialization and streaming of function bodies. On error,
68 /// this returns null, and fills in *ErrMsg with an error description 70 /// this returns null, and fills in *ErrMsg with an error description
69 /// if ErrMsg is non-null. 71 /// if ErrMsg is non-null.
70 /// 72 ///
71 /// See getNaClLazyBitcodeModule for an explanation of arguments 73 /// See getNaClLazyBitcodeModule for an explanation of argument
72 /// Verbose, AcceptSupportedOnly. 74 /// AcceptSupportedOnly.
73 /// TODO(kschimpf): Refactor this and getStreamedBitcodeModule to use 75 /// TODO(kschimpf): Refactor this and getStreamedBitcodeModule to use
74 /// ErrorOr<Module *> API so that all methods have the same interface. 76 /// ErrorOr<Module *> API so that all methods have the same interface.
75 Module *getNaClStreamedBitcodeModule(const std::string &name, 77 Module *getNaClStreamedBitcodeModule(
76 StreamingMemoryObject *streamer, 78 const std::string &name, StreamingMemoryObject *streamer,
77 LLVMContext &Context, 79 LLVMContext &Context,
78 raw_ostream *Verbose = nullptr, 80 DiagnosticHandlerFunction DiagnosticHandler = nullptr,
79 std::string *ErrMsg = nullptr, 81 std::string *ErrMsg = nullptr, bool AcceptSupportedOnly = true);
80 bool AcceptSupportedOnly = true);
81 82
82 /// Read the bitcode file from a buffer, returning the module. 83 /// Read the bitcode file from a buffer, returning the module.
83 /// 84 ///
84 /// See getNaClLazyBitcodeModule for an explanation of arguments 85 /// See getNaClLazyBitcodeModule for an explanation of argument
85 /// Verbose, AcceptSupportedOnly. 86 /// AcceptSupportedOnly.
86 ErrorOr<Module *> NaClParseBitcodeFile(MemoryBufferRef Buffer, 87 ErrorOr<Module *>
87 LLVMContext &Context, 88 NaClParseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context,
88 raw_ostream *Verbose = nullptr, 89 DiagnosticHandlerFunction DiagnosticHandler = nullptr,
89 bool AcceptSupportedOnly = true); 90 bool AcceptSupportedOnly = true);
90 91
91 /// Read the textual bitcode records in Filename, returning the module. 92 /// Read the textual bitcode records in Filename, returning the module.
92 /// Note: If Filename is "-", stdin will be read. 93 /// Note: If Filename is "-", stdin will be read.
93 /// 94 ///
94 /// See getNaClLazyBitcodeModule for an explanation of argument Verbose. 95 /// TODO(kschimpf) Replace Verbose argument with a DiagnosticHandlerFunction.
95 ErrorOr<Module *> parseNaClBitcodeText(const std::string &Filename, 96 ErrorOr<Module *> parseNaClBitcodeText(const std::string &Filename,
96 LLVMContext &Context, 97 LLVMContext &Context,
97 raw_ostream *Verbose = nullptr); 98 raw_ostream *Verbose = nullptr);
98 99
99 /// Write the specified module to the specified raw output stream, using 100 /// Write the specified module to the specified raw output stream, using
100 /// PNaCl wire format. For streams where it matters, the given stream 101 /// PNaCl wire format. For streams where it matters, the given stream
101 /// should be in "binary" mode. 102 /// should be in "binary" mode.
102 /// 103 ///
103 /// The AcceptSupportedOnly argument is used to decide which PNaCl versions 104 /// The AcceptSupportedOnly argument is used to decide which PNaCl versions
104 /// of the PNaCl bitcode to generate. There are two forms: 105 /// of the PNaCl bitcode to generate. There are two forms:
(...skipping 28 matching lines...) Expand all
133 NaClBitstreamWriter &Stream); 134 NaClBitstreamWriter &Stream);
134 135
135 /// NaClObjDump - Read PNaCl bitcode file from input, and print a 136 /// NaClObjDump - Read PNaCl bitcode file from input, and print a
136 /// textual representation of its contents. NoRecords and NoAssembly 137 /// textual representation of its contents. NoRecords and NoAssembly
137 /// define what should not be included in the dump. 138 /// define what should not be included in the dump.
138 bool NaClObjDump(MemoryBufferRef Input, raw_ostream &output, 139 bool NaClObjDump(MemoryBufferRef Input, raw_ostream &output,
139 bool NoRecords, bool NoAssembly); 140 bool NoRecords, bool NoAssembly);
140 141
141 } // end llvm namespace 142 } // end llvm namespace
142 #endif 143 #endif
OLDNEW
« no previous file with comments | « include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h ('k') | include/llvm/IRReader/IRReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698