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;
30 class MipsAsmBackend : public MCAsmBackend {
32 bool IsLittle; // Big or little endian
36 MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT,
37 StringRef CPU, bool N32)
38 : TheTriple(TT), IsLittle(TT.isLittleEndian()), IsN32(N32) {}
40 std::unique_ptr<MCObjectWriter>
41 createObjectWriter(raw_pwrite_stream &OS) const override;
43 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
44 const MCValue &Target, MutableArrayRef<char> Data,
45 uint64_t Value, bool IsResolved) const override;
47 Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
48 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
50 unsigned getNumFixupKinds() const override {
51 return Mips::NumTargetFixupKinds;
54 /// @name Target Relaxation Interfaces
57 /// MayNeedRelaxation - Check whether the given instruction may need
60 /// \param Inst - The instruction to test.
61 bool mayNeedRelaxation(const MCInst &Inst) const override {
65 /// fixupNeedsRelaxation - Target specific predicate for whether a given
66 /// fixup requires the associated instruction to be relaxed.
67 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
68 const MCRelaxableFragment *DF,
69 const MCAsmLayout &Layout) const override {
71 llvm_unreachable("RelaxInstruction() unimplemented");
75 /// RelaxInstruction - Relax the instruction in the given fragment
76 /// to the next wider instruction.
78 /// \param Inst - The instruction to relax, which may be the same
80 /// \param [out] Res On return, the relaxed instruction.
81 void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
82 MCInst &Res) const override {}
86 bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
88 }; // class MipsAsmBackend