LLVM 20.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
17#include "llvm/ADT/StringRef.h"
19#include <memory>
20
21namespace llvm {
22
23class MemoryBuffer;
24class MemoryBufferRef;
25class Module;
26class SMDiagnostic;
27class LLVMContext;
28
29/// If the given MemoryBuffer 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. This takes ownership
34/// of \p Buffer.
35std::unique_ptr<Module> getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer,
36 SMDiagnostic &Err, LLVMContext &Context,
37 bool ShouldLazyLoadMetadata = false);
38
39/// If the given file holds a bitcode image, return a Module
40/// for it which does lazy deserialization of function bodies. Otherwise,
41/// attempt to parse it as LLVM Assembly and return a fully populated
42/// Module. The ShouldLazyLoadMetadata flag is passed down to the bitcode
43/// reader to optionally enable lazy metadata loading.
44std::unique_ptr<Module>
45getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
46 bool ShouldLazyLoadMetadata = false);
47
48/// If the given MemoryBuffer holds a bitcode image, return a Module
49/// for it. Otherwise, attempt to parse it as LLVM Assembly and return
50/// a Module for it.
51/// \param DataLayoutCallback Override datalayout in the llvm assembly.
52std::unique_ptr<Module> parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
53 LLVMContext &Context,
54 ParserCallbacks Callbacks = {});
55
56/// If the given file holds a bitcode image, return a Module for it.
57/// Otherwise, attempt to parse it as LLVM Assembly and return a Module
58/// for it.
59/// \param DataLayoutCallback Override datalayout in the llvm assembly.
60std::unique_ptr<Module> parseIRFile(StringRef Filename, SMDiagnostic &Err,
61 LLVMContext &Context,
62 ParserCallbacks Callbacks = {});
63}
64
65#endif
Machine Check Debug Module
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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
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
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
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