• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- AVRAsmBackend.h - AVR Asm Backend  --------------------------------===//
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 // \file The AVR assembly backend implementation.
11 //
12 //===----------------------------------------------------------------------===//
13 //
14 
15 #ifndef LLVM_AVR_ASM_BACKEND_H
16 #define LLVM_AVR_ASM_BACKEND_H
17 
18 #include "MCTargetDesc/AVRFixupKinds.h"
19 
20 #include "llvm/ADT/Triple.h"
21 #include "llvm/MC/MCAsmBackend.h"
22 
23 namespace llvm {
24 
25 class MCAssembler;
26 class MCObjectWriter;
27 class Target;
28 
29 struct MCFixupKindInfo;
30 
31 /// Utilities for manipulating generated AVR machine code.
32 class AVRAsmBackend : public MCAsmBackend {
33 public:
AVRAsmBackend(Triple::OSType OSType)34   AVRAsmBackend(Triple::OSType OSType)
35       : MCAsmBackend(support::little), OSType(OSType) {}
36 
37   void adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
38                         uint64_t &Value, MCContext *Ctx = nullptr) const;
39 
40   std::unique_ptr<MCObjectTargetWriter>
41   createObjectTargetWriter() const override;
42 
43   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
44                   const MCValue &Target, MutableArrayRef<char> Data,
45                   uint64_t Value, bool IsResolved,
46                   const MCSubtargetInfo *STI) const override;
47 
48   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
49 
getNumFixupKinds()50   unsigned getNumFixupKinds() const override {
51     return AVR::NumTargetFixupKinds;
52   }
53 
mayNeedRelaxation(const MCInst & Inst,const MCSubtargetInfo & STI)54   bool mayNeedRelaxation(const MCInst &Inst,
55                          const MCSubtargetInfo &STI) const override {
56     return false;
57   }
58 
fixupNeedsRelaxation(const MCFixup & Fixup,uint64_t Value,const MCRelaxableFragment * DF,const MCAsmLayout & Layout)59   bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
60                             const MCRelaxableFragment *DF,
61                             const MCAsmLayout &Layout) const override {
62     llvm_unreachable("RelaxInstruction() unimplemented");
63     return false;
64   }
65 
relaxInstruction(const MCInst & Inst,const MCSubtargetInfo & STI,MCInst & Res)66   void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
67                         MCInst &Res) const override {}
68 
69   bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
70 
71   bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
72                              const MCValue &Target) override;
73 
74 private:
75   Triple::OSType OSType;
76 };
77 
78 } // end namespace llvm
79 
80 #endif // LLVM_AVR_ASM_BACKEND_H
81 
82