| OLD | NEW | 
|    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/Support/CommandLine.h" |   19 #include "llvm/Support/CommandLine.h" | 
 |   20 #include "llvm/Support/ErrorOr.h" | 
|   20  |   21  | 
|   21 #include <string> |   22 #include <string> | 
|   22  |   23  | 
|   23 namespace llvm { |   24 namespace llvm { | 
|   24   class MemoryBuffer; |   25   class MemoryBuffer; | 
|   25   class LLVMContext; |   26   class LLVMContext; | 
|   26   class Module; |   27   class Module; | 
|   27   class raw_ostream; |   28   class raw_ostream; | 
|   28   class NaClBitcodeHeader; |   29   class NaClBitcodeHeader; | 
|   29   class NaClBitstreamWriter; |   30   class NaClBitstreamWriter; | 
|   30   class StreamingMemoryObject; |   31   class StreamingMemoryObject; | 
|   31  |   32  | 
|   32   /// Defines the data layout used for PNaCl bitcode files. We set the |   33   /// Defines the data layout used for PNaCl bitcode files. We set the | 
|   33   /// data layout of the module in the bitcode readers rather than in |   34   /// data layout of the module in the bitcode readers rather than in | 
|   34   /// pnacl-llc so that 'opt' will also use the correct data layout if |   35   /// pnacl-llc so that 'opt' will also use the correct data layout if | 
|   35   /// it is run on a pexe. |   36   /// it is run on a pexe. | 
|   36   extern const char *PNaClDataLayout; |   37   extern const char *PNaClDataLayout; | 
|   37  |   38  | 
|   38   /// Allows (function) local symbol tables (unsupported) in PNaCl bitcode |   39   /// Allows (function) local symbol tables (unsupported) in PNaCl bitcode | 
|   39   /// files. |   40   /// files. | 
|   40   extern cl::opt<bool> PNaClAllowLocalSymbolTables; |   41   extern cl::opt<bool> PNaClAllowLocalSymbolTables; | 
|   41  |   42  | 
|   42   /// \brief Defines the integer bit size used to model pointers in PNaCl. |   43   /// \brief Defines the integer bit size used to model pointers in PNaCl. | 
|   43   static const unsigned PNaClIntPtrTypeBitSize = 32; |   44   static const unsigned PNaClIntPtrTypeBitSize = 32; | 
|   44  |   45  | 
|   45   /// getNaClLazyBitcodeModule - Read the header of the specified bitcode buffer |   46   /// getNaClLazyBitcodeModule - Read the header of the specified bitcode buffer | 
|   46   /// and prepare for lazy deserialization of function bodies.  If successful, |   47   /// and prepare for lazy deserialization of function bodies.  If successful, | 
|   47   /// this takes ownership of 'buffer' and returns a non-null pointer.  On |   48   /// takes ownership of 'buffer' and returns a non-null pointer.  On | 
|   48   /// error, this returns null, *does not* take ownership of Buffer, and fills |   49   /// error, this returns an error code and *does not* take ownership of Buffer. | 
|   49   /// in *ErrMsg with an error description if ErrMsg is non-null. |   50   /// | 
 |   51   /// When Verbose is non-null, more descriptive error messages are also | 
 |   52   /// written to Verbose. | 
|   50   /// |   53   /// | 
|   51   /// The AcceptSupportedOnly argument is used to decide which PNaCl versions |   54   /// The AcceptSupportedOnly argument is used to decide which PNaCl versions | 
|   52   /// of the PNaCl bitcode to accept. There are three forms: |   55   /// of the PNaCl bitcode to accept. There are three forms: | 
|   53   ///    1) Readable and supported. |   56   ///    1) Readable and supported. | 
|   54   ///    2) Readable and unsupported. Allows testing of code before becoming |   57   ///    2) Readable and unsupported. Allows testing of code before becoming | 
|   55   ///       supported, as well as running experiments on the bitcode format. |   58   ///       supported, as well as running experiments on the bitcode format. | 
|   56   ///    3) Unreadable. |   59   ///    3) Unreadable. | 
|   57   /// When AcceptSupportedOnly is true, only form 1 is allowed. When |   60   /// When AcceptSupportedOnly is true, only form 1 is allowed. When | 
|   58   /// AcceptSupportedOnly is false, forms 1 and 2 are allowed. |   61   /// AcceptSupportedOnly is false, forms 1 and 2 are allowed. | 
|   59   Module *getNaClLazyBitcodeModule(MemoryBuffer *Buffer, |   62   ErrorOr<Module *> getNaClLazyBitcodeModule(MemoryBuffer *Buffer, | 
|   60                                    LLVMContext &Context, |   63                                              LLVMContext &Context, | 
|   61                                    std::string *ErrMsg = 0, |   64                                              raw_ostream *Verbose = nullptr, | 
|   62                                    bool AcceptSupportedOnly = true); |   65                                              bool AcceptSupportedOnly = true); | 
|   63  |   66  | 
|   64   /// getNaClStreamedBitcodeModule - Read the header of the specified stream |   67   /// getNaClStreamedBitcodeModule - Read the header of the specified stream | 
|   65   /// and prepare for lazy deserialization and streaming of function bodies. |   68   /// and prepare for lazy deserialization and streaming of function bodies. | 
|   66   /// On error, this returns null, and fills in *ErrMsg with an error |   69   /// On error, this returns null, and fills in *ErrMsg with an error | 
|   67   /// description if ErrMsg is non-null. |   70   /// description if ErrMsg is non-null. | 
|   68   /// |   71   /// | 
|   69   /// See getNaClLazyBitcodeModule for an explanation of argument |   72   /// See getNaClLazyBitcodeModule for an explanation of arguments | 
|   70   /// AcceptSupportedOnly. |   73   /// Verbose, AcceptSupportedOnly. | 
 |   74   /// TODO(kschimpf): Refactor this and getStreamedBitcodeModule to use | 
 |   75   /// ErrorOr<Module *> API so that all methods have the same interface. | 
|   71   Module *getNaClStreamedBitcodeModule(const std::string &name, |   76   Module *getNaClStreamedBitcodeModule(const std::string &name, | 
|   72                                        StreamingMemoryObject *streamer, |   77                                        StreamingMemoryObject *streamer, | 
|   73                                        LLVMContext &Context, |   78                                        LLVMContext &Context, | 
|   74                                        std::string *ErrMsg = 0, |   79                                        raw_ostream *Verbose = nullptr, | 
 |   80                                        std::string *ErrMsg = nullptr, | 
|   75                                        bool AcceptSupportedOnly = true); |   81                                        bool AcceptSupportedOnly = true); | 
|   76  |   82  | 
|   77   /// NaClParseBitcodeFile - Read the specified bitcode file, |   83   /// NaClParseBitcodeFile - Read the specified bitcode file, | 
|   78   /// returning the module.  If an error occurs, this returns null and |   84   /// returning the module.  If successful, takes ownership of | 
|   79   /// fills in *ErrMsg if it is non-null.  This method *never* takes |   85   /// 'buffer' and returns a non-null pointer.  On error, this returns | 
|   80   /// ownership of Buffer. |   86   /// an error code and *does not* take ownership of Buffer. | 
|   81   /// |   87   /// | 
|   82   /// See getNaClLazyBitcodeModule for an explanation of argument |   88   /// See getNaClLazyBitcodeModule for an explanation of arguments | 
|   83   /// AcceptSupportedOnly. |   89   /// Verbose, AcceptSupportedOnly. | 
|   84   Module *NaClParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext &Context, |   90   ErrorOr<Module *> NaClParseBitcodeFile(MemoryBuffer *Buffer, | 
|   85                                std::string *ErrMsg = 0, |   91                                          LLVMContext &Context, | 
|   86                                bool AcceptSupportedOnly = true); |   92                                          raw_ostream *Verbose = nullptr, | 
 |   93                                          bool AcceptSupportedOnly = true); | 
|   87  |   94  | 
|   88   /// NaClWriteBitcodeToFile - Write the specified module to the |   95   /// NaClWriteBitcodeToFile - Write the specified module to the | 
|   89   /// specified raw output stream, using PNaCl wire format.  For |   96   /// specified raw output stream, using PNaCl wire format.  For | 
|   90   /// streams where it matters, the given stream should be in "binary" |   97   /// streams where it matters, the given stream should be in "binary" | 
|   91   /// mode. |   98   /// mode. | 
|   92   /// |   99   /// | 
|   93   /// The AcceptSupportedOnly argument is used to decide which PNaCl versions |  100   /// The AcceptSupportedOnly argument is used to decide which PNaCl versions | 
|   94   /// of the PNaCl bitcode to generate. There are two forms: |  101   /// of the PNaCl bitcode to generate. There are two forms: | 
|   95   ///    1) Writable and supported. |  102   ///    1) Writable and supported. | 
|   96   ///    2) Writable and unsupported. Allows testing of code before becoming |  103   ///    2) Writable and unsupported. Allows testing of code before becoming | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|  124  |  131  | 
|  125   /// NaClObjDump - Read PNaCl bitcode file from input, and print a |  132   /// NaClObjDump - Read PNaCl bitcode file from input, and print a | 
|  126   /// textual representation of its contents. NoRecords and NoAssembly |  133   /// textual representation of its contents. NoRecords and NoAssembly | 
|  127   /// define what should not be included in the dump. Note: The caller |  134   /// define what should not be included in the dump. Note: The caller | 
|  128   /// retains ownership of the Input memory buffer. |  135   /// retains ownership of the Input memory buffer. | 
|  129   bool NaClObjDump(MemoryBuffer *Input, raw_ostream &output, |  136   bool NaClObjDump(MemoryBuffer *Input, raw_ostream &output, | 
|  130                    bool NoRecords, bool NoAssembly); |  137                    bool NoRecords, bool NoAssembly); | 
|  131  |  138  | 
|  132 } // end llvm namespace |  139 } // end llvm namespace | 
|  133 #endif |  140 #endif | 
| OLD | NEW |