80 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H10#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H11 12#include "RISCVTargetStreamer.h"13#include "llvm/MC/MCELFStreamer.h"14 15namespace llvm {16 17class RISCVELFStreamer : public MCELFStreamer {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 DenseMap<const MCSection *, ElfMappingSymbol> LastMappingSymbols;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 33 void changeSection(MCSection *Section, uint32_t Subsection) override;34 void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;35 void emitBytes(StringRef Data) override;36 void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc) override;37 void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;38};39 40class RISCVTargetELFStreamer : public RISCVTargetStreamer {41private:42 StringRef CurrentVendor;43 44 MCSection *AttributeSection = nullptr;45 46 void emitAttribute(unsigned Attribute, unsigned Value) override;47 void emitTextAttribute(unsigned Attribute, StringRef String) override;48 void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,49 StringRef StringValue) override;50 void finishAttributeSection() override;51 52 void reset() override;53 54public:55 RISCVELFStreamer &getStreamer();56 RISCVTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);57 58 void emitDirectiveOptionExact() override;59 void emitDirectiveOptionNoExact() override;60 void emitDirectiveOptionPIC() override;61 void emitDirectiveOptionNoPIC() override;62 void emitDirectiveOptionPop() override;63 void emitDirectiveOptionPush() override;64 void emitDirectiveOptionRelax() override;65 void emitDirectiveOptionNoRelax() override;66 void emitDirectiveOptionRVC() override;67 void emitDirectiveOptionNoRVC() override;68 void emitDirectiveVariantCC(MCSymbol &Symbol) override;69 70 void finish() override;71};72 73MCStreamer *createRISCVELFStreamer(const Triple &, MCContext &C,74 std::unique_ptr<MCAsmBackend> &&MAB,75 std::unique_ptr<MCObjectWriter> &&MOW,76 std::unique_ptr<MCCodeEmitter> &&MCE);77} // namespace llvm78 79#endif // LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H80