1 //===-- MipsAsmBackend.h - Mips Asm Backend ------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the MipsAsmBackend class.
12 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
16 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
18 #include "MCTargetDesc/MipsFixupKinds.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/MC/MCAsmBackend.h"
25 struct MCFixupKindInfo;
31 class MipsAsmBackend : public MCAsmBackend {
36 MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT,
37 StringRef CPU, bool N32)
38 : MCAsmBackend(TT.isLittleEndian() ? support::little : support::big),
39 TheTriple(TT), IsN32(N32) {}
41 std::unique_ptr<MCObjectTargetWriter>
42 createObjectTargetWriter() const override;
44 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
45 const MCValue &Target, MutableArrayRef<char> Data,
46 uint64_t Value, bool IsResolved,
47 const MCSubtargetInfo *STI) const override;
49 Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
50 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
52 unsigned getNumFixupKinds() const override {
53 return Mips::NumTargetFixupKinds;
56 /// @name Target Relaxation Interfaces
59 /// MayNeedRelaxation - Check whether the given instruction may need
62 /// \param Inst - The instruction to test.
63 bool mayNeedRelaxation(const MCInst &Inst,
64 const MCSubtargetInfo &STI) const override {
68 /// fixupNeedsRelaxation - Target specific predicate for whether a given
69 /// fixup requires the associated instruction to be relaxed.
70 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
71 const MCRelaxableFragment *DF,
72 const MCAsmLayout &Layout) const override {
74 llvm_unreachable("RelaxInstruction() unimplemented");
78 /// RelaxInstruction - Relax the instruction in the given fragment
79 /// to the next wider instruction.
81 /// \param Inst - The instruction to relax, which may be the same
83 /// \param [out] Res On return, the relaxed instruction.
84 void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
85 MCInst &Res) const override {}
89 bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
91 bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
92 const MCValue &Target) override;
94 bool isMicroMips(const MCSymbol *Sym) const override;
95 }; // class MipsAsmBackend