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/LoongArchFixupKinds.h" 18 #include "MCTargetDesc/LoongArchMCTargetDesc.h" 19 #include "llvm/MC/MCAsmBackend.h" 20 #include "llvm/MC/MCFixupKindInfo.h" 21 #include "llvm/MC/MCSubtargetInfo.h" 22 23 namespace llvm { 24 25 class LoongArchAsmBackend : public MCAsmBackend { 26 const MCSubtargetInfo &STI; 27 uint8_t OSABI; 28 bool Is64Bit; 29 30 public: 31 LoongArchAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit) 32 : MCAsmBackend(support::little), STI(STI), OSABI(OSABI), 33 Is64Bit(Is64Bit) {} 34 ~LoongArchAsmBackend() override {} 35 36 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, 37 const MCValue &Target, MutableArrayRef<char> Data, 38 uint64_t Value, bool IsResolved, 39 const MCSubtargetInfo *STI) const override; 40 41 bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, 42 const MCValue &Target) override; 43 44 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, 45 const MCRelaxableFragment *DF, 46 const MCAsmLayout &Layout) const override { 47 return false; 48 } 49 50 unsigned getNumFixupKinds() const override { 51 return LoongArch::NumTargetFixupKinds; 52 } 53 54 std::optional<MCFixupKind> getFixupKind(StringRef Name) const override; 55 56 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override; 57 58 void relaxInstruction(MCInst &Inst, 59 const MCSubtargetInfo &STI) const override {} 60 61 bool writeNopData(raw_ostream &OS, uint64_t Count, 62 const MCSubtargetInfo *STI) const override; 63 64 std::unique_ptr<MCObjectTargetWriter> 65 createObjectTargetWriter() const override; 66 }; 67 } // end namespace llvm 68 69 #endif // LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHASMBACKEND_H 70