1 //===-- ARMAsmBackend.h - ARM Assembler Backend -----------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
10 #define LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
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"
20 class ARMAsmBackend
: public MCAsmBackend
{
21 bool isThumbMode
; // Currently emitting Thumb code.
23 ARMAsmBackend(const Target
&T
, bool isThumb
, llvm::endianness Endian
)
24 : MCAsmBackend(Endian
), isThumbMode(isThumb
) {}
26 unsigned getNumFixupKinds() const override
{
27 return ARM::NumTargetFixupKinds
;
30 bool hasNOP(const MCSubtargetInfo
*STI
) const {
31 return STI
->hasFeature(ARM::HasV6T2Ops
);
34 std::optional
<MCFixupKind
> getFixupKind(StringRef Name
) const override
;
36 const MCFixupKindInfo
&getFixupKindInfo(MCFixupKind Kind
) const override
;
38 bool shouldForceRelocation(const MCAssembler
&Asm
, const MCFixup
&Fixup
,
39 const MCValue
&Target
,
40 const MCSubtargetInfo
*STI
) override
;
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;
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
;
52 unsigned getRelaxedOpcode(unsigned Op
, const MCSubtargetInfo
&STI
) const;
54 bool mayNeedRelaxation(const MCInst
&Inst
,
55 const MCSubtargetInfo
&STI
) const override
;
57 const char *reasonForFixupRelaxation(const MCFixup
&Fixup
,
58 uint64_t Value
) const;
60 bool fixupNeedsRelaxation(const MCFixup
&Fixup
,
61 uint64_t Value
) const override
;
63 void relaxInstruction(MCInst
&Inst
,
64 const MCSubtargetInfo
&STI
) const override
;
66 bool writeNopData(raw_ostream
&OS
, uint64_t Count
,
67 const MCSubtargetInfo
*STI
) const override
;
69 void handleAssemblerFlag(MCAssemblerFlag Flag
) override
;
71 unsigned getPointerSize() const { return 4; }
72 bool isThumb() const { return isThumbMode
; }
73 void setIsThumb(bool it
) { isThumbMode
= it
; }
75 } // end namespace llvm