Pass endian information to constructors. Define separate functions to create
objects for big endian and little endian targets.
Patch by Jack Carter.
llvm-svn: 151788
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
index ca60225..d69570b 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
@@ -70,10 +70,16 @@
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 @@
}
};
-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);
}