diff options
Diffstat (limited to 'llvm/include/llvm/AsmParser/Parser.h')
-rw-r--r-- | llvm/include/llvm/AsmParser/Parser.h | 81 |
1 files changed, 32 insertions, 49 deletions
diff --git a/llvm/include/llvm/AsmParser/Parser.h b/llvm/include/llvm/AsmParser/Parser.h index b0c603497805..e1c7f746a335 100644 --- a/llvm/include/llvm/AsmParser/Parser.h +++ b/llvm/include/llvm/AsmParser/Parser.h @@ -13,18 +13,24 @@ #ifndef LLVM_ASMPARSER_PARSER_H #define LLVM_ASMPARSER_PARSER_H -#include "llvm/Support/MemoryBuffer.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringRef.h" +#include <memory> namespace llvm { class Constant; class LLVMContext; +class MemoryBufferRef; class Module; class ModuleSummaryIndex; struct SlotMapping; class SMDiagnostic; class Type; +typedef llvm::function_ref<Optional<std::string>(StringRef)> + DataLayoutCallbackTy; + /// This function is a main interface to the LLVM Assembly Parser. It parses /// an ASCII file that (presumably) contains LLVM Assembly code. It returns a /// Module (intermediate representation) with the corresponding features. Note @@ -36,14 +42,9 @@ class Type; /// \param Context Context in which to allocate globals info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. -/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. -/// This option should only be set to false by llvm-as -/// for use inside the LLVM testuite! -/// \param DataLayoutString Override datalayout in the llvm assembly. -std::unique_ptr<Module> -parseAssemblyFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, - SlotMapping *Slots = nullptr, bool UpgradeDebugInfo = true, - StringRef DataLayoutString = ""); +std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err, + LLVMContext &Context, + SlotMapping *Slots = nullptr); /// The function is a secondary interface to the LLVM Assembly Parser. It parses /// an ASCII string that (presumably) contains LLVM Assembly code. It returns a @@ -56,16 +57,10 @@ parseAssemblyFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, /// \param Context Context in which to allocate globals info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. -/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. -/// This option should only be set to false by llvm-as -/// for use inside the LLVM testuite! -/// \param DataLayoutString Override datalayout in the llvm assembly. std::unique_ptr<Module> parseAssemblyString(StringRef AsmString, SMDiagnostic &Err, LLVMContext &Context, - SlotMapping *Slots = nullptr, - bool UpgradeDebugInfo = true, - StringRef DataLayoutString = ""); + SlotMapping *Slots = nullptr); /// Holds the Module and ModuleSummaryIndex returned by the interfaces /// that parse both. @@ -86,15 +81,16 @@ struct ParsedModuleAndIndex { /// \param Context Context in which to allocate globals info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. -/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. -/// This option should only be set to false by llvm-as -/// for use inside the LLVM testuite! -/// \param DataLayoutString Override datalayout in the llvm assembly. -ParsedModuleAndIndex -parseAssemblyFileWithIndex(StringRef Filename, SMDiagnostic &Err, - LLVMContext &Context, SlotMapping *Slots = nullptr, - bool UpgradeDebugInfo = true, - StringRef DataLayoutString = ""); +/// \param DataLayoutCallback Override datalayout in the llvm assembly. +ParsedModuleAndIndex parseAssemblyFileWithIndex( + StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, + SlotMapping *Slots = nullptr, + DataLayoutCallbackTy DataLayoutCallback = [](StringRef) { return None; }); + +/// Only for use in llvm-as for testing; this does not produce a valid module. +ParsedModuleAndIndex parseAssemblyFileWithIndexNoUpgradeDebugInfo( + StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, + SlotMapping *Slots, DataLayoutCallbackTy DataLayoutCallback); /// This function is a main interface to the LLVM Assembly Parser. It parses /// an ASCII file that (presumably) contains LLVM Assembly code for a module @@ -113,15 +109,11 @@ parseSummaryIndexAssemblyFile(StringRef Filename, SMDiagnostic &Err); /// \param Err Error result info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. -/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. -/// This option should only be set to false by llvm-as -/// for use inside the LLVM testuite! -/// \param DataLayoutString Override datalayout in the llvm assembly. -std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, - LLVMContext &Context, - SlotMapping *Slots = nullptr, - bool UpgradeDebugInfo = true, - StringRef DataLayoutString = ""); +/// \param DataLayoutCallback Override datalayout in the llvm assembly. +std::unique_ptr<Module> parseAssembly( + MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, + SlotMapping *Slots = nullptr, + DataLayoutCallbackTy DataLayoutCallback = [](StringRef) { return None; }); /// Parse LLVM Assembly including the summary index from a MemoryBuffer. /// @@ -129,18 +121,12 @@ std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, /// \param Err Error result info. /// \param Slots The optional slot mapping that will be initialized during /// parsing. -/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. -/// This option should only be set to false by llvm-as -/// for use inside the LLVM testuite! -/// \param DataLayoutString Override datalayout in the llvm assembly. /// /// parseAssemblyFileWithIndex is a wrapper around this function. ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, - SlotMapping *Slots = nullptr, - bool UpgradeDebugInfo = true, - StringRef DataLayoutString = ""); + SlotMapping *Slots = nullptr); /// Parse LLVM Assembly for summary index from a MemoryBuffer. /// @@ -163,14 +149,11 @@ parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err); /// \param Slots The optional slot mapping that will be initialized during /// parsing. /// \return true on error. -/// \param UpgradeDebugInfo Run UpgradeDebugInfo, which runs the Verifier. -/// This option should only be set to false by llvm-as -/// for use inside the LLVM testuite! -/// \param DataLayoutString Override datalayout in the llvm assembly. -bool parseAssemblyInto(MemoryBufferRef F, Module *M, ModuleSummaryIndex *Index, - SMDiagnostic &Err, SlotMapping *Slots = nullptr, - bool UpgradeDebugInfo = true, - StringRef DataLayoutString = ""); +/// \param DataLayoutCallback Override datalayout in the llvm assembly. +bool parseAssemblyInto( + MemoryBufferRef F, Module *M, ModuleSummaryIndex *Index, SMDiagnostic &Err, + SlotMapping *Slots = nullptr, + DataLayoutCallbackTy DataLayoutCallback = [](StringRef) { return None; }); /// Parse a type and a constant value in the given string. /// |