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 emitDirectiveVariantCC(MCSymbol &Symbol); 37 virtual void emitAttribute(unsigned Attribute, unsigned Value); 38 virtual void finishAttributeSection(); 39 virtual void emitTextAttribute(unsigned Attribute, StringRef String); 40 virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, 41 StringRef StringValue); 42 43 void emitTargetAttributes(const MCSubtargetInfo &STI); 44 void setTargetABI(RISCVABI::ABI ABI); 45 RISCVABI::ABI getTargetABI() const { return TargetABI; } 46 }; 47 48 // This part is for ascii assembly output 49 class RISCVTargetAsmStreamer : public RISCVTargetStreamer { 50 formatted_raw_ostream &OS; 51 52 void finishAttributeSection() override; 53 void emitAttribute(unsigned Attribute, unsigned Value) override; 54 void emitTextAttribute(unsigned Attribute, StringRef String) override; 55 void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, 56 StringRef StringValue) override; 57 58 public: 59 RISCVTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); 60 61 void emitDirectiveOptionPush() override; 62 void emitDirectiveOptionPop() override; 63 void emitDirectiveOptionPIC() override; 64 void emitDirectiveOptionNoPIC() override; 65 void emitDirectiveOptionRVC() override; 66 void emitDirectiveOptionNoRVC() override; 67 void emitDirectiveOptionRelax() override; 68 void emitDirectiveOptionNoRelax() override; 69 void emitDirectiveVariantCC(MCSymbol &Symbol) override; 70 }; 71 72 } 73 #endif 74