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:
34 
35   AVRAsmBackend(Triple::OSType OSType)
36       : MCAsmBackend(), OSType(OSType) {}
37 
38   void adjustFixupValue(const MCFixup &Fixup, uint64_t &Value,
39                         MCContext *Ctx = nullptr) const;
40 
41   MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override;
42 
43   void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
44                   uint64_t Value, bool IsPCRel) const override;
45 
46   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
47 
48   unsigned getNumFixupKinds() const override {
49     return AVR::NumTargetFixupKinds;
50   }
51 
52   bool mayNeedRelaxation(const MCInst &Inst) const override { return false; }
53 
54   bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
55                             const MCRelaxableFragment *DF,
56                             const MCAsmLayout &Layout) const override {
57     llvm_unreachable("RelaxInstruction() unimplemented");
58     return false;
59   }
60 
61   void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
62                         MCInst &Res) const override {}
63 
64   bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
65 
66   void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
67                          const MCFixup &Fixup, const MCFragment *DF,
68                          const MCValue &Target, uint64_t &Value,
69                          bool &IsResolved) override;
70 
71 private:
72   Triple::OSType OSType;
73 };
74 
75 } // end namespace llvm
76 
77 #endif // LLVM_AVR_ASM_BACKEND_H
78 
79