xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h (revision 37f253ed0ff80cd6a0937859a4c3c80c256f6d61)
1 //===-- MipsAsmBackend.h - Mips Asm Backend  ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the MipsAsmBackend class.
10 //
11 //===----------------------------------------------------------------------===//
12 //
13 
14 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
15 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
16 
17 #include "MCTargetDesc/MipsFixupKinds.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/MC/MCAsmBackend.h"
20 
21 namespace llvm {
22 
23 class MCAssembler;
24 struct MCFixupKindInfo;
25 class MCRegisterInfo;
26 class Target;
27 
28 class MipsAsmBackend : public MCAsmBackend {
29   Triple TheTriple;
30   bool IsN32;
31 
32 public:
33   MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT,
34                  StringRef CPU, bool N32)
35       : MCAsmBackend(TT.isLittleEndian() ? support::little : support::big),
36         TheTriple(TT), IsN32(N32) {}
37 
38   std::unique_ptr<MCObjectTargetWriter>
39   createObjectTargetWriter() const override;
40 
41   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
42                   const MCValue &Target, MutableArrayRef<char> Data,
43                   uint64_t Value, bool IsResolved,
44                   const MCSubtargetInfo *STI) const override;
45 
46   Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
47   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
48 
49   unsigned getNumFixupKinds() const override {
50     return Mips::NumTargetFixupKinds;
51   }
52 
53   /// @name Target Relaxation Interfaces
54   /// @{
55 
56   /// MayNeedRelaxation - Check whether the given instruction may need
57   /// relaxation.
58   ///
59   /// \param Inst - The instruction to test.
60   bool mayNeedRelaxation(const MCInst &Inst,
61                          const MCSubtargetInfo &STI) const override {
62     return false;
63   }
64 
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 {
70     // FIXME.
71     llvm_unreachable("RelaxInstruction() unimplemented");
72     return false;
73   }
74 
75   bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
76 
77   bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
78                              const MCValue &Target) override;
79 
80   bool isMicroMips(const MCSymbol *Sym) const override;
81 }; // class MipsAsmBackend
82 
83 } // namespace
84 
85 #endif
86