xref: /freebsd/contrib/llvm-project/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h (revision 5abaf0866445a61c11665fffc148ecd13a7bb9ac)
1 //===-- LoongArchAsmBackend.h - LoongArch Assembler Backend ---*- C++ -*---===//
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 LoongArchAsmBackend class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHASMBACKEND_H
14 #define LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHASMBACKEND_H
15 
16 #include "MCTargetDesc/LoongArchBaseInfo.h"
17 #include "MCTargetDesc/LoongArchMCTargetDesc.h"
18 #include "llvm/MC/MCAsmBackend.h"
19 #include "llvm/MC/MCFixupKindInfo.h"
20 #include "llvm/MC/MCSubtargetInfo.h"
21 
22 namespace llvm {
23 
24 class LoongArchAsmBackend : public MCAsmBackend {
25   uint8_t OSABI;
26   bool Is64Bit;
27 
28 public:
29   LoongArchAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit)
30       : MCAsmBackend(support::little), OSABI(OSABI), Is64Bit(Is64Bit) {}
31   ~LoongArchAsmBackend() override {}
32 
33   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
34                   const MCValue &Target, MutableArrayRef<char> Data,
35                   uint64_t Value, bool IsResolved,
36                   const MCSubtargetInfo *STI) const override;
37 
38   bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
39                              const MCValue &Target) override;
40 
41   bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
42                             const MCRelaxableFragment *DF,
43                             const MCAsmLayout &Layout) const override {
44     return false;
45   }
46 
47   unsigned getNumFixupKinds() const override {
48     // FIXME: Implement this when we define fixup kind
49     return 0;
50   }
51 
52   void relaxInstruction(MCInst &Inst,
53                         const MCSubtargetInfo &STI) const override {}
54 
55   bool writeNopData(raw_ostream &OS, uint64_t Count,
56                     const MCSubtargetInfo *STI) const override;
57 
58   std::unique_ptr<MCObjectTargetWriter>
59   createObjectTargetWriter() const override;
60 };
61 } // end namespace llvm
62 
63 #endif // LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHASMBACKEND_H
64