xref: /freebsd/contrib/llvm-project/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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:
CSKYAsmBackend(const MCSubtargetInfo & STI,const MCTargetOptions & OP)22   CSKYAsmBackend(const MCSubtargetInfo &STI, const MCTargetOptions &OP)
23       : MCAsmBackend(llvm::endianness::little) {}
24 
25   std::optional<bool> evaluateFixup(const MCFragment &, MCFixup &, MCValue &,
26                                     uint64_t &) override;
27   void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
28                   MutableArrayRef<char> Data, uint64_t Value,
29                   bool IsResolved) override;
30 
31   MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override;
32 
33   bool fixupNeedsRelaxation(const MCFixup &Fixup,
34                             uint64_t Value) const override;
35 
36   bool mayNeedRelaxation(unsigned Opcode, ArrayRef<MCOperand> Operands,
37                          const MCSubtargetInfo &STI) const override;
38   void relaxInstruction(MCInst &Inst,
39                         const MCSubtargetInfo &STI) const override;
40 
41   bool fixupNeedsRelaxationAdvanced(const MCFixup &, const MCValue &, uint64_t,
42                                     bool) const override;
43 
44   bool writeNopData(raw_ostream &OS, uint64_t Count,
45                     const MCSubtargetInfo *STI) const override;
46 
47   bool shouldForceRelocation(const MCFixup &Fixup, const MCValue &Target);
48 
49   std::unique_ptr<MCObjectTargetWriter>
50   createObjectTargetWriter() const override;
51 };
52 } // namespace llvm
53 
54 #endif // LLVM_LIB_TARGET_CSKY_MCTARGETDESC_CSKYASMBACKEND_H
55