Home | History | Annotate | Download | only in IRReader
      1 //===---- llvm/IRReader/IRReader.h - Reader for LLVM IR files ---*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file defines functions for reading LLVM IR. They support both
     11 // Bitcode and Assembly, automatically detecting the input format.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_IRREADER_IRREADER_H
     16 #define LLVM_IRREADER_IRREADER_H
     17 
     18 #include <memory>
     19 
     20 namespace llvm {
     21 
     22 class StringRef;
     23 class MemoryBufferRef;
     24 class Module;
     25 class SMDiagnostic;
     26 class LLVMContext;
     27 
     28 /// If the given file holds a bitcode image, return a Module
     29 /// for it which does lazy deserialization of function bodies.  Otherwise,
     30 /// attempt to parse it as LLVM Assembly and return a fully populated
     31 /// Module. The ShouldLazyLoadMetadata flag is passed down to the bitcode
     32 /// reader to optionally enable lazy metadata loading.
     33 std::unique_ptr<Module>
     34 getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
     35                     bool ShouldLazyLoadMetadata = false);
     36 
     37 /// If the given MemoryBuffer holds a bitcode image, return a Module
     38 /// for it.  Otherwise, attempt to parse it as LLVM Assembly and return
     39 /// a Module for it.
     40 /// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier.
     41 ///                         This option should only be set to false by llvm-as
     42 ///                         for use inside the LLVM testuite!
     43 std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
     44                                 LLVMContext &Context,
     45                                 bool UpgradeDebugInfo = true);
     46 
     47 /// If the given file holds a bitcode image, return a Module for it.
     48 /// Otherwise, attempt to parse it as LLVM Assembly and return a Module
     49 /// for it.
     50 /// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier.
     51 ///                         This option should only be set to false by llvm-as
     52 ///                         for use inside the LLVM testuite!
     53 std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err,
     54                                     LLVMContext &Context,
     55                                     bool UpgradeDebugInfo = true);
     56 }
     57 
     58 #endif
     59