xref: /freebsd/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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"
13 #include "llvm/MC/MCELFStreamer.h"
14 
15 using namespace llvm;
16 
17 class RISCVELFStreamer : public MCELFStreamer {
18   void reset() override;
19 
20 public:
21   RISCVELFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> MAB,
22                    std::unique_ptr<MCObjectWriter> MOW,
23                    std::unique_ptr<MCCodeEmitter> MCE)
24       : MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}
25 };
26 
27 namespace llvm {
28 
29 class RISCVTargetELFStreamer : public RISCVTargetStreamer {
30 private:
31   StringRef CurrentVendor;
32 
33   MCSection *AttributeSection = nullptr;
34   const MCSubtargetInfo &STI;
35 
36   void emitAttribute(unsigned Attribute, unsigned Value) override;
37   void emitTextAttribute(unsigned Attribute, StringRef String) override;
38   void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
39                             StringRef StringValue) override;
40   void finishAttributeSection() override;
41 
42   void reset() override;
43 
44 public:
45   RISCVELFStreamer &getStreamer();
46   RISCVTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
47 
48   void emitDirectiveOptionPush() override;
49   void emitDirectiveOptionPop() override;
50   void emitDirectiveOptionPIC() override;
51   void emitDirectiveOptionNoPIC() override;
52   void emitDirectiveOptionRVC() override;
53   void emitDirectiveOptionNoRVC() override;
54   void emitDirectiveOptionRelax() override;
55   void emitDirectiveOptionNoRelax() override;
56   void emitDirectiveVariantCC(MCSymbol &Symbol) override;
57 
58   void finish() override;
59 };
60 
61 MCELFStreamer *createRISCVELFStreamer(MCContext &C,
62                                       std::unique_ptr<MCAsmBackend> MAB,
63                                       std::unique_ptr<MCObjectWriter> MOW,
64                                       std::unique_ptr<MCCodeEmitter> MCE,
65                                       bool RelaxAll);
66 }
67 #endif
68