LLVM 20.0.0git
RISCVELFStreamer.h
Go to the documentation of this file.
1//===-- RISCVELFStreamer.h - RISC-V ELF Target Streamer ---------*- 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_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H
10#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H
11
12#include "RISCVTargetStreamer.h"
14
15namespace llvm {
16
18 void reset() override;
19 void emitDataMappingSymbol();
20 void emitInstructionsMappingSymbol();
21 void emitMappingSymbol(StringRef Name);
22
23 enum ElfMappingSymbol { EMS_None, EMS_Instructions, EMS_Data };
24
26 ElfMappingSymbol LastEMS = EMS_None;
27
28public:
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)) {}
33
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;
39};
40
42private:
43 StringRef CurrentVendor;
44
45 MCSection *AttributeSection = nullptr;
46
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;
52
53 void reset() override;
54
55public:
58
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;
68
69 void finish() override;
70};
71
73 std::unique_ptr<MCAsmBackend> MAB,
74 std::unique_ptr<MCObjectWriter> MOW,
75 std::unique_ptr<MCCodeEmitter> MCE);
76} // namespace llvm
77
78#endif // LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H
std::string Name
uint64_t Size
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:185
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
Streaming machine code generation interface.
Definition: MCStreamer.h:213
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
void changeSection(MCSection *Section, uint32_t Subsection) override
This is called by popSection and switchSection, if the current section changes.
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
RISCVELFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > MOW, std::unique_ptr< MCCodeEmitter > MCE)
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc) override
Emit Size bytes worth of the value specified by FillValue.
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override
Emit the expression Value into the output as a native integer of the given Size bytes.
void emitDirectiveOptionPop() override
void emitDirectiveOptionPush() override
void emitDirectiveOptionNoPIC() override
void emitDirectiveOptionNoRVC() override
void emitDirectiveVariantCC(MCSymbol &Symbol) override
void emitDirectiveOptionRelax() override
RISCVELFStreamer & getStreamer()
void emitDirectiveOptionNoRelax() override
void emitDirectiveOptionPIC() override
void emitDirectiveOptionRVC() override
Represents a location in source code.
Definition: SMLoc.h:23
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
LLVM Value Representation.
Definition: Value.h:74
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:1873
MCELFStreamer * createRISCVELFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > MOW, std::unique_ptr< MCCodeEmitter > MCE)
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858