diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-11-05 18:48:58 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-11-05 18:48:58 +0000 |
commit | c9d1439051d130cfb947ef9ab4a95737c41e2fd1 (patch) | |
tree | 0f739dfe9d2f28078bb3574fe01f6dc85cb35fd6 | |
parent | 41ed3ca19d406b6eef47c01ea16453f3080f32e8 (diff) | |
download | external_llvm-c9d1439051d130cfb947ef9ab4a95737c41e2fd1.zip external_llvm-c9d1439051d130cfb947ef9ab4a95737c41e2fd1.tar.gz external_llvm-c9d1439051d130cfb947ef9ab4a95737c41e2fd1.tar.bz2 |
Allow targets to specify the MachO CPUType/CPUSubtype information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118288 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/MC/MachObjectWriter.h | 3 | ||||
-rw-r--r-- | lib/MC/MachObjectWriter.cpp | 20 | ||||
-rw-r--r-- | lib/Target/ARM/ARMAsmBackend.cpp | 5 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmBackend.cpp | 7 |
4 files changed, 24 insertions, 11 deletions
diff --git a/include/llvm/MC/MachObjectWriter.h b/include/llvm/MC/MachObjectWriter.h index f1079e3..01f7aaf 100644 --- a/include/llvm/MC/MachObjectWriter.h +++ b/include/llvm/MC/MachObjectWriter.h @@ -25,7 +25,8 @@ class MachObjectWriter : public MCObjectWriter { void *Impl; public: - MachObjectWriter(raw_ostream &OS, bool Is64Bit, bool IsLittleEndian = true); + MachObjectWriter(raw_ostream &OS, bool Is64Bit, uint32_t CPUType, + uint32_t CPUSubtype, bool IsLittleEndian = true); virtual ~MachObjectWriter(); virtual void ExecutePostLayoutBinding(MCAssembler &Asm); diff --git a/lib/MC/MachObjectWriter.cpp b/lib/MC/MachObjectWriter.cpp index 61df5bb..e98d27d 100644 --- a/lib/MC/MachObjectWriter.cpp +++ b/lib/MC/MachObjectWriter.cpp @@ -290,9 +290,14 @@ class MachObjectWriterImpl { unsigned Is64Bit : 1; + uint32_t CPUType; + uint32_t CPUSubtype; + public: - MachObjectWriterImpl(MachObjectWriter *_Writer, bool _Is64Bit) - : Writer(_Writer), OS(Writer->getStream()), Is64Bit(_Is64Bit) { + MachObjectWriterImpl(MachObjectWriter *_Writer, bool _Is64Bit, + uint32_t _CPUType, uint32_t _CPUSubtype) + : Writer(_Writer), OS(Writer->getStream()), Is64Bit(_Is64Bit), + CPUType(_CPUType), CPUSubtype(_CPUSubtype) { } void Write8(uint8_t Value) { Writer->Write8(Value); } @@ -319,10 +324,9 @@ public: Write32(Is64Bit ? Header_Magic64 : Header_Magic32); - // FIXME: Support cputype. - Write32(Is64Bit ? MachO::CPUTypeX86_64 : MachO::CPUTypeI386); - // FIXME: Support cpusubtype. - Write32(MachO::CPUSubType_I386_ALL); + Write32(CPUType); + Write32(CPUSubtype); + Write32(HFT_Object); Write32(NumLoadCommands); // Object files have a single load command, the // segment. @@ -1329,10 +1333,12 @@ public: MachObjectWriter::MachObjectWriter(raw_ostream &OS, bool Is64Bit, + uint32_t CPUType, + uint32_t CPUSubtype, bool IsLittleEndian) : MCObjectWriter(OS, IsLittleEndian) { - Impl = new MachObjectWriterImpl(this, Is64Bit); + Impl = new MachObjectWriterImpl(this, Is64Bit, CPUType, CPUSubtype); } MachObjectWriter::~MachObjectWriter() { diff --git a/lib/Target/ARM/ARMAsmBackend.cpp b/lib/Target/ARM/ARMAsmBackend.cpp index 4be0242..e1c4524 100644 --- a/lib/Target/ARM/ARMAsmBackend.cpp +++ b/lib/Target/ARM/ARMAsmBackend.cpp @@ -20,6 +20,7 @@ #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MachObjectWriter.h" #include "llvm/Support/ELF.h" +#include "llvm/Support/MachO.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegistry.h" @@ -128,7 +129,9 @@ public: } MCObjectWriter *createObjectWriter(raw_ostream &OS) const { - return new MachObjectWriter(OS, /*Is64Bit=*/false); + // FIXME: Subtarget info should be derived. Force v7 for now. + return new MachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeARM, + MachO::CPUSubType_ARM_V7); } virtual bool doesSectionRequireSymbols(const MCSection &Section) const { diff --git a/lib/Target/X86/X86AsmBackend.cpp b/lib/Target/X86/X86AsmBackend.cpp index 687971d..42643a3 100644 --- a/lib/Target/X86/X86AsmBackend.cpp +++ b/lib/Target/X86/X86AsmBackend.cpp @@ -21,6 +21,7 @@ #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MachObjectWriter.h" #include "llvm/Support/ELF.h" +#include "llvm/Support/MachO.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegistry.h" @@ -396,7 +397,8 @@ public: } MCObjectWriter *createObjectWriter(raw_ostream &OS) const { - return new MachObjectWriter(OS, /*Is64Bit=*/false); + return new MachObjectWriter(OS, /*Is64Bit=*/false, MachO::CPUTypeI386, + MachO::CPUSubType_I386_ALL); } }; @@ -412,7 +414,8 @@ public: } MCObjectWriter *createObjectWriter(raw_ostream &OS) const { - return new MachObjectWriter(OS, /*Is64Bit=*/true); + return new MachObjectWriter(OS, /*Is64Bit=*/true, MachO::CPUTypeX86_64, + MachO::CPUSubType_I386_ALL); } virtual bool doesSectionRequireSymbols(const MCSection &Section) const { |