LLVM  14.0.0git
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 Function;
27 class MIRParserImpl;
28 class MachineModuleInfo;
29 class SMDiagnostic;
30 class StringRef;
31 
34 
35 /// This class initializes machine functions by applying the state loaded from
36 /// a MIR file.
37 class MIRParser {
38  std::unique_ptr<MIRParserImpl> Impl;
39 
40 public:
41  MIRParser(std::unique_ptr<MIRParserImpl> Impl);
42  MIRParser(const MIRParser &) = delete;
43  ~MIRParser();
44 
45  /// Parses the optional LLVM IR module in the MIR file.
46  ///
47  /// A new, empty module is created if the LLVM IR isn't present.
48  /// \returns nullptr if a parsing error occurred.
49  std::unique_ptr<Module> parseIRModule(
50  DataLayoutCallbackTy DataLayoutCallback = [](StringRef) { return None; });
51 
52  /// Parses MachineFunctions in the MIR file and add them to the given
53  /// MachineModuleInfo \p MMI.
54  ///
55  /// \returns true if an error occurred.
57 };
58 
59 /// This function is the main interface to the MIR serialization format parser.
60 ///
61 /// It reads in a MIR file and returns a MIR parser that can parse the embedded
62 /// LLVM IR module and initialize the machine functions by parsing the machine
63 /// function's state.
64 ///
65 /// \param Filename - The name of the file to parse.
66 /// \param Error - Error result info.
67 /// \param Context - Context which will be used for the parsed LLVM IR module.
68 /// \param ProcessIRFunction - function to run on every IR function or stub
69 /// loaded from the MIR file.
70 std::unique_ptr<MIRParser> createMIRParserFromFile(
72  std::function<void(Function &)> ProcessIRFunction = nullptr);
73 
74 /// This function is another interface to the MIR serialization format parser.
75 ///
76 /// It returns a MIR parser that works with the given memory buffer and that can
77 /// parse the embedded LLVM IR module and initialize the machine functions by
78 /// parsing the machine function's state.
79 ///
80 /// \param Contents - The MemoryBuffer containing the machine level IR.
81 /// \param Context - Context which will be used for the parsed LLVM IR module.
82 std::unique_ptr<MIRParser>
83 createMIRParser(std::unique_ptr<MemoryBuffer> Contents, LLVMContext &Context,
84  std::function<void(Function &)> ProcessIRFunction = nullptr);
85 
86 } // end namespace llvm
87 
88 #endif // LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
MemoryBuffer.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::MIRParser::parseIRModule
std::unique_ptr< Module > parseIRModule(DataLayoutCallbackTy DataLayoutCallback=[](StringRef) { return None;})
Parses the optional LLVM IR module in the MIR file.
Definition: MIRParser.cpp:1009
llvm::Function
Definition: Function.h:61
Module.h
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::SMDiagnostic
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:251
llvm::MachineModuleInfo
This class contains meta information specific to a module.
Definition: MachineModuleInfo.h:78
llvm::None
const NoneType None
Definition: None.h:23
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::createMIRParser
std::unique_ptr< MIRParser > createMIRParser(std::unique_ptr< MemoryBuffer > Contents, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction=nullptr)
This function is another interface to the MIR serialization format parser.
Definition: MIRParser.cpp:1031
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::MIRParser::~MIRParser
~MIRParser()
Definition: MIRParser.cpp:1006
llvm::createMIRParserFromFile
std::unique_ptr< MIRParser > createMIRParserFromFile(StringRef Filename, SMDiagnostic &Error, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction=nullptr)
This function is the main interface to the MIR serialization format parser.
Definition: MIRParser.cpp:1017
llvm::MIRParser
This class initializes machine functions by applying the state loaded from a MIR file.
Definition: MIRParser.h:37
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MIRParser::MIRParser
MIRParser(std::unique_ptr< MIRParserImpl > Impl)
Definition: MIRParser.cpp:1003
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::MIRParser::parseMachineFunctions
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Parses MachineFunctions in the MIR file and add them to the given MachineModuleInfo MMI.
Definition: MIRParser.cpp:1013
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::DataLayoutCallbackTy
llvm::function_ref< Optional< std::string >StringRef)> DataLayoutCallbackTy
Definition: Parser.h:29