Resubmit r237708 (MIR Serialization: print and parse LLVM IR using MIR format).
[oota-llvm.git] / include / llvm / CodeGen / MIR / MIRParser.h
1 //===- MIRParser.h - MIR serialization format parser ----------------------===//
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_MIR_MIRPARSER_H
19 #define LLVM_CODEGEN_MIR_MIRPARSER_H
20
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/IR/Module.h"
23 #include "llvm/Support/MemoryBuffer.h"
24 #include <memory>
25
26 namespace llvm {
27
28 class SMDiagnostic;
29
30 /// This function is the main interface to the MIR serialization format parser.
31 ///
32 /// It reads a YAML file that has an optional LLVM IR and returns an LLVM
33 /// module.
34 /// \param Filename - The name of the file to parse.
35 /// \param Error - Error result info.
36 /// \param Context - Context in which to allocate globals info.
37 std::unique_ptr<Module> parseMIRFile(StringRef Filename, SMDiagnostic &Error,
38                                      LLVMContext &Context);
39
40 /// This function is another interface to the MIR serialization format parser.
41 ///
42 /// It parses the optional LLVM IR in the given buffer, and returns an LLVM
43 /// module.
44 /// \param Contents - The MemoryBuffer containing the machine level IR.
45 /// \param Error - Error result info.
46 /// \param Context - Context in which to allocate globals info.
47 std::unique_ptr<Module> parseMIR(std::unique_ptr<MemoryBuffer> Contents,
48                                  SMDiagnostic &Error, LLVMContext &Context);
49
50 } // end namespace llvm
51
52 #endif