From e9e520f23ec3e5dc26e0801ac0d8b9e6899e2626 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Thu, 1 Mar 2012 01:53:15 +0000 Subject: Pass endian information to constructors. Define separate functions to create objects for big endian and little endian targets. Patch by Jack Carter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151788 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp | 44 +++++++++---------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp') diff --git a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp index ca60225f10..d69570bdf0 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -70,10 +70,16 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) { namespace { class MipsAsmBackend : public MCAsmBackend { + Triple::OSType OSType; + bool IsLittle; // Big or little endian + public: - uint8_t OSABI; - MipsAsmBackend(const Target &T, uint8_t OSABI_) : - MCAsmBackend(), OSABI(OSABI_) {} + MipsAsmBackend(const Target &T, Triple::OSType _OSType, bool _isLittle) : + MCAsmBackend(), OSType(_OSType), IsLittle(_isLittle) {} + + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { + return createMipsELFObjectWriter(OS, OSType, IsLittle); + } /// 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,33 +197,15 @@ public: } }; -class MipsEB_AsmBackend : public MipsAsmBackend { -public: - MipsEB_AsmBackend(const Target &T, uint8_t _OSABI) - : MipsAsmBackend(T, _OSABI) {} - - MCObjectWriter *createObjectWriter(raw_ostream &OS) const { - return createMipsELFObjectWriter(OS, /*IsLittleEndian*/ false, OSABI); - } -}; - -class MipsEL_AsmBackend : public MipsAsmBackend { -public: - MipsEL_AsmBackend(const Target &T, uint8_t _OSABI) - : MipsAsmBackend(T, _OSABI) {} - - MCObjectWriter *createObjectWriter(raw_ostream &OS) const { - return createMipsELFObjectWriter(OS, /*IsLittleEndian*/ true, OSABI); - } -}; } // namespace -MCAsmBackend *llvm::createMipsBEAsmBackend(const Target &T, StringRef TT) { - uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(Triple(TT).getOS()); - return new MipsEB_AsmBackend(T, OSABI); +// MCAsmBackend +MCAsmBackend *llvm::createMipsAsmBackendEL(const Target &T, StringRef TT) { + return new MipsAsmBackend(T, Triple(TT).getOS(), + /*IsLittle*/true); } -MCAsmBackend *llvm::createMipsLEAsmBackend(const Target &T, StringRef TT) { - uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(Triple(TT).getOS()); - return new MipsEL_AsmBackend(T, OSABI); +MCAsmBackend *llvm::createMipsAsmBackendEB(const Target &T, StringRef TT) { + return new MipsAsmBackend(T, Triple(TT).getOS(), + /*IsLittle*/false); } -- cgit v1.2.3