LLVM  10.0.0svn
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/ADT/SmallPtrSet.h"
15 #include "llvm/MC/MCDirectives.h"
17 #include "llvm/MC/MCObjectWriter.h"
18 #include "llvm/MC/SectionKind.h"
19 #include "llvm/Support/DataTypes.h"
20 
21 namespace llvm {
22 class MCAssembler;
23 class MCExpr;
24 class MCInst;
25 class raw_ostream;
26 
28 public:
29  MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
30  std::unique_ptr<MCObjectWriter> OW,
31  std::unique_ptr<MCCodeEmitter> Emitter)
32  : MCObjectStreamer(Context, std::move(TAB), std::move(OW),
33  std::move(Emitter)),
34  SeenIdent(false) {}
35 
36  ~MCWasmStreamer() override;
37 
38  /// state management
39  void reset() override {
40  SeenIdent = false;
42  }
43 
44  /// \name MCStreamer Interface
45  /// @{
46 
47  void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
48  void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
49  void EmitThumbFunc(MCSymbol *Func) override;
50  void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
51  bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
52  void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
53  void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
54  unsigned ByteAlignment) override;
55 
56  void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
57 
58  void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
59  unsigned ByteAlignment) override;
60 
61  void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
62  uint64_t Size = 0, unsigned ByteAlignment = 0,
63  SMLoc Loc = SMLoc()) override;
64  void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
65  unsigned ByteAlignment = 0) override;
66  void EmitValueImpl(const MCExpr *Value, unsigned Size,
67  SMLoc Loc = SMLoc()) override;
68 
69  void EmitIdent(StringRef IdentString) override;
70 
71  void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
72 
73  void FinishImpl() override;
74 
75 private:
76  void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
77  void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
78 
79  /// Merge the content of the fragment \p EF into the fragment \p DF.
80  void mergeFragment(MCDataFragment *, MCDataFragment *);
81 
82  bool SeenIdent;
83 };
84 
85 } // end namespace llvm
86 
87 #endif
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
This class represents lattice values for constants.
Definition: AllocatorList.h:23
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Definition: BitVector.h:937
void EmitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
~MCWasmStreamer() override
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
Context object for machine code objects.
Definition: MCContext.h:65
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
Streaming object file generation interface.
void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0) override
Emit a thread local bss (.tbss) symbol.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:131
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
void EmitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
void reset() override
state management
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a local common (.lcomm) symbol.
void EmitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
void FinishImpl() override
Streamer specific finalization.
MCSymbolAttr
Definition: MCDirectives.h:18
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.
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
MCAssemblerFlag
Definition: MCDirectives.h:49
void reset() override
state management
Generic base class for all target subtargets.
MCWasmStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc()) override
Emit the expression Value into the output as a native integer of the given Size bytes.
uint32_t Size
Definition: Profile.cpp:46
void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
Fragment for data and encoded instructions.
Definition: MCFragment.h:243
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override
Emit an ELF .size directive.
LLVM Value Representation.
Definition: Value.h:74
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Represents a location in source code.
Definition: SMLoc.h:23