1 //===-- SparcAsmBackend.cpp - Sparc 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 "llvm/MC/MCAsmBackend.h"
11 #include "MCTargetDesc/SparcMCTargetDesc.h"
12 #include "MCTargetDesc/SparcFixupKinds.h"
13 #include "llvm/MC/MCFixupKindInfo.h"
14 #include "llvm/MC/MCObjectWriter.h"
15 #include "llvm/Support/TargetRegistry.h"
20 class SparcAsmBackend : public MCAsmBackend {
23 SparcAsmBackend(const Target &T) : MCAsmBackend() {}
25 unsigned getNumFixupKinds() const {
26 return Sparc::NumTargetFixupKinds;
29 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
30 const static MCFixupKindInfo Infos[Sparc::NumTargetFixupKinds] = {
31 // name offset bits flags
32 { "fixup_sparc_call30", 0, 30, MCFixupKindInfo::FKF_IsPCRel },
33 { "fixup_sparc_br22", 0, 22, MCFixupKindInfo::FKF_IsPCRel },
34 { "fixup_sparc_br19", 0, 19, MCFixupKindInfo::FKF_IsPCRel }
37 if (Kind < FirstTargetFixupKind)
38 return MCAsmBackend::getFixupKindInfo(Kind);
40 assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
42 return Infos[Kind - FirstTargetFixupKind];
45 bool mayNeedRelaxation(const MCInst &Inst) const {
50 /// fixupNeedsRelaxation - Target specific predicate for whether a given
51 /// fixup requires the associated instruction to be relaxed.
52 bool fixupNeedsRelaxation(const MCFixup &Fixup,
54 const MCRelaxableFragment *DF,
55 const MCAsmLayout &Layout) const {
57 assert(0 && "fixupNeedsRelaxation() unimplemented");
60 void relaxInstruction(const MCInst &Inst, MCInst &Res) const {
62 assert(0 && "relaxInstruction() unimplemented");
65 bool writeNopData(uint64_t Count, MCObjectWriter *OW) const {
66 // FIXME: Zero fill for now.
67 for (uint64_t i = 0; i != Count; ++i)
73 class ELFSparcAsmBackend : public SparcAsmBackend {
75 ELFSparcAsmBackend(const Target &T, Triple::OSType OSType) :
76 SparcAsmBackend(T) { }
78 void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
79 uint64_t Value) const {
80 assert(0 && "applyFixup not implemented yet");
83 MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
84 assert(0 && "Object Writer not implemented yet");
88 virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
93 } // end anonymous namespace
96 MCAsmBackend *llvm::createSparcAsmBackend(const Target &T,
97 const MCRegisterInfo &MRI,
100 return new ELFSparcAsmBackend(T, Triple(TT).getOS());