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