MCWinCOFFObjectWriter.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/MC/MCWinCOFFObjectWriter.h - Win COFF Object Writer -*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCWINCOFFOBJECTWRITER_H
  14. #define LLVM_MC_MCWINCOFFOBJECTWRITER_H
  15. #include "llvm/MC/MCObjectWriter.h"
  16. #include <memory>
  17. namespace llvm {
  18. class MCAsmBackend;
  19. class MCContext;
  20. class MCFixup;
  21. class MCValue;
  22. class raw_pwrite_stream;
  23. class MCWinCOFFObjectTargetWriter : public MCObjectTargetWriter {
  24. virtual void anchor();
  25. const unsigned Machine;
  26. protected:
  27. MCWinCOFFObjectTargetWriter(unsigned Machine_);
  28. public:
  29. virtual ~MCWinCOFFObjectTargetWriter() = default;
  30. Triple::ObjectFormatType getFormat() const override { return Triple::COFF; }
  31. static bool classof(const MCObjectTargetWriter *W) {
  32. return W->getFormat() == Triple::COFF;
  33. }
  34. unsigned getMachine() const { return Machine; }
  35. virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
  36. const MCFixup &Fixup, bool IsCrossSection,
  37. const MCAsmBackend &MAB) const = 0;
  38. virtual bool recordRelocation(const MCFixup &) const { return true; }
  39. };
  40. /// Construct a new Win COFF writer instance.
  41. ///
  42. /// \param MOTW - The target specific WinCOFF writer subclass.
  43. /// \param OS - The stream to write to.
  44. /// \returns The constructed object writer.
  45. std::unique_ptr<MCObjectWriter>
  46. createWinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
  47. raw_pwrite_stream &OS);
  48. } // end namespace llvm
  49. #endif // LLVM_MC_MCWINCOFFOBJECTWRITER_H
  50. #ifdef __GNUC__
  51. #pragma GCC diagnostic pop
  52. #endif