LLVM  17.0.0git
IRReader.h
Go to the documentation of this file.
1 //===---- llvm/IRReader/IRReader.h - Reader for LLVM IR files ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines functions for reading LLVM IR. They support both
10 // Bitcode and Assembly, automatically detecting the input format.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_IRREADER_IRREADER_H
15 #define LLVM_IRREADER_IRREADER_H
16 
18 #include "llvm/ADT/StringRef.h"
20 #include <memory>
21 #include <optional>
22 
23 namespace llvm {
24 
25 class MemoryBuffer;
26 class MemoryBufferRef;
27 class Module;
28 class SMDiagnostic;
29 class LLVMContext;
30 
31 /// If the given MemoryBuffer holds a bitcode image, return a Module
32 /// for it which does lazy deserialization of function bodies. Otherwise,
33 /// attempt to parse it as LLVM Assembly and return a fully populated
34 /// Module. The ShouldLazyLoadMetadata flag is passed down to the bitcode
35 /// reader to optionally enable lazy metadata loading. This takes ownership
36 /// of \p Buffer.
37 std::unique_ptr<Module> getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer,
38  SMDiagnostic &Err, LLVMContext &Context,
39  bool ShouldLazyLoadMetadata = false);
40 
41 /// If the given file holds a bitcode image, return a Module
42 /// for it which does lazy deserialization of function bodies. Otherwise,
43 /// attempt to parse it as LLVM Assembly and return a fully populated
44 /// Module. The ShouldLazyLoadMetadata flag is passed down to the bitcode
45 /// reader to optionally enable lazy metadata loading.
46 std::unique_ptr<Module>
47 getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
48  bool ShouldLazyLoadMetadata = false);
49 
50 /// If the given MemoryBuffer holds a bitcode image, return a Module
51 /// for it. Otherwise, attempt to parse it as LLVM Assembly and return
52 /// a Module for it.
53 /// \param DataLayoutCallback Override datalayout in the llvm assembly.
54 std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
55  LLVMContext &Context,
56  ParserCallbacks Callbacks = {});
57 
58 /// If the given file holds a bitcode image, return a Module for it.
59 /// Otherwise, attempt to parse it as LLVM Assembly and return a Module
60 /// for it.
61 /// \param DataLayoutCallback Override datalayout in the llvm assembly.
62 std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err,
63  LLVMContext &Context,
64  ParserCallbacks Callbacks = {});
65 }
66 
67 #endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::parseIRFile
std::unique_ptr< Module > parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, ParserCallbacks Callbacks={})
If the given file holds a bitcode image, return a Module for it.
Definition: IRReader.cpp:94
StringRef.h
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::getLazyIRFileModule
std::unique_ptr< Module > getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, bool ShouldLazyLoadMetadata=false)
If the given file holds a bitcode image, return a Module for it which does lazy deserialization of fu...
Definition: IRReader.cpp:53
STLFunctionalExtras.h
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::parseIR
std::unique_ptr< Module > parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, LLVMContext &Context, ParserCallbacks Callbacks={})
If the given MemoryBuffer holds a bitcode image, return a Module for it.
Definition: IRReader.cpp:69
llvm::getLazyIRModule
std::unique_ptr< Module > getLazyIRModule(std::unique_ptr< MemoryBuffer > Buffer, SMDiagnostic &Err, LLVMContext &Context, bool ShouldLazyLoadMetadata=false)
If the given MemoryBuffer holds a bitcode image, return a Module for it which does lazy deserializati...
Definition: IRReader.cpp:34
BitcodeReader.h