1 //===-- HexagonAsmBackend.cpp - Hexagon Assembler 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 #include "HexagonMCTargetDesc.h"
11 #include "llvm/MC/MCAsmBackend.h"
12 #include "llvm/MC/MCELFObjectWriter.h"
13 
14 using namespace llvm;
15 
16 namespace {
17 
18 class HexagonAsmBackend : public MCAsmBackend {
19 public:
HexagonAsmBackend(Target const &)20   HexagonAsmBackend(Target const & /*T*/) {}
21 
getNumFixupKinds() const22   unsigned getNumFixupKinds() const override { return 0; }
23 
applyFixup(MCFixup const &,char *,unsigned,uint64_t,bool) const24   void applyFixup(MCFixup const & /*Fixup*/, char * /*Data*/,
25                   unsigned /*DataSize*/, uint64_t /*Value*/,
26                   bool /*IsPCRel*/) const override {
27     return;
28   }
29 
mayNeedRelaxation(MCInst const &) const30   bool mayNeedRelaxation(MCInst const & /*Inst*/) const override {
31     return false;
32   }
33 
fixupNeedsRelaxation(MCFixup const &,uint64_t,MCRelaxableFragment const *,MCAsmLayout const &) const34   bool fixupNeedsRelaxation(MCFixup const & /*Fixup*/, uint64_t /*Value*/,
35                             MCRelaxableFragment const * /*DF*/,
36                             MCAsmLayout const & /*Layout*/) const override {
37     llvm_unreachable("fixupNeedsRelaxation() unimplemented");
38   }
39 
relaxInstruction(MCInst const &,MCInst &) const40   void relaxInstruction(MCInst const & /*Inst*/,
41                         MCInst & /*Res*/) const override {
42     llvm_unreachable("relaxInstruction() unimplemented");
43   }
44 
writeNopData(uint64_t,MCObjectWriter *) const45   bool writeNopData(uint64_t /*Count*/,
46                     MCObjectWriter * /*OW*/) const override {
47     return true;
48   }
49 };
50 } // end anonymous namespace
51 
52 namespace {
53 class ELFHexagonAsmBackend : public HexagonAsmBackend {
54   uint8_t OSABI;
55 
56 public:
ELFHexagonAsmBackend(Target const & T,uint8_t OSABI)57   ELFHexagonAsmBackend(Target const &T, uint8_t OSABI)
58       : HexagonAsmBackend(T), OSABI(OSABI) {}
59 
createObjectWriter(raw_ostream & OS) const60   MCObjectWriter *createObjectWriter(raw_ostream &OS) const override {
61     StringRef CPU("HexagonV4");
62     return createHexagonELFObjectWriter(OS, OSABI, CPU);
63   }
64 };
65 } // end anonymous namespace
66 
67 namespace llvm {
createHexagonAsmBackend(Target const & T,MCRegisterInfo const &,StringRef TT,StringRef)68 MCAsmBackend *createHexagonAsmBackend(Target const &T,
69                                       MCRegisterInfo const & /*MRI*/,
70                                       StringRef TT, StringRef /*CPU*/) {
71   uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(Triple(TT).getOS());
72   return new ELFHexagonAsmBackend(T, OSABI);
73 }
74 }
75