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"
21#include <memory>
22
23namespace llvm {
24
25class MemoryBuffer;
26class MemoryBufferRef;
27class Module;
28class SMDiagnostic;
29class 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.
37LLVM_ABI std::unique_ptr<Module>
38getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err,
39 LLVMContext &Context, 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.
46LLVM_ABI std::unique_ptr<Module>
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.
54LLVM_ABI std::unique_ptr<Module>
56 ParserCallbacks Callbacks = {},
57 AsmParserContext *ParserContext = nullptr);
58
59/// If the given file holds a bitcode image, return a Module for it.
60/// Otherwise, attempt to parse it as LLVM Assembly and return a Module
61/// for it.
62/// \param DataLayoutCallback Override datalayout in the llvm assembly.
63LLVM_ABI std::unique_ptr<Module>
65 ParserCallbacks Callbacks = {},
66 AsmParserContext *ParserContext = nullptr);
67}
68
69#endif
#define LLVM_ABI
Definition Compiler.h:213
Registry of file location information for LLVM IR constructs.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
This interface provides simple read-only access to a block of memory, and provides simple methods for...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition SourceMgr.h:297
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::unique_ptr< Module > parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, LLVMContext &Context, ParserCallbacks Callbacks={}, AsmParserContext *ParserContext=nullptr)
If the given MemoryBuffer holds a bitcode image, return a Module for it.
Definition IRReader.cpp:70
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:54
LLVM_ABI std::unique_ptr< Module > parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, ParserCallbacks Callbacks={}, AsmParserContext *ParserContext=nullptr)
If the given file holds a bitcode image, return a Module for it.
Definition IRReader.cpp:97
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:35