ARMAsmBackend.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
  9. #define LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
  10. #include "MCTargetDesc/ARMFixupKinds.h"
  11. #include "MCTargetDesc/ARMMCTargetDesc.h"
  12. #include "llvm/MC/MCAsmBackend.h"
  13. #include "llvm/MC/MCSubtargetInfo.h"
  14. #include "llvm/MC/TargetRegistry.h"
  15. namespace llvm {
  16. class ARMAsmBackend : public MCAsmBackend {
  17. bool isThumbMode; // Currently emitting Thumb code.
  18. public:
  19. ARMAsmBackend(const Target &T, bool isThumb, support::endianness Endian)
  20. : MCAsmBackend(Endian), isThumbMode(isThumb) {}
  21. unsigned getNumFixupKinds() const override {
  22. return ARM::NumTargetFixupKinds;
  23. }
  24. bool hasNOP(const MCSubtargetInfo *STI) const {
  25. return STI->getFeatureBits()[ARM::HasV6T2Ops];
  26. }
  27. std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
  28. const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
  29. bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
  30. const MCValue &Target) override;
  31. unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup,
  32. const MCValue &Target, uint64_t Value,
  33. bool IsResolved, MCContext &Ctx,
  34. const MCSubtargetInfo *STI) const;
  35. void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
  36. const MCValue &Target, MutableArrayRef<char> Data,
  37. uint64_t Value, bool IsResolved,
  38. const MCSubtargetInfo *STI) const override;
  39. unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const;
  40. bool mayNeedRelaxation(const MCInst &Inst,
  41. const MCSubtargetInfo &STI) const override;
  42. const char *reasonForFixupRelaxation(const MCFixup &Fixup,
  43. uint64_t Value) const;
  44. bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
  45. const MCRelaxableFragment *DF,
  46. const MCAsmLayout &Layout) const override;
  47. void relaxInstruction(MCInst &Inst,
  48. const MCSubtargetInfo &STI) const override;
  49. bool writeNopData(raw_ostream &OS, uint64_t Count,
  50. const MCSubtargetInfo *STI) const override;
  51. void handleAssemblerFlag(MCAssemblerFlag Flag) override;
  52. unsigned getPointerSize() const { return 4; }
  53. bool isThumb() const { return isThumbMode; }
  54. void setIsThumb(bool it) { isThumbMode = it; }
  55. };
  56. } // end namespace llvm
  57. #endif