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 
17 #include "MCTargetDesc/AVRFixupKinds.h"
18 
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/MC/MCAsmBackend.h"
21 
22 namespace llvm {
23 
24 class MCAssembler;
25 class MCContext;
26 struct MCFixupKindInfo;
27 
28 /// Utilities for manipulating generated AVR machine code.
29 class AVRAsmBackend : public MCAsmBackend {
30 public:
AVRAsmBackend(Triple::OSType OSType)31   AVRAsmBackend(Triple::OSType OSType)
32       : MCAsmBackend(support::little), OSType(OSType) {}
33 
34   void adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
35                         uint64_t &Value, MCContext *Ctx = nullptr) const;
36 
37   std::unique_ptr<MCObjectTargetWriter>
38   createObjectTargetWriter() const override;
39 
40   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
41                   const MCValue &Target, MutableArrayRef<char> Data,
42                   uint64_t Value, bool IsResolved,
43                   const MCSubtargetInfo *STI) const override;
44 
45   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
46 
getNumFixupKinds()47   unsigned getNumFixupKinds() const override {
48     return AVR::NumTargetFixupKinds;
49   }
50 
fixupNeedsRelaxation(const MCFixup & Fixup,uint64_t Value,const MCRelaxableFragment * DF,const MCAsmLayout & Layout)51   bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
52                             const MCRelaxableFragment *DF,
53                             const MCAsmLayout &Layout) const override {
54     llvm_unreachable("RelaxInstruction() unimplemented");
55     return false;
56   }
57 
58   bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
59 
60   bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
61                              const MCValue &Target) override;
62 
63 private:
64   Triple::OSType OSType;
65 };
66 
67 } // end namespace llvm
68 
69 #endif // LLVM_AVR_ASM_BACKEND_H
70 
71