Parser.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //===-- Parser.h - Parser for LLVM IR text assembly files -------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // These classes are implemented by the lib/AsmParser library.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_ASMPARSER_PARSER_H
  14. #define LLVM_ASMPARSER_PARSER_H
  15. #include "llvm/Support/MemoryBuffer.h"
  16. namespace llvm {
  17. class LLVMContext;
  18. class Module;
  19. struct SlotMapping;
  20. class SMDiagnostic;
  21. /// This function is the main interface to the LLVM Assembly Parser. It parses
  22. /// an ASCII file that (presumably) contains LLVM Assembly code. It returns a
  23. /// Module (intermediate representation) with the corresponding features. Note
  24. /// that this does not verify that the generated Module is valid, so you should
  25. /// run the verifier after parsing the file to check that it is okay.
  26. /// \brief Parse LLVM Assembly from a file
  27. /// \param Filename The name of the file to parse
  28. /// \param Error Error result info.
  29. /// \param Context Context in which to allocate globals info.
  30. /// \param Slots The optional slot mapping that will be initialized during
  31. /// parsing.
  32. std::unique_ptr<Module> parseAssemblyFile(StringRef Filename,
  33. SMDiagnostic &Error,
  34. LLVMContext &Context,
  35. SlotMapping *Slots = nullptr);
  36. /// The function is a secondary interface to the LLVM Assembly Parser. It parses
  37. /// an ASCII string that (presumably) contains LLVM Assembly code. It returns a
  38. /// Module (intermediate representation) with the corresponding features. Note
  39. /// that this does not verify that the generated Module is valid, so you should
  40. /// run the verifier after parsing the file to check that it is okay.
  41. /// \brief Parse LLVM Assembly from a string
  42. /// \param AsmString The string containing assembly
  43. /// \param Error Error result info.
  44. /// \param Context Context in which to allocate globals info.
  45. /// \param Slots The optional slot mapping that will be initialized during
  46. /// parsing.
  47. std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
  48. SMDiagnostic &Error,
  49. LLVMContext &Context,
  50. SlotMapping *Slots = nullptr);
  51. /// parseAssemblyFile and parseAssemblyString are wrappers around this function.
  52. /// \brief Parse LLVM Assembly from a MemoryBuffer.
  53. /// \param F The MemoryBuffer containing assembly
  54. /// \param Err Error result info.
  55. /// \param Slots The optional slot mapping that will be initialized during
  56. /// parsing.
  57. std::unique_ptr<Module> parseAssembly(MemoryBufferRef F, SMDiagnostic &Err,
  58. LLVMContext &Context,
  59. SlotMapping *Slots = nullptr);
  60. /// This function is the low-level interface to the LLVM Assembly Parser.
  61. /// This is kept as an independent function instead of being inlined into
  62. /// parseAssembly for the convenience of interactive users that want to add
  63. /// recently parsed bits to an existing module.
  64. ///
  65. /// \param F The MemoryBuffer containing assembly
  66. /// \param M The module to add data to.
  67. /// \param Err Error result info.
  68. /// \param Slots The optional slot mapping that will be initialized during
  69. /// parsing.
  70. /// \return true on error.
  71. bool parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err,
  72. SlotMapping *Slots = nullptr);
  73. } // End llvm namespace
  74. #endif