AsmParser: Extend the API to make the global value and metadata node slot mappings...
[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 LLVMContext;
22 class Module;
23 struct SlotMapping;
24 class SMDiagnostic;
25
26 /// This function is the main interface to the LLVM Assembly Parser. It parses
27 /// an ASCII file that (presumably) contains LLVM Assembly code. It returns a
28 /// Module (intermediate representation) with the corresponding features. Note
29 /// that this does not verify that the generated Module is valid, so you should
30 /// run the verifier after parsing the file to check that it is okay.
31 /// \brief Parse LLVM Assembly from a file
32 /// \param Filename The name of the file to parse
33 /// \param Error Error result info.
34 /// \param Context Context in which to allocate globals info.
35 /// \param Slots The optional slot mapping that will be initialized during
36 ///              parsing.
37 std::unique_ptr<Module> parseAssemblyFile(StringRef Filename,
38                                           SMDiagnostic &Error,
39                                           LLVMContext &Context,
40                                           SlotMapping *Slots = nullptr);
41
42 /// The function is a secondary interface to the LLVM Assembly Parser. It parses
43 /// an ASCII string that (presumably) contains LLVM Assembly code. It returns a
44 /// Module (intermediate representation) with the corresponding features. Note
45 /// that this does not verify that the generated Module is valid, so you should
46 /// run the verifier after parsing the file to check that it is okay.
47 /// \brief Parse LLVM Assembly from a string
48 /// \param AsmString The string containing assembly
49 /// \param Error Error result info.
50 /// \param Context Context in which to allocate globals info.
51 /// \param Slots The optional slot mapping that will be initialized during
52 ///              parsing.
53 std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
54                                             SMDiagnostic &Error,
55                                             LLVMContext &Context,
56                                             SlotMapping *Slots = nullptr);
57
58 /// parseAssemblyFile and parseAssemblyString are wrappers around this function.
59 /// \brief Parse LLVM Assembly from a MemoryBuffer.
60 /// \param F The MemoryBuffer containing assembly
61 /// \param Err Error result info.
62 /// \param Slots The optional slot mapping that will be initialized during
63 ///              parsing.
64 std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err,
65                                       LLVMContext &Context,
66                                       SlotMapping *Slots = nullptr);
67
68 /// This function is the low-level interface to the LLVM Assembly Parser.
69 /// This is kept as an independent function instead of being inlined into
70 /// parseAssembly for the convenience of interactive users that want to add
71 /// recently parsed bits to an existing module.
72 ///
73 /// \param F The MemoryBuffer containing assembly
74 /// \param M The module to add data to.
75 /// \param Err Error result info.
76 /// \param Slots The optional slot mapping that will be initialized during
77 ///              parsing.
78 /// \return true on error.
79 bool parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err,
80                        SlotMapping *Slots = nullptr);
81
82 } // End llvm namespace
83
84 #endif