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 15 namespace llvm { 16 17 class MCAsmBackend; 18 class MCContext; 19 class MCCodeEmitter; 20 class MCInst; 21 class MCSection; 22 class MCSubtargetInfo; 23 class MCSymbol; 24 class StringRef; 25 class raw_pwrite_stream; 26 27 class MCWinCOFFStreamer : public MCObjectStreamer { 28 public: 29 MCWinCOFFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB, 30 std::unique_ptr<MCCodeEmitter> CE, 31 std::unique_ptr<MCObjectWriter> OW); 32 33 /// state management reset()34 void reset() override { 35 CurSymbol = nullptr; 36 MCObjectStreamer::reset(); 37 } 38 39 /// \name MCStreamer interface 40 /// \{ 41 42 void InitSections(bool NoExecStack) override; 43 void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; 44 void EmitAssemblerFlag(MCAssemblerFlag Flag) override; 45 void EmitThumbFunc(MCSymbol *Func) override; 46 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; 47 void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; 48 void BeginCOFFSymbolDef(MCSymbol const *Symbol) override; 49 void EmitCOFFSymbolStorageClass(int StorageClass) override; 50 void EmitCOFFSymbolType(int Type) override; 51 void EndCOFFSymbolDef() override; 52 void EmitCOFFSafeSEH(MCSymbol const *Symbol) override; 53 void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override; 54 void EmitCOFFSectionIndex(MCSymbol const *Symbol) override; 55 void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override; 56 void EmitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override; 57 void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 58 unsigned ByteAlignment) override; 59 void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 60 unsigned ByteAlignment) override; 61 void EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, 62 unsigned ByteAlignment, SMLoc Loc = SMLoc()) override; 63 void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, 64 unsigned ByteAlignment) override; 65 void EmitIdent(StringRef IdentString) override; 66 void EmitWinEHHandlerData(SMLoc Loc) override; 67 void FinishImpl() override; 68 69 /// \} 70 71 protected: 72 const MCSymbol *CurSymbol; 73 74 void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override; 75 76 private: 77 void Error(const Twine &Msg) const; 78 }; 79 80 } // end namespace llvm 81 82 #endif // LLVM_MC_MCWINCOFFSTREAMER_H 83