1 //===-- RISCVELFStreamer.h - RISC-V ELF Target Streamer ---------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H
10 #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H
12 #include "RISCVTargetStreamer.h"
13 #include "llvm/MC/MCELFStreamer.h"
17 class RISCVELFStreamer
: public MCELFStreamer
{
18 void reset() override
;
19 void emitDataMappingSymbol();
20 void emitInstructionsMappingSymbol();
21 void emitMappingSymbol(StringRef Name
);
23 enum ElfMappingSymbol
{ EMS_None
, EMS_Instructions
, EMS_Data
};
25 DenseMap
<const MCSection
*, ElfMappingSymbol
> LastMappingSymbols
;
26 ElfMappingSymbol LastEMS
= EMS_None
;
29 RISCVELFStreamer(MCContext
&C
, std::unique_ptr
<MCAsmBackend
> MAB
,
30 std::unique_ptr
<MCObjectWriter
> MOW
,
31 std::unique_ptr
<MCCodeEmitter
> MCE
)
32 : MCELFStreamer(C
, std::move(MAB
), std::move(MOW
), std::move(MCE
)) {}
34 void changeSection(MCSection
*Section
, uint32_t Subsection
) override
;
35 void emitInstruction(const MCInst
&Inst
, const MCSubtargetInfo
&STI
) override
;
36 void emitBytes(StringRef Data
) override
;
37 void emitFill(const MCExpr
&NumBytes
, uint64_t FillValue
, SMLoc Loc
) override
;
38 void emitValueImpl(const MCExpr
*Value
, unsigned Size
, SMLoc Loc
) override
;
41 class RISCVTargetELFStreamer
: public RISCVTargetStreamer
{
43 StringRef CurrentVendor
;
45 MCSection
*AttributeSection
= nullptr;
47 void emitAttribute(unsigned Attribute
, unsigned Value
) override
;
48 void emitTextAttribute(unsigned Attribute
, StringRef String
) override
;
49 void emitIntTextAttribute(unsigned Attribute
, unsigned IntValue
,
50 StringRef StringValue
) override
;
51 void finishAttributeSection() override
;
53 void reset() override
;
56 RISCVELFStreamer
&getStreamer();
57 RISCVTargetELFStreamer(MCStreamer
&S
, const MCSubtargetInfo
&STI
);
59 void emitDirectiveOptionPush() override
;
60 void emitDirectiveOptionPop() override
;
61 void emitDirectiveOptionPIC() override
;
62 void emitDirectiveOptionNoPIC() override
;
63 void emitDirectiveOptionRVC() override
;
64 void emitDirectiveOptionNoRVC() override
;
65 void emitDirectiveOptionRelax() override
;
66 void emitDirectiveOptionNoRelax() override
;
67 void emitDirectiveVariantCC(MCSymbol
&Symbol
) override
;
69 void finish() override
;
72 MCELFStreamer
*createRISCVELFStreamer(MCContext
&C
,
73 std::unique_ptr
<MCAsmBackend
> MAB
,
74 std::unique_ptr
<MCObjectWriter
> MOW
,
75 std::unique_ptr
<MCCodeEmitter
> MCE
);
78 #endif // LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H