blob: edcaa3216053c0fd8f338263bb53ae0ab5851de9 [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"
14#include "llvm/MC/MCAsmBackend.h"
15#include "llvm/MC/MCSubtargetInfo.h"
16
17using namespace llvm;
18
19namespace {
20
21class ARMAsmBackend : public MCAsmBackend {
22 const MCSubtargetInfo *STI;
23 bool isThumbMode; // Currently emitting Thumb code.
24 bool IsLittleEndian; // Big or little endian.
25public:
Daniel Sanders418caf52015-06-10 10:35:34 +000026 ARMAsmBackend(const Target &T, const Triple &TT, bool IsLittle)
27 : MCAsmBackend(), STI(ARM_MC::createARMMCSubtargetInfo(TT.str(), "", "")),
28 isThumbMode(TT.getArchName().startswith("thumb")),
29 IsLittleEndian(IsLittle) {}
Joe Abbey8e72eb72014-09-16 09:18:23 +000030
31 ~ARMAsmBackend() override { delete STI; }
32
33 unsigned getNumFixupKinds() const override {
34 return ARM::NumTargetFixupKinds;
35 }
36
Michael Kupersteindb0712f2015-05-26 10:47:10 +000037 bool hasNOP() const { return STI->getFeatureBits()[ARM::HasV6T2Ops]; }
Joe Abbey8e72eb72014-09-16 09:18:23 +000038
39 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
40
41 /// processFixupValue - Target hook to process the literal value of a fixup
42 /// if necessary.
43 void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
44 const MCFixup &Fixup, const MCFragment *DF,
45 const MCValue &Target, uint64_t &Value,
46 bool &IsResolved) override;
47
48 void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
49 uint64_t Value, bool IsPCRel) const override;
50
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
55 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
56 const MCRelaxableFragment *DF,
57 const MCAsmLayout &Layout) const override;
58
59 void relaxInstruction(const MCInst &Inst, MCInst &Res) const override;
60
61 bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
62
63 void handleAssemblerFlag(MCAssemblerFlag Flag) override;
64
65 unsigned getPointerSize() const { return 4; }
66 bool isThumb() const { return isThumbMode; }
67 void setIsThumb(bool it) { isThumbMode = it; }
68 bool isLittle() const { return IsLittleEndian; }
69};
70} // end anonymous namespace
71
72#endif