Add big endian mips support. Based on a patch by Jack Carter.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 11 Jan 2012 04:04:14 +0000 (04:04 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 11 Jan 2012 04:04:14 +0000 (04:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147924 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h
test/MC/Mips/elf_basic.s

index bd9b6412a58bef2717e0c6e4aa047aa6375170b4..f4227f794b799a405e957f966f933d93329d7350 100644 (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);
 }
index 4584d6d4e1fc3561f014279c53910d6f90bb20f0..154ca17ba0ff397502ee264cea76715434971d8a 100644 (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,
index de8234787dce356c87319d0141d2e95e353084d3..63cb24052dec555a596d352b1c3084da0a22cfdc 100644 (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,
index 4a53a8047eaf369be76f3683b298f7a047b54c73..46211823b668d99b2dfd675abf01b2456dddd41b 100644 (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)