1//===- MCWinCOFFStreamer.h - COFF Object File Interface ---------*- C++ -*-===//
2//
3// 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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_MC_MCWINCOFFSTREAMER_H
10#define LLVM_MC_MCWINCOFFSTREAMER_H
11
12#include "llvm/MC/MCDirectives.h"
13#include "llvm/MC/MCObjectStreamer.h"
14
15namespace llvm {
16
17class MCAsmBackend;
18class MCContext;
19class MCCodeEmitter;
20class MCInst;
21class MCSection;
22class MCSubtargetInfo;
23class MCSymbol;
24class StringRef;
25class WinCOFFObjectWriter;
26class raw_pwrite_stream;
27
28class MCWinCOFFStreamer : public MCObjectStreamer {
29public:
30 MCWinCOFFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
31 std::unique_ptr<MCCodeEmitter> CE,
32 std::unique_ptr<MCObjectWriter> OW);
33
34 /// state management
35 void reset() override {
36 CurSymbol = nullptr;
37 MCObjectStreamer::reset();
38 }
39
40 WinCOFFObjectWriter &getWriter();
41
42 /// \name MCStreamer interface
43 /// \{
44
45 void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
46 void changeSection(MCSection *Section, uint32_t Subsection = 0) override;
47 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
48 void emitAssemblerFlag(MCAssemblerFlag Flag) override;
49 void emitThumbFunc(MCSymbol *Func) override;
50 bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
51 void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
52 void beginCOFFSymbolDef(MCSymbol const *Symbol) override;
53 void emitCOFFSymbolStorageClass(int StorageClass) override;
54 void emitCOFFSymbolType(int Type) override;
55 void endCOFFSymbolDef() override;
56 void emitCOFFSafeSEH(MCSymbol const *Symbol) override;
57 void emitCOFFSymbolIndex(MCSymbol const *Symbol) override;
58 void emitCOFFSectionIndex(MCSymbol const *Symbol) override;
59 void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
60 void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override;
61 void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
62 Align ByteAlignment) override;
63 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
64 Align ByteAlignment) override;
65 void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
66 void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
67 Align ByteAlignment, SMLoc Loc = SMLoc()) override;
68 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
69 Align ByteAlignment) override;
70 void emitIdent(StringRef IdentString) override;
71 void emitWinEHHandlerData(SMLoc Loc) override;
72 void emitCGProfileEntry(const MCSymbolRefExpr *From,
73 const MCSymbolRefExpr *To, uint64_t Count) override;
74 void finishImpl() override;
75
76 /// \}
77
78protected:
79 const MCSymbol *CurSymbol;
80
81 void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override;
82
83 void finalizeCGProfileEntry(const MCSymbolRefExpr *&S);
84
85private:
86 void Error(const Twine &Msg) const;
87};
88
89} // end namespace llvm
90
91#endif // LLVM_MC_MCWINCOFFSTREAMER_H
92