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