LLVM  9.0.0svn
AVRAsmBackend.h
Go to the documentation of this file.
1 //===-- AVRAsmBackend.h - AVR Asm Backend --------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // \file The AVR assembly backend implementation.
10 //
11 //===----------------------------------------------------------------------===//
12 //
13 
14 #ifndef LLVM_AVR_ASM_BACKEND_H
15 #define LLVM_AVR_ASM_BACKEND_H
16 
18 
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/MC/MCAsmBackend.h"
21 
22 namespace llvm {
23 
24 class MCAssembler;
25 class MCObjectWriter;
26 class Target;
27 
28 struct MCFixupKindInfo;
29 
30 /// Utilities for manipulating generated AVR machine code.
31 class AVRAsmBackend : public MCAsmBackend {
32 public:
34  : MCAsmBackend(support::little), OSType(OSType) {}
35 
36  void adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
37  uint64_t &Value, MCContext *Ctx = nullptr) const;
38 
39  std::unique_ptr<MCObjectTargetWriter>
40  createObjectTargetWriter() const override;
41 
42  void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
43  const MCValue &Target, MutableArrayRef<char> Data,
44  uint64_t Value, bool IsResolved,
45  const MCSubtargetInfo *STI) const override;
46 
47  const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
48 
49  unsigned getNumFixupKinds() const override {
51  }
52 
53  bool mayNeedRelaxation(const MCInst &Inst,
54  const MCSubtargetInfo &STI) const override {
55  return false;
56  }
57 
58  bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
59  const MCRelaxableFragment *DF,
60  const MCAsmLayout &Layout) const override {
61  llvm_unreachable("RelaxInstruction() unimplemented");
62  return false;
63  }
64 
65  void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
66  MCInst &Res) const override {}
67 
68  bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
69 
70  bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
71  const MCValue &Target) override;
72 
73 private:
74  Triple::OSType OSType;
75 };
76 
77 } // end namespace llvm
78 
79 #endif // LLVM_AVR_ASM_BACKEND_H
80 
AVRAsmBackend(Triple::OSType OSType)
Definition: AVRAsmBackend.h:33
unsigned getNumFixupKinds() const override
Get the number of target specific fixup kinds.
Definition: AVRAsmBackend.h:49
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This represents an "assembler immediate".
Definition: MCValue.h:39
bool writeNopData(raw_ostream &OS, uint64_t Count) const override
Write an (optimal) nop sequence of Count bytes to the given output.
bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override
Check whether the given instruction may need relaxation.
Definition: AVRAsmBackend.h:53
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.
Definition: AVRAsmBackend.h:58
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.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:73
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, MCInst &Res) const override
Relax the instruction in the given fragment to the next wider instruction.
Definition: AVRAsmBackend.h:65
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
Context object for machine code objects.
Definition: MCContext.h:62
Utilities for manipulating generated AVR machine code.
Definition: AVRAsmBackend.h:31
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCFragment.h:270
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:290
const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:22
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
PowerPC TLS Dynamic Call Fixup
Target - Wrapper for Target specific information.
Generic base class for all target subtargets.
Target independent information on a fixup kind.
const unsigned Kind
LLVM Value Representation.
Definition: Value.h:72
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:41
void adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t &Value, MCContext *Ctx=nullptr) const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
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...