Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / lib / Target / RISCV / MCTargetDesc / RISCVELFStreamer.h
bloba6f54bf67b5d2bbfc612cc7427baa3fc31e2a17e
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 //===----------------------------------------------------------------------===//
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"
15 using namespace llvm;
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 int64_t MappingSymbolCounter = 0;
26 DenseMap<const MCSection *, ElfMappingSymbol> LastMappingSymbols;
27 ElfMappingSymbol LastEMS = EMS_None;
29 public:
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)) {}
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;
42 namespace llvm {
44 class RISCVTargetELFStreamer : public RISCVTargetStreamer {
45 private:
46 StringRef CurrentVendor;
48 MCSection *AttributeSection = nullptr;
49 const MCSubtargetInfo &STI;
51 void emitAttribute(unsigned Attribute, unsigned Value) override;
52 void emitTextAttribute(unsigned Attribute, StringRef String) override;
53 void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
54 StringRef StringValue) override;
55 void finishAttributeSection() override;
57 void reset() override;
59 public:
60 RISCVELFStreamer &getStreamer();
61 RISCVTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
63 void emitDirectiveOptionPush() override;
64 void emitDirectiveOptionPop() override;
65 void emitDirectiveOptionPIC() override;
66 void emitDirectiveOptionNoPIC() override;
67 void emitDirectiveOptionRVC() override;
68 void emitDirectiveOptionNoRVC() override;
69 void emitDirectiveOptionRelax() override;
70 void emitDirectiveOptionNoRelax() override;
71 void emitDirectiveVariantCC(MCSymbol &Symbol) override;
73 void finish() override;
76 MCELFStreamer *createRISCVELFStreamer(MCContext &C,
77 std::unique_ptr<MCAsmBackend> MAB,
78 std::unique_ptr<MCObjectWriter> MOW,
79 std::unique_ptr<MCCodeEmitter> MCE,
80 bool RelaxAll);
82 #endif