1 //===-- ARMAsmBackend.h - ARM Assembler Backend -----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
11 #define LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
13 #include "MCTargetDesc/ARMFixupKinds.h"
14 #include "MCTargetDesc/ARMMCTargetDesc.h"
15 #include "llvm/MC/MCAsmBackend.h"
16 #include "llvm/MC/MCSubtargetInfo.h"
17 #include "llvm/Support/TargetRegistry.h"
21 class ARMAsmBackend : public MCAsmBackend {
22 // The STI from the target triple the MCAsmBackend was instantiated with
23 // note that MCFragments may have a different local STI that should be
24 // used in preference.
25 const MCSubtargetInfo &STI;
26 bool isThumbMode; // Currently emitting Thumb code.
28 ARMAsmBackend(const Target &T, const MCSubtargetInfo &STI,
29 support::endianness Endian)
30 : MCAsmBackend(Endian), STI(STI),
31 isThumbMode(STI.getTargetTriple().isThumb()) {}
33 unsigned getNumFixupKinds() const override {
34 return ARM::NumTargetFixupKinds;
37 // FIXME: this should be calculated per fragment as the STI may be
39 bool hasNOP() const { return STI.getFeatureBits()[ARM::HasV6T2Ops]; }
41 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
43 bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
44 const MCValue &Target) override;
46 unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup,
47 const MCValue &Target, uint64_t Value,
48 bool IsResolved, MCContext &Ctx,
49 const MCSubtargetInfo *STI) const;
51 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
52 const MCValue &Target, MutableArrayRef<char> Data,
53 uint64_t Value, bool IsResolved,
54 const MCSubtargetInfo *STI) const override;
56 unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const;
58 bool mayNeedRelaxation(const MCInst &Inst,
59 const MCSubtargetInfo &STI) const override;
61 const char *reasonForFixupRelaxation(const MCFixup &Fixup,
62 uint64_t Value) const;
64 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
65 const MCRelaxableFragment *DF,
66 const MCAsmLayout &Layout) const override;
68 void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
69 MCInst &Res) const override;
71 bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
73 void handleAssemblerFlag(MCAssemblerFlag Flag) override;
75 unsigned getPointerSize() const { return 4; }
76 bool isThumb() const { return isThumbMode; }
77 void setIsThumb(bool it) { isThumbMode = it; }
79 } // end namespace llvm