blob: 155aa9ef955757b1c1e5b5db8e0c756635de73ce [file] [log] [blame]
Colin LeMahieu2c769202014-11-06 17:05:51 +00001//===-- 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
14using namespace llvm;
15
16namespace {
17
18class HexagonAsmBackend : public MCAsmBackend {
19public:
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
52namespace {
53class ELFHexagonAsmBackend : public HexagonAsmBackend {
54 uint8_t OSABI;
55
56public:
57 ELFHexagonAsmBackend(Target const &T, uint8_t OSABI)
58 : HexagonAsmBackend(T), OSABI(OSABI) {}
59
Rafael Espindola5560a4c2015-04-14 22:14:34 +000060 MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override {
Colin LeMahieu2c769202014-11-06 17:05:51 +000061 StringRef CPU("HexagonV4");
62 return createHexagonELFObjectWriter(OS, OSABI, CPU);
63 }
64};
65} // end anonymous namespace
66
67namespace llvm {
68MCAsmBackend *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}