LLVM 19.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
15using namespace 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
25 int64_t MappingSymbolCounter = 0;
27 ElfMappingSymbol LastEMS = EMS_None;
28
29public:
30 RISCVELFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> MAB,
31 std::unique_ptr<MCObjectWriter> MOW,
32 std::unique_ptr<MCCodeEmitter> MCE)
33 : MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}
34
35 void changeSection(MCSection *Section, const MCExpr *Subsection) override;
36 void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
37 void emitBytes(StringRef Data) override;
38 void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc) override;
39 void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;
40};
41
42namespace llvm {
43
45private:
46 StringRef CurrentVendor;
47
48 MCSection *AttributeSection = nullptr;
49
50 void emitAttribute(unsigned Attribute, unsigned Value) override;
51 void emitTextAttribute(unsigned Attribute, StringRef String) override;
52 void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
53 StringRef StringValue) override;
54 void finishAttributeSection() override;
55
56 void reset() override;
57
58public:
61
62 void emitDirectiveOptionPush() override;
63 void emitDirectiveOptionPop() override;
64 void emitDirectiveOptionPIC() override;
65 void emitDirectiveOptionNoPIC() override;
66 void emitDirectiveOptionRVC() override;
67 void emitDirectiveOptionNoRVC() override;
68 void emitDirectiveOptionRelax() override;
69 void emitDirectiveOptionNoRelax() override;
70 void emitDirectiveVariantCC(MCSymbol &Symbol) override;
71
72 void finish() override;
73};
74
76 std::unique_ptr<MCAsmBackend> MAB,
77 std::unique_ptr<MCObjectWriter> MOW,
78 std::unique_ptr<MCCodeEmitter> MCE,
79 bool RelaxAll);
80}
81#endif
std::string Name
uint64_t Size
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void changeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
RISCVELFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > MOW, std::unique_ptr< MCCodeEmitter > MCE)
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
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.
Context object for machine code objects.
Definition: MCContext.h:81
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
Streaming machine code generation interface.
Definition: MCStreamer.h:212
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:40
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:50
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:1849
MCELFStreamer * createRISCVELFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > MOW, std::unique_ptr< MCCodeEmitter > MCE, bool RelaxAll)
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858