blob: f84fdb65901b7c536d79f6d1817193dfe8aa9cd3 [file] [log] [blame]
Akira Hatanaka82ea7312011-09-30 21:04:02 +00001#include "MCTargetDesc/MipsMCTargetDesc.h"
2#include "llvm/ADT/Twine.h"
3#include "llvm/MC/MCAssembler.h"
4#include "llvm/MC/MCDirectives.h"
5#include "llvm/MC/MCELFObjectWriter.h"
6#include "llvm/MC/MCExpr.h"
7#include "llvm/MC/MCMachObjectWriter.h"
8#include "llvm/MC/MCObjectWriter.h"
9#include "llvm/MC/MCSectionELF.h"
10#include "llvm/MC/MCSectionMachO.h"
11#include "llvm/MC/MCAsmBackend.h"
12#include "llvm/MC/MCSubtargetInfo.h"
13#include "llvm/Object/MachOFormat.h"
14#include "llvm/Support/ELF.h"
15#include "llvm/Support/ErrorHandling.h"
16#include "llvm/Support/raw_ostream.h"
17using namespace llvm;
18
19namespace {
20class MipsELFObjectWriter : public MCELFObjectTargetWriter {
21public:
22 MipsELFObjectWriter(bool is64Bit, Triple::OSType OSType, uint16_t EMachine,
23 bool HasRelocationAddend)
24 : MCELFObjectTargetWriter(is64Bit, OSType, EMachine,
25 HasRelocationAddend) {}
26};
27
28class MipsAsmBackend : public MCAsmBackend {
29public:
30 MipsAsmBackend(const Target &T)
31 : MCAsmBackend() {}
32
33 unsigned getNumFixupKinds() const {
34 return 1; //tbd
35 }
36};
37
38class MipsEB_AsmBackend : public MipsAsmBackend {
39public:
40 Triple::OSType OSType;
41
42 MipsEB_AsmBackend(const Target &T, Triple::OSType _OSType)
43 : MipsAsmBackend(T), OSType(_OSType) {}
44
45 MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
46 return createELFObjectWriter(createELFObjectTargetWriter(),
47 OS, /*IsLittleEndian*/ false);
48 }
49
50 MCELFObjectTargetWriter *createELFObjectTargetWriter() const {
51 return new MipsELFObjectWriter(false, OSType, ELF::EM_MIPS, false);
52 }
53};
54
55class MipsEL_AsmBackend : public MipsAsmBackend {
56public:
57 Triple::OSType OSType;
58
59 MipsEL_AsmBackend(const Target &T, Triple::OSType _OSType)
60 : MipsAsmBackend(T), OSType(_OSType) {}
61
62 MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
63 return createELFObjectWriter(createELFObjectTargetWriter(),
64 OS, /*IsLittleEndian*/ true);
65 }
66
67 MCELFObjectTargetWriter *createELFObjectTargetWriter() const {
68 return new MipsELFObjectWriter(false, OSType, ELF::EM_MIPS, false);
69 }
70};
71}