blob: 3d5e16fcf9b415e72177c78968d6cd38eb974d16 [file] [log] [blame]
Zoran Jovanovicada38ef2014-03-27 12:38:40 +00001//===-- 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 Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
16#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000017
18#include "MCTargetDesc/MipsFixupKinds.h"
Daniel Sanders50f17232015-09-15 16:17:27 +000019#include "llvm/ADT/Triple.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000020#include "llvm/MC/MCAsmBackend.h"
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000021
22namespace llvm {
23
24class MCAssembler;
Aaron Ballmanbe648a32014-03-27 14:10:00 +000025struct MCFixupKindInfo;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000026class MCObjectWriter;
Simon Atanasyan6d795862017-09-07 12:54:26 +000027class MCRegisterInfo;
28class Target;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000029
30class MipsAsmBackend : public MCAsmBackend {
Simon Atanasyan6d795862017-09-07 12:54:26 +000031 Triple TheTriple;
Simon Atanasyan117665582017-09-21 10:44:26 +000032 bool IsN32;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000033
34public:
Simon Atanasyan6d795862017-09-07 12:54:26 +000035 MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT,
Simon Atanasyan117665582017-09-21 10:44:26 +000036 StringRef CPU, bool N32)
Peter Collingbourne571a3302018-05-21 17:57:19 +000037 : MCAsmBackend(TT.isLittleEndian() ? support::little : support::big),
38 TheTriple(TT), IsN32(N32) {}
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000039
Peter Collingbournedcd7d6c2018-05-21 19:20:29 +000040 std::unique_ptr<MCObjectTargetWriter>
41 createObjectTargetWriter() const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000042
Rafael Espindola801b42d2017-06-23 22:52:36 +000043 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
44 const MCValue &Target, MutableArrayRef<char> Data,
Peter Smith57f661b2018-06-06 09:40:06 +000045 uint64_t Value, bool IsResolved,
46 const MCSubtargetInfo *STI) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000047
David Majnemerce108422016-01-19 23:05:27 +000048 Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
Craig Topper56c590a2014-04-29 07:58:02 +000049 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000050
Craig Topper56c590a2014-04-29 07:58:02 +000051 unsigned getNumFixupKinds() const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000052 return Mips::NumTargetFixupKinds;
53 }
54
55 /// @name Target Relaxation Interfaces
56 /// @{
57
58 /// MayNeedRelaxation - Check whether the given instruction may need
59 /// relaxation.
60 ///
61 /// \param Inst - The instruction to test.
Peter Smith57f661b2018-06-06 09:40:06 +000062 bool mayNeedRelaxation(const MCInst &Inst,
63 const MCSubtargetInfo &STI) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000064 return false;
65 }
66
67 /// fixupNeedsRelaxation - Target specific predicate for whether a given
68 /// fixup requires the associated instruction to be relaxed.
69 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
70 const MCRelaxableFragment *DF,
Craig Topper56c590a2014-04-29 07:58:02 +000071 const MCAsmLayout &Layout) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000072 // FIXME.
Craig Topper35b2f752014-06-19 06:10:58 +000073 llvm_unreachable("RelaxInstruction() unimplemented");
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000074 return false;
75 }
76
77 /// RelaxInstruction - Relax the instruction in the given fragment
78 /// to the next wider instruction.
79 ///
80 /// \param Inst - The instruction to relax, which may be the same
81 /// as the output.
82 /// \param [out] Res On return, the relaxed instruction.
Nirav Dave86030622016-07-11 14:23:53 +000083 void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
84 MCInst &Res) const override {}
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000085
86 /// @}
87
Peter Collingbourne571a3302018-05-21 17:57:19 +000088 bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000089
Simon Atanasyan3a44bcf2018-06-01 16:37:42 +000090 bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
91 const MCValue &Target) override;
92
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000093}; // class MipsAsmBackend
94
Alexander Kornienkof00654e2015-06-23 09:49:53 +000095} // namespace
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000096
97#endif