c362a1774399f98d2a7f84b1dfd5f82f33701b5e
[oota-llvm.git] / include / llvm / AsmParser / Parser.h
1 //===-- Parser.h - Parser for LLVM IR text assembly files -------*- 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 //  These classes are implemented by the lib/AsmParser library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ASMPARSER_PARSER_H
15 #define LLVM_ASMPARSER_PARSER_H
16
17 #include "llvm/ADT/StringRef.h"
18 #include <memory>
19
20 namespace llvm {
21
22 class Module;
23 class MemoryBuffer;
24 class SMDiagnostic;
25 class LLVMContext;
26
27 /// This function is the main interface to the LLVM Assembly Parser. It parses
28 /// an ASCII file that (presumably) contains LLVM Assembly code. It returns a
29 /// Module (intermediate representation) with the corresponding features. Note
30 /// that this does not verify that the generated Module is valid, so you should
31 /// run the verifier after parsing the file to check that it is okay.
32 /// @brief Parse LLVM Assembly from a file
33 /// @param Filename The name of the file to parse
34 /// @param Error Error result info.
35 /// @param Context Context in which to allocate globals info.
36 std::unique_ptr<Module> parseAssemblyFile(StringRef Filename,
37                                           SMDiagnostic &Error,
38                                           LLVMContext &Context);
39
40 /// The function is a secondary interface to the LLVM Assembly Parser. It parses
41 /// an ASCII string that (presumably) contains LLVM Assembly code. It returns a
42 /// Module (intermediate representation) with the corresponding features. Note
43 /// that this does not verify that the generated Module is valid, so you should
44 /// run the verifier after parsing the file to check that it is okay.
45 /// @brief Parse LLVM Assembly from a string
46 /// @param AsmString The string containing assembly
47 /// @param Error Error result info.
48 /// @param Context Context in which to allocate globals info.
49 std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
50                                             SMDiagnostic &Error,
51                                             LLVMContext &Context);
52
53 /// parseAssemblyFile and parseAssemblyString are wrappers around this function.
54 /// @brief Parse LLVM Assembly from a MemoryBuffer.
55 /// @param F The MemoryBuffer containing assembly
56 /// @param Err Error result info.
57 /// @param Context Context in which to allocate globals info.
58 std::unique_ptr<Module> parseAssembly(std::unique_ptr<MemoryBuffer> F,
59                                       SMDiagnostic &Err, LLVMContext &Context);
60
61 /// This function is the low-level interface to the LLVM Assembly Parser.
62 /// This is kept as an independent function instead of being inlined into
63 /// parseAssembly for the convenience of interactive users that want to add
64 /// recently parsed bits to an existing module.
65 ///
66 /// @param F The MemoryBuffer containing assembly
67 /// @param M The module to add data to.
68 /// @param Err Error result info.
69 /// @return true on error.
70 bool parseAssemblyInto(std::unique_ptr<MemoryBuffer> F, Module &M,
71                        SMDiagnostic &Err);
72
73 } // End llvm namespace
74
75 #endif