Add big endian mips support. Based on a patch by Jack Carter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147924 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2012-01-11 04:04:14 +00:00
parent fddf804597
commit 29a17145ad
4 changed files with 22 additions and 16 deletions

View File

@ -71,7 +71,9 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
namespace {
class MipsAsmBackend : public MCAsmBackend {
public:
MipsAsmBackend(const Target &T) : MCAsmBackend() {}
uint8_t OSABI;
MipsAsmBackend(const Target &T, uint8_t OSABI_) :
MCAsmBackend(), OSABI(OSABI_) {}
/// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
/// data fragment, at the offset specified by the fixup and following the
@ -191,10 +193,8 @@ public:
class MipsEB_AsmBackend : public MipsAsmBackend {
public:
uint8_t OSABI;
MipsEB_AsmBackend(const Target &T, uint8_t _OSABI)
: MipsAsmBackend(T), OSABI(_OSABI) {}
: MipsAsmBackend(T, _OSABI) {}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createMipsELFObjectWriter(OS, /*IsLittleEndian*/ false, OSABI);
@ -203,10 +203,8 @@ public:
class MipsEL_AsmBackend : public MipsAsmBackend {
public:
uint8_t OSABI;
MipsEL_AsmBackend(const Target &T, uint8_t _OSABI)
: MipsAsmBackend(T), OSABI(_OSABI) {}
: MipsAsmBackend(T, _OSABI) {}
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
return createMipsELFObjectWriter(OS, /*IsLittleEndian*/ true, OSABI);
@ -214,11 +212,12 @@ public:
};
} // namespace
MCAsmBackend *llvm::createMipsAsmBackend(const Target &T, StringRef TT) {
Triple TheTriple(TT);
MCAsmBackend *llvm::createMipsBEAsmBackend(const Target &T, StringRef TT) {
uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(Triple(TT).getOS());
return new MipsEB_AsmBackend(T, OSABI);
}
// just return little endian for now
//
MCAsmBackend *llvm::createMipsLEAsmBackend(const Target &T, StringRef TT) {
uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(Triple(TT).getOS());
return new MipsEL_AsmBackend(T, OSABI);
}

View File

@ -136,10 +136,14 @@ extern "C" void LLVMInitializeMipsTargetMC() {
TargetRegistry::RegisterMCObjectStreamer(TheMips64elTarget, createMCStreamer);
// Register the asm backend.
TargetRegistry::RegisterMCAsmBackend(TheMipsTarget, createMipsAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheMipselTarget, createMipsAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheMips64Target, createMipsAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheMips64elTarget, createMipsAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheMipsTarget,
createMipsBEAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheMipselTarget,
createMipsLEAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheMips64Target,
createMipsBEAsmBackend);
TargetRegistry::RegisterMCAsmBackend(TheMips64elTarget,
createMipsLEAsmBackend);
TargetRegistry::RegisterMCCodeEmitter(TheMipsTarget, createMipsMCCodeEmitter);
TargetRegistry::RegisterMCCodeEmitter(TheMipselTarget,

View File

@ -36,7 +36,8 @@ MCCodeEmitter *createMipsMCCodeEmitter(const MCInstrInfo &MCII,
const MCSubtargetInfo &STI,
MCContext &Ctx);
MCAsmBackend *createMipsAsmBackend(const Target &T, StringRef TT);
MCAsmBackend *createMipsBEAsmBackend(const Target &T, StringRef TT);
MCAsmBackend *createMipsLEAsmBackend(const Target &T, StringRef TT);
MCObjectWriter *createMipsELFObjectWriter(raw_ostream &OS,
bool IsLittleEndian,

View File

@ -1,5 +1,7 @@
; RUN: llc -filetype=obj -mtriple mips-unknown-linux %s -o - | elf-dump --dump-section-data | FileCheck -check-prefix=CHECK-BE %s
; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux %s -o - | elf-dump --dump-section-data | FileCheck -check-prefix=CHECK-LE %s
; Check that we produce the correct endian.
; CHECK-BE: ('e_indent[EI_DATA]', 0x02)
; CHECK-LE: ('e_indent[EI_DATA]', 0x01)