[llvm] r212716 - [x32] Add AsmBackend for X32 which uses ELF32 with x86_64 (the author is Pavel Chupin).

Zinovy Nis zinovy.nis at gmail.com
Thu Jul 10 06:03:27 PDT 2014


Author: zinovy.nis
Date: Thu Jul 10 08:03:26 2014
New Revision: 212716

URL: http://llvm.org/viewvc/llvm-project?rev=212716&view=rev
Log:
[x32] Add AsmBackend for X32 which uses ELF32 with x86_64 (the author is Pavel Chupin).

This is minimal change for backend required to have "hello world" compiled and working on x32 target (x86_64-linux-gnux32). More patches for x32 will follow.

Differential Revision: http://reviews.llvm.org/D4181


Modified:
    llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp?rev=212716&r1=212715&r2=212716&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp Thu Jul 10 08:03:26 2014
@@ -366,6 +366,17 @@ public:
   }
 };
 
+class ELFX86_X32AsmBackend : public ELFX86AsmBackend {
+public:
+  ELFX86_X32AsmBackend(const Target &T, uint8_t OSABI, StringRef CPU)
+      : ELFX86AsmBackend(T, OSABI, CPU) {}
+
+  MCObjectWriter *createObjectWriter(raw_ostream &OS) const override {
+    return createX86ELFObjectWriter(OS, /*IsELF64*/ false, OSABI,
+                                    ELF::EM_X86_64);
+  }
+};
+
 class ELFX86_64AsmBackend : public ELFX86AsmBackend {
 public:
   ELFX86_64AsmBackend(const Target &T, uint8_t OSABI, StringRef CPU)
@@ -824,5 +835,8 @@ MCAsmBackend *llvm::createX86_64AsmBacke
     return new WindowsX86AsmBackend(T, true, CPU);
 
   uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
+
+  if (TheTriple.getEnvironment() == Triple::GNUX32)
+    return new ELFX86_X32AsmBackend(T, OSABI, CPU);
   return new ELFX86_64AsmBackend(T, OSABI, CPU);
 }





More information about the llvm-commits mailing list