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