LLVM API Documentation
00001 //===-- Parser.h - Parser for LLVM IR text assembly files -------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // These classes are implemented by the lib/AsmParser library. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_ASMPARSER_PARSER_H 00015 #define LLVM_ASMPARSER_PARSER_H 00016 00017 #include "llvm/Support/MemoryBuffer.h" 00018 00019 namespace llvm { 00020 00021 class Module; 00022 class SMDiagnostic; 00023 class LLVMContext; 00024 00025 /// This function is the main interface to the LLVM Assembly Parser. It parses 00026 /// an ASCII file that (presumably) contains LLVM Assembly code. It returns a 00027 /// Module (intermediate representation) with the corresponding features. Note 00028 /// that this does not verify that the generated Module is valid, so you should 00029 /// run the verifier after parsing the file to check that it is okay. 00030 /// @brief Parse LLVM Assembly from a file 00031 /// @param Filename The name of the file to parse 00032 /// @param Error Error result info. 00033 /// @param Context Context in which to allocate globals info. 00034 std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, 00035 SMDiagnostic &Error, 00036 LLVMContext &Context); 00037 00038 /// The function is a secondary interface to the LLVM Assembly Parser. It parses 00039 /// an ASCII string that (presumably) contains LLVM Assembly code. It returns a 00040 /// Module (intermediate representation) with the corresponding features. Note 00041 /// that this does not verify that the generated Module is valid, so you should 00042 /// run the verifier after parsing the file to check that it is okay. 00043 /// @brief Parse LLVM Assembly from a string 00044 /// @param AsmString The string containing assembly 00045 /// @param Error Error result info. 00046 /// @param Context Context in which to allocate globals info. 00047 std::unique_ptr<Module> parseAssemblyString(StringRef AsmString, 00048 SMDiagnostic &Error, 00049 LLVMContext &Context); 00050 00051 /// parseAssemblyFile and parseAssemblyString are wrappers around this function. 00052 /// @brief Parse LLVM Assembly from a MemoryBuffer. 00053 /// @param F The MemoryBuffer containing assembly 00054 /// @param Err Error result info. 00055 /// @param Context Context in which to allocate globals info. 00056 std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, 00057 LLVMContext &Context); 00058 00059 /// This function is the low-level interface to the LLVM Assembly Parser. 00060 /// This is kept as an independent function instead of being inlined into 00061 /// parseAssembly for the convenience of interactive users that want to add 00062 /// recently parsed bits to an existing module. 00063 /// 00064 /// @param F The MemoryBuffer containing assembly 00065 /// @param M The module to add data to. 00066 /// @param Err Error result info. 00067 /// @return true on error. 00068 bool parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err); 00069 00070 } // End llvm namespace 00071 00072 #endif