[llvm-commits] [llvm] r129974 - /llvm/trunk/lib/Object/MachOObjectFile.cpp
Chris Lattner
clattner at apple.com
Thu Apr 21 22:07:59 PDT 2011
> Add an ObjectFile implementation for mach-o.
>
> Patch by Patrick Walton!
Very nice! Instead of duplicating these magic constants, can you use include/llvm/Support/MachO.h?
-Chris
On Apr 21, 2011, at 8:19 PM, Eric Christopher wrote:
> +StringRef MachOObjectFile::getFileFormatName() const {
> + if (!MachOObj->is64Bit()) {
> + switch (MachOObj->getHeader().CPUType) {
> + case 0x00000007:
> + return "MACHO32-i386";
> + case 0x01000007:
> + return "MACHO32-x86-64";
> + case 0x0000000c:
> + return "MACHO32-arm";
> + case 0x00000012:
> + return "MACHO32-ppc";
> + case 0x01000012:
> + return "MACHO32-ppc64";
> + }
> + }
> +
> + switch (MachOObj->getHeader().CPUType) {
> + case 0x00000007:
> + return "MACHO64-i386";
> + case 0x01000007:
> + return "MACHO64-x86-64";
> + case 0x0000000c:
> + return "MACHO64-arm";
> + case 0x00000012:
> + return "MACHO64-ppc";
> + case 0x01000012:
> + return "MACHO64-ppc64";
> + default:
> + return "MACHO64-unknown";
> + }
> +}
> +
> +unsigned MachOObjectFile::getArch() const {
> + switch (MachOObj->getHeader().CPUType) {
> + case 0x00000007:
> + return Triple::x86;
> + case 0x01000007:
> + return Triple::x86_64;
> + case 0x0000000c:
> + return Triple::arm;
> + case 0x00000012:
> + return Triple::ppc;
> + case 0x01000012:
> + return Triple::ppc64;
> + default:
> + return Triple::UnknownArch;
> + }
> +}
> +
> +} // end namespace llvm
> +
More information about the llvm-commits
mailing list