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
18namespace llvm {
19
20class ARMAsmBackend : public MCAsmBackend {
21public:
22 ARMAsmBackend(const Target &T, llvm::endianness Endian)
23 : MCAsmBackend(Endian) {}
24
25 bool hasNOP(const MCSubtargetInfo *STI) const {
26 return STI->hasFeature(Feature: 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 uint8_t *Data, uint64_t Value, bool IsResolved) override;
44
45 unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const;
46
47 bool mayNeedRelaxation(unsigned Opcode, ArrayRef<MCOperand> Operands,
48 const MCSubtargetInfo &STI) const override;
49
50 const char *reasonForFixupRelaxation(const MCFixup &Fixup,
51 uint64_t Value) const;
52
53 bool fixupNeedsRelaxationAdvanced(const MCFragment &, const MCFixup &,
54 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
63 unsigned getPointerSize() const { return 4; }
64};
65} // end namespace llvm
66
67#endif
68