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