1
//===-- Parser.h - Parser for LLVM IR text assembly files -------*- C++ -*-===//
3
// The LLVM Compiler Infrastructure
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
10
// These classes are implemented by the lib/AsmParser library.
12
//===----------------------------------------------------------------------===//
14
#ifndef LLVM_ASMPARSER_PARSER_H
15
#define LLVM_ASMPARSER_PARSER_H
17
#include "llvm/Support/MemoryBuffer.h"
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
37
std::unique_ptr<Module> parseAssemblyFile(StringRef Filename,
40
SlotMapping *Slots = nullptr);
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
53
std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
56
SlotMapping *Slots = nullptr);
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
64
std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err,
66
SlotMapping *Slots = nullptr);
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.
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
78
/// \return true on error.
79
bool parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err,
80
SlotMapping *Slots = nullptr);
82
} // End llvm namespace