LLVM  8.0.1
MIRParser.h
Go to the documentation of this file.
1 //===- MIRParser.h - MIR serialization format parser ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This MIR serialization library is currently a work in progress. It can't
11 // serialize machine functions at this time.
12 //
13 // This file declares the functions that parse the MIR serialization format
14 // files.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
19 #define LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
20 
21 #include "llvm/IR/Module.h"
23 #include <memory>
24 
25 namespace llvm {
26 
27 class StringRef;
28 class MIRParserImpl;
29 class MachineModuleInfo;
30 class SMDiagnostic;
31 
32 /// This class initializes machine functions by applying the state loaded from
33 /// a MIR file.
34 class MIRParser {
35  std::unique_ptr<MIRParserImpl> Impl;
36 
37 public:
38  MIRParser(std::unique_ptr<MIRParserImpl> Impl);
39  MIRParser(const MIRParser &) = delete;
40  ~MIRParser();
41 
42  /// Parses the optional LLVM IR module in the MIR file.
43  ///
44  /// A new, empty module is created if the LLVM IR isn't present.
45  /// \returns nullptr if a parsing error occurred.
46  std::unique_ptr<Module> parseIRModule();
47 
48  /// Parses MachineFunctions in the MIR file and add them to the given
49  /// MachineModuleInfo \p MMI.
50  ///
51  /// \returns true if an error occurred.
53 };
54 
55 /// This function is the main interface to the MIR serialization format parser.
56 ///
57 /// It reads in a MIR file and returns a MIR parser that can parse the embedded
58 /// LLVM IR module and initialize the machine functions by parsing the machine
59 /// function's state.
60 ///
61 /// \param Filename - The name of the file to parse.
62 /// \param Error - Error result info.
63 /// \param Context - Context which will be used for the parsed LLVM IR module.
64 std::unique_ptr<MIRParser> createMIRParserFromFile(StringRef Filename,
67 
68 /// This function is another interface to the MIR serialization format parser.
69 ///
70 /// It returns a MIR parser that works with the given memory buffer and that can
71 /// parse the embedded LLVM IR module and initialize the machine functions by
72 /// parsing the machine function's state.
73 ///
74 /// \param Contents - The MemoryBuffer containing the machine level IR.
75 /// \param Context - Context which will be used for the parsed LLVM IR module.
76 std::unique_ptr<MIRParser>
77 createMIRParser(std::unique_ptr<MemoryBuffer> Contents, LLVMContext &Context);
78 
79 } // end namespace llvm
80 
81 #endif // LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This class initializes machine functions by applying the state loaded from a MIR file.
Definition: MIRParser.h:34
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:915
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Parses MachineFunctions in the MIR file and add them to the given MachineModuleInfo MMI...
Definition: MIRParser.cpp:898
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
Module.h This file contains the declarations for the Module class.
MIRParser(std::unique_ptr< MIRParserImpl > Impl)
Definition: MIRParser.cpp:889
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
std::unique_ptr< Module > parseIRModule()
Parses the optional LLVM IR module in the MIR file.
Definition: MIRParser.cpp:894
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
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:902
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:260