xref: /freebsd/contrib/llvm-project/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h (revision 96190b4fef3b4a0cc3ca0606b0c4e3e69a5e6717)
1 //===-- CSKYAsmBackend.h - CSKY Assembler 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 #ifndef LLVM_LIB_TARGET_CSKY_MCTARGETDESC_CSKYASMBACKEND_H
10 #define LLVM_LIB_TARGET_CSKY_MCTARGETDESC_CSKYASMBACKEND_H
11 
12 #include "MCTargetDesc/CSKYFixupKinds.h"
13 #include "llvm/MC/MCAsmBackend.h"
14 #include "llvm/MC/MCSubtargetInfo.h"
15 #include "llvm/MC/MCTargetOptions.h"
16 
17 namespace llvm {
18 
19 class CSKYAsmBackend : public MCAsmBackend {
20 
21 public:
22   CSKYAsmBackend(const MCSubtargetInfo &STI, const MCTargetOptions &OP)
23       : MCAsmBackend(llvm::endianness::little) {}
24 
25   unsigned int getNumFixupKinds() const override {
26     return CSKY::NumTargetFixupKinds;
27   }
28 
29   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
30                   const MCValue &Target, MutableArrayRef<char> Data,
31                   uint64_t Value, bool IsResolved,
32                   const MCSubtargetInfo *STI) const override;
33 
34   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
35 
36   bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
37                             const MCRelaxableFragment *DF,
38                             const MCAsmLayout &Layout) const override;
39 
40   void relaxInstruction(MCInst &Inst,
41                         const MCSubtargetInfo &STI) const override;
42 
43   bool mayNeedRelaxation(const MCInst &Inst,
44                          const MCSubtargetInfo &STI) const override;
45 
46   bool fixupNeedsRelaxationAdvanced(const MCFixup &Fixup, bool Resolved,
47                                     uint64_t Value,
48                                     const MCRelaxableFragment *DF,
49                                     const MCAsmLayout &Layout,
50                                     const bool WasForced) const override;
51 
52   bool writeNopData(raw_ostream &OS, uint64_t Count,
53                     const MCSubtargetInfo *STI) const override;
54 
55   bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
56                              const MCValue &Target,
57                              const MCSubtargetInfo *STI) override;
58 
59   std::unique_ptr<MCObjectTargetWriter>
60   createObjectTargetWriter() const override;
61 };
62 } // namespace llvm
63 
64 #endif // LLVM_LIB_TARGET_CSKY_MCTARGETDESC_CSKYASMBACKEND_H
65