• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- Nios2AsmBackend.h - Nios2 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 // This file defines the Nios2AsmBackend class.
11 //
12 //===----------------------------------------------------------------------===//
13 //
14 
15 #ifndef LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2ASMBACKEND_H
16 #define LLVM_LIB_TARGET_NIOS2_MCTARGETDESC_NIOS2ASMBACKEND_H
17 
18 #include "MCTargetDesc/Nios2FixupKinds.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/MC/MCAsmBackend.h"
21 
22 namespace llvm {
23 
24 class MCAssembler;
25 struct MCFixupKindInfo;
26 class Target;
27 class MCObjectWriter;
28 
29 class Nios2AsmBackend : public MCAsmBackend {
30   Triple::OSType OSType;
31 
32 public:
Nios2AsmBackend(const Target & T,Triple::OSType OSType)33   Nios2AsmBackend(const Target &T, Triple::OSType OSType)
34       : MCAsmBackend(support::little), OSType(OSType) {}
35 
36   std::unique_ptr<MCObjectTargetWriter>
37   createObjectTargetWriter() const override;
38 
39   bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
40 
41   void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
42                   const MCValue &Target, MutableArrayRef<char> Data,
43                   uint64_t Value, bool IsResolved) const override;
44 
45   Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
46   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
47 
getNumFixupKinds()48   unsigned getNumFixupKinds() const override {
49     return Nios2::NumTargetFixupKinds;
50   }
51 
52   /// MayNeedRelaxation - Check whether the given instruction may need
53   /// relaxation.
54   ///
55   /// \param Inst - The instruction to test.
mayNeedRelaxation(const MCInst & Inst)56   bool mayNeedRelaxation(const MCInst &Inst) const override { return false; }
57 
58   /// fixupNeedsRelaxation - Target specific predicate for whether a given
59   /// fixup requires the associated instruction to be relaxed.
fixupNeedsRelaxation(const MCFixup & Fixup,uint64_t Value,const MCRelaxableFragment * DF,const MCAsmLayout & Layout)60   bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
61                             const MCRelaxableFragment *DF,
62                             const MCAsmLayout &Layout) const override {
63     // FIXME.
64     llvm_unreachable("RelaxInstruction() unimplemented");
65     return false;
66   }
67 
68   /// RelaxInstruction - Relax the instruction in the given fragment
69   /// to the next wider instruction.
70   ///
71   /// \param Inst - The instruction to relax, which may be the same
72   /// as the output.
73   /// \param [out] Res On return, the relaxed instruction.
relaxInstruction(const MCInst & Inst,const MCSubtargetInfo & STI,MCInst & Res)74   void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
75                         MCInst &Res) const override {}
76 
77 }; // class Nios2AsmBackend
78 
79 } // namespace llvm
80 
81 #endif
82