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 bool isThumbMode; // Currently emitting Thumb code. 22 public: ARMAsmBackend(const Target & T,bool isThumb,llvm::endianness Endian)23 ARMAsmBackend(const Target &T, bool isThumb, llvm::endianness Endian) 24 : MCAsmBackend(Endian), isThumbMode(isThumb) {} 25 getNumFixupKinds()26 unsigned getNumFixupKinds() const override { 27 return ARM::NumTargetFixupKinds; 28 } 29 hasNOP(const MCSubtargetInfo * STI)30 bool hasNOP(const MCSubtargetInfo *STI) const { 31 return STI->hasFeature(ARM::HasV6T2Ops); 32 } 33 34 std::optional<MCFixupKind> getFixupKind(StringRef Name) const override; 35 36 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override; 37 38 bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, 39 const MCValue &Target, 40 const MCSubtargetInfo *STI) override; 41 42 unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup, 43 const MCValue &Target, uint64_t Value, 44 bool IsResolved, MCContext &Ctx, 45 const MCSubtargetInfo *STI) const; 46 47 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, 48 const MCValue &Target, MutableArrayRef<char> Data, 49 uint64_t Value, bool IsResolved, 50 const MCSubtargetInfo *STI) const override; 51 52 unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const; 53 54 bool mayNeedRelaxation(const MCInst &Inst, 55 const MCSubtargetInfo &STI) const override; 56 57 const char *reasonForFixupRelaxation(const MCFixup &Fixup, 58 uint64_t Value) const; 59 60 bool fixupNeedsRelaxation(const MCFixup &Fixup, 61 uint64_t Value) const override; 62 63 void relaxInstruction(MCInst &Inst, 64 const MCSubtargetInfo &STI) const override; 65 66 bool writeNopData(raw_ostream &OS, uint64_t Count, 67 const MCSubtargetInfo *STI) const override; 68 69 void handleAssemblerFlag(MCAssemblerFlag Flag) override; 70 getPointerSize()71 unsigned getPointerSize() const { return 4; } isThumb()72 bool isThumb() const { return isThumbMode; } setIsThumb(bool it)73 void setIsThumb(bool it) { isThumbMode = it; } 74 }; 75 } // end namespace llvm 76 77 #endif 78