1 //===-- RISCVTargetStreamer.h - RISCV 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_RISCVTARGETSTREAMER_H
10 #define LLVM_LIB_TARGET_RISCV_RISCVTARGETSTREAMER_H
11 
12 #include "llvm/MC/MCStreamer.h"
13 #include "llvm/MC/MCSubtargetInfo.h"
14 
15 namespace llvm {
16 
17 class RISCVTargetStreamer : public MCTargetStreamer {
18 public:
19   RISCVTargetStreamer(MCStreamer &S);
20   void finish() override;
21 
22   virtual void emitDirectiveOptionPush();
23   virtual void emitDirectiveOptionPop();
24   virtual void emitDirectiveOptionPIC();
25   virtual void emitDirectiveOptionNoPIC();
26   virtual void emitDirectiveOptionRVC();
27   virtual void emitDirectiveOptionNoRVC();
28   virtual void emitDirectiveOptionRelax();
29   virtual void emitDirectiveOptionNoRelax();
30   virtual void emitAttribute(unsigned Attribute, unsigned Value);
31   virtual void finishAttributeSection();
32   virtual void emitTextAttribute(unsigned Attribute, StringRef String);
33   virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
34                                     StringRef StringValue);
35 
36   void emitTargetAttributes(const MCSubtargetInfo &STI);
37 };
38 
39 // This part is for ascii assembly output
40 class RISCVTargetAsmStreamer : public RISCVTargetStreamer {
41   formatted_raw_ostream &OS;
42 
43   void finishAttributeSection() override;
44   void emitAttribute(unsigned Attribute, unsigned Value) override;
45   void emitTextAttribute(unsigned Attribute, StringRef String) override;
46   void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
47                             StringRef StringValue) override;
48 
49 public:
50   RISCVTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
51 
52   void emitDirectiveOptionPush() override;
53   void emitDirectiveOptionPop() override;
54   void emitDirectiveOptionPIC() override;
55   void emitDirectiveOptionNoPIC() override;
56   void emitDirectiveOptionRVC() override;
57   void emitDirectiveOptionNoRVC() override;
58   void emitDirectiveOptionRelax() override;
59   void emitDirectiveOptionNoRelax() override;
60 };
61 
62 }
63 #endif
64