1 //===-- ARMAsmBackend.h - ARM 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 #ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H 10 #define LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H 11 12 #include "MCTargetDesc/ARMFixupKinds.h" 13 #include "MCTargetDesc/ARMMCTargetDesc.h" 14 #include "llvm/MC/MCAsmBackend.h" 15 #include "llvm/MC/MCSubtargetInfo.h" 16 #include "llvm/MC/TargetRegistry.h" 17 18 namespace llvm { 19 20 class ARMAsmBackend : public MCAsmBackend { 21 public: ARMAsmBackend(const Target & T,llvm::endianness Endian)22 ARMAsmBackend(const Target &T, llvm::endianness Endian) 23 : MCAsmBackend(Endian) {} 24 hasNOP(const MCSubtargetInfo * STI)25 bool hasNOP(const MCSubtargetInfo *STI) const { 26 return STI->hasFeature(ARM::HasV6T2Ops); 27 } 28 29 std::optional<MCFixupKind> getFixupKind(StringRef Name) const override; 30 31 MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override; 32 33 bool shouldForceRelocation(const MCFixup &Fixup, const MCValue &Target); 34 35 unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup, 36 const MCValue &Target, uint64_t Value, 37 bool IsResolved, MCContext &Ctx, 38 const MCSubtargetInfo *STI) const; 39 40 std::optional<bool> evaluateFixup(const MCFragment &, MCFixup &, MCValue &, 41 uint64_t &) override; 42 void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, 43 MutableArrayRef<char> Data, uint64_t Value, 44 bool IsResolved) override; 45 46 unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const; 47 48 bool mayNeedRelaxation(unsigned Opcode, ArrayRef<MCOperand> Operands, 49 const MCSubtargetInfo &STI) const override; 50 51 const char *reasonForFixupRelaxation(const MCFixup &Fixup, 52 uint64_t Value) const; 53 54 bool fixupNeedsRelaxationAdvanced(const MCFixup &, const MCValue &, uint64_t, 55 bool) const override; 56 57 void relaxInstruction(MCInst &Inst, 58 const MCSubtargetInfo &STI) const override; 59 60 bool writeNopData(raw_ostream &OS, uint64_t Count, 61 const MCSubtargetInfo *STI) const override; 62 getPointerSize()63 unsigned getPointerSize() const { return 4; } 64 }; 65 } // end namespace llvm 66 67 #endif 68