blob: 3015efe7389e44183d9ae3673d253e78e79deef6 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- llvm/MC/MCWinCOFFObjectWriter.h - Win COFF Object Writer -*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_MC_MCWINCOFFOBJECTWRITER_H
10#define LLVM_MC_MCWINCOFFOBJECTWRITER_H
11
Andrew Scullcdfcccc2018-10-05 20:58:37 +010012#include "llvm/MC/MCObjectWriter.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010013#include <memory>
14
15namespace llvm {
16
17class MCAsmBackend;
18class MCContext;
19class MCFixup;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010020class MCValue;
21class raw_pwrite_stream;
22
Andrew Scullcdfcccc2018-10-05 20:58:37 +010023 class MCWinCOFFObjectTargetWriter : public MCObjectTargetWriter {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010024 virtual void anchor();
25
26 const unsigned Machine;
27
28 protected:
29 MCWinCOFFObjectTargetWriter(unsigned Machine_);
30
31 public:
32 virtual ~MCWinCOFFObjectTargetWriter() = default;
33
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020034 Triple::ObjectFormatType getFormat() const override { return Triple::COFF; }
Andrew Scullcdfcccc2018-10-05 20:58:37 +010035 static bool classof(const MCObjectTargetWriter *W) {
36 return W->getFormat() == Triple::COFF;
37 }
38
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010039 unsigned getMachine() const { return Machine; }
40 virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
41 const MCFixup &Fixup, bool IsCrossSection,
42 const MCAsmBackend &MAB) const = 0;
43 virtual bool recordRelocation(const MCFixup &) const { return true; }
44 };
45
Andrew Scullcdfcccc2018-10-05 20:58:37 +010046 /// Construct a new Win COFF writer instance.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010047 ///
48 /// \param MOTW - The target specific WinCOFF writer subclass.
49 /// \param OS - The stream to write to.
50 /// \returns The constructed object writer.
51 std::unique_ptr<MCObjectWriter>
52 createWinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
53 raw_pwrite_stream &OS);
54} // end namespace llvm
55
56#endif // LLVM_MC_MCWINCOFFOBJECTWRITER_H