Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 1 | //===-- MipsAsmBackend.h - Mips Asm Backend ------------------------------===// |
| 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 | // This file defines the MipsAsmBackend class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | // |
| 14 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H |
| 16 | #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 17 | |
| 18 | #include "MCTargetDesc/MipsFixupKinds.h" |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame^] | 19 | #include "llvm/ADT/Triple.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCAsmBackend.h" |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | |
| 24 | class MCAssembler; |
Aaron Ballman | be648a3 | 2014-03-27 14:10:00 +0000 | [diff] [blame] | 25 | struct MCFixupKindInfo; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 26 | class Target; |
| 27 | class MCObjectWriter; |
| 28 | |
| 29 | class MipsAsmBackend : public MCAsmBackend { |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame^] | 30 | Triple::OSType OSType; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 31 | bool IsLittle; // Big or little endian |
| 32 | bool Is64Bit; // 32 or 64 bit words |
| 33 | |
| 34 | public: |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame^] | 35 | MipsAsmBackend(const Target &T, Triple::OSType OSType, bool IsLittle, |
David Blaikie | 9f380a3 | 2015-03-16 18:06:57 +0000 | [diff] [blame] | 36 | bool Is64Bit) |
| 37 | : MCAsmBackend(), OSType(OSType), IsLittle(IsLittle), Is64Bit(Is64Bit) {} |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 38 | |
Rafael Espindola | 5560a4c | 2015-04-14 22:14:34 +0000 | [diff] [blame] | 39 | MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 40 | |
| 41 | void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 42 | uint64_t Value, bool IsPCRel) const override; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 43 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 44 | const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 45 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 46 | unsigned getNumFixupKinds() const override { |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 47 | return Mips::NumTargetFixupKinds; |
| 48 | } |
| 49 | |
| 50 | /// @name Target Relaxation Interfaces |
| 51 | /// @{ |
| 52 | |
| 53 | /// MayNeedRelaxation - Check whether the given instruction may need |
| 54 | /// relaxation. |
| 55 | /// |
| 56 | /// \param Inst - The instruction to test. |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 57 | bool mayNeedRelaxation(const MCInst &Inst) const override { |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 58 | return false; |
| 59 | } |
| 60 | |
| 61 | /// fixupNeedsRelaxation - Target specific predicate for whether a given |
| 62 | /// fixup requires the associated instruction to be relaxed. |
| 63 | bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, |
| 64 | const MCRelaxableFragment *DF, |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 65 | const MCAsmLayout &Layout) const override { |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 66 | // FIXME. |
Craig Topper | 35b2f75 | 2014-06-19 06:10:58 +0000 | [diff] [blame] | 67 | llvm_unreachable("RelaxInstruction() unimplemented"); |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 68 | return false; |
| 69 | } |
| 70 | |
| 71 | /// RelaxInstruction - Relax the instruction in the given fragment |
| 72 | /// to the next wider instruction. |
| 73 | /// |
| 74 | /// \param Inst - The instruction to relax, which may be the same |
| 75 | /// as the output. |
| 76 | /// \param [out] Res On return, the relaxed instruction. |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 77 | void relaxInstruction(const MCInst &Inst, MCInst &Res) const override {} |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 78 | |
| 79 | /// @} |
| 80 | |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 81 | bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 82 | |
| 83 | void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout, |
| 84 | const MCFixup &Fixup, const MCFragment *DF, |
Rafael Espindola | 3e3de5e | 2014-03-28 16:06:09 +0000 | [diff] [blame] | 85 | const MCValue &Target, uint64_t &Value, |
Craig Topper | 56c590a | 2014-04-29 07:58:02 +0000 | [diff] [blame] | 86 | bool &IsResolved) override; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 87 | |
| 88 | }; // class MipsAsmBackend |
| 89 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 90 | } // namespace |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 91 | |
| 92 | #endif |