xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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/MC/MCAsmBackend.h"
19 #include "llvm/TargetParser/Triple.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:
MipsAsmBackend(const Target & T,const MCRegisterInfo & MRI,const Triple & TT,StringRef CPU,bool N32)33   MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT,
34                  StringRef CPU, bool N32)
35       : MCAsmBackend(TT.isLittleEndian() ? llvm::endianness::little
36                                          : llvm::endianness::big),
37         TheTriple(TT), IsN32(N32) {}
38 
39   std::unique_ptr<MCObjectTargetWriter>
40   createObjectTargetWriter() const override;
41 
42   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
43                   const MCValue &Target, MutableArrayRef<char> Data,
44                   uint64_t Value, bool IsResolved,
45                   const MCSubtargetInfo *STI) const override;
46 
47   std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
48   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
49 
getNumFixupKinds()50   unsigned getNumFixupKinds() const override {
51     return Mips::NumTargetFixupKinds;
52   }
53 
54   bool writeNopData(raw_ostream &OS, uint64_t Count,
55                     const MCSubtargetInfo *STI) const override;
56 
57   bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
58                              const MCValue &Target,
59                              const MCSubtargetInfo *STI) override;
60 
61   bool isMicroMips(const MCSymbol *Sym) const override;
62 }; // class MipsAsmBackend
63 
64 } // namespace
65 
66 #endif
67