LLVM  14.0.0git
MCWasmStreamer.h
Go to the documentation of this file.
1 //===- MCWasmStreamer.h - MCStreamer Wasm 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_MCWASMSTREAMER_H
10 #define LLVM_MC_MCWASMSTREAMER_H
11 
12 #include "MCAsmBackend.h"
13 #include "MCCodeEmitter.h"
14 #include "llvm/MC/MCDirectives.h"
16 #include "llvm/MC/MCObjectWriter.h"
17 #include "llvm/Support/DataTypes.h"
18 
19 namespace llvm {
20 class MCExpr;
21 class MCInst;
22 
24 public:
25  MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
26  std::unique_ptr<MCObjectWriter> OW,
27  std::unique_ptr<MCCodeEmitter> Emitter)
28  : MCObjectStreamer(Context, std::move(TAB), std::move(OW),
29  std::move(Emitter)),
30  SeenIdent(false) {}
31 
32  ~MCWasmStreamer() override;
33 
34  /// state management
35  void reset() override {
36  SeenIdent = false;
38  }
39 
40  /// \name MCStreamer Interface
41  /// @{
42 
43  void changeSection(MCSection *Section, const MCExpr *Subsection) override;
44  void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
46  uint64_t Offset) override;
47  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
48  void emitThumbFunc(MCSymbol *Func) override;
49  void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
51  void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
53  unsigned ByteAlignment) override;
54 
55  void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
56 
58  unsigned ByteAlignment) override;
59 
60  void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
61  uint64_t Size = 0, unsigned ByteAlignment = 0,
62  SMLoc Loc = SMLoc()) override;
64  unsigned ByteAlignment = 0) override;
65 
66  void emitIdent(StringRef IdentString) override;
67 
68  void finishImpl() override;
69 
70 private:
71  void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
72  void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
73 
74  void fixSymbolsInTLSFixups(const MCExpr *expr);
75 
76  /// Merge the content of the fragment \p EF into the fragment \p DF.
77  void mergeFragment(MCDataFragment *, MCDataFragment *);
78 
79  bool SeenIdent;
80 };
81 
82 } // end namespace llvm
83 
84 #endif
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::MCWasmStreamer::emitZerofill
void emitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, unsigned ByteAlignment=0, SMLoc Loc=SMLoc()) override
Emit the zerofill section and an optional symbol.
Definition: MCWasmStreamer.cpp:261
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::Attribute
Definition: Attributes.h:52
MCCodeEmitter.h
MCDirectives.h
llvm::MCWasmStreamer::emitAssemblerFlag
void emitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
Definition: MCWasmStreamer.cpp:73
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::MCAssemblerFlag
MCAssemblerFlag
Definition: MCDirectives.h:50
llvm::MCObjectStreamer::reset
void reset() override
state management
Definition: MCObjectStreamer.cpp:157
llvm::MCWasmStreamer::emitELFSize
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override
Emit an ELF .size directive.
Definition: MCWasmStreamer.cpp:167
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::MCSymbolAttr
MCSymbolAttr
Definition: MCDirectives.h:18
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
MCObjectStreamer.h
llvm::MCFragment
Definition: MCFragment.h:31
llvm::MCWasmStreamer::changeSection
void changeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
Definition: MCWasmStreamer.cpp:81
MCAsmBackend.h
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::MCWasmStreamer::reset
void reset() override
state management
Definition: MCWasmStreamer.h:35
false
Definition: StackSlotColoring.cpp:142
llvm::MCWasmStreamer::emitLabel
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
Definition: MCWasmStreamer.cpp:52
llvm::MCObjectStreamer
Streaming object file generation interface.
Definition: MCObjectStreamer.h:36
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:146
llvm::MCWasmStreamer::MCWasmStreamer
MCWasmStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Definition: MCWasmStreamer.h:25
llvm::MCWasmStreamer
Definition: MCWasmStreamer.h:23
llvm::MCWasmStreamer::emitCommonSymbol
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
Definition: MCWasmStreamer.cpp:162
uint64_t
llvm::MCWasmStreamer::~MCWasmStreamer
~MCWasmStreamer() override
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::MCWasmStreamer::emitWeakReference
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
Definition: MCWasmStreamer.cpp:93
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
llvm::MCWasmStreamer::emitIdent
void emitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
Definition: MCWasmStreamer.cpp:176
llvm::MCWasmStreamer::emitSymbolAttribute
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Definition: MCWasmStreamer.cpp:101
MCObjectWriter.h
std
Definition: BitVector.h:838
llvm::MCWasmStreamer::emitTBSSSymbol
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0) override
Emit a thread local bss (.tbss) symbol.
Definition: MCWasmStreamer.cpp:267
llvm::MCWasmStreamer::emitLabelAtPos
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F, uint64_t Offset) override
Definition: MCWasmStreamer.cpp:62
llvm::LCOMM::ByteAlignment
@ ByteAlignment
Definition: MCAsmInfo.h:50
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
llvm::MCWasmStreamer::finishImpl
void finishImpl() override
Streamer specific finalization.
Definition: MCWasmStreamer.cpp:214
llvm::MCWasmStreamer::emitSymbolDesc
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
Definition: MCWasmStreamer.cpp:257
llvm::MCWasmStreamer::emitLocalCommonSymbol
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a local common (.lcomm) symbol.
Definition: MCWasmStreamer.cpp:171
llvm::MCWasmStreamer::emitThumbFunc
void emitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
Definition: MCWasmStreamer.cpp:253
DataTypes.h
llvm::MCDataFragment
Fragment for data and encoded instructions.
Definition: MCFragment.h:242
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35