LLVM  10.0.0svn
MIRParser.h
Go to the documentation of this file.
1 //===- MIRParser.h - MIR serialization format parser ------------*- 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 MIR serialization library is currently a work in progress. It can't
10 // serialize machine functions at this time.
11 //
12 // This file declares the functions that parse the MIR serialization format
13 // files.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
18 #define LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
19 
20 #include "llvm/IR/Module.h"
22 #include <memory>
23 
24 namespace llvm {
25 
26 class StringRef;
27 class MIRParserImpl;
28 class MachineModuleInfo;
29 class SMDiagnostic;
30 
31 /// This class initializes machine functions by applying the state loaded from
32 /// a MIR file.
33 class MIRParser {
34  std::unique_ptr<MIRParserImpl> Impl;
35 
36 public:
37  MIRParser(std::unique_ptr<MIRParserImpl> Impl);
38  MIRParser(const MIRParser &) = delete;
39  ~MIRParser();
40 
41  /// Parses the optional LLVM IR module in the MIR file.
42  ///
43  /// A new, empty module is created if the LLVM IR isn't present.
44  /// \returns nullptr if a parsing error occurred.
45  std::unique_ptr<Module> parseIRModule();
46 
47  /// Parses MachineFunctions in the MIR file and add them to the given
48  /// MachineModuleInfo \p MMI.
49  ///
50  /// \returns true if an error occurred.
52 };
53 
54 /// This function is the main interface to the MIR serialization format parser.
55 ///
56 /// It reads in a MIR file and returns a MIR parser that can parse the embedded
57 /// LLVM IR module and initialize the machine functions by parsing the machine
58 /// function's state.
59 ///
60 /// \param Filename - The name of the file to parse.
61 /// \param Error - Error result info.
62 /// \param Context - Context which will be used for the parsed LLVM IR module.
63 std::unique_ptr<MIRParser> createMIRParserFromFile(StringRef Filename,
66 
67 /// This function is another interface to the MIR serialization format parser.
68 ///
69 /// It returns a MIR parser that works with the given memory buffer and that can
70 /// parse the embedded LLVM IR module and initialize the machine functions by
71 /// parsing the machine function's state.
72 ///
73 /// \param Contents - The MemoryBuffer containing the machine level IR.
74 /// \param Context - Context which will be used for the parsed LLVM IR module.
75 std::unique_ptr<MIRParser>
76 createMIRParser(std::unique_ptr<MemoryBuffer> Contents, LLVMContext &Context);
77 
78 } // end namespace llvm
79 
80 #endif // LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This class initializes machine functions by applying the state loaded from a MIR file.
Definition: MIRParser.h:33
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
std::unique_ptr< MIRParser > createMIRParser(std::unique_ptr< MemoryBuffer > Contents, LLVMContext &Context)
This function is another interface to the MIR serialization format parser.
Definition: MIRParser.cpp:941
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Parses MachineFunctions in the MIR file and add them to the given MachineModuleInfo MMI...
Definition: MIRParser.cpp:924
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:64
Module.h This file contains the declarations for the Module class.
MIRParser(std::unique_ptr< MIRParserImpl > Impl)
Definition: MIRParser.cpp:915
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
std::unique_ptr< Module > parseIRModule()
Parses the optional LLVM IR module in the MIR file.
Definition: MIRParser.cpp:920
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
std::unique_ptr< MIRParser > createMIRParserFromFile(StringRef Filename, SMDiagnostic &Error, LLVMContext &Context)
This function is the main interface to the MIR serialization format parser.
Definition: MIRParser.cpp:928
This class contains meta information specific to a module.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:261