LLVM  8.0.1
ARMAsmBackend.h
Go to the documentation of this file.
1 //===-- 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 
15 #include "llvm/MC/MCAsmBackend.h"
18 
19 namespace llvm {
20 
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.
27 public:
28  ARMAsmBackend(const Target &T, const MCSubtargetInfo &STI,
30  : MCAsmBackend(Endian), STI(STI),
31  isThumbMode(STI.getTargetTriple().isThumb()) {}
32 
33  unsigned getNumFixupKinds() const override {
35  }
36 
37  // FIXME: this should be calculated per fragment as the STI may be
38  // different.
39  bool hasNOP() const { return STI.getFeatureBits()[ARM::HasV6T2Ops]; }
40 
41  const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
42 
44  const MCValue &Target) override;
45 
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;
50 
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;
55 
56  unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const;
57 
58  bool mayNeedRelaxation(const MCInst &Inst,
59  const MCSubtargetInfo &STI) const override;
60 
61  const char *reasonForFixupRelaxation(const MCFixup &Fixup,
62  uint64_t Value) const;
63 
64  bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
65  const MCRelaxableFragment *DF,
66  const MCAsmLayout &Layout) const override;
67 
68  void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
69  MCInst &Res) const override;
70 
71  bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
72 
74 
75  unsigned getPointerSize() const { return 4; }
76  bool isThumb() const { return isThumbMode; }
77  void setIsThumb(bool it) { isThumbMode = it; }
78 };
79 } // end namespace llvm
80 
81 #endif
unsigned getNumFixupKinds() const override
Get the number of target specific fixup kinds.
Definition: ARMAsmBackend.h:33
unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const
void setIsThumb(bool it)
Definition: ARMAsmBackend.h:77
unsigned getPointerSize() const
Definition: ARMAsmBackend.h:75
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
const char * reasonForFixupRelaxation(const MCFixup &Fixup, uint64_t Value) const
const support::endianness Endian
Definition: MCAsmBackend.h:53
bool hasNOP() const
Definition: ARMAsmBackend.h:39
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:74
const FeatureBitset & getFeatureBits() const
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:29
Context object for machine code objects.
Definition: MCContext.h:63
ARMAsmBackend(const Target &T, const MCSubtargetInfo &STI, support::endianness Endian)
Definition: ARMAsmBackend.h:28
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:118
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCFragment.h:271
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:291
bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const override
Simple predicate for targets where !Resolved implies requiring relaxation.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:23
const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, uint64_t Value, bool IsResolved, MCContext &Ctx, const MCSubtargetInfo *STI) const
bool writeNopData(raw_ostream &OS, uint64_t Count) const override
Write an (optimal) nop sequence of Count bytes to the given output.
PowerPC TLS Dynamic Call Fixup
void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, MCInst &Res) const override
Relax the instruction in the given fragment to the next wider instruction.
Target - Wrapper for Target specific information.
void handleAssemblerFlag(MCAssemblerFlag Flag) override
Handle any target-specific assembler flags. By default, do nothing.
MCAssemblerFlag
Definition: MCDirectives.h:48
Generic base class for all target subtargets.
Target independent information on a fixup kind.
const unsigned Kind
bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override
Check whether the given instruction may need relaxation.
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const override
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup...
LLVM Value Representation.
Definition: Value.h:73
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:42
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
bool isThumb() const
Definition: ARMAsmBackend.h:76
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target) override
Hook to check if a relocation is needed for some target specific reason.