Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- llvm/MC/MCWinCOFFObjectWriter.h - Win COFF Object Writer -*- 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 | #ifndef LLVM_MC_MCWINCOFFOBJECTWRITER_H |
| 11 | #define LLVM_MC_MCWINCOFFOBJECTWRITER_H |
| 12 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 13 | #include "llvm/MC/MCObjectWriter.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
| 16 | namespace llvm { |
| 17 | |
| 18 | class MCAsmBackend; |
| 19 | class MCContext; |
| 20 | class MCFixup; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 21 | class MCValue; |
| 22 | class raw_pwrite_stream; |
| 23 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 24 | class MCWinCOFFObjectTargetWriter : public MCObjectTargetWriter { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 25 | virtual void anchor(); |
| 26 | |
| 27 | const unsigned Machine; |
| 28 | |
| 29 | protected: |
| 30 | MCWinCOFFObjectTargetWriter(unsigned Machine_); |
| 31 | |
| 32 | public: |
| 33 | virtual ~MCWinCOFFObjectTargetWriter() = default; |
| 34 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 35 | virtual Triple::ObjectFormatType getFormat() const { return Triple::COFF; } |
| 36 | static bool classof(const MCObjectTargetWriter *W) { |
| 37 | return W->getFormat() == Triple::COFF; |
| 38 | } |
| 39 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 40 | unsigned getMachine() const { return Machine; } |
| 41 | virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target, |
| 42 | const MCFixup &Fixup, bool IsCrossSection, |
| 43 | const MCAsmBackend &MAB) const = 0; |
| 44 | virtual bool recordRelocation(const MCFixup &) const { return true; } |
| 45 | }; |
| 46 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 47 | /// Construct a new Win COFF writer instance. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 48 | /// |
| 49 | /// \param MOTW - The target specific WinCOFF writer subclass. |
| 50 | /// \param OS - The stream to write to. |
| 51 | /// \returns The constructed object writer. |
| 52 | std::unique_ptr<MCObjectWriter> |
| 53 | createWinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW, |
| 54 | raw_pwrite_stream &OS); |
| 55 | } // end namespace llvm |
| 56 | |
| 57 | #endif // LLVM_MC_MCWINCOFFOBJECTWRITER_H |