1 //===-- HexagonAsmBackend.cpp - Hexagon Assembler Backend -----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "HexagonMCTargetDesc.h"
11 #include "llvm/MC/MCAsmBackend.h"
12 #include "llvm/MC/MCELFObjectWriter.h"
18 class HexagonAsmBackend : public MCAsmBackend {
20 HexagonAsmBackend(Target const & /*T*/) {}
22 unsigned getNumFixupKinds() const override { return 0; }
24 void applyFixup(MCFixup const & /*Fixup*/, char * /*Data*/,
25 unsigned /*DataSize*/, uint64_t /*Value*/,
26 bool /*IsPCRel*/) const override {
30 bool mayNeedRelaxation(MCInst const & /*Inst*/) const override {
34 bool fixupNeedsRelaxation(MCFixup const & /*Fixup*/, uint64_t /*Value*/,
35 MCRelaxableFragment const * /*DF*/,
36 MCAsmLayout const & /*Layout*/) const override {
37 llvm_unreachable("fixupNeedsRelaxation() unimplemented");
40 void relaxInstruction(MCInst const & /*Inst*/,
41 MCInst & /*Res*/) const override {
42 llvm_unreachable("relaxInstruction() unimplemented");
45 bool writeNopData(uint64_t /*Count*/,
46 MCObjectWriter * /*OW*/) const override {
50 } // end anonymous namespace
53 class ELFHexagonAsmBackend : public HexagonAsmBackend {
57 ELFHexagonAsmBackend(Target const &T, uint8_t OSABI)
58 : HexagonAsmBackend(T), OSABI(OSABI) {}
60 MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override {
61 StringRef CPU("HexagonV4");
62 return createHexagonELFObjectWriter(OS, OSABI, CPU);
65 } // end anonymous namespace
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);