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