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 | |
21 | namespace llvm { |
22 | |
23 | class StringRef; |
24 | class MemoryBufferRef; |
25 | class Module; |
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. The ShouldLazyLoadMetadata flag is passed down to the bitcode |
33 | /// reader to optionally enable lazy metadata loading. |
34 | std::unique_ptr<Module> |
35 | getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, |
36 | bool ShouldLazyLoadMetadata = false); |
37 | |
38 | /// If the given MemoryBuffer holds a bitcode image, return a Module |
39 | /// for it. Otherwise, attempt to parse it as LLVM Assembly and return |
40 | /// a Module for it. |
41 | /// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. |
42 | /// This option should only be set to false by llvm-as |
43 | /// for use inside the LLVM testuite! |
44 | /// \param DataLayoutString Override datalayout in the llvm assembly. |
45 | std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, |
46 | LLVMContext &Context, |
47 | bool UpgradeDebugInfo = true, |
48 | StringRef DataLayoutString = "" ); |
49 | |
50 | /// If the given file holds a bitcode image, return a Module for it. |
51 | /// Otherwise, attempt to parse it as LLVM Assembly and return a Module |
52 | /// for it. |
53 | /// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. |
54 | /// This option should only be set to false by llvm-as |
55 | /// for use inside the LLVM testuite! |
56 | /// \param DataLayoutString Override datalayout in the llvm assembly. |
57 | std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err, |
58 | LLVMContext &Context, |
59 | bool UpgradeDebugInfo = true, |
60 | StringRef DataLayoutString = "" ); |
61 | } |
62 | |
63 | #endif |
64 | |