| Rafael Espindola | 320296a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 1 | //===-- MipsTargetStreamer.h - Mips Target Streamer ------------*- C++ -*--===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef MIPSTARGETSTREAMER_H |
| 11 | #define MIPSTARGETSTREAMER_H |
| 12 | |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCELFStreamer.h" |
| Rafael Espindola | 320296a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCStreamer.h" |
| 15 | |
| 16 | namespace llvm { |
| 17 | class MipsTargetStreamer : public MCTargetStreamer { |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 18 | virtual void anchor(); |
| Eric Christopher | e40e68a | 2013-11-19 02:01:07 +0000 | [diff] [blame] | 19 | |
| Rafael Espindola | 320296a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 20 | public: |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 21 | MipsTargetStreamer(MCStreamer &S); |
| 22 | virtual void emitDirectiveSetMicroMips() = 0; |
| 23 | virtual void emitDirectiveSetNoMicroMips() = 0; |
| 24 | virtual void emitDirectiveSetMips16() = 0; |
| 25 | virtual void emitDirectiveSetNoMips16() = 0; |
| 26 | |
| 27 | virtual void emitDirectiveSetReorder() = 0; |
| 28 | virtual void emitDirectiveSetNoReorder() = 0; |
| 29 | virtual void emitDirectiveSetMacro() = 0; |
| 30 | virtual void emitDirectiveSetNoMacro() = 0; |
| 31 | virtual void emitDirectiveSetAt() = 0; |
| 32 | virtual void emitDirectiveSetNoAt() = 0; |
| 33 | virtual void emitDirectiveEnd(StringRef Name) = 0; |
| 34 | |
| 35 | virtual void emitDirectiveEnt(const MCSymbol &Symbol) = 0; |
| 36 | virtual void emitDirectiveAbiCalls() = 0; |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 37 | virtual void emitDirectiveNaN2008() = 0; |
| 38 | virtual void emitDirectiveNaNLegacy() = 0; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 39 | virtual void emitDirectiveOptionPic0() = 0; |
| 40 | virtual void emitDirectiveOptionPic2() = 0; |
| 41 | virtual void emitFrame(unsigned StackReg, unsigned StackSize, |
| 42 | unsigned ReturnReg) = 0; |
| 43 | virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) = 0; |
| 44 | virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) = 0; |
| 45 | |
| 46 | virtual void emitDirectiveSetMips32R2() = 0; |
| 47 | virtual void emitDirectiveSetMips64() = 0; |
| 48 | virtual void emitDirectiveSetMips64R2() = 0; |
| 49 | virtual void emitDirectiveSetDsp() = 0; |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 50 | |
| 51 | // PIC support |
| 52 | virtual void emitDirectiveCpload(unsigned RegNo) = 0; |
| 53 | virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
| 54 | const MCSymbol &Sym, bool IsReg) = 0; |
| Rafael Espindola | 320296a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 55 | }; |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 56 | |
| 57 | // This part is for ascii assembly output |
| 58 | class MipsTargetAsmStreamer : public MipsTargetStreamer { |
| Bill Wendling | a87a147 | 2013-11-20 06:21:08 +0000 | [diff] [blame] | 59 | formatted_raw_ostream &OS; |
| 60 | |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 61 | public: |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 62 | MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 63 | void emitDirectiveSetMicroMips() override; |
| 64 | void emitDirectiveSetNoMicroMips() override; |
| 65 | void emitDirectiveSetMips16() override; |
| 66 | void emitDirectiveSetNoMips16() override; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 67 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 68 | void emitDirectiveSetReorder() override; |
| 69 | void emitDirectiveSetNoReorder() override; |
| 70 | void emitDirectiveSetMacro() override; |
| 71 | void emitDirectiveSetNoMacro() override; |
| 72 | void emitDirectiveSetAt() override; |
| 73 | void emitDirectiveSetNoAt() override; |
| 74 | void emitDirectiveEnd(StringRef Name) override; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 75 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 76 | void emitDirectiveEnt(const MCSymbol &Symbol) override; |
| 77 | void emitDirectiveAbiCalls() override; |
| 78 | void emitDirectiveNaN2008() override; |
| 79 | void emitDirectiveNaNLegacy() override; |
| 80 | void emitDirectiveOptionPic0() override; |
| 81 | void emitDirectiveOptionPic2() override; |
| 82 | void emitFrame(unsigned StackReg, unsigned StackSize, |
| 83 | unsigned ReturnReg) override; |
| 84 | void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; |
| 85 | void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 86 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 87 | void emitDirectiveSetMips32R2() override; |
| 88 | void emitDirectiveSetMips64() override; |
| 89 | void emitDirectiveSetMips64R2() override; |
| 90 | void emitDirectiveSetDsp() override; |
| 91 | |
| 92 | // PIC support |
| 93 | virtual void emitDirectiveCpload(unsigned RegNo); |
| 94 | void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
| 95 | const MCSymbol &Sym, bool IsReg) override; |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | // This part is for ELF object output |
| 99 | class MipsTargetELFStreamer : public MipsTargetStreamer { |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 100 | bool MicroMipsEnabled; |
| 101 | const MCSubtargetInfo &STI; |
| 102 | bool Pic; |
| 103 | |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 104 | public: |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 105 | bool isMicroMipsEnabled() const { return MicroMipsEnabled; } |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 106 | MCELFStreamer &getStreamer(); |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 107 | MipsTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI); |
| 108 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 109 | void emitLabel(MCSymbol *Symbol) override; |
| 110 | void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 111 | void finish() override; |
| 112 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 113 | void emitDirectiveSetMicroMips() override; |
| 114 | void emitDirectiveSetNoMicroMips() override; |
| 115 | void emitDirectiveSetMips16() override; |
| 116 | void emitDirectiveSetNoMips16() override; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 117 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 118 | void emitDirectiveSetReorder() override; |
| 119 | void emitDirectiveSetNoReorder() override; |
| 120 | void emitDirectiveSetMacro() override; |
| 121 | void emitDirectiveSetNoMacro() override; |
| 122 | void emitDirectiveSetAt() override; |
| 123 | void emitDirectiveSetNoAt() override; |
| 124 | void emitDirectiveEnd(StringRef Name) override; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 125 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 126 | void emitDirectiveEnt(const MCSymbol &Symbol) override; |
| 127 | void emitDirectiveAbiCalls() override; |
| 128 | void emitDirectiveNaN2008() override; |
| 129 | void emitDirectiveNaNLegacy() override; |
| 130 | void emitDirectiveOptionPic0() override; |
| 131 | void emitDirectiveOptionPic2() override; |
| 132 | void emitFrame(unsigned StackReg, unsigned StackSize, |
| 133 | unsigned ReturnReg) override; |
| 134 | void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override; |
| 135 | void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override; |
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 136 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 137 | void emitDirectiveSetMips32R2() override; |
| 138 | void emitDirectiveSetMips64() override; |
| 139 | void emitDirectiveSetMips64R2() override; |
| 140 | void emitDirectiveSetDsp() override; |
| 141 | |
| 142 | // PIC support |
| 143 | virtual void emitDirectiveCpload(unsigned RegNo); |
| 144 | void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, |
| 145 | const MCSymbol &Sym, bool IsReg) override; |
| 146 | |
| 147 | protected: |
| 148 | bool isO32() const { return STI.getFeatureBits() & Mips::FeatureO32; } |
| 149 | bool isN32() const { return STI.getFeatureBits() & Mips::FeatureN32; } |
| 150 | bool isN64() const { return STI.getFeatureBits() & Mips::FeatureN64; } |
| Jack Carter | 4c1625b | 2013-11-18 23:55:27 +0000 | [diff] [blame] | 151 | }; |
| Rafael Espindola | 320296a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 152 | } |
| Rafael Espindola | 320296a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 153 | #endif |