Skip to content

Commit

Permalink
[x32] Add AsmBackend for X32 which uses ELF32 with x86_64 (the author…
Browse files Browse the repository at this point in the history
… 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

llvm-svn: 212716
  • Loading branch information
irishrover committed Jul 10, 2014
1 parent 8fc7e1f commit cad431c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Expand Up @@ -366,6 +366,17 @@ class ELFX86_32AsmBackend : public ELFX86AsmBackend {
}
};

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)
Expand Down Expand Up @@ -824,5 +835,8 @@ MCAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
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);
}

0 comments on commit cad431c

Please sign in to comment.