1f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===-- Parser.h - Parser for LLVM IR text assembly files -------*- C++ -*-===// 2f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 3f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// The LLVM Compiler Infrastructure 4f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 5f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// This file is distributed under the University of Illinois Open Source 6f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// License. See LICENSE.TXT for details. 7f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 8f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===----------------------------------------------------------------------===// 9f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 10f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// These classes are implemented by the lib/AsmParser library. 11f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 12f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===----------------------------------------------------------------------===// 13f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 14f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#ifndef LLVM_ASMPARSER_PARSER_H 15f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#define LLVM_ASMPARSER_PARSER_H 16f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 17f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#include "llvm/Support/MemoryBuffer.h" 18f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 19f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotnamespace llvm { 20f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 21f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Constant; 22f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass LLVMContext; 23f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Module; 24f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotstruct SlotMapping; 25f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass SMDiagnostic; 26f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Type; 27f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 28f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// This function is the main interface to the LLVM Assembly Parser. It parses 29f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// an ASCII file that (presumably) contains LLVM Assembly code. It returns a 30f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Module (intermediate representation) with the corresponding features. Note 31f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// that this does not verify that the generated Module is valid, so you should 32f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// run the verifier after parsing the file to check that it is okay. 33f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \brief Parse LLVM Assembly from a file 34f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Filename The name of the file to parse 35f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Error Error result info. 36f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Context Context in which to allocate globals info. 37f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Slots The optional slot mapping that will be initialized during 38f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// parsing. 39f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotstd::unique_ptr<Module> parseAssemblyFile(StringRef Filename, 40f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SMDiagnostic &Error, 41f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot LLVMContext &Context, 42f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SlotMapping *Slots = nullptr); 43f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 44f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// The function is a secondary interface to the LLVM Assembly Parser. It parses 45f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// an ASCII string that (presumably) contains LLVM Assembly code. It returns a 46f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Module (intermediate representation) with the corresponding features. Note 47f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// that this does not verify that the generated Module is valid, so you should 48f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// run the verifier after parsing the file to check that it is okay. 49f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \brief Parse LLVM Assembly from a string 50f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param AsmString The string containing assembly 51f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Error Error result info. 52f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Context Context in which to allocate globals info. 53f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Slots The optional slot mapping that will be initialized during 54f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// parsing. 55f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotstd::unique_ptr<Module> parseAssemblyString(StringRef AsmString, 56f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SMDiagnostic &Error, 57f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot LLVMContext &Context, 58f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SlotMapping *Slots = nullptr); 59f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 60f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// parseAssemblyFile and parseAssemblyString are wrappers around this function. 61f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \brief Parse LLVM Assembly from a MemoryBuffer. 62f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param F The MemoryBuffer containing assembly 63f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Err Error result info. 64f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Slots The optional slot mapping that will be initialized during 65f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// parsing. 66f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotstd::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, 67f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot LLVMContext &Context, 68f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SlotMapping *Slots = nullptr); 69f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 70f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// This function is the low-level interface to the LLVM Assembly Parser. 71f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// This is kept as an independent function instead of being inlined into 72f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// parseAssembly for the convenience of interactive users that want to add 73f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// recently parsed bits to an existing module. 74f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 75f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param F The MemoryBuffer containing assembly 76f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param M The module to add data to. 77f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Err Error result info. 78f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Slots The optional slot mapping that will be initialized during 79f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// parsing. 80f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \return true on error. 81f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotbool parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err, 82f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SlotMapping *Slots = nullptr); 83f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 84f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Parse a type and a constant value in the given string. 85f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 86f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// The constant value can be any LLVM constant, including a constant 87f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// expression. 88f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 89f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Slots The optional slot mapping that will restore the parsing state 90f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// of the module. 91f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \return null on error. 92f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotConstant *parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M, 93f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SlotMapping *Slots = nullptr); 94f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 95f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Parse a type in the given string. 96f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 97f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Slots The optional slot mapping that will restore the parsing state 98f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// of the module. 99f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \return null on error. 100f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotType *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M, 101f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SlotMapping *Slots = nullptr); 102f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 103f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Parse a string \p Asm that starts with a type. 104f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \p Read[out] gives the number of characters that have been read to parse 105f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// the type in \p Asm. 106f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 107f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \param Slots The optional slot mapping that will restore the parsing state 108f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// of the module. 109f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// \return null on error. 110f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotType *parseTypeAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err, 111f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const Module &M, const SlotMapping *Slots = nullptr); 112f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 113f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot} // End llvm namespace 114f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 115f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#endif 116