c3ccffefa84cb97d85954df0dbd6d3ba706cf9fa
[oota-llvm.git] / include / llvm / IRReader / IRReader.h
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 "llvm/ADT/StringRef.h"
19 #include <memory>
20 #include <string>
21
22 namespace llvm {
23
24 class Module;
25 class MemoryBuffer;
26 class SMDiagnostic;
27 class LLVMContext;
28
29 /// If the given file holds a bitcode image, return a Module
30 /// for it which does lazy deserialization of function bodies.  Otherwise,
31 /// attempt to parse it as LLVM Assembly and return a fully populated
32 /// Module.
33 std::unique_ptr<Module> getLazyIRFileModule(StringRef Filename,
34                                             SMDiagnostic &Err,
35                                             LLVMContext &Context);
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. This function *never* takes ownership of Buffer.
40 std::unique_ptr<Module> parseIR(MemoryBuffer *Buffer, SMDiagnostic &Err,
41                                 LLVMContext &Context);
42
43 /// If the given file holds a bitcode image, return a Module for it.
44 /// Otherwise, attempt to parse it as LLVM Assembly and return a Module
45 /// for it.
46 std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err,
47                                     LLVMContext &Context);
48 }
49
50 #endif