Path: blob/main/contrib/llvm-project/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
35294 views
//===-- LoongArchAsmBackend.h - LoongArch Assembler Backend ---*- C++ -*---===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines the LoongArchAsmBackend class.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHASMBACKEND_H13#define LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHASMBACKEND_H1415#include "MCTargetDesc/LoongArchBaseInfo.h"16#include "MCTargetDesc/LoongArchFixupKinds.h"17#include "MCTargetDesc/LoongArchMCTargetDesc.h"18#include "llvm/MC/MCAsmBackend.h"19#include "llvm/MC/MCExpr.h"20#include "llvm/MC/MCFixupKindInfo.h"21#include "llvm/MC/MCSection.h"22#include "llvm/MC/MCSubtargetInfo.h"2324namespace llvm {2526class LoongArchAsmBackend : public MCAsmBackend {27const MCSubtargetInfo &STI;28uint8_t OSABI;29bool Is64Bit;30const MCTargetOptions &TargetOptions;31DenseMap<MCSection *, const MCSymbolRefExpr *> SecToAlignSym;3233public:34LoongArchAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit,35const MCTargetOptions &Options)36: MCAsmBackend(llvm::endianness::little,37LoongArch::fixup_loongarch_relax),38STI(STI), OSABI(OSABI), Is64Bit(Is64Bit), TargetOptions(Options) {}39~LoongArchAsmBackend() override {}4041bool handleAddSubRelocations(const MCAssembler &Asm, const MCFragment &F,42const MCFixup &Fixup, const MCValue &Target,43uint64_t &FixedValue) const override;4445void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,46const MCValue &Target, MutableArrayRef<char> Data,47uint64_t Value, bool IsResolved,48const MCSubtargetInfo *STI) const override;4950// Return Size with extra Nop Bytes for alignment directive in code section.51bool shouldInsertExtraNopBytesForCodeAlign(const MCAlignFragment &AF,52unsigned &Size) override;5354// Insert target specific fixup type for alignment directive in code section.55bool shouldInsertFixupForCodeAlign(MCAssembler &Asm,56MCAlignFragment &AF) override;5758bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,59const MCValue &Target,60const MCSubtargetInfo *STI) override;6162unsigned getNumFixupKinds() const override {63return LoongArch::NumTargetFixupKinds;64}6566std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;6768const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;6970void relaxInstruction(MCInst &Inst,71const MCSubtargetInfo &STI) const override {}7273std::pair<bool, bool> relaxLEB128(const MCAssembler &Asm, MCLEBFragment &LF,74int64_t &Value) const override;7576bool relaxDwarfLineAddr(const MCAssembler &Asm, MCDwarfLineAddrFragment &DF,77bool &WasRelaxed) const override;78bool relaxDwarfCFA(const MCAssembler &Asm, MCDwarfCallFrameFragment &DF,79bool &WasRelaxed) const override;8081bool writeNopData(raw_ostream &OS, uint64_t Count,82const MCSubtargetInfo *STI) const override;8384std::unique_ptr<MCObjectTargetWriter>85createObjectTargetWriter() const override;86const MCTargetOptions &getTargetOptions() const { return TargetOptions; }87DenseMap<MCSection *, const MCSymbolRefExpr *> &getSecToAlignSym() {88return SecToAlignSym;89}90};91} // end namespace llvm9293#endif // LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHASMBACKEND_H949596