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