Home | History | Annotate | Download | only in MCTargetDesc
      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:
     20   HexagonAsmBackend(Target const & /*T*/) {}
     21 
     22   unsigned getNumFixupKinds() const override { return 0; }
     23 
     24   void applyFixup(MCFixup const & /*Fixup*/, char * /*Data*/,
     25                   unsigned /*DataSize*/, uint64_t /*Value*/,
     26                   bool /*IsPCRel*/) const override {
     27     return;
     28   }
     29 
     30   bool mayNeedRelaxation(MCInst const & /*Inst*/) const override {
     31     return false;
     32   }
     33 
     34   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 
     40   void relaxInstruction(MCInst const & /*Inst*/,
     41                         MCInst & /*Res*/) const override {
     42     llvm_unreachable("relaxInstruction() unimplemented");
     43   }
     44 
     45   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:
     57   ELFHexagonAsmBackend(Target const &T, uint8_t OSABI)
     58       : HexagonAsmBackend(T), OSABI(OSABI) {}
     59 
     60   MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override {
     61     StringRef CPU("HexagonV4");
     62     return createHexagonELFObjectWriter(OS, OSABI, CPU);
     63   }
     64 };
     65 } // end anonymous namespace
     66 
     67 namespace llvm {
     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