blob: c8527e5cca20cff6fcf9895fb46a166fbbe8310b [file] [log] [blame]
Joe Abbey8e72eb72014-09-16 09:18:23 +00001//===-- ARMAsmBackend.h - ARM Assembler Backend -----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
11#define LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
12
13#include "MCTargetDesc/ARMFixupKinds.h"
Benjamin Kramerb32a5042016-01-27 19:29:42 +000014#include "MCTargetDesc/ARMMCTargetDesc.h"
Joe Abbey8e72eb72014-09-16 09:18:23 +000015#include "llvm/MC/MCAsmBackend.h"
16#include "llvm/MC/MCSubtargetInfo.h"
Benjamin Kramerb32a5042016-01-27 19:29:42 +000017#include "llvm/Support/TargetRegistry.h"
Joe Abbey8e72eb72014-09-16 09:18:23 +000018
Benjamin Kramerb32a5042016-01-27 19:29:42 +000019namespace llvm {
Joe Abbey8e72eb72014-09-16 09:18:23 +000020
21class ARMAsmBackend : public MCAsmBackend {
Alex Bradbury46db78b2018-01-03 13:46:21 +000022 const MCSubtargetInfo &STI;
Joe Abbey8e72eb72014-09-16 09:18:23 +000023 bool isThumbMode; // Currently emitting Thumb code.
24 bool IsLittleEndian; // Big or little endian.
25public:
Alex Bradbury46db78b2018-01-03 13:46:21 +000026 ARMAsmBackend(const Target &T, const MCSubtargetInfo &STI, bool IsLittle)
27 : MCAsmBackend(), STI(STI),
28 isThumbMode(STI.getTargetTriple().isThumb()),
Daniel Sanders418caf52015-06-10 10:35:34 +000029 IsLittleEndian(IsLittle) {}
Joe Abbey8e72eb72014-09-16 09:18:23 +000030
Joe Abbey8e72eb72014-09-16 09:18:23 +000031 unsigned getNumFixupKinds() const override {
32 return ARM::NumTargetFixupKinds;
33 }
34
Alex Bradbury46db78b2018-01-03 13:46:21 +000035 bool hasNOP() const { return STI.getFeatureBits()[ARM::HasV6T2Ops]; }
Joe Abbey8e72eb72014-09-16 09:18:23 +000036
37 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
38
Rafael Espindola76287ab2017-06-30 22:47:27 +000039 bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
40 const MCValue &Target) override;
Joe Abbey8e72eb72014-09-16 09:18:23 +000041
Rafael Espindola801b42d2017-06-23 22:52:36 +000042 unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup,
Rafael Espindola1beb7022017-07-11 23:18:25 +000043 const MCValue &Target, uint64_t Value,
44 bool IsResolved, MCContext &Ctx,
45 bool IsLittleEndian) const;
Tim Northover8d67b8e2015-10-02 18:07:18 +000046
Rafael Espindola801b42d2017-06-23 22:52:36 +000047 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
48 const MCValue &Target, MutableArrayRef<char> Data,
Rafael Espindola1beb7022017-07-11 23:18:25 +000049 uint64_t Value, bool IsResolved) const override;
Joe Abbey8e72eb72014-09-16 09:18:23 +000050
Tim Northover42335572015-04-06 18:44:42 +000051 unsigned getRelaxedOpcode(unsigned Op) const;
52
Joe Abbey8e72eb72014-09-16 09:18:23 +000053 bool mayNeedRelaxation(const MCInst &Inst) const override;
54
Tim Northover8d67b8e2015-10-02 18:07:18 +000055 const char *reasonForFixupRelaxation(const MCFixup &Fixup,
56 uint64_t Value) const;
57
Joe Abbey8e72eb72014-09-16 09:18:23 +000058 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
59 const MCRelaxableFragment *DF,
60 const MCAsmLayout &Layout) const override;
61
Nirav Dave86030622016-07-11 14:23:53 +000062 void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
63 MCInst &Res) const override;
Joe Abbey8e72eb72014-09-16 09:18:23 +000064
65 bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
66
67 void handleAssemblerFlag(MCAssemblerFlag Flag) override;
68
69 unsigned getPointerSize() const { return 4; }
70 bool isThumb() const { return isThumbMode; }
71 void setIsThumb(bool it) { isThumbMode = it; }
72 bool isLittle() const { return IsLittleEndian; }
73};
Benjamin Kramerb32a5042016-01-27 19:29:42 +000074} // end namespace llvm
Joe Abbey8e72eb72014-09-16 09:18:23 +000075
76#endif